added a11y disclosure prompt for Android (#2102)

This commit is contained in:
mp-bw 2022-09-27 14:03:06 -04:00 committed by GitHub
parent f9a32e4abc
commit 425be32c15
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 64 additions and 16 deletions

View file

@ -6,4 +6,5 @@
android:accessibilityFeedbackType="feedbackGeneric" android:accessibilityFeedbackType="feedbackGeneric"
android:accessibilityFlags="flagReportViewIds|flagRetrieveInteractiveWindows" android:accessibilityFlags="flagReportViewIds|flagRetrieveInteractiveWindows"
android:notificationTimeout="100" android:notificationTimeout="100"
android:canRetrieveWindowContent="true"/> android:canRetrieveWindowContent="true"
android:isAccessibilityTool="false"/>

View file

@ -83,7 +83,7 @@
StyleClass="box-value" StyleClass="box-value"
HorizontalOptions="End" /> HorizontalOptions="End" />
<Button <Button
Clicked="ToggleAccessibility" Command="{Binding ToggleAccessibilityCommand}"
StyleClass="box-overlay" StyleClass="box-overlay"
RelativeLayout.XConstraint="0" RelativeLayout.XConstraint="0"
RelativeLayout.YConstraint="0" RelativeLayout.YConstraint="0"

View file

@ -55,14 +55,6 @@ namespace Bit.App.Pages
_vm.ToggleInlineAutofill(); _vm.ToggleInlineAutofill();
} }
private void ToggleAccessibility(object sender, EventArgs e)
{
if (DoOnce())
{
_vm.ToggleAccessibility();
}
}
private void ToggleDrawOver(object sender, EventArgs e) private void ToggleDrawOver(object sender, EventArgs e)
{ {
if (DoOnce()) if (DoOnce())

View file

@ -1,9 +1,11 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Input;
using Bit.App.Abstractions; using Bit.App.Abstractions;
using Bit.App.Resources; using Bit.App.Resources;
using Bit.App.Services; using Bit.App.Services;
using Bit.Core.Abstractions; using Bit.Core.Abstractions;
using Bit.Core.Utilities; using Bit.Core.Utilities;
using Xamarin.CommunityToolkit.ObjectModel;
namespace Bit.App.Pages namespace Bit.App.Pages
{ {
@ -12,6 +14,8 @@ namespace Bit.App.Pages
private readonly IDeviceActionService _deviceActionService; private readonly IDeviceActionService _deviceActionService;
private readonly IStateService _stateService; private readonly IStateService _stateService;
private readonly MobileI18nService _i18nService; private readonly MobileI18nService _i18nService;
private readonly IPlatformUtilsService _platformUtilsService;
readonly LazyResolve<ILogger> _logger = new LazyResolve<ILogger>("logger");
private bool _autofillServiceToggled; private bool _autofillServiceToggled;
private bool _inlineAutofillToggled; private bool _inlineAutofillToggled;
@ -24,7 +28,11 @@ namespace Bit.App.Pages
_deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService"); _deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
_stateService = ServiceContainer.Resolve<IStateService>("stateService"); _stateService = ServiceContainer.Resolve<IStateService>("stateService");
_i18nService = ServiceContainer.Resolve<II18nService>("i18nService") as MobileI18nService; _i18nService = ServiceContainer.Resolve<II18nService>("i18nService") as MobileI18nService;
_platformUtilsService = ServiceContainer.Resolve<IPlatformUtilsService>("platformUtilsService");
PageTitle = AppResources.AutofillServices; PageTitle = AppResources.AutofillServices;
ToggleAccessibilityCommand = new AsyncCommand(ToggleAccessibilityAsync,
onException: ex => _logger.Value.Exception(ex),
allowsMultipleExecutions: false);
} }
#region Autofill Service #region Autofill Service
@ -74,6 +82,8 @@ namespace Bit.App.Pages
#region Accessibility #region Accessibility
public ICommand ToggleAccessibilityCommand { get; }
public string AccessibilityDescriptionLabel public string AccessibilityDescriptionLabel
{ {
get get
@ -176,8 +186,18 @@ namespace Bit.App.Pages
InlineAutofillToggled = !InlineAutofillToggled; InlineAutofillToggled = !InlineAutofillToggled;
} }
public void ToggleAccessibility() public async Task ToggleAccessibilityAsync()
{ {
if (!_deviceActionService.AutofillAccessibilityServiceRunning())
{
var accept = await _platformUtilsService.ShowDialogAsync(AppResources.AccessibilityDisclosureText,
AppResources.AccessibilityServiceDisclosure, AppResources.Accept,
AppResources.Decline);
if (!accept)
{
return;
}
}
_deviceActionService.OpenAccessibilitySettings(); _deviceActionService.OpenAccessibilitySettings();
} }

View file

@ -1,4 +1,4 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.42000 // Runtime Version:4.0.30319.42000
@ -4265,13 +4265,12 @@ namespace Bit.App.Resources {
} }
} }
public static string AllNotifications public static string AllNotifications {
{ get {
get
{
return ResourceManager.GetString("AllNotifications", resourceCulture); return ResourceManager.GetString("AllNotifications", resourceCulture);
} }
} }
public static string PasswordType { public static string PasswordType {
get { get {
return ResourceManager.GetString("PasswordType", resourceCulture); return ResourceManager.GetString("PasswordType", resourceCulture);
@ -4415,5 +4414,29 @@ namespace Bit.App.Resources {
return ResourceManager.GetString("Random", resourceCulture); return ResourceManager.GetString("Random", resourceCulture);
} }
} }
public static string AccessibilityServiceDisclosure {
get {
return ResourceManager.GetString("AccessibilityServiceDisclosure", resourceCulture);
}
}
public static string AccessibilityDisclosureText {
get {
return ResourceManager.GetString("AccessibilityDisclosureText", resourceCulture);
}
}
public static string Accept {
get {
return ResourceManager.GetString("Accept", resourceCulture);
}
}
public static string Decline {
get {
return ResourceManager.GetString("Decline", resourceCulture);
}
}
} }
} }

View file

@ -2449,4 +2449,16 @@ select Add TOTP to store the key safely</value>
<data name="Random" xml:space="preserve"> <data name="Random" xml:space="preserve">
<value>Random</value> <value>Random</value>
</data> </data>
<data name="AccessibilityServiceDisclosure" xml:space="preserve">
<value>Accessibility Service Disclosure</value>
</data>
<data name="AccessibilityDisclosureText" xml:space="preserve">
<value>Bitwarden uses the Accessibility Service to search for login fields in apps and websites, then establish the appropriate field IDs for entering a username &amp; password when a match for the app or site is found. We do not store any of the information presented to us by the service, nor do we make any attempt to control any on-screen elements beyond text entry of credentials.</value>
</data>
<data name="Accept" xml:space="preserve">
<value>Accept</value>
</data>
<data name="Decline" xml:space="preserve">
<value>Decline</value>
</data>
</root> </root>