mirror of
https://github.com/bitwarden/mobile
synced 2025-12-28 22:23:35 +00:00
* UI support in app settings for handling overlay permission requirement in Accessibility Service implementation * Cleaned up shorthand operator with new var
67 lines
1.9 KiB
C#
67 lines
1.9 KiB
C#
using Bit.App.Abstractions;
|
|
using Bit.App.Resources;
|
|
using Bit.Core.Utilities;
|
|
|
|
namespace Bit.App.Pages
|
|
{
|
|
public class AccessibilityServicePageViewModel : BaseViewModel
|
|
{
|
|
private readonly IDeviceActionService _deviceActionService;
|
|
|
|
private bool _enabled;
|
|
private bool _permitted;
|
|
|
|
public AccessibilityServicePageViewModel()
|
|
{
|
|
_deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
|
|
PageTitle = AppResources.AutofillAccessibilityService;
|
|
}
|
|
|
|
public bool Enabled
|
|
{
|
|
get => _enabled;
|
|
set => SetProperty(ref _enabled, value,
|
|
additionalPropertyNames: new string[]
|
|
{
|
|
nameof(EnabledWithoutPermission),
|
|
nameof(EnabledAndPermitted)
|
|
});
|
|
}
|
|
|
|
public bool Permitted
|
|
{
|
|
get => _permitted;
|
|
set => SetProperty(ref _permitted, value,
|
|
additionalPropertyNames: new string[]
|
|
{
|
|
nameof(EnabledWithoutPermission),
|
|
nameof(EnabledAndPermitted)
|
|
});
|
|
}
|
|
|
|
public bool EnabledWithoutPermission => _enabled && !_permitted;
|
|
|
|
public bool EnabledAndPermitted => _enabled && _permitted;
|
|
|
|
public void OpenSettings()
|
|
{
|
|
_deviceActionService.OpenAccessibilitySettings();
|
|
}
|
|
|
|
public void OpenOverlayPermissionSettings()
|
|
{
|
|
_deviceActionService.OpenAccessibilityOverlayPermissionSettings();
|
|
}
|
|
|
|
public void UpdateEnabled()
|
|
{
|
|
Enabled = _deviceActionService.AutofillAccessibilityServiceRunning();
|
|
}
|
|
|
|
public void UpdatePermitted()
|
|
{
|
|
Permitted = _deviceActionService.AutofillAccessibilityOverlayPermitted();
|
|
}
|
|
}
|
|
}
|