new autofill options

This commit is contained in:
Kyle Spearrin 2019-06-03 10:45:27 -04:00
parent 59f1dcca12
commit 8658ebd6bb
6 changed files with 214 additions and 42 deletions

View File

@ -90,54 +90,94 @@
Text="{u:I18n DisableWebsiteIconsDescription}"
StyleClass="box-footer-label" />
</StackLayout>
<StackLayout StyleClass="box">
<StackLayout StyleClass="box-row-header">
<Label Text="{u:I18n AutofillAccessibilityService}"
StyleClass="box-header, box-header-platform" />
</StackLayout>
<StackLayout StyleClass="box-row, box-row-switch">
<StackLayout Spacing="0" Padding="0" IsVisible="{Binding AndroidOptions}">
<StackLayout StyleClass="box">
<StackLayout StyleClass="box-row-header">
<Label Text="{u:I18n AutofillService}"
StyleClass="box-header, box-header-platform" />
</StackLayout>
<StackLayout StyleClass="box-row, box-row-switch">
<Label
Text="{u:I18n DisableSavePrompt}"
StyleClass="box-label, box-label-regular"
HorizontalOptions="StartAndExpand" />
<Switch
IsToggled="{Binding AutofillDisableSavePrompt}"
StyleClass="box-value"
HorizontalOptions="End" />
</StackLayout>
<Label
Text="{u:I18n AutofillAlways}"
StyleClass="box-label, box-label-regular"
HorizontalOptions="StartAndExpand" />
<Switch
IsToggled="{Binding AutofillAlwaysScan}"
StyleClass="box-value"
HorizontalOptions="End" />
Text="{u:I18n DisableSavePromptDescription}"
StyleClass="box-footer-label" />
</StackLayout>
<Label
Text="{u:I18n AutofillAlwaysDescription}"
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 BlacklistedUris}"
StyleClass="box-label" />
<Editor
x:Name="_blacklistedUrisEditor"
Text="{Binding AutofillBlacklistedUris}"
StyleClass="box-value"
AutoSize="TextChanges"
IsSpellCheckEnabled="False"
IsTextPredictionEnabled="False"
Keyboard="Plain"
Unfocused="BlacklistedUrisEditor_Unfocused" />
</StackLayout>
<Label
Text="{u:I18n AutofillPersistNotification}"
StyleClass="box-label, box-label-regular"
HorizontalOptions="StartAndExpand" />
<Switch
IsToggled="{Binding AutofillPersistNotification}"
StyleClass="box-value"
HorizontalOptions="End" />
Text="{u:I18n BlacklistedUrisDescription}"
StyleClass="box-footer-label" />
</StackLayout>
<Label
Text="{u:I18n AutofillPersistNotificationDescription}"
StyleClass="box-footer-label" />
</StackLayout>
<StackLayout StyleClass="box">
<StackLayout StyleClass="box-row, box-row-switch">
<StackLayout StyleClass="box">
<StackLayout StyleClass="box-row-header">
<Label Text="{u:I18n AutofillAccessibilityService}"
StyleClass="box-header, box-header-platform" />
</StackLayout>
<StackLayout StyleClass="box-row, box-row-switch">
<Label
Text="{u:I18n AutofillAlways}"
StyleClass="box-label, box-label-regular"
HorizontalOptions="StartAndExpand" />
<Switch
IsToggled="{Binding AutofillAlwaysScan}"
StyleClass="box-value"
HorizontalOptions="End" />
</StackLayout>
<Label
Text="{u:I18n AutofillPasswordField}"
StyleClass="box-label, box-label-regular"
HorizontalOptions="StartAndExpand" />
<Switch
IsToggled="{Binding AutofillPasswordField}"
StyleClass="box-value"
HorizontalOptions="End" />
Text="{u:I18n AutofillAlwaysDescription}"
StyleClass="box-footer-label" />
</StackLayout>
<StackLayout StyleClass="box">
<StackLayout StyleClass="box-row, box-row-switch">
<Label
Text="{u:I18n AutofillPersistNotification}"
StyleClass="box-label, box-label-regular"
HorizontalOptions="StartAndExpand" />
<Switch
IsToggled="{Binding AutofillPersistNotification}"
StyleClass="box-value"
HorizontalOptions="End" />
</StackLayout>
<Label
Text="{u:I18n AutofillPersistNotificationDescription}"
StyleClass="box-footer-label" />
</StackLayout>
<StackLayout StyleClass="box">
<StackLayout StyleClass="box-row, box-row-switch">
<Label
Text="{u:I18n AutofillPasswordField}"
StyleClass="box-label, box-label-regular"
HorizontalOptions="StartAndExpand" />
<Switch
IsToggled="{Binding AutofillPasswordField}"
StyleClass="box-value"
HorizontalOptions="End" />
</StackLayout>
<Label
Text="{u:I18n AutofillPasswordFieldDescription}"
StyleClass="box-footer-label" />
</StackLayout>
<Label
Text="{u:I18n AutofillPasswordFieldDescription}"
StyleClass="box-footer-label" />
</StackLayout>
</StackLayout>
</ScrollView>

View File

@ -19,6 +19,7 @@ namespace Bit.App.Pages
_clearClipboardPicker.ItemDisplayBinding = new Binding("Value");
if(Device.RuntimePlatform == Device.Android)
{
_vm.AndroidOptions = true;
_themeDescriptionLabel.Text = string.Concat(_themeDescriptionLabel.Text, " ",
AppResources.RestartIsRequired);
}
@ -29,5 +30,16 @@ namespace Bit.App.Pages
base.OnAppearing();
await _vm.InitAsync();
}
protected async override void OnDisappearing()
{
base.OnDisappearing();
await _vm.UpdateAutofillBlacklistedUris();
}
private async void BlacklistedUrisEditor_Unfocused(object sender, FocusEventArgs e)
{
await _vm.UpdateAutofillBlacklistedUris();
}
}
}

