1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-11-23 11:45:38 +01:00

default to "My Vault" option

This commit is contained in:
Kyle Spearrin 2017-11-27 14:41:15 -05:00
parent 3f99c513f3
commit b07dc8443e
7 changed files with 81 additions and 2 deletions

View File

@ -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; }

View File

@ -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";

View File

@ -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<IAppSettingsService>().DefaultPageVault)
{
SelectedItem = vaultNavigation;
}

View File

@ -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;

View File

@ -880,6 +880,24 @@ namespace Bit.App.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Default To &quot;My Vault&quot;.
/// </summary>
public static string DefaultPageVault {
get {
return ResourceManager.GetString("DefaultPageVault", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Default to the &quot;My Vault&quot; page instead of &quot;Favorites&quot; whenever I open the app..
/// </summary>
public static string DefaultPageVaultDescription {
get {
return ResourceManager.GetString("DefaultPageVaultDescription", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Delete.
/// </summary>

View File

@ -1197,4 +1197,10 @@
<data name="Collections" xml:space="preserve">
<value>Collections</value>
</data>
<data name="DefaultPageVault" xml:space="preserve">
<value>Default To "My Vault"</value>
</data>
<data name="DefaultPageVaultDescription" xml:space="preserve">
<value>Default to the "My Vault" page instead of "Favorites" whenever I open the app.</value>
</data>
</root>

View File

@ -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