From 602627b5fa145c1654ca6ac1b13d0bda8124e306 Mon Sep 17 00:00:00 2001 From: Dinis Vieira Date: Fri, 1 Mar 2024 19:17:45 +0000 Subject: [PATCH] PM-6552 Fix for App only showing Home (Login) Page after closed after opening Accessibility Settings (#3047) --- src/Core/App.xaml.cs | 14 ++++++++++++++ .../AutofillSettingsPageViewModel.android.cs | 5 +++++ 2 files changed, 19 insertions(+) diff --git a/src/Core/App.xaml.cs b/src/Core/App.xaml.cs index 25b882d72..b94e95df6 100644 --- a/src/Core/App.xaml.cs +++ b/src/Core/App.xaml.cs @@ -108,6 +108,8 @@ namespace Bit.App } } + public bool HasNavigatedToAccessibilitySettings { get; set; } + protected override Window CreateWindow(IActivationState activationState) { //When executing from AutofillExternalActivity we don't have "Options" so we need to filter "manually" @@ -146,6 +148,18 @@ namespace Bit.App _hasNavigatedToAutofillWindow = false; } + // WORKAROUND: This workaround is similar to the one above (_hasNavigatedToAutofillWindow) related with Accessibility Services but this one specifically + // is due to trying to open the Accessibility Settings Page for enabled/disabling + if(HasNavigatedToAccessibilitySettings) + { + homePage.PerformNavigationOnAccountChangedOnLoad = true; + // this is needed because when coming back from AutofillWindow OnResume won't be called and we need this flag + // so that void Navigate(NavigationTarget navTarget, INavigationParams navParams) doesn't enqueue the navigation + // and it performs it directly. + _isResumed = true; + HasNavigatedToAccessibilitySettings = false; + } + //If we have an existing MainAppWindow we can use that one var mainAppWindow = Windows.OfType().FirstOrDefault(); if (mainAppWindow != null) diff --git a/src/Core/Pages/Settings/AutofillSettingsPageViewModel.android.cs b/src/Core/Pages/Settings/AutofillSettingsPageViewModel.android.cs index 90e3b42c3..0d7ead1dd 100644 --- a/src/Core/Pages/Settings/AutofillSettingsPageViewModel.android.cs +++ b/src/Core/Pages/Settings/AutofillSettingsPageViewModel.android.cs @@ -158,6 +158,11 @@ namespace Bit.App.Pages await MainThread.InvokeOnMainThreadAsync(() => TriggerPropertyChanged(nameof(UseAccessibility))); return; } + +#if ANDROID + // WORKAROUND: Set workaround property to avoid an issue when launching the app after being in Accessibility Settings. More Info on App.xaml.cs + ((App)Application.Current).HasNavigatedToAccessibilitySettings = true; +#endif _deviceActionService.OpenAccessibilitySettings(); }