Splash screen, styling updates, focus with delay for android.

This commit is contained in:
Kyle Spearrin 2016-08-19 00:27:37 -04:00
parent 90a6855e39
commit c27d427799
17 changed files with 101 additions and 17 deletions

View file

@ -317,6 +317,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\ReflectionService.cs" />
<Compile Include="Services\SqlService.cs" />
<Compile Include="SplashActivity.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
@ -596,6 +597,9 @@
<ItemGroup>
<AndroidResource Include="Resources\drawable-xxxhdpi\globe.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\splash_screen.xml" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<Import Project="..\..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\build\Xamarin.Android.Support.Vector.Drawable.targets" Condition="Exists('..\..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\build\Xamarin.Android.Support.Vector.Drawable.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

View file

@ -28,7 +28,7 @@ namespace Bit.Android.Controls
}
else
{
View.SetMainTextColor(Color.FromHex("d2d6de"));
View.SetMainTextColor(Color.FromHex("777777"));
}
}

View file

@ -42,11 +42,18 @@ namespace Bit.Android.Controls
private int ComputeHeight(AListView listView, int width)
{
var element = Element as ExtendedTableView;
var adapter = listView.Adapter;
var totalHeight = listView.PaddingTop + listView.PaddingBottom;
var desiredWidth = MeasureSpec.MakeMeasureSpec(width, global::Android.Views.MeasureSpecMode.AtMost);
for(var i = 0; i < adapter.Count; i++)
{
if(i == 0 && (element?.NoHeader ?? false))
{
continue;
}
var view = adapter.GetView(i, null, listView);
view.LayoutParameters = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent);
view.Measure(desiredWidth, MeasureSpec.MakeMeasureSpec(0, global::Android.Views.MeasureSpecMode.Unspecified));

View file

@ -18,7 +18,10 @@ using System.Reflection;
namespace Bit.Android
{
[Activity(Label = "bitwarden", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
[Activity(Label = "bitwarden",
Icon = "@drawable/icon",
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation,
WindowSoftInputMode = SoftInput.StateHidden)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
{
private const string HockeyAppId = "d3834185b4a643479047b86c65293d42";
@ -27,7 +30,8 @@ namespace Bit.Android
{
base.OnCreate(bundle);
Console.WriteLine("A OnCreate");
Window.SetSoftInputMode(SoftInput.StateAlwaysHidden);
Window.SetSoftInputMode(SoftInput.StateHidden);
Window.AddFlags(WindowManagerFlags.Secure);
var appIdService = Resolver.Resolve<IAppIdService>();
var authService = Resolver.Resolve<IAuthService>();

View file

@ -2710,8 +2710,8 @@ namespace Bit.Android
// aapt resource value: 0x7f0200da
public const int mr_ic_play_light = 2130837722;
// aapt resource value: 0x7f0200e1
public const int notification_template_icon_bg = 2130837729;
// aapt resource value: 0x7f0200e2
public const int notification_template_icon_bg = 2130837730;
// aapt resource value: 0x7f0200db
public const int plus = 2130837723;
@ -2726,10 +2726,13 @@ namespace Bit.Android
public const int roundedbgdark = 2130837726;
// aapt resource value: 0x7f0200df
public const int upload = 2130837727;
public const int splash_screen = 2130837727;
// aapt resource value: 0x7f0200e0
public const int user = 2130837728;
public const int upload = 2130837728;
// aapt resource value: 0x7f0200e1
public const int user = 2130837729;
static Drawable()
{
@ -4520,6 +4523,9 @@ namespace Bit.Android
// aapt resource value: 0x7f0d0175
public const int BitwardenTheme = 2131558773;
// aapt resource value: 0x7f0d0176
public const int BitwardenTheme_Splash = 2131558774;
// aapt resource value: 0x7f0d0017
public const int CardView = 2131558423;

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<color android:color="@color/lightgray"/>
</item>
<item>
<bitmap android:src="@drawable/logo" android:tileMode="disabled" android:gravity="center"/>
</item>
</layer-list>

View file

@ -8,4 +8,8 @@
<item name="android:windowBackground">@color/lightgray</item>
<item name="android:navigationBarColor">@color/darkaccent</item>
</style>
<style name="BitwardenTheme.Splash" parent="Theme.AppCompat.Light">
<item name="android:windowBackground">@drawable/splash_screen</item>
<item name="android:windowNoTitle">true</item>
</style>
</resources>

View file

@ -0,0 +1,32 @@
using System;
using Android.App;
using Android.OS;
using Android.Content;
using Android.Support.V7.App;
using System.Threading.Tasks;
namespace Bit.Android
{
[Activity(Theme = "@style/BitwardenTheme.Splash",
MainLauncher = true,
NoHistory = true,
WindowSoftInputMode = global::Android.Views.SoftInput.StateHidden)]
public class SplashActivity : AppCompatActivity
{
public override void OnCreate(Bundle savedInstanceState, PersistableBundle persistentState)
{
base.OnCreate(savedInstanceState, persistentState);
}
protected override void OnResume()
{
base.OnResume();
var startupWork = new Task(() =>
{
StartActivity(new Intent(Application.Context, typeof(MainActivity)));
});
startupWork.Start();
}
}
}

View file

@ -54,7 +54,8 @@ namespace Bit.App.Pages
Command = new Command(async () => await RegisterAsync()),
VerticalOptions = LayoutOptions.End,
HorizontalOptions = LayoutOptions.Fill,
Style = (Style)Application.Current.Resources["btn-primary"]
Style = (Style)Application.Current.Resources["btn-primary"],
FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Button))
};
var loginButton = new Button
@ -63,7 +64,8 @@ namespace Bit.App.Pages
Command = new Command(async () => await LoginAsync()),
VerticalOptions = LayoutOptions.End,
Style = (Style)Application.Current.Resources["btn-primaryAccent"],
HorizontalOptions = LayoutOptions.Fill
HorizontalOptions = LayoutOptions.Fill,
BackgroundColor = Color.Transparent
};
var buttonStackLayout = new StackLayout

View file

@ -98,7 +98,7 @@ namespace Bit.App.Pages
protected override void OnAppearing()
{
base.OnAppearing();
PasswordCell.Entry.Focus();
PasswordCell.Entry.FocusWithDelay();
}
protected async Task CheckPasswordAsync()

View file

@ -85,7 +85,7 @@ namespace Bit.App.Pages
protected override void OnAppearing()
{
base.OnAppearing();
PinControl.Entry.Focus();
PinControl.Entry.FocusWithDelay();
}
protected void PinEntered(object sender, EventArgs args)

View file

@ -138,11 +138,11 @@ namespace Bit.App.Pages
{
if(!string.IsNullOrWhiteSpace(EmailCell.Entry.Text))
{
PasswordCell.Entry.Focus();
PasswordCell.Entry.FocusWithDelay();
}
else
{
EmailCell.Entry.Focus();
EmailCell.Entry.FocusWithDelay();
}
}
}

View file

@ -103,7 +103,7 @@ namespace Bit.App.Pages
protected override void OnAppearing()
{
base.OnAppearing();
CodeCell.Entry.Focus();
CodeCell.Entry.FocusWithDelay();
}
private async void Entry_Completed(object sender, EventArgs e)

View file

@ -93,7 +93,7 @@ namespace Bit.App.Pages
protected override void OnAppearing()
{
base.OnAppearing();
EmailCell.Entry.Focus();
EmailCell.Entry.FocusWithDelay();
}
private async void Entry_Completed(object sender, EventArgs e)

View file

@ -145,7 +145,7 @@ namespace Bit.App.Pages
{
base.OnAppearing();
MessagingCenter.Send(Application.Current, "ShowStatusBar", true);
EmailCell.Entry.Focus();
EmailCell.Entry.FocusWithDelay();
}
private async void Entry_Completed(object sender, EventArgs e)

View file

@ -70,7 +70,7 @@ namespace Bit.App.Pages
protected override void OnAppearing()
{
base.OnAppearing();
PinControl.Entry.Focus();
PinControl.Entry.FocusWithDelay();
}
protected void PinEntered(object sender, EventArgs args)

View file

@ -28,5 +28,21 @@ namespace Bit.App
{
return !page.IsPortrait();
}
public static void FocusWithDelay(this Entry entry, int delay = 500)
{
if(Device.OS == TargetPlatform.Android)
{
System.Threading.Tasks.Task.Run(async () =>
{
await System.Threading.Tasks.Task.Delay(delay);
Device.BeginInvokeOnMainThread(() => entry.Focus());
});
}
else
{
entry.Focus();
}
}
}
}