1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-28 14:13:25 +00:00

PM-5903 Changed App.xaml.cs SetOption to only update the needed properties instead of replacing the existing Options object which would cause the AccountSwitcher button bug (#2973)

This commit is contained in:
Dinis Vieira
2024-02-03 15:59:22 +00:00
committed by GitHub
parent eb95a54db2
commit f1854f2c04
2 changed files with 22 additions and 4 deletions

View File

@@ -76,7 +76,8 @@ namespace Bit.Droid
//We need to get and set the Options before calling OnCreate as that will "trigger" CreateWindow on App.xaml.cs
_appOptions = GetOptions();
((Bit.App.App)Microsoft.Maui.Controls.Application.Current).SetOptions(_appOptions);
//This does not replace existing Options in App.xaml.cs if it exists already. It only updates properties in Options related with Autofill/CreateSend/etc..
((Bit.App.App)Microsoft.Maui.Controls.Application.Current).SetAndroidOptions(_appOptions);
base.OnCreate(savedInstanceState);

View File

@@ -85,10 +85,27 @@ namespace Bit.App
}
}
//Allows setting Options from MainActivity before base.OnCreate
public void SetOptions(AppOptions appOptions)
/// <summary>
/// Allows setting Options from MainActivity before base.OnCreate
/// Note 1: This is only be used by Android due to way it's Lifecycle works
/// Note 2: This method does not replace existing Options in App.xaml.cs if it exists already.
/// It only updates properties in Options related with Autofill/CreateSend/etc..
/// </summary>
/// <param name="appOptions">Options created in Android MainActivity.cs</param>
public void SetAndroidOptions(AppOptions appOptions)
{
Options = appOptions ?? new AppOptions();
if (Options == null)
{
Options = appOptions ?? new AppOptions();
}
else if(appOptions != null)
{
Options.Uri = appOptions.Uri;
Options.MyVaultTile = appOptions.MyVaultTile;
Options.GeneratorTile = appOptions.GeneratorTile;
Options.FromAutofillFramework = appOptions.FromAutofillFramework;
Options.CreateSend = appOptions.CreateSend;
}
}
protected override Window CreateWindow(IActivationState activationState)