more options

This commit is contained in:
Kyle Spearrin 2019-05-29 14:11:15 -04:00
parent 6be54fa7ee
commit 48376d0a93
6 changed files with 359 additions and 27 deletions

View File

@ -12,37 +12,84 @@
<pages:OptionsPageViewModel />
</ContentPage.BindingContext>
<StackLayout Padding="0" Spacing="0">
<StackLayout StyleClass="box">
<StackLayout StyleClass="box-row, box-row-switch">
<ScrollView>
<StackLayout Padding="0" Spacing="20">
<StackLayout StyleClass="box">
<StackLayout StyleClass="box-row, box-row-input">
<Label
Text="{u:I18n DefaultUriMatchDetection}"
StyleClass="box-label" />
<Picker
x:Name="_uriMatchPicker"
ItemsSource="{Binding UriMatchOptions, Mode=OneTime}"
SelectedIndex="{Binding UriMatchSelectedIndex}"
StyleClass="box-value" />
</StackLayout>
<Label
Text="{u:I18n DisableWebsiteIcons}"
StyleClass="box-label, box-label-regular"
HorizontalOptions="StartAndExpand" />
<Switch
IsToggled="{Binding DisableFavicon}"
StyleClass="box-value"
HorizontalOptions="End" />
Text="{u:I18n DefaultUriMatchDetectionDescription}"
StyleClass="box-footer-label" />
</StackLayout>
<Label
Text="{u:I18n DisableWebsiteIconsDescription}"
StyleClass="box-footer-label" />
</StackLayout>
<StackLayout StyleClass="box">
<StackLayout StyleClass="box-row, box-row-switch">
<StackLayout StyleClass="box">
<StackLayout StyleClass="box-row, box-row-input">
<Label
Text="{u:I18n ClearClipboard}"
StyleClass="box-label" />
<Picker
x:Name="_clearClipboardPicker"
ItemsSource="{Binding ClearClipboardOptions, Mode=OneTime}"
SelectedIndex="{Binding ClearClipboardSelectedIndex}"
StyleClass="box-value" />
</StackLayout>
<Label
Text="{u:I18n DisableAutoTotpCopy}"
StyleClass="box-label, box-label-regular"
HorizontalOptions="StartAndExpand" />
<Switch
IsToggled="{Binding DisableAutoTotpCopy}"
StyleClass="box-value"
HorizontalOptions="End" />
Text="{u:I18n ClearClipboardDescription}"
StyleClass="box-footer-label" />
</StackLayout>
<StackLayout StyleClass="box">
<StackLayout StyleClass="box-row, box-row-switch">
<Label
Text="{u:I18n DisableAutoTotpCopy}"
StyleClass="box-label, box-label-regular"
HorizontalOptions="StartAndExpand" />
<Switch
IsToggled="{Binding DisableAutoTotpCopy}"
StyleClass="box-value"
HorizontalOptions="End" />
</StackLayout>
<Label
Text="{u:I18n DisableAutoTotpCopyDescription}"
StyleClass="box-footer-label" />
</StackLayout>
<StackLayout StyleClass="box">
<StackLayout StyleClass="box-row, box-row-switch">
<Label
Text="{u:I18n DisableWebsiteIcons}"
StyleClass="box-label, box-label-regular"
HorizontalOptions="StartAndExpand" />
<Switch
IsToggled="{Binding DisableFavicon}"
StyleClass="box-value"
HorizontalOptions="End" />
</StackLayout>
<Label
Text="{u:I18n DisableWebsiteIconsDescription}"
StyleClass="box-footer-label" />
</StackLayout>
<StackLayout StyleClass="box">
<StackLayout StyleClass="box-row, box-row-input">
<Label
Text="{u:I18n Theme}"
StyleClass="box-label" />
<Picker
x:Name="_themePicker"
ItemsSource="{Binding ThemeOptions, Mode=OneTime}"
SelectedIndex="{Binding ThemeSelectedIndex}"
StyleClass="box-value" />
</StackLayout>
<Label
Text="{u:I18n ThemeDescription}"
StyleClass="box-footer-label" />
</StackLayout>
<Label
Text="{u:I18n DisableAutoTotpCopyDescription}"
StyleClass="box-footer-label" />
</StackLayout>
</StackLayout>
</ScrollView>
</pages:BaseContentPage>

View File

@ -1,4 +1,5 @@
using System;
using Xamarin.Forms;
namespace Bit.App.Pages
{
@ -11,6 +12,9 @@ namespace Bit.App.Pages
InitializeComponent();
_vm = BindingContext as OptionsPageViewModel;
_vm.Page = this;
_themePicker.ItemDisplayBinding = new Binding("Value");
_uriMatchPicker.ItemDisplayBinding = new Binding("Value");
_clearClipboardPicker.ItemDisplayBinding = new Binding("Value");
}
protected async override void OnAppearing()

View File

