diff --git a/src/App/Abstractions/Services/IAppSettingsService.cs b/src/App/Abstractions/Services/IAppSettingsService.cs index f10fe8a5f..7b9981717 100644 --- a/src/App/Abstractions/Services/IAppSettingsService.cs +++ b/src/App/Abstractions/Services/IAppSettingsService.cs @@ -4,6 +4,7 @@ namespace Bit.App.Abstractions { public interface IAppSettingsService { + bool DefaultPageVault { get; set; } bool Locked { get; set; } DateTime LastActivity { get; set; } DateTime LastCacheClear { get; set; } diff --git a/src/App/Constants.cs b/src/App/Constants.cs index 315920f05..8070fd2b4 100644 --- a/src/App/Constants.cs +++ b/src/App/Constants.cs @@ -13,6 +13,7 @@ public const string SettingDisableTotpCopy = "setting:disableAutoCopyTotp"; public const string AutofillPersistNotification = "setting:persistNotification"; public const string AutofillPasswordField = "setting:autofillPasswordField"; + public const string SettingDefaultPageVault = "setting:defaultPageVault"; public const string PasswordGeneratorLength = "pwGenerator:length"; public const string PasswordGeneratorUppercase = "pwGenerator:uppercase"; diff --git a/src/App/Pages/MainPage.cs b/src/App/Pages/MainPage.cs index 652476648..89b99e5f9 100644 --- a/src/App/Pages/MainPage.cs +++ b/src/App/Pages/MainPage.cs @@ -1,6 +1,8 @@ using System; using Bit.App.Controls; using Xamarin.Forms; +using XLabs.Ioc; +using Bit.App.Abstractions; namespace Bit.App.Pages { @@ -25,7 +27,7 @@ namespace Bit.App.Pages Children.Add(toolsNavigation); Children.Add(settingsNavigation); - if(myVault) + if(myVault || Resolver.Resolve().DefaultPageVault) { SelectedItem = vaultNavigation; } diff --git a/src/App/Pages/Settings/SettingsFeaturesPage.cs b/src/App/Pages/Settings/SettingsFeaturesPage.cs index 20e2ee226..67c1f6b0e 100644 --- a/src/App/Pages/Settings/SettingsFeaturesPage.cs +++ b/src/App/Pages/Settings/SettingsFeaturesPage.cs @@ -25,6 +25,8 @@ namespace Bit.App.Pages } private StackLayout StackLayout { get; set; } + private ExtendedSwitchCell DefaultPageVaultCell { get; set; } + private Label DefaultPageVaultLabel { get; set; } private ExtendedSwitchCell CopyTotpCell { get; set; } private Label CopyTotpLabel { get; set; } private ExtendedSwitchCell AnalyticsCell { get; set; } @@ -40,13 +42,30 @@ namespace Bit.App.Pages private void Init() { + DefaultPageVaultCell = new ExtendedSwitchCell + { + Text = AppResources.DefaultPageVault, + On = _appSettings.DefaultPageVault + }; + + var defaultPageVaultTable = new FormTableView(true) + { + Root = new TableRoot + { + new TableSection(Helpers.GetEmptyTableSectionTitle()) + { + DefaultPageVaultCell + } + } + }; + WebsiteIconsCell = new ExtendedSwitchCell { Text = AppResources.DisableWebsiteIcons, On = _appSettings.DisableWebsiteIcons }; - var websiteIconsTable = new FormTableView(true) + var websiteIconsTable = new FormTableView { Root = new TableRoot { @@ -91,6 +110,11 @@ namespace Bit.App.Pages } }; + DefaultPageVaultLabel = new FormTableLabel(this) + { + Text = AppResources.DefaultPageVaultDescription + }; + CopyTotpLabel = new FormTableLabel(this) { Text = AppResources.DisableAutoTotpCopyDescription @@ -110,6 +134,7 @@ namespace Bit.App.Pages { Children = { + defaultPageVaultTable, DefaultPageVaultLabel, websiteIconsTable, WebsiteIconsLabel, totpTable, CopyTotpLabel, analyticsTable, AnalyticsLabel @@ -214,6 +239,7 @@ namespace Bit.App.Pages { base.OnAppearing(); + DefaultPageVaultCell.OnChanged += DefaultPageVaultCell_Changed; AnalyticsCell.OnChanged += AnalyticsCell_Changed; WebsiteIconsCell.OnChanged += WebsiteIconsCell_Changed; CopyTotpCell.OnChanged += CopyTotpCell_OnChanged; @@ -231,6 +257,7 @@ namespace Bit.App.Pages { base.OnDisappearing(); + DefaultPageVaultCell.OnChanged -= DefaultPageVaultCell_Changed; AnalyticsCell.OnChanged -= AnalyticsCell_Changed; WebsiteIconsCell.OnChanged -= WebsiteIconsCell_Changed; CopyTotpCell.OnChanged -= CopyTotpCell_OnChanged; @@ -246,6 +273,7 @@ namespace Bit.App.Pages private void Layout_LayoutChanged(object sender, EventArgs e) { + DefaultPageVaultLabel.WidthRequest = StackLayout.Bounds.Width - DefaultPageVaultLabel.Bounds.Left * 2; AnalyticsLabel.WidthRequest = StackLayout.Bounds.Width - AnalyticsLabel.Bounds.Left * 2; WebsiteIconsLabel.WidthRequest = StackLayout.Bounds.Width - WebsiteIconsLabel.Bounds.Left * 2; CopyTotpLabel.WidthRequest = StackLayout.Bounds.Width - CopyTotpLabel.Bounds.Left * 2; @@ -267,6 +295,17 @@ namespace Bit.App.Pages } } + private void DefaultPageVaultCell_Changed(object sender, ToggledEventArgs e) + { + var cell = sender as ExtendedSwitchCell; + if(cell == null) + { + return; + } + + _appSettings.DefaultPageVault = cell.On; + } + private void WebsiteIconsCell_Changed(object sender, ToggledEventArgs e) { var cell = sender as ExtendedSwitchCell; diff --git a/src/App/Resources/AppResources.Designer.cs b/src/App/Resources/AppResources.Designer.cs index 2d402ad43..05d1527cc 100644 --- a/src/App/Resources/AppResources.Designer.cs +++ b/src/App/Resources/AppResources.Designer.cs @@ -880,6 +880,24 @@ namespace Bit.App.Resources { } } + /// + /// Looks up a localized string similar to Default To "My Vault". + /// + public static string DefaultPageVault { + get { + return ResourceManager.GetString("DefaultPageVault", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Default to the "My Vault" page instead of "Favorites" whenever I open the app.. + /// + public static string DefaultPageVaultDescription { + get { + return ResourceManager.GetString("DefaultPageVaultDescription", resourceCulture); + } + } + /// /// Looks up a localized string similar to Delete. /// diff --git a/src/App/Resources/AppResources.resx b/src/App/Resources/AppResources.resx index 5494135b6..9b89bef8a 100644 --- a/src/App/Resources/AppResources.resx +++ b/src/App/Resources/AppResources.resx @@ -1197,4 +1197,10 @@ Collections + + Default To "My Vault" + + + Default to the "My Vault" page instead of "Favorites" whenever I open the app. + \ No newline at end of file diff --git a/src/App/Services/AppSettingsService.cs b/src/App/Services/AppSettingsService.cs index be2bc2f01..a9bf2d641 100644 --- a/src/App/Services/AppSettingsService.cs +++ b/src/App/Services/AppSettingsService.cs @@ -14,6 +14,18 @@ namespace Bit.App.Services _settings = settings; } + public bool DefaultPageVault + { + get + { + return _settings.GetValueOrDefault(Constants.SettingDefaultPageVault, false); + } + set + { + _settings.AddOrUpdateValue(Constants.SettingDefaultPageVault, value); + } + } + public bool Locked { get