diff --git a/src/Android/Android.csproj b/src/Android/Android.csproj index 640c1b329..7ba058cd6 100644 --- a/src/Android/Android.csproj +++ b/src/Android/Android.csproj @@ -205,6 +205,7 @@ + diff --git a/src/Android/Controls/ExtendedNavigationPage.cs b/src/Android/Controls/ExtendedNavigationPage.cs new file mode 100644 index 000000000..05b72afbc --- /dev/null +++ b/src/Android/Controls/ExtendedNavigationPage.cs @@ -0,0 +1,27 @@ +using Android.App; +using Android.Graphics.Drawables; +using Bit.Android.Controls; +using Bit.App.Controls; +using Xamarin.Forms; +using Xamarin.Forms.Platform.Android; + +[assembly: ExportRenderer(typeof(ExtendedNavigationPage), typeof(ExtendedNavigationRenderer))] +namespace Bit.Android.Controls +{ + public class ExtendedNavigationRenderer : NavigationRenderer + { + protected override void OnElementChanged(ElementChangedEventArgs e) + { + base.OnElementChanged(e); + + RemoveAppIconFromActionBar(); + } + + private void RemoveAppIconFromActionBar() + { + // ref: http://stackoverflow.com/questions/14606294/remove-icon-logo-from-action-bar-on-android + var actionBar = ((Activity)Context).ActionBar; + actionBar.SetIcon(new ColorDrawable(Color.Transparent.ToAndroid())); + } + } +} diff --git a/src/App/Pages/SettingsPage.cs b/src/App/Pages/SettingsPage.cs index 0e1e7edef..79b088c4f 100644 --- a/src/App/Pages/SettingsPage.cs +++ b/src/App/Pages/SettingsPage.cs @@ -53,9 +53,9 @@ namespace Bit.App.Pages LockOptionsCell = new ExtendedTextCell { Text = "Lock Options", - // TODO: Set detail based on setting - Detail = "Immediately", - ShowDisclousure = true + Detail = GetLockOptionsDetailsText(), + ShowDisclousure = true, + TextColor = Color.FromHex("333333") }; LockOptionsCell.Tapped += LockOptionsCell_Tapped; @@ -125,7 +125,12 @@ namespace Bit.App.Pages private async void LockOptionsCell_Tapped(object sender, EventArgs e) { var selection = await DisplayActionSheet("Lock Options", AppResources.Cancel, null, - "Immediately", "1 minute", "3 minutes", "15 minutes", "1 hour", "8 hours", "24 hours", "Never"); + "Immediately", "1 minute", "15 minutes", "1 hour", "4 hours", "Never"); + + if(selection == AppResources.Cancel) + { + return; + } if(selection == "Immediately") { @@ -135,10 +140,24 @@ namespace Bit.App.Pages { _settings.AddOrUpdateValue(Constants.SettingLockSeconds, 60); } - // TODO: others - else + else if(selection == "5 minutes") + { + _settings.AddOrUpdateValue(Constants.SettingLockSeconds, 60 * 5); + } + else if(selection == "15 minutes") + { + _settings.AddOrUpdateValue(Constants.SettingLockSeconds, 60 * 15); + } + else if(selection == "1 hour") + { + _settings.AddOrUpdateValue(Constants.SettingLockSeconds, 60 * 60); + } + else if(selection == "4 hours") + { + _settings.AddOrUpdateValue(Constants.SettingLockSeconds, 60 * 60 * 4); + } + else if(selection == "Never") { - // Never lock _settings.Remove(Constants.SettingLockSeconds); } @@ -208,5 +227,39 @@ namespace Bit.App.Pages { Navigation.PushAsync(new SettingsListFoldersPage()); } + + private string GetLockOptionsDetailsText() + { + var lockSeconds = _settings.GetValueOrDefault(Constants.SettingLockSeconds); + if(!lockSeconds.HasValue) + { + return "Never"; + } + + if(lockSeconds.Value == 60) + { + return "1 minute"; + } + else if(lockSeconds.Value == 60 * 5) + { + return "5 minutes"; + } + else if(lockSeconds.Value == 60 * 15) + { + return "15 minutes"; + } + else if(lockSeconds.Value == 60 * 60) + { + return "1 hour"; + } + else if(lockSeconds.Value == 60 * 60 * 4) + { + return "4 hours"; + } + else + { + return "Immediately"; + } + } } }