@ -1,9 +1,11 @@
@@ -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
@@ -12,6 +14,8 @@ namespace Bit.App.Pages
private readonly IDeviceActionService _d eviceActionService ;
private readonly IStateService _ stateService ;
private readonly MobileI18nService _ i18nService ;
private readonly IPlatformUtilsService _ platformUtilsService ;
readonly LazyResolve < ILogger > _l ogger = new LazyResolve < ILogger > ( "logger" ) ;
private bool _ autofillServiceToggled ;
private bool _ inlineAutofillToggled ;
@ -24,7 +28,11 @@ namespace Bit.App.Pages
@@ -24,7 +28,11 @@ namespace Bit.App.Pages
_d eviceActionService = 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 = > _l ogger . Value . Exception ( ex ) ,
allowsMultipleExecutions : false ) ;
}
#region Autofill Service
@ -74,6 +82,8 @@ namespace Bit.App.Pages
@@ -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
@@ -176,8 +186,18 @@ namespace Bit.App.Pages
InlineAutofillToggled = ! InlineAutofillToggled ;
}
public void ToggleAccessibility ( )
public async Task ToggleAccessibilityAsync ( )
{
if ( ! _d eviceActionService . AutofillAccessibilityServiceRunning ( ) )
{
var accept = await _ platformUtilsService . ShowDialogAsync ( AppResources . AccessibilityDisclosureText ,
AppResources . AccessibilityServiceDisclosure , AppResources . Accept ,
AppResources . Decline ) ;
if ( ! accept )
{
return ;
}
}
_d eviceActionService . OpenAccessibilitySettings ( ) ;
}