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:
45
src/Core/ResumeWindow.cs
Normal file
45
src/Core/ResumeWindow.cs
Normal 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){ }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user