1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-05 23:53:33 +00:00

accessibility service autofill

This commit is contained in:
Kyle Spearrin
2019-05-30 12:37:35 -04:00
parent 21bbb2af42
commit dc7b37c8f2
2 changed files with 136 additions and 12 deletions

View File

@@ -20,12 +20,17 @@ namespace Bit.App.Pages
private readonly IStateService _stateService;
private readonly IMessagingService _messagingService;
private bool _autofillAlwaysScan;
private bool _autofillPersistNotification;
private bool _autofillPasswordField;
private bool _disableFavicon;
private bool _disableAutoTotpCopy;
private int _clearClipboardSelectedIndex;
private int _themeSelectedIndex;
private int _uriMatchSelectedIndex;
private bool _inited;
private bool _updatingAutofill;
public OptionsPageViewModel()
{
@@ -129,10 +134,51 @@ namespace Bit.App.Pages
}
}
public bool AutofillAlwaysScan
{
get => _autofillAlwaysScan;
set
{
if(SetProperty(ref _autofillAlwaysScan, value))
{
var task = UpdateAutofillAsync(false, false);
}
}
}
public bool AutofillPersistNotification
{
get => _autofillPersistNotification;
set
{
if(SetProperty(ref _autofillPersistNotification, value))
{
var task = UpdateAutofillAsync(value, false);
}
}
}
public bool AutofillPasswordField
{
get => _autofillPasswordField;
set
{
if(SetProperty(ref _autofillPasswordField, value))
{
var task = UpdateAutofillAsync(false, value);
}
}
}
public async Task InitAsync()
{
AutofillPersistNotification = (await _storageService.GetAsync<bool?>(
Constants.AccessibilityAutofillPersistNotificationKey)).GetValueOrDefault();
AutofillPasswordField = (await _storageService.GetAsync<bool?>(
Constants.AccessibilityAutofillPasswordFieldKey)).GetValueOrDefault();
AutofillAlwaysScan = !AutofillPersistNotification && !AutofillPasswordField;
DisableAutoTotpCopy = !(await _totpService.IsAutoCopyEnabledAsync());
DisableFavicon = await _storageService.GetAsync<bool>(Constants.DisableFaviconKey);
DisableFavicon = (await _storageService.GetAsync<bool?>(Constants.DisableFaviconKey)).GetValueOrDefault();
var theme = await _storageService.GetAsync<string>(Constants.ThemeKey);
ThemeSelectedIndex = ThemeOptions.FindIndex(k => k.Key == theme);
var defaultUriMatch = await _storageService.GetAsync<int?>(Constants.DefaultUriMatch);
@@ -143,6 +189,35 @@ namespace Bit.App.Pages
_inited = true;
}
private async Task UpdateAutofillAsync(bool persistNotification, bool passwordField)
{
if(_inited && !_updatingAutofill)
{
_updatingAutofill = true;
if(persistNotification)
{
AutofillAlwaysScan = false;
AutofillPasswordField = false;
}
else if(passwordField)
{
AutofillAlwaysScan = false;
AutofillPersistNotification = false;
}
else
{
AutofillAlwaysScan = true;
AutofillPersistNotification = false;
AutofillPasswordField = false;
}
await _storageService.SaveAsync(Constants.AccessibilityAutofillPersistNotificationKey,
AutofillPersistNotification);
await _storageService.SaveAsync(Constants.AccessibilityAutofillPasswordFieldKey,
AutofillPasswordField);
_updatingAutofill = false;
}
}
private async Task UpdateAutoTotpCopyAsync()
{
if(_inited)