View File

@ -24,6 +24,8 @@ namespace Bit.App.Pages
private bool _autofillAlwaysScan;
private bool _autofillPersistNotification;
private bool _autofillPasswordField;
private bool _autofillDisableSavePrompt;
private string _autofillBlacklistedUris;
private bool _disableFavicon;
private bool _disableAutoTotpCopy;
private int _clearClipboardSelectedIndex;
@ -31,6 +33,7 @@ namespace Bit.App.Pages
private int _uriMatchSelectedIndex;
private bool _inited;
private bool _updatingAutofill;
private bool _androidOptions;
public OptionsPageViewModel()
{
@ -174,8 +177,37 @@ namespace Bit.App.Pages
}
}
public bool AutofillDisableSavePrompt
{
get => _autofillDisableSavePrompt;
set
{
if(SetProperty(ref _autofillDisableSavePrompt, value))
{
var task = UpdateAutofillDisableSavePromptAsync();
}
}
}
public string AutofillBlacklistedUris
{
get => _autofillBlacklistedUris;
set => SetProperty(ref _autofillBlacklistedUris, value);
}
public bool AndroidOptions
{
get => _androidOptions;
set => SetProperty(ref _androidOptions, value);
}
public async Task InitAsync()
{
AutofillDisableSavePrompt = (await _storageService.GetAsync<bool?>(
Constants.AutofillDisableSavePromptKey)).GetValueOrDefault();
var blacklistedUrisList = await _storageService.GetAsync<List<string>>(
Constants.AutofillBlacklistedUrisKey);
AutofillBlacklistedUris = blacklistedUrisList != null ? string.Join(", ", blacklistedUrisList) : null;
AutofillPersistNotification = (await _storageService.GetAsync<bool?>(
Constants.AccessibilityAutofillPersistNotificationKey)).GetValueOrDefault();
AutofillPasswordField = (await _storageService.GetAsync<bool?>(
@ -271,5 +303,43 @@ namespace Bit.App.Pages
(int?)UriMatchOptions[UriMatchSelectedIndex].Key);
}
}
private async Task UpdateAutofillDisableSavePromptAsync()
{
if(_inited)
{
await _storageService.SaveAsync(Constants.AutofillDisableSavePromptKey, AutofillDisableSavePrompt);
}
}
public async Task UpdateAutofillBlacklistedUris()
{
if(_inited)
{
if(string.IsNullOrWhiteSpace(AutofillBlacklistedUris))
{
await _storageService.RemoveAsync(Constants.AutofillBlacklistedUrisKey);
AutofillBlacklistedUris = null;
return;
}
try
{
var csv = AutofillBlacklistedUris;
var urisList = new List<string>();
foreach(var uri in csv.Split(','))
{
if(!uri.StartsWith("http://") && !uri.StartsWith("https://") &&
!uri.StartsWith(Constants.AndroidAppProtocol))
{
continue;
}
urisList.Add(uri.Replace("\\n", string.Empty).Trim());
}
await _storageService.SaveAsync(Constants.AutofillBlacklistedUrisKey, urisList);
AutofillBlacklistedUris = string.Join(", ", urisList);
}
catch { }
}
}
}
}

View File

@ -735,6 +735,24 @@ namespace Bit.App.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Blacklisted URIs.
/// </summary>
public static string BlacklistedUris {
get {
return ResourceManager.GetString("BlacklistedUris", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to URIs that are blacklisted will not offer auto-fill. The list of apps should be comma separated. Ex: &quot;https://twitter.com, androidapp://com.twitter.android&quot;..
/// </summary>
public static string BlacklistedUrisDescription {
get {
return ResourceManager.GetString("BlacklistedUrisDescription", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Brand.
/// </summary>
@ -1230,6 +1248,24 @@ namespace Bit.App.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Disable Save Prompt.
/// </summary>
public static string DisableSavePrompt {
get {
return ResourceManager.GetString("DisableSavePrompt", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The &quot;Save Prompt&quot; automatically prompts you to save new items to your vault whenever you enter them for the first time..
/// </summary>
public static string DisableSavePromptDescription {
get {
return ResourceManager.GetString("DisableSavePromptDescription", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Disable Website Icons.
/// </summary>

View File

@ -1580,4 +1580,16 @@
<value>Black</value>
<comment>The color black</comment>
</data>
<data name="BlacklistedUris" xml:space="preserve">
<value>Blacklisted URIs</value>
</data>
<data name="BlacklistedUrisDescription" xml:space="preserve">
<value>URIs that are blacklisted will not offer auto-fill. The list of apps should be comma separated. Ex: "https://twitter.com, androidapp://com.twitter.android".</value>
</data>
<data name="DisableSavePrompt" xml:space="preserve">
<value>Disable Save Prompt</value>
</data>
<data name="DisableSavePromptDescription" xml:space="preserve">
<value>The "Save Prompt" automatically prompts you to save new items to your vault whenever you enter them for the first time.</value>
</data>
</root>

View File

@ -15,6 +15,8 @@
public static string LastFileCacheClearKey = "lastFileCacheClear";
public static string AccessibilityAutofillPasswordFieldKey = "accessibilityAutofillPasswordField";
public static string AccessibilityAutofillPersistNotificationKey = "accessibilityAutofillPersistNotification";
public static string AutofillDisableSavePromptKey = "autofillDisableSavePrompt";
public static string AutofillBlacklistedUrisKey = "autofillBlacklistedUris";
public static string DisableFaviconKey = "disableFavicon";
public static string PushRegisteredTokenKey = "pushRegisteredToken";
public static string PushCurrentTokenKey = "pushCurrentToken";