mirror of
https://github.com/bitwarden/mobile.git
synced 2024-11-07 09:20:04 +01:00
Reusing App.xaml.cs Navigation for the Android RedirectPage
Some other cleanup and changes
This commit is contained in:
parent
da0866cc85
commit
e39898bba6
@ -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;
|
||||
}
|
||||
|
||||
|
@ -85,6 +85,9 @@
|
||||
<LastGenOutput>AppResources.Designer.cs</LastGenOutput>
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
</EmbeddedResource>
|
||||
<Compile Update="Pages\AndroidNavigationRedirectPage.xaml.cs">
|
||||
<DependentUpon>AndroidNavigationRedirectPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Resources\Localization\AppResources.Designer.cs">
|
||||
<DependentUpon>AppResources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
@ -92,7 +95,7 @@
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<MauiXaml Update="Pages\AndroidExtSplashPage.xaml">
|
||||
<MauiXaml Update="Pages\AndroidNavigationRedirectPage.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</MauiXaml>
|
||||
</ItemGroup>
|
||||
|
@ -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<IConditionedAwaiterManager>();
|
||||
_vaultTimeoutService = ServiceContainer.Resolve<IVaultTimeoutService>("vaultTimeoutService");
|
||||
_stateService = ServiceContainer.Resolve<IStateService>();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
@ -1,9 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="Bit.Core.Pages.AndroidExtSplashPage"
|
||||
Title="AndroidExtSplashPage"
|
||||
Loaded="AndroidExtSplashPage_OnLoaded">
|
||||
x:Class="Bit.Core.Pages.AndroidNavigationRedirectPage"
|
||||
Loaded="AndroidNavigationRedirectPage_OnLoaded">
|
||||
<Grid>
|
||||
<ActivityIndicator VerticalOptions="Center" HorizontalOptions="Center" IsRunning="True" />
|
||||
</Grid>
|
20
src/Core/Pages/AndroidNavigationRedirectPage.xaml.cs
Normal file
20
src/Core/Pages/AndroidNavigationRedirectPage.xaml.cs
Normal file
@ -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<IAccountsManager>("accountsManager");
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void AndroidNavigationRedirectPage_OnLoaded(object sender, EventArgs e)
|
||||
{
|
||||
_accountsManager.NavigateOnAccountChangeAsync().FireAndForget();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user