From c44726bd54f311975071169a8248e568845670e0 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 30 Jul 2016 16:39:52 -0400 Subject: [PATCH] Moved to default lock of 15 minutes. Removed context options from vault list. Made folder add name selectable. --- .../Pages/Settings/SettingsAddFolderPage.cs | 5 ++- .../Pages/Settings/SettingsEditFolderPage.cs | 4 ++ src/App/Pages/Settings/SettingsPage.cs | 23 ++++------ src/App/Pages/Vault/VaultListSitesPage.cs | 42 ------------------- src/App/Services/LockService.cs | 8 ++-- 5 files changed, 19 insertions(+), 63 deletions(-) diff --git a/src/App/Pages/Settings/SettingsAddFolderPage.cs b/src/App/Pages/Settings/SettingsAddFolderPage.cs index 596a9e15e..d55a12f1c 100644 --- a/src/App/Pages/Settings/SettingsAddFolderPage.cs +++ b/src/App/Pages/Settings/SettingsAddFolderPage.cs @@ -35,7 +35,6 @@ namespace Bit.App.Pages Intent = TableIntent.Settings, EnableScrolling = false, HasUnevenRows = true, - EnableSelection = false, Root = new TableRoot { new TableSection() @@ -94,7 +93,11 @@ namespace Bit.App.Pages { ToolbarItems.Add(new DismissModalToolBarItem(this, "Cancel")); } + } + protected override void OnAppearing() + { + base.OnAppearing(); if(!_connectivity.IsConnected) { AlertNoConnection(); diff --git a/src/App/Pages/Settings/SettingsEditFolderPage.cs b/src/App/Pages/Settings/SettingsEditFolderPage.cs index 0205540a5..fa4557dc4 100644 --- a/src/App/Pages/Settings/SettingsEditFolderPage.cs +++ b/src/App/Pages/Settings/SettingsEditFolderPage.cs @@ -107,7 +107,11 @@ namespace Bit.App.Pages { ToolbarItems.Add(new DismissModalToolBarItem(this, "Cancel")); } + } + protected override void OnAppearing() + { + base.OnAppearing(); if(!_connectivity.IsConnected) { AlertNoConnection(); diff --git a/src/App/Pages/Settings/SettingsPage.cs b/src/App/Pages/Settings/SettingsPage.cs index 73aa4f118..a33ffc1e3 100644 --- a/src/App/Pages/Settings/SettingsPage.cs +++ b/src/App/Pages/Settings/SettingsPage.cs @@ -205,10 +205,6 @@ namespace Bit.App.Pages { _settings.AddOrUpdateValue(Constants.SettingLockSeconds, 60); } - else if(selection == "5 minutes") - { - _settings.AddOrUpdateValue(Constants.SettingLockSeconds, 60 * 5); - } else if(selection == "15 minutes") { _settings.AddOrUpdateValue(Constants.SettingLockSeconds, 60 * 15); @@ -223,7 +219,7 @@ namespace Bit.App.Pages } else if(selection == "Never") { - _settings.Remove(Constants.SettingLockSeconds); + _settings.AddOrUpdateValue(Constants.SettingLockSeconds, -1); } LockOptionsCell.Detail = selection; @@ -349,29 +345,24 @@ namespace Bit.App.Pages private string GetLockOptionsDetailsText() { - var lockSeconds = _settings.GetValueOrDefault(Constants.SettingLockSeconds); - if(!lockSeconds.HasValue) + var lockSeconds = _settings.GetValueOrDefault(Constants.SettingLockSeconds, 60 * 15); + if(lockSeconds == -1) { return "Never"; } - - if(lockSeconds.Value == 60) + else if(lockSeconds == 60) { return "1 minute"; } - else if(lockSeconds.Value == 60 * 5) - { - return "5 minutes"; - } - else if(lockSeconds.Value == 60 * 15) + else if(lockSeconds == 60 * 15) { return "15 minutes"; } - else if(lockSeconds.Value == 60 * 60) + else if(lockSeconds == 60 * 60) { return "1 hour"; } - else if(lockSeconds.Value == 60 * 60 * 4) + else if(lockSeconds == 60 * 60 * 4) { return "4 hours"; } diff --git a/src/App/Pages/Vault/VaultListSitesPage.cs b/src/App/Pages/Vault/VaultListSitesPage.cs index 567442ce1..4db32ddc9 100644 --- a/src/App/Pages/Vault/VaultListSitesPage.cs +++ b/src/App/Pages/Vault/VaultListSitesPage.cs @@ -282,30 +282,6 @@ namespace Bit.App.Pages _userDialogs.Toast(string.Format(AppResources.ValueHasBeenCopied, alertLabel)); } - private async void DeleteClickedAsync(object sender, EventArgs e) - { - if(!await _userDialogs.ConfirmAsync(AppResources.DoYouReallyWantToDelete, null, AppResources.Yes, AppResources.No)) - { - return; - } - - var mi = sender as MenuItem; - var site = mi.CommandParameter as VaultListPageModel.Site; - var deleteCall = await _siteService.DeleteAsync(site.Id); - - if(deleteCall.Succeeded) - { - var folder = PresentationFolders.Single(f => f.Id == site.FolderId); - var siteIndex = folder.Select((s, i) => new { s, i }).First(s => s.s.Id == site.Id).i; - folder.RemoveAt(siteIndex); - _userDialogs.Toast(AppResources.SiteDeleted); - } - else if(deleteCall.Errors.Count() > 0) - { - await DisplayAlert(AppResources.AnErrorHasOccurred, deleteCall.Errors.First().Message, AppResources.Ok); - } - } - private class AddSiteToolBarItem : ToolbarItem { private readonly VaultListSitesPage _page; @@ -336,21 +312,10 @@ namespace Bit.App.Pages { _page = page; - var deleteAction = new MenuItem { Text = AppResources.Delete, IsDestructive = true }; - deleteAction.SetBinding(MenuItem.CommandParameterProperty, new Binding(".")); - deleteAction.Clicked += page.DeleteClickedAsync; - - var moreAction = new MenuItem { Text = AppResources.More }; - moreAction.SetBinding(MenuItem.CommandParameterProperty, new Binding(".")); - moreAction.Clicked += MoreAction_Clicked; - SetBinding(SiteParameterProperty, new Binding(".")); Label.SetBinding(Label.TextProperty, s => s.Name); Detail.SetBinding(Label.TextProperty, s => s.Username); - ContextActions.Add(deleteAction); - ContextActions.Add(moreAction); - Button.Image = "more"; Button.Command = new Command(() => ShowMore()); Button.BackgroundColor = Color.Transparent; @@ -364,13 +329,6 @@ namespace Bit.App.Pages set { SetValue(SiteParameterProperty, value); } } - private void MoreAction_Clicked(object sender, EventArgs e) - { - var menuItem = sender as MenuItem; - var site = menuItem.CommandParameter as VaultListPageModel.Site; - _page.MoreClickedAsync(site); - } - private void ShowMore() { _page.MoreClickedAsync(SiteParameter); diff --git a/src/App/Services/LockService.cs b/src/App/Services/LockService.cs index 592bffb59..6d2012e9e 100644 --- a/src/App/Services/LockService.cs +++ b/src/App/Services/LockService.cs @@ -33,9 +33,9 @@ namespace Bit.App.Services // Are we forcing a lock? (i.e. clicking a button to lock the app manually, immediately) if(!forceLock && !_settings.GetValueOrDefault(Constants.SettingLocked, false)) { - // Lock seconds tells if if they want to lock the app or not - var lockSeconds = _settings.GetValueOrDefault(Constants.SettingLockSeconds); - if(!lockSeconds.HasValue) + // Lock seconds tells if they want to lock the app or not + var lockSeconds = _settings.GetValueOrDefault(Constants.SettingLockSeconds, 60 * 15); + if(lockSeconds == -1) { return LockType.None; } @@ -43,7 +43,7 @@ namespace Bit.App.Services // Has it been longer than lockSeconds since the last time the app was backgrounded? var now = DateTime.UtcNow; var lastBackground = _settings.GetValueOrDefault(Constants.SettingLastBackgroundedDate, now.AddYears(-1)); - if((now - lastBackground).TotalSeconds < lockSeconds.Value) + if((now - lastBackground).TotalSeconds < lockSeconds) { return LockType.None; }