diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ee1088cd37..fe6f6a1768 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -153,17 +153,17 @@ jobs: # - name: Verify Format # run: dotnet tool run dotnet-format --check - # - name: Run Core tests - # run: dotnet test test/Core.Test/Core.Test.csproj --logger "trx;LogFileName=test-results.trx" + - name: Run Core tests + run: dotnet test test/Core.Test/Core.Test.csproj --logger "trx;LogFileName=test-results.trx" /p:CustomConstants=UT - #- name: Report test results - # uses: dorny/test-reporter@c9b3d0e2bd2a4e96aaf424dbaa31c46b42318226 # v1.6.0 - # if: always() - # with: - # name: Test Results - # path: "**/test-results.trx" - # reporter: dotnet-trx - # fail-on-error: true + - name: Report test results + uses: dorny/test-reporter@c9b3d0e2bd2a4e96aaf424dbaa31c46b42318226 # v1.6.0 + if: always() + with: + name: Test Results + path: "**/test-results.trx" + reporter: dotnet-trx + fail-on-error: true - name: Build Play Store publisher if: ${{ matrix.variant == 'prod' }} diff --git a/Directory.Build.props b/Directory.Build.props index bf789590a0..1be40c6008 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,7 @@ 8.0.4-nightly.* + + \ No newline at end of file diff --git a/src/Core/App.xaml.cs b/src/Core/App.xaml.cs index 8124ac3ee8..7deed659dd 100644 --- a/src/Core/App.xaml.cs +++ b/src/Core/App.xaml.cs @@ -46,6 +46,7 @@ namespace Bit.App // This queue keeps those actions so that when the app has resumed they can still be executed. // Links: https://github.com/dotnet/maui/issues/11501 and https://bitwarden.atlassian.net/wiki/spaces/NMME/pages/664862722/MainPage+Assignments+not+working+on+Android+on+Background+or+App+resume private readonly Queue _onResumeActions = new Queue(); + private bool _hasNavigatedToAutofillWindow; #if ANDROID @@ -89,7 +90,7 @@ namespace Bit.App { Options = appOptions ?? new AppOptions(); } - + protected override Window CreateWindow(IActivationState activationState) { //When executing from AutofillExternalActivity we don't have "Options" so we need to filter "manually" @@ -106,18 +107,37 @@ namespace Bit.App if (Options != null && (Options.FromAutofillFramework || Options.Uri != null || Options.OtpData != null || Options.CreateSend != null)) { _isResumed = true; //Specifically for the Autofill scenario we need to manually set the _isResumed here + _hasNavigatedToAutofillWindow = true; return new AutoFillWindow(new NavigationPage(new AndroidNavigationRedirectPage())); } + var homePage = new HomePage(Options); + // WORKAROUND: If the user autofills with Accessibility Services enabled and goes back to the application then there is currently an issue + // where this method is called again + // thus it goes through here and the user goes to HomePage as we see here. + // So to solve this, the next flag check has been added which then turns on a flag on the home page + // that will trigger a navigation on the accounts manager when it loads; workarounding this behavior and navigating the user + // to the proper page depending on its state. + // WARNING: this doens't navigate the user to where they were but it acts as if the user had changed their account. + if(_hasNavigatedToAutofillWindow) + { + homePage.PerformNavigationOnAccountChangedOnLoad = true; + // this is needed because when coming back from AutofillWindow OnResume won't be called and we need this flag + // so that void Navigate(NavigationTarget navTarget, INavigationParams navParams) doesn't enqueue the navigation + // and it performs it directly. + _isResumed = true; + _hasNavigatedToAutofillWindow = false; + } + //If we have an existing MainAppWindow we can use that one var mainAppWindow = Windows.OfType().FirstOrDefault(); if (mainAppWindow != null) { - mainAppWindow.PendingPage = new NavigationPage(new HomePage(Options)); + mainAppWindow.PendingPage = new NavigationPage(homePage); } //Create new main window - return new MainAppWindow(new NavigationPage(new HomePage(Options))); + return new MainAppWindow(new NavigationPage(homePage)); } #else //iOS doesn't use the CreateWindow override used in Android so we just set the Application.Current.MainPage directly diff --git a/src/Core/ExternalLinksConstants.cs b/src/Core/ExternalLinksConstants.cs index fbb70030ab..6db6292a27 100644 --- a/src/Core/ExternalLinksConstants.cs +++ b/src/Core/ExternalLinksConstants.cs @@ -13,6 +13,11 @@ /// public const string WEB_VAULT_SETTINGS_FORMAT = "{0}/#/settings"; + /// + /// Link to go to individual vault import page. Requires to pass vault URL as parameter. + /// + public const string WEB_VAULT_TOOLS_IMPORT_FORMAT = "{0}/#/tools/import"; + /// /// General website, not in the full format of a URL given that this is used as parameter of string resources to be shown to the user. /// diff --git a/src/Core/Pages/Accounts/HomePage.xaml b/src/Core/Pages/Accounts/HomePage.xaml index 0061612485..fe69921554 100644 --- a/src/Core/Pages/Accounts/HomePage.xaml +++ b/src/Core/Pages/Accounts/HomePage.xaml @@ -9,6 +9,7 @@ x:DataType="pages:HomeViewModel" HideSoftInputOnTapped="True" x:Name="_page" + Loaded="HomePage_Loaded" Title="{Binding PageTitle}"> diff --git a/src/Core/Pages/Accounts/HomePage.xaml.cs b/src/Core/Pages/Accounts/HomePage.xaml.cs index 03f8c8da48..11c5b36bad 100644 --- a/src/Core/Pages/Accounts/HomePage.xaml.cs +++ b/src/Core/Pages/Accounts/HomePage.xaml.cs @@ -1,8 +1,8 @@ -using Bit.App.Models; +using Bit.App.Abstractions; +using Bit.App.Models; using Bit.App.Utilities; using Bit.Core.Abstractions; using Bit.Core.Utilities; -using Microsoft.Maui.Platform; namespace Bit.App.Pages { @@ -44,6 +44,21 @@ namespace Bit.App.Pages } } + public bool PerformNavigationOnAccountChangedOnLoad { get; internal set; } + + void HomePage_Loaded(System.Object sender, System.EventArgs e) + { +#if ANDROID + // WORKAROUND: This is needed to fix the navigation when coming back from autofill when Accessibility Services is enabled + // See App.xaml.cs -> CreateWindow(...) for more info. + if (PerformNavigationOnAccountChangedOnLoad && ServiceContainer.TryResolve(out var accountsManager)) + { + PerformNavigationOnAccountChangedOnLoad = false; + accountsManager.NavigateOnAccountChangeAsync().FireAndForget(); + } +#endif + } + public async Task DismissRegisterPageAndLogInAsync(string email) { await Navigation.PopModalAsync(); diff --git a/src/Core/Pages/Settings/VaultSettingsPageViewModel.cs b/src/Core/Pages/Settings/VaultSettingsPageViewModel.cs index ae676ba0b1..3ebfbffe02 100644 --- a/src/Core/Pages/Settings/VaultSettingsPageViewModel.cs +++ b/src/Core/Pages/Settings/VaultSettingsPageViewModel.cs @@ -41,11 +41,11 @@ namespace Bit.App.Pages private async Task GoToImportItemsAsync() { - var webVaultUrl = _environmentService.GetWebVaultUrl(); - var body = string.Format(AppResources.YouCanImportDataToYourVaultOnX, webVaultUrl); + var toolsImportUrl = string.Format(ExternalLinksConstants.WEB_VAULT_TOOLS_IMPORT_FORMAT, _environmentService.GetWebVaultUrl()); + var body = string.Format(AppResources.YouCanImportDataToYourVaultOnX, toolsImportUrl); if (await _platformUtilsService.ShowDialogAsync(body, AppResources.ContinueToWebApp, AppResources.Continue, AppResources.Cancel)) { - _platformUtilsService.LaunchUri(webVaultUrl); + _platformUtilsService.LaunchUri(toolsImportUrl); } } } diff --git a/test/Core.Test/Core.Test.csproj b/test/Core.Test/Core.Test.csproj index 79a3df6a7d..6062ea90c6 100644 --- a/test/Core.Test/Core.Test.csproj +++ b/test/Core.Test/Core.Test.csproj @@ -4,11 +4,6 @@ net8.0 false Bit.Core.Test - -