diff --git a/src/Core/Pages/Accounts/EnvironmentPage.xaml.cs b/src/Core/Pages/Accounts/EnvironmentPage.xaml.cs index fb4a28d08..5724faaa4 100644 --- a/src/Core/Pages/Accounts/EnvironmentPage.xaml.cs +++ b/src/Core/Pages/Accounts/EnvironmentPage.xaml.cs @@ -1,6 +1,7 @@ using Bit.Core.Abstractions; using Bit.Core.Resources.Localization; using Bit.Core.Utilities; +using Microsoft.Maui.Platform; namespace Bit.App.Pages { @@ -26,7 +27,7 @@ namespace Bit.App.Pages _apiEntry.ReturnCommand = new Command(() => _identityEntry.Focus()); _identityEntry.ReturnType = ReturnType.Next; _identityEntry.ReturnCommand = new Command(() => _iconsEntry.Focus()); - _vm.SubmitSuccessAction = () => MainThread.BeginInvokeOnMainThread(async () => await SubmitSuccessAsync()); + _vm.SubmitSuccessTask = () => MainThread.InvokeOnMainThreadAsync(SubmitSuccessAsync); _vm.CloseAction = async () => { await Navigation.PopModalAsync(); @@ -37,6 +38,12 @@ namespace Bit.App.Pages { _platformUtilsService.ShowToast("success", null, AppResources.EnvironmentSaved); await Navigation.PopModalAsync(); +#if ANDROID + if (Platform.CurrentActivity.CurrentFocus != null) + { + Platform.CurrentActivity.HideKeyboard(Platform.CurrentActivity.CurrentFocus); + } +#endif } private void Close_Clicked(object sender, EventArgs e) diff --git a/src/Core/Pages/Accounts/EnvironmentPageViewModel.cs b/src/Core/Pages/Accounts/EnvironmentPageViewModel.cs index f003fcbd4..f70d0e60d 100644 --- a/src/Core/Pages/Accounts/EnvironmentPageViewModel.cs +++ b/src/Core/Pages/Accounts/EnvironmentPageViewModel.cs @@ -44,7 +44,7 @@ namespace Bit.App.Pages public string WebVaultUrl { get; set; } public string IconsUrl { get; set; } public string NotificationsUrls { get; set; } - public Action SubmitSuccessAction { get; set; } + public Func SubmitSuccessTask { get; set; } public Action CloseAction { get; set; } public async Task SubmitAsync() @@ -73,7 +73,10 @@ namespace Bit.App.Pages IconsUrl = resUrls.Icons; NotificationsUrls = resUrls.Notifications; - SubmitSuccessAction?.Invoke(); + if (SubmitSuccessTask != null) + { + await SubmitSuccessTask(); + } } public bool ValidateUrls() diff --git a/src/iOS.Autofill/CredentialProviderViewController.cs b/src/iOS.Autofill/CredentialProviderViewController.cs index 30ff9c555..2ad523d22 100644 --- a/src/iOS.Autofill/CredentialProviderViewController.cs +++ b/src/iOS.Autofill/CredentialProviderViewController.cs @@ -452,7 +452,11 @@ namespace Bit.iOS.Autofill ThemeManager.ApplyResourcesTo(environmentPage); if (environmentPage.BindingContext is EnvironmentPageViewModel vm) { - vm.SubmitSuccessAction = () => DismissViewController(false, () => LaunchHomePage()); + vm.SubmitSuccessTask = async () => + { + await DismissViewControllerAsync(false); + await MainThread.InvokeOnMainThreadAsync(() => LaunchHomePage()); + }; vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage()); } diff --git a/src/iOS.Extension/LoadingViewController.cs b/src/iOS.Extension/LoadingViewController.cs index b3874fa64..75d8cc8a6 100644 --- a/src/iOS.Extension/LoadingViewController.cs +++ b/src/iOS.Extension/LoadingViewController.cs @@ -18,6 +18,7 @@ using Bit.iOS.Core.Views; using Bit.iOS.Extension.Models; using CoreNFC; using Foundation; +using Microsoft.Maui.ApplicationModel; using Microsoft.Maui.Controls; using Microsoft.Maui.Platform; using MobileCoreServices; @@ -528,7 +529,11 @@ namespace Bit.iOS.Extension ThemeManager.ApplyResourcesTo(environmentPage); if (environmentPage.BindingContext is EnvironmentPageViewModel vm) { - vm.SubmitSuccessAction = () => DismissViewController(false, () => LaunchHomePage()); + vm.SubmitSuccessTask = async () => + { + await DismissViewControllerAsync(false); + await MainThread.InvokeOnMainThreadAsync(() => LaunchHomePage()); + }; vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage()); } diff --git a/src/iOS.ShareExtension/LoadingViewController.cs b/src/iOS.ShareExtension/LoadingViewController.cs index 22cb86fb8..acf295d56 100644 --- a/src/iOS.ShareExtension/LoadingViewController.cs +++ b/src/iOS.ShareExtension/LoadingViewController.cs @@ -17,6 +17,7 @@ using Bit.iOS.Core.Views; using Bit.iOS.ShareExtension.Models; using CoreNFC; using Foundation; +using Microsoft.Maui.ApplicationModel; using Microsoft.Maui.Controls; using Microsoft.Maui.Platform; using MobileCoreServices; @@ -321,7 +322,11 @@ namespace Bit.iOS.ShareExtension ThemeManager.ApplyResourcesTo(environmentPage); if (environmentPage.BindingContext is EnvironmentPageViewModel vm) { - vm.SubmitSuccessAction = () => DismissAndLaunch(() => LaunchHomePage()); + vm.SubmitSuccessTask = async () => + { + await DismissViewControllerAsync(false); + await MainThread.InvokeOnMainThreadAsync(() => LaunchHomePage()); + }; vm.CloseAction = () => DismissAndLaunch(() => LaunchHomePage()); }