mirror of
https://github.com/bitwarden/android.git
synced 2024-12-24 18:08:26 +03:00
accessibility service autofill
This commit is contained in:
parent
21bbb2af42
commit
dc7b37c8f2
2 changed files with 136 additions and 12 deletions
|
@ -14,6 +14,22 @@
|
|||
|
||||
<ScrollView>
|
||||
<StackLayout Padding="0" Spacing="20">
|
||||
<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
|
||||
StyleClass="box-footer-label"
|
||||
Text="{u:I18n ThemeDescription}"
|
||||
x:Name="_themeDescriptionLabel" />
|
||||
</StackLayout>
|
||||
<StackLayout StyleClass="box">
|
||||
<StackLayout StyleClass="box-row, box-row-input">
|
||||
<Label
|
||||
|
@ -75,20 +91,53 @@
|
|||
StyleClass="box-footer-label" />
|
||||
</StackLayout>
|
||||
<StackLayout StyleClass="box">
|
||||
<StackLayout StyleClass="box-row, box-row-input">
|
||||
<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 Theme}"
|
||||
StyleClass="box-label" />
|
||||
<Picker
|
||||
x:Name="_themePicker"
|
||||
ItemsSource="{Binding ThemeOptions, Mode=OneTime}"
|
||||
SelectedIndex="{Binding ThemeSelectedIndex}"
|
||||
StyleClass="box-value" />
|
||||
Text="{u:I18n AutofillAlways}"
|
||||
StyleClass="box-label, box-label-regular"
|
||||
HorizontalOptions="StartAndExpand" />
|
||||
<Switch
|
||||
IsToggled="{Binding AutofillAlwaysScan}"
|
||||
StyleClass="box-value"
|
||||
HorizontalOptions="End" />
|
||||
</StackLayout>
|
||||
<Label
|
||||
StyleClass="box-footer-label"
|
||||
Text="{u:I18n ThemeDescription}"
|
||||
x:Name="_themeDescriptionLabel" />
|
||||
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>
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue