diff --git a/src/Core/App.xaml.cs b/src/Core/App.xaml.cs index 71e62a0b9..9c7f3eb68 100644 --- a/src/Core/App.xaml.cs +++ b/src/Core/App.xaml.cs @@ -96,8 +96,9 @@ namespace Bit.App if (Options != null && (Options.FromAutofillFramework || Options.Uri != null || Options.OtpData != null || Options.CreateSend != null)) //"Internal" Autofill and Uri/Otp/CreateSend { - _autofillWindow = new Window(new NavigationPage(new AndroidExtSplashPage(Options))); + _autofillWindow = new Window(new NavigationPage(new AndroidNavigationRedirectPage())); CurrentWindow = _autofillWindow; + _isResumed = true; return CurrentWindow; } diff --git a/src/Core/Core.csproj b/src/Core/Core.csproj index 11894a2d2..dd00cad53 100644 --- a/src/Core/Core.csproj +++ b/src/Core/Core.csproj @@ -85,6 +85,9 @@ AppResources.Designer.cs PublicResXFileCodeGenerator + + AndroidNavigationRedirectPage.xaml + AppResources.resx True @@ -92,7 +95,7 @@ - + MSBuild:Compile diff --git a/src/Core/Pages/AndroidExtSplashPage.xaml.cs b/src/Core/Pages/AndroidExtSplashPage.xaml.cs deleted file mode 100644 index a35894ae9..000000000 --- a/src/Core/Pages/AndroidExtSplashPage.xaml.cs +++ /dev/null @@ -1,105 +0,0 @@ -using Bit.App.Models; -using Bit.App.Pages; -using Bit.App.Utilities.AccountManagement; -using Bit.Core.Abstractions; -using Bit.Core.Utilities; - -namespace Bit.Core.Pages; - -public partial class AndroidExtSplashPage : ContentPage -{ - private IConditionedAwaiterManager _conditionedAwaiterManager; - private IVaultTimeoutService _vaultTimeoutService; - private IStateService _stateService; - private AppOptions _appOptions; - - public AndroidExtSplashPage(AppOptions appOptions) - { - InitializeComponent(); - _appOptions = appOptions ?? new AppOptions(); - _conditionedAwaiterManager = ServiceContainer.Resolve(); - _vaultTimeoutService = ServiceContainer.Resolve("vaultTimeoutService"); - _stateService = ServiceContainer.Resolve(); - } - - private async Task GetNavigationToExecuteAsync(AppOptions options, Window window) - { - await _conditionedAwaiterManager.GetAwaiterForPrecondition(AwaiterPrecondition.EnvironmentUrlsInited); - - var authed = await _stateService.IsAuthenticatedAsync(); - if (authed) - { - if (await _vaultTimeoutService.IsLoggedOutByTimeoutAsync() || - await _vaultTimeoutService.ShouldLogOutByTimeoutAsync()) - { - // TODO implement orgIdentifier flow to SSO Login page, same as email flow below - // var orgIdentifier = await _stateService.GetOrgIdentifierAsync(); - - var email = await _stateService.GetEmailAsync(); - options.HideAccountSwitcher = await _stateService.GetActiveUserIdAsync() == null; - var navParams = new LoginNavigationParams(email); - if (navParams is LoginNavigationParams loginParams) - { - window.Page = new NavigationPage(new LoginPage(loginParams.Email, options)); - } - } - else if (await _vaultTimeoutService.IsLockedAsync() || - await _vaultTimeoutService.ShouldLockAsync()) - { - /* //TODO: is lockParams needed here? - if (navParams is LockNavigationParams lockParams) - { - return () => new Window(new NavigationPage(new LockPage(Options, lockParams.AutoPromptBiometric))); - } - else - {*/ - window.Page = new NavigationPage(new LockPage(options)); - /*}*/ - } - else if (options.FromAutofillFramework && options.SaveType.HasValue) - { - window.Page = new NavigationPage(new CipherAddEditPage(appOptions: options)); - } - else if (options.Uri != null) - { - window.Page = new NavigationPage(new CipherSelectionPage(options)); - } - else if (options.OtpData != null) - { - window.Page = new NavigationPage(new CipherSelectionPage(options)); - } - else if (options.CreateSend != null) - { - window.Page = new NavigationPage(new SendAddEditPage(options)); - } - else - { - window.Page = new TabsPage(options); - } - } - else - { - options.HideAccountSwitcher = await _stateService.GetActiveUserIdAsync() == null; - if (await _vaultTimeoutService.IsLoggedOutByTimeoutAsync() || - await _vaultTimeoutService.ShouldLogOutByTimeoutAsync()) - { - // TODO implement orgIdentifier flow to SSO Login page, same as email flow below - // var orgIdentifier = await _stateService.GetOrgIdentifierAsync(); - - var email = await _stateService.GetEmailAsync(); - await _stateService.SetRememberedEmailAsync(email); - - window.Page = new NavigationPage(new HomePage(options)); - } - else - { - window.Page = new NavigationPage(new HomePage(options)); - } - } - } - - private async void AndroidExtSplashPage_OnLoaded(object sender, EventArgs e) - { - await GetNavigationToExecuteAsync(_appOptions, this.Window); - } -} diff --git a/src/Core/Pages/AndroidExtSplashPage.xaml b/src/Core/Pages/AndroidNavigationRedirectPage.xaml similarity index 66% rename from src/Core/Pages/AndroidExtSplashPage.xaml rename to src/Core/Pages/AndroidNavigationRedirectPage.xaml index e54fc5a37..7ef2ab683 100644 --- a/src/Core/Pages/AndroidExtSplashPage.xaml +++ b/src/Core/Pages/AndroidNavigationRedirectPage.xaml @@ -1,9 +1,8 @@ + x:Class="Bit.Core.Pages.AndroidNavigationRedirectPage" + Loaded="AndroidNavigationRedirectPage_OnLoaded"> diff --git a/src/Core/Pages/AndroidNavigationRedirectPage.xaml.cs b/src/Core/Pages/AndroidNavigationRedirectPage.xaml.cs new file mode 100644 index 000000000..a96fa09ee --- /dev/null +++ b/src/Core/Pages/AndroidNavigationRedirectPage.xaml.cs @@ -0,0 +1,20 @@ +using Bit.App.Abstractions; +using Bit.Core.Utilities; + +namespace Bit.Core.Pages; + +public partial class AndroidNavigationRedirectPage : ContentPage +{ + private readonly IAccountsManager _accountsManager; + + public AndroidNavigationRedirectPage() + { + _accountsManager = ServiceContainer.Resolve("accountsManager"); + InitializeComponent(); + } + + private void AndroidNavigationRedirectPage_OnLoaded(object sender, EventArgs e) + { + _accountsManager.NavigateOnAccountChangeAsync().FireAndForget(); + } +}