1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-09-27 03:52:57 +02:00
bitwarden-mobile/src/Core/ResumeWindow.cs
Dinis Vieira 40c80f082d
[PM-6552] Fix for Android Window issues when opening Autofill/Accessibility (#3051)
* PM-6552 Removed several of the Window Workarounds for Android. Now always relying on the AndroidNavigationRedirectPage.
AndroidNavigationRedirectPage now more resilient to failure and navigates to HomePage as fallback.

* Update src/Core/Pages/AndroidNavigationRedirectPage.xaml.cs

Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>

---------

Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
2024-03-04 13:03:09 +00:00

36 lines
1.1 KiB
C#

namespace Bit.Core
{
// This ResumeWindow is used as a Workaround for Android to be able to find the current "IsActive" Window
// It also allows setting a "PendingPage" on an existing Window which then navigates when the Window is active.
public class ResumeWindow : Window
{
public Page PendingPage {get;set;}
public bool IsActive { get; set; }
public ResumeWindow(Page page) : base(page) { }
/// <summary>
/// You need to do this inside OnActivated not OnResumed
/// Androids OnResume maps to OnActivated
/// Androids OnRestart is what Maps to OnResumed
/// I realize this is confusing from the perspective of Android
/// https://github.com/dotnet/maui/issues/1720 explains it a bit better
/// </summary>
protected override void OnActivated()
{
base.OnActivated();
if (PendingPage is not null)
Page = PendingPage;
PendingPage = null;
IsActive = true;
}
protected override void OnDeactivated()
{
IsActive = false;
}
}
}