1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-17 08:43:21 +00:00

PM-3349 Added custom window so that we can always get the current Active Window. This is used to support the Android Autofil and multi-window scenarios.

This commit is contained in:
Dinis Vieira
2023-12-23 12:30:21 +00:00
parent 6d4c706026
commit b6ff6e34f6
2 changed files with 65 additions and 56 deletions

45
src/Core/ResumeWindow.cs Normal file
View File

@@ -0,0 +1,45 @@
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;
}
}
public class MainAppWindow : ResumeWindow
{
public MainAppWindow(Page page) : base(page) { }
}
public class AutoFillWindow : ResumeWindow
{
public AutoFillWindow(Page page) : base(page){ }
}
}