From 3c87d4db1c8c24cb599cc1d20328678e1b6fce16 Mon Sep 17 00:00:00 2001 From: Dinis Vieira Date: Fri, 15 Dec 2023 13:48:34 +0000 Subject: [PATCH] minor improvemments on autofill-redirect --- src/Core/App.xaml.cs | 18 +++++++++--------- src/Core/Pages/AndroidExtSplashPage.xaml.cs | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Core/App.xaml.cs b/src/Core/App.xaml.cs index d902582f6..0b53091dd 100644 --- a/src/Core/App.xaml.cs +++ b/src/Core/App.xaml.cs @@ -81,7 +81,7 @@ namespace Bit.App public void SetOptions(AppOptions appOptions) { - Options = appOptions; + Options = appOptions ?? new AppOptions(); } protected override Window CreateWindow(IActivationState activationState) @@ -93,25 +93,25 @@ namespace Bit.App { return new Window(new NavigationPage()); //No actual page needed. Only used for auto-filling the fields directly (externally) } - else if (Options.FromAutofillFramework || Options.Uri != null || Options.OtpData != null || Options.CreateSend != null) //"Internal" Autofill and Uri/Otp/CreateSend + + 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))); CurrentWindow = _autofillWindow; return CurrentWindow; } - else if(CurrentWindow != null) + + if(CurrentWindow != null) { //TODO: This likely crashes if we try to have two apps side-by-side on Android //TODO: Question: In these scenarios should a new Window be created or can the same one be reused? CurrentWindow = _mainWindow; return CurrentWindow; } - else - { - _mainWindow = new Window(new NavigationPage(new HomePage(Options))); - CurrentWindow = _mainWindow; - return CurrentWindow; - } + + _mainWindow = new Window(new NavigationPage(new HomePage(Options))); + CurrentWindow = _mainWindow; + return CurrentWindow; } #elif IOS public new static Page MainPage diff --git a/src/Core/Pages/AndroidExtSplashPage.xaml.cs b/src/Core/Pages/AndroidExtSplashPage.xaml.cs index 90485c534..a35894ae9 100644 --- a/src/Core/Pages/AndroidExtSplashPage.xaml.cs +++ b/src/Core/Pages/AndroidExtSplashPage.xaml.cs @@ -16,7 +16,7 @@ public partial class AndroidExtSplashPage : ContentPage public AndroidExtSplashPage(AppOptions appOptions) { InitializeComponent(); - _appOptions = appOptions; + _appOptions = appOptions ?? new AppOptions(); _conditionedAwaiterManager = ServiceContainer.Resolve(); _vaultTimeoutService = ServiceContainer.Resolve("vaultTimeoutService"); _stateService = ServiceContainer.Resolve();