@ -2,7 +2,9 @@
using Bit.App.Resources;
using Bit.Core;
using Bit.Core.Abstractions;
using Bit.Core.Enums;
using Bit.Core.Utilities;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Bit.App.Pages
@ -18,6 +20,10 @@ namespace Bit.App.Pages
private bool _disableFavicon;
private bool _disableAutoTotpCopy;
private int _clearClipboardSelectedIndex;
private int _themeSelectedIndex;
private int _uriMatchSelectedIndex;
public OptionsPageViewModel()
{
_deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
@ -27,6 +33,72 @@ namespace Bit.App.Pages
_stateService = ServiceContainer.Resolve<IStateService>("stateService");
PageTitle = AppResources.Options;
ClearClipboardOptions = new List<KeyValuePair<int?, string>>
{
new KeyValuePair<int?, string>(null, AppResources.Never),
new KeyValuePair<int?, string>(10, AppResources.TenSeconds),
new KeyValuePair<int?, string>(20, AppResources.TwentySeconds),
new KeyValuePair<int?, string>(30, AppResources.ThirtySeconds),
new KeyValuePair<int?, string>(60, AppResources.OneMinute),
new KeyValuePair<int?, string>(120, AppResources.TwoMinutes),
new KeyValuePair<int?, string>(300, AppResources.FiveMinutes),
};
ThemeOptions = new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>(null, AppResources.Default),
new KeyValuePair<string, string>("light", AppResources.Light),
new KeyValuePair<string, string>("dark", AppResources.Dark),
};
UriMatchOptions = new List<KeyValuePair<UriMatchType?, string>>
{
new KeyValuePair<UriMatchType?, string>(UriMatchType.Domain, AppResources.BaseDomain),
new KeyValuePair<UriMatchType?, string>(UriMatchType.Host, AppResources.Host),
new KeyValuePair<UriMatchType?, string>(UriMatchType.StartsWith, AppResources.StartsWith),
new KeyValuePair<UriMatchType?, string>(UriMatchType.RegularExpression, AppResources.RegEx),
new KeyValuePair<UriMatchType?, string>(UriMatchType.Exact, AppResources.Exact),
new KeyValuePair<UriMatchType?, string>(UriMatchType.Never, AppResources.Never),
};
}
public List<KeyValuePair<int?, string>> ClearClipboardOptions { get; set; }
public List<KeyValuePair<string, string>> ThemeOptions { get; set; }
public List<KeyValuePair<UriMatchType?, string>> UriMatchOptions { get; set; }
public int ClearClipboardSelectedIndex
{
get => _clearClipboardSelectedIndex;
set
{
if(SetProperty(ref _clearClipboardSelectedIndex, value))
{
var task = SaveClipboardChangedAsync();
}
}
}
public int ThemeSelectedIndex
{
get => _themeSelectedIndex;
set
{
if(SetProperty(ref _themeSelectedIndex, value))
{
var task = SaveThemeAsync();
}
}
}
public int UriMatchSelectedIndex
{
get => _uriMatchSelectedIndex;
set
{
if(SetProperty(ref _uriMatchSelectedIndex, value))
{
var task = SaveDefaultUriAsync();
}
}
}
public bool DisableFavicon
@ -57,6 +129,13 @@ namespace Bit.App.Pages
{
DisableAutoTotpCopy = !(await _totpService.IsAutoCopyEnabledAsync());
DisableFavicon = await _storageService.GetAsync<bool>(Constants.DisableFaviconKey);
var theme = await _storageService.GetAsync<string>(Constants.ThemeKey);
ThemeSelectedIndex = ThemeOptions.FindIndex(k => k.Key == theme);
var defaultUriMatch = await _storageService.GetAsync<int?>(Constants.DefaultUriMatch);
UriMatchSelectedIndex = defaultUriMatch == null ? 0 :
UriMatchOptions.FindIndex(k => (int?)k.Key == defaultUriMatch);
var clearClipboard = await _storageService.GetAsync<int?>(Constants.ClearClipboardKey);
ClearClipboardSelectedIndex = ClearClipboardOptions.FindIndex(k => k.Key == clearClipboard);
}
private async Task UpdateAutoTotpCopyAsync()
@ -69,5 +148,31 @@ namespace Bit.App.Pages
await _storageService.SaveAsync(Constants.DisableFaviconKey, DisableFavicon);
await _stateService.SaveAsync(Constants.DisableFaviconKey, DisableFavicon);
}
private async Task SaveClipboardChangedAsync()
{
if(ClearClipboardSelectedIndex > -1)
{
await _storageService.SaveAsync(Constants.ClearClipboardKey,
ClearClipboardOptions[ClearClipboardSelectedIndex].Key);
}
}
private async Task SaveThemeAsync()
{
if(ThemeSelectedIndex > -1)
{
await _storageService.SaveAsync(Constants.ThemeKey, ThemeOptions[ThemeSelectedIndex].Key);
// TODO: change theme
}
}
private async Task SaveDefaultUriAsync()
{
if(UriMatchSelectedIndex > -1)
{
await _storageService.SaveAsync(Constants.DefaultUriMatch, UriMatchOptions[UriMatchSelectedIndex].Key);
}
}
}
}

View File

@ -879,6 +879,24 @@ namespace Bit.App.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Clear Clipboard.
/// </summary>
public static string ClearClipboard {
get {
return ResourceManager.GetString("ClearClipboard", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Automatically clear copied values from your clipboard..
/// </summary>
public static string ClearClipboardDescription {
get {
return ResourceManager.GetString("ClearClipboardDescription", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Close.
/// </summary>
@ -1086,6 +1104,15 @@ namespace Bit.App.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Dark.
/// </summary>
public static string Dark {
get {
return ResourceManager.GetString("Dark", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Password Updated.
/// </summary>
@ -1122,6 +1149,24 @@ namespace Bit.App.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Default URI Match Detection.
/// </summary>
public static string DefaultUriMatchDetection {
get {
return ResourceManager.GetString("DefaultUriMatchDetection", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Choose the default way that URI match detection is handled for logins when performing actions such as auto-fill..
/// </summary>
public static string DefaultUriMatchDetectionDescription {
get {
return ResourceManager.GetString("DefaultUriMatchDetectionDescription", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Delete.
/// </summary>
@ -1644,6 +1689,15 @@ namespace Bit.App.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to 5 minutes.
/// </summary>
public static string FiveMinutes {
get {
return ResourceManager.GetString("FiveMinutes", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Folder.
/// </summary>
@ -2040,6 +2094,15 @@ namespace Bit.App.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Light.
/// </summary>
public static string Light {
get {
return ResourceManager.GetString("Light", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Lock.
/// </summary>
@ -2706,6 +2769,15 @@ namespace Bit.App.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to 1 minute.
/// </summary>
public static string OneMinute {
get {
return ResourceManager.GetString("OneMinute", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Option defaults are set from the main Bitwarden app&apos;s password generator tool..
/// </summary>
@ -3381,6 +3453,15 @@ namespace Bit.App.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to 10 seconds.
/// </summary>
public static string TenSeconds {
get {
return ResourceManager.GetString("TenSeconds", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Thank You.
/// </summary>
@ -3390,6 +3471,33 @@ namespace Bit.App.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Theme.
/// </summary>
public static string Theme {
get {
return ResourceManager.GetString("Theme", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Change the application&apos;s color theme..
/// </summary>
public static string ThemeDescription {
get {
return ResourceManager.GetString("ThemeDescription", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 30 seconds.
/// </summary>
public static string ThirtySeconds {
get {
return ResourceManager.GetString("ThirtySeconds", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Title.
/// </summary>
@ -3435,6 +3543,24 @@ namespace Bit.App.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to 20 seconds.
/// </summary>
public static string TwentySeconds {
get {
return ResourceManager.GetString("TwentySeconds", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 2 minutes.
/// </summary>
public static string TwoMinutes {
get {
return ResourceManager.GetString("TwoMinutes", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Two-step Login.
/// </summary>

View File

@ -1509,4 +1509,52 @@
<data name="VaultLockedPIN" xml:space="preserve">
<value>Your vault is locked. Verify your PIN code to continue.</value>
</data>
<data name="Dark" xml:space="preserve">
<value>Dark</value>
<comment>A dark color</comment>
</data>
<data name="Light" xml:space="preserve">
<value>Light</value>
<comment>A light color</comment>
</data>
<data name="FiveMinutes" xml:space="preserve">
<value>5 minutes</value>
</data>
<data name="OneMinute" xml:space="preserve">
<value>1 minute</value>
</data>
<data name="TenSeconds" xml:space="preserve">
<value>10 seconds</value>
</data>
<data name="ThirtySeconds" xml:space="preserve">
<value>30 seconds</value>
</data>
<data name="TwentySeconds" xml:space="preserve">
<value>20 seconds</value>
</data>
<data name="TwoMinutes" xml:space="preserve">
<value>2 minutes</value>
</data>
<data name="ClearClipboard" xml:space="preserve">
<value>Clear Clipboard</value>
<comment>Clipboard is the operating system thing where you copy/paste data to on your device.</comment>
</data>
<data name="ClearClipboardDescription" xml:space="preserve">
<value>Automatically clear copied values from your clipboard.</value>
<comment>Clipboard is the operating system thing where you copy/paste data to on your device.</comment>
</data>
<data name="DefaultUriMatchDetection" xml:space="preserve">
<value>Default URI Match Detection</value>
<comment>Default URI match detection for auto-fill.</comment>
</data>
<data name="DefaultUriMatchDetectionDescription" xml:space="preserve">
<value>Choose the default way that URI match detection is handled for logins when performing actions such as auto-fill.</value>
</data>
<data name="Theme" xml:space="preserve">
<value>Theme</value>
<comment>Color theme</comment>
</data>
<data name="ThemeDescription" xml:space="preserve">
<value>Change the application's color theme.</value>
</data>
</root>

View File

@ -20,6 +20,8 @@
public static string PushCurrentTokenKey = "pushCurrentToken";
public static string PushLastRegistrationDateKey = "pushLastRegistrationDate";
public static string PushInitialPromptShownKey = "pushInitialPromptShown";
public static string ThemeKey = "theme";
public static string ClearClipboardKey = "clearClipboard";
public const int SelectFileRequestCode = 42;
public const int SelectFilePermissionRequestCode = 43;
}