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:accessibilityFlags="flagReportViewIds|flagRetrieveInteractiveWindows"
android:notificationTimeout="100"
android:canRetrieveWindowContent="true"/>
android:canRetrieveWindowContent="true"
android:isAccessibilityTool="false"/>

View File

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

View File

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

View File

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

View File

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