diff --git a/src/Android/MainActivity.cs b/src/Android/MainActivity.cs index 61101dcfc..be2d84886 100644 --- a/src/Android/MainActivity.cs +++ b/src/Android/MainActivity.cs @@ -7,7 +7,6 @@ using Bit.App.Abstractions; using XLabs.Ioc; using Plugin.Settings.Abstractions; using Plugin.Connectivity.Abstractions; -using Acr.UserDialogs; using Android.Content; using System.Reflection; using Xamarin.Forms.Platform.Android; @@ -77,12 +76,10 @@ namespace Bit.Android _appOptions, Resolver.Resolve(), Resolver.Resolve(), - Resolver.Resolve(), Resolver.Resolve(), Resolver.Resolve(), _settings, Resolver.Resolve(), - Resolver.Resolve(), Resolver.Resolve(), Resolver.Resolve(), Resolver.Resolve(), diff --git a/src/Android/Services/DeviceActionService.cs b/src/Android/Services/DeviceActionService.cs index 18f0fa8ec..d473bcfe3 100644 --- a/src/Android/Services/DeviceActionService.cs +++ b/src/Android/Services/DeviceActionService.cs @@ -23,7 +23,6 @@ using Android.App.Assist; using Bit.Android.Autofill; using System.Linq; using Plugin.Settings.Abstractions; -using Acr.UserDialogs; using Android.Views.InputMethods; namespace Bit.Android.Services @@ -31,16 +30,13 @@ namespace Bit.Android.Services public class DeviceActionService : IDeviceActionService { private readonly IAppSettingsService _appSettingsService; - private readonly IUserDialogs _userDialogs; private bool _cameraPermissionsDenied; private DateTime? _lastAction; public DeviceActionService( - IAppSettingsService appSettingsService, - IUserDialogs userDialogs) + IAppSettingsService appSettingsService) { _appSettingsService = appSettingsService; - _userDialogs = userDialogs; } private Context CurrentContext => CrossCurrentActivity.Current.Activity; @@ -312,7 +308,7 @@ namespace Bit.Android.Services activity.StartActivity(intent); } - public void LaunchApp(string appName) + public async Task LaunchAppAsync(string appName, Page page) { var activity = (MainActivity)CurrentContext; if(_lastAction.LastActionWasRecent()) @@ -325,7 +321,7 @@ namespace Bit.Android.Services var launchIntent = activity.PackageManager.GetLaunchIntentForPackage(appName); if(launchIntent == null) { - _userDialogs.Alert(string.Format(AppResources.CannotOpenApp, appName)); + await page.DisplayAlert(null, string.Format(AppResources.CannotOpenApp, appName), AppResources.Ok); } else { diff --git a/src/App/Abstractions/Services/IDeviceActionService.cs b/src/App/Abstractions/Services/IDeviceActionService.cs index b31ae08f7..ea44b66f4 100644 --- a/src/App/Abstractions/Services/IDeviceActionService.cs +++ b/src/App/Abstractions/Services/IDeviceActionService.cs @@ -1,5 +1,6 @@ using System; using System.Threading.Tasks; +using Xamarin.Forms; namespace Bit.App.Abstractions { @@ -18,6 +19,6 @@ namespace Bit.App.Abstractions void DismissKeyboard(); void OpenAccessibilitySettings(); void OpenAutofillSettings(); - void LaunchApp(string appName); + Task LaunchAppAsync(string appName, Page page); } } diff --git a/src/App/App.cs b/src/App/App.cs index 771cbb12a..ed42aea3c 100644 --- a/src/App/App.cs +++ b/src/App/App.cs @@ -9,8 +9,6 @@ using Plugin.Settings.Abstractions; using Bit.App.Controls; using Plugin.Connectivity.Abstractions; using System.Net; -using Acr.UserDialogs; -using XLabs.Ioc; using System.Reflection; using Bit.App.Resources; using Bit.App.Utilities; @@ -21,14 +19,12 @@ namespace Bit.App public class App : Application { private AppOptions _options; + private readonly IAuthService _authService; private readonly IDatabaseService _databaseService; private readonly IConnectivity _connectivity; - private readonly IUserDialogs _userDialogs; private readonly ISyncService _syncService; - private readonly IAuthService _authService; private readonly ISettings _settings; private readonly ILockService _lockService; - private readonly IGoogleAnalyticsService _googleAnalyticsService; private readonly ILocalizeService _localizeService; private readonly IAppInfoService _appInfoService; private readonly IAppSettingsService _appSettingsService; @@ -38,26 +34,22 @@ namespace Bit.App AppOptions options, IAuthService authService, IConnectivity connectivity, - IUserDialogs userDialogs, IDatabaseService databaseService, ISyncService syncService, ISettings settings, ILockService lockService, - IGoogleAnalyticsService googleAnalyticsService, ILocalizeService localizeService, IAppInfoService appInfoService, IAppSettingsService appSettingsService, IDeviceActionService deviceActionService) { _options = options ?? new AppOptions(); + _authService = authService; _databaseService = databaseService; _connectivity = connectivity; - _userDialogs = userDialogs; _syncService = syncService; - _authService = authService; _settings = settings; _lockService = lockService; - _googleAnalyticsService = googleAnalyticsService; _localizeService = localizeService; _appInfoService = appInfoService; _appSettingsService = appSettingsService; diff --git a/src/App/Pages/EnvironmentPage.cs b/src/App/Pages/EnvironmentPage.cs index f11d1d476..9a6bb0d44 100644 --- a/src/App/Pages/EnvironmentPage.cs +++ b/src/App/Pages/EnvironmentPage.cs @@ -13,7 +13,6 @@ namespace Bit.App.Pages public class EnvironmentPage : ExtendedContentPage { private IAppSettingsService _appSettings; - private IUserDialogs _userDialogs; private IDeviceActionService _deviceActionService; private IGoogleAnalyticsService _googleAnalyticsService; @@ -21,7 +20,6 @@ namespace Bit.App.Pages : base(updateActivity: false) { _appSettings = Resolver.Resolve(); - _userDialogs = Resolver.Resolve(); _deviceActionService = Resolver.Resolve(); _googleAnalyticsService = Resolver.Resolve(); @@ -170,7 +168,8 @@ namespace Bit.App.Pages BaseUrlCell.Entry.Text = FixUrl(BaseUrlCell.Entry.Text); if(!Uri.TryCreate(BaseUrlCell.Entry.Text, UriKind.Absolute, out result)) { - _userDialogs.Alert(string.Format(AppResources.FormattedIncorrectly, AppResources.ServerUrl)); + await DisplayAlert(null, string.Format(AppResources.FormattedIncorrectly, AppResources.ServerUrl), + AppResources.Ok); return; } } @@ -184,7 +183,8 @@ namespace Bit.App.Pages WebVaultUrlCell.Entry.Text = FixUrl(WebVaultUrlCell.Entry.Text); if(!Uri.TryCreate(WebVaultUrlCell.Entry.Text, UriKind.Absolute, out result)) { - _userDialogs.Alert(string.Format(AppResources.FormattedIncorrectly, AppResources.WebVaultUrl)); + await DisplayAlert(null, string.Format(AppResources.FormattedIncorrectly, AppResources.WebVaultUrl), + AppResources.Ok); return; } } @@ -198,7 +198,8 @@ namespace Bit.App.Pages ApiUrlCell.Entry.Text = FixUrl(ApiUrlCell.Entry.Text); if(!Uri.TryCreate(ApiUrlCell.Entry.Text, UriKind.Absolute, out result)) { - _userDialogs.Alert(string.Format(AppResources.FormattedIncorrectly, AppResources.ApiUrl)); + await DisplayAlert(null, string.Format(AppResources.FormattedIncorrectly, AppResources.ApiUrl), + AppResources.Ok); return; } } @@ -212,7 +213,8 @@ namespace Bit.App.Pages IdentityUrlCell.Entry.Text = FixUrl(IdentityUrlCell.Entry.Text); if(!Uri.TryCreate(IdentityUrlCell.Entry.Text, UriKind.Absolute, out result)) { - _userDialogs.Alert(string.Format(AppResources.FormattedIncorrectly, AppResources.IdentityUrl)); + await DisplayAlert(null, string.Format(AppResources.FormattedIncorrectly, AppResources.IdentityUrl), + AppResources.Ok); return; } } @@ -226,7 +228,8 @@ namespace Bit.App.Pages IconsUrlCell.Entry.Text = FixUrl(IconsUrlCell.Entry.Text); if(!Uri.TryCreate(IconsUrlCell.Entry.Text, UriKind.Absolute, out result)) { - _userDialogs.Alert(string.Format(AppResources.FormattedIncorrectly, AppResources.IconsUrl)); + await DisplayAlert(null, string.Format(AppResources.FormattedIncorrectly, AppResources.IconsUrl), + AppResources.Ok); return; } } diff --git a/src/App/Pages/Lock/BaseLockPage.cs b/src/App/Pages/Lock/BaseLockPage.cs index 1cd5eff5f..137b4c826 100644 --- a/src/App/Pages/Lock/BaseLockPage.cs +++ b/src/App/Pages/Lock/BaseLockPage.cs @@ -15,12 +15,10 @@ namespace Bit.App.Pages public BaseLockPage() : base(false, false) { - UserDialogs = Resolver.Resolve(); AuthService = Resolver.Resolve(); _deviceActionService = Resolver.Resolve(); } - protected IUserDialogs UserDialogs { get; set; } protected IAuthService AuthService { get; set; } protected override bool OnBackButtonPressed() @@ -31,7 +29,8 @@ namespace Bit.App.Pages protected async Task LogoutAsync() { - if(!await UserDialogs.ConfirmAsync(AppResources.LogoutConfirmation, null, AppResources.Yes, AppResources.Cancel)) + var confirmed = await DisplayAlert(null, AppResources.LogoutConfirmation, AppResources.Yes, AppResources.Cancel); + if(!confirmed) { return; } diff --git a/src/App/Pages/Lock/LockPasswordPage.cs b/src/App/Pages/Lock/LockPasswordPage.cs index 5507825b7..2f3d5963b 100644 --- a/src/App/Pages/Lock/LockPasswordPage.cs +++ b/src/App/Pages/Lock/LockPasswordPage.cs @@ -159,7 +159,7 @@ namespace Bit.App.Pages { // TODO: keep track of invalid attempts and logout? - UserDialogs.Alert(AppResources.InvalidMasterPassword); + await DisplayAlert(null, AppResources.InvalidMasterPassword, AppResources.Ok); PasswordCell.Entry.Text = string.Empty; PasswordCell.Entry.Focus(); } diff --git a/src/App/Pages/Lock/LockPinPage.cs b/src/App/Pages/Lock/LockPinPage.cs index e425f3af3..f371cdcb6 100644 --- a/src/App/Pages/Lock/LockPinPage.cs +++ b/src/App/Pages/Lock/LockPinPage.cs @@ -113,7 +113,7 @@ namespace Bit.App.Pages PinControl.Dispose(); } - protected void PinEntered(object sender, EventArgs args) + protected async void PinEntered(object sender, EventArgs args) { if(_lastAction.LastActionWasRecent()) { @@ -125,13 +125,13 @@ namespace Bit.App.Pages { _appSettingsService.Locked = false; PinControl.Entry.Unfocus(); - Navigation.PopModalAsync(); + await Navigation.PopModalAsync(); } else { // TODO: keep track of invalid attempts and logout? - UserDialogs.Alert(AppResources.InvalidPIN); + await DisplayAlert(null, AppResources.InvalidPIN, AppResources.Ok); Model.PIN = string.Empty; PinControl.Entry.Focus(); } diff --git a/src/App/Pages/LoginTwoFactorPage.cs b/src/App/Pages/LoginTwoFactorPage.cs index 7f0b38b1f..7a9ff24be 100644 --- a/src/App/Pages/LoginTwoFactorPage.cs +++ b/src/App/Pages/LoginTwoFactorPage.cs @@ -377,7 +377,7 @@ namespace Bit.App.Pages } else if(!response.Succeeded) { - _userDialogs.Alert(AppResources.VerificationEmailNotSent); + await DisplayAlert(null, AppResources.VerificationEmailNotSent, AppResources.Ok); } } @@ -406,6 +406,7 @@ namespace Bit.App.Pages var response = await _authService.TokenPostTwoFactorAsync(_providerType.Value, token, RememberCell.On, _email, _masterPasswordHash, _key); _userDialogs.HideLoading(); + if(!response.Success) { ListenYubiKey(true); diff --git a/src/App/Pages/PasswordHintPage.cs b/src/App/Pages/PasswordHintPage.cs index db20e1216..6f2642dc5 100644 --- a/src/App/Pages/PasswordHintPage.cs +++ b/src/App/Pages/PasswordHintPage.cs @@ -127,6 +127,7 @@ namespace Bit.App.Pages _userDialogs.ShowLoading(AppResources.Submitting, MaskType.Black); var response = await _accountApiRepository.PostPasswordHintAsync(request); _userDialogs.HideLoading(); + if(!response.Succeeded) { await DisplayAlert(AppResources.AnErrorHasOccurred, response.Errors.FirstOrDefault()?.Message, AppResources.Ok); diff --git a/src/App/Pages/RegisterPage.cs b/src/App/Pages/RegisterPage.cs index fc116ac71..b333763ac 100644 --- a/src/App/Pages/RegisterPage.cs +++ b/src/App/Pages/RegisterPage.cs @@ -216,6 +216,7 @@ namespace Bit.App.Pages _userDialogs.ShowLoading(AppResources.CreatingAccount, MaskType.Black); var response = await _accountsApiRepository.PostRegisterAsync(request); _userDialogs.HideLoading(); + if(!response.Succeeded) { await DisplayAlert(AppResources.AnErrorHasOccurred, response.Errors.FirstOrDefault()?.Message, diff --git a/src/App/Pages/Settings/SettingsAddFolderPage.cs b/src/App/Pages/Settings/SettingsAddFolderPage.cs index 1e06a6de1..b9fc700a0 100644 --- a/src/App/Pages/Settings/SettingsAddFolderPage.cs +++ b/src/App/Pages/Settings/SettingsAddFolderPage.cs @@ -86,7 +86,6 @@ namespace Bit.App.Pages _userDialogs.ShowLoading(AppResources.Saving, MaskType.Black); var saveResult = await _folderService.SaveAsync(folder); - _userDialogs.HideLoading(); if(saveResult.Succeeded) @@ -97,11 +96,11 @@ namespace Bit.App.Pages } else if(saveResult.Errors.Count() > 0) { - await _userDialogs.AlertAsync(saveResult.Errors.First().Message, AppResources.AnErrorHasOccurred); + await DisplayAlert(AppResources.AnErrorHasOccurred, saveResult.Errors.First().Message, AppResources.Ok); } else { - await _userDialogs.AlertAsync(AppResources.AnErrorHasOccurred); + await DisplayAlert(null, AppResources.AnErrorHasOccurred, AppResources.Ok); } }, ToolbarItemOrder.Default, 0); diff --git a/src/App/Pages/Settings/SettingsEditFolderPage.cs b/src/App/Pages/Settings/SettingsEditFolderPage.cs index 381d2df90..35d411dee 100644 --- a/src/App/Pages/Settings/SettingsEditFolderPage.cs +++ b/src/App/Pages/Settings/SettingsEditFolderPage.cs @@ -100,7 +100,6 @@ namespace Bit.App.Pages _userDialogs.ShowLoading(AppResources.Saving, MaskType.Black); var saveResult = await _folderService.SaveAsync(folder); - _userDialogs.HideLoading(); if(saveResult.Succeeded) @@ -111,11 +110,11 @@ namespace Bit.App.Pages } else if(saveResult.Errors.Count() > 0) { - await _userDialogs.AlertAsync(saveResult.Errors.First().Message, AppResources.AnErrorHasOccurred); + await DisplayAlert(AppResources.AnErrorHasOccurred, saveResult.Errors.First().Message, AppResources.Ok); } else { - await _userDialogs.AlertAsync(AppResources.AnErrorHasOccurred); + await DisplayAlert(null, AppResources.AnErrorHasOccurred, AppResources.Ok); } }, ToolbarItemOrder.Default, 0); @@ -157,7 +156,8 @@ namespace Bit.App.Pages // TODO: Validate the delete operation. ex. Cannot delete a folder that has ciphers in it? - if(!await _userDialogs.ConfirmAsync(AppResources.DoYouReallyWantToDelete, null, AppResources.Yes, AppResources.No)) + var confirmed = await DisplayAlert(null, AppResources.DoYouReallyWantToDelete, AppResources.Yes, AppResources.No); + if(!confirmed) { return; } @@ -173,11 +173,11 @@ namespace Bit.App.Pages } else if(deleteTask.Errors.Count() > 0) { - await _userDialogs.AlertAsync(deleteTask.Errors.First().Message, AppResources.AnErrorHasOccurred); + await DisplayAlert(AppResources.AnErrorHasOccurred, deleteTask.Errors.First().Message, AppResources.Ok); } else { - await _userDialogs.AlertAsync(AppResources.AnErrorHasOccurred); + await DisplayAlert(null, AppResources.AnErrorHasOccurred, AppResources.Ok); } } diff --git a/src/App/Pages/Settings/SettingsListFoldersPage.cs b/src/App/Pages/Settings/SettingsListFoldersPage.cs index 34d674590..88d56cb62 100644 --- a/src/App/Pages/Settings/SettingsListFoldersPage.cs +++ b/src/App/Pages/Settings/SettingsListFoldersPage.cs @@ -1,8 +1,6 @@ using System; -using System.Collections.ObjectModel; using System.Linq; using System.Threading.Tasks; -using Acr.UserDialogs; using Bit.App.Abstractions; using Bit.App.Controls; using Bit.App.Models.Page; @@ -16,12 +14,10 @@ namespace Bit.App.Pages public class SettingsListFoldersPage : ExtendedContentPage { private readonly IFolderService _folderService; - private readonly IUserDialogs _userDialogs; + public SettingsListFoldersPage() { _folderService = Resolver.Resolve(); - _userDialogs = Resolver.Resolve(); - Init(); } diff --git a/src/App/Pages/Settings/SettingsPage.cs b/src/App/Pages/Settings/SettingsPage.cs index f3c17f252..f41f2eb9d 100644 --- a/src/App/Pages/Settings/SettingsPage.cs +++ b/src/App/Pages/Settings/SettingsPage.cs @@ -14,7 +14,6 @@ namespace Bit.App.Pages public class SettingsPage : ExtendedContentPage { private readonly IAuthService _authService; - private readonly IUserDialogs _userDialogs; private readonly ISettings _settings; private readonly IFingerprint _fingerprint; private readonly IPushNotificationService _pushNotification; @@ -28,7 +27,6 @@ namespace Bit.App.Pages public SettingsPage() { _authService = Resolver.Resolve(); - _userDialogs = Resolver.Resolve(); _settings = Resolver.Resolve(); _fingerprint = Resolver.Resolve(); _pushNotification = Resolver.Resolve(); @@ -271,8 +269,9 @@ namespace Bit.App.Pages private async void TwoStepCell_Tapped(object sender, EventArgs e) { - if(!await _userDialogs.ConfirmAsync(AppResources.TwoStepLoginConfirmation, null, AppResources.Yes, - AppResources.Cancel)) + var confirmed = await DisplayAlert(null, AppResources.TwoStepLoginConfirmation, AppResources.Yes, + AppResources.Cancel); + if(!confirmed) { return; } @@ -349,7 +348,9 @@ namespace Bit.App.Pages private async void LogOutCell_Tapped(object sender, EventArgs e) { - if(!await _userDialogs.ConfirmAsync(AppResources.LogoutConfirmation, null, AppResources.Yes, AppResources.Cancel)) + var confirmed = await DisplayAlert(null, AppResources.LogoutConfirmation, AppResources.Yes, + AppResources.Cancel); + if(!confirmed) { return; } @@ -359,8 +360,9 @@ namespace Bit.App.Pages private async void ChangeMasterPasswordCell_Tapped(object sender, EventArgs e) { - if(!await _userDialogs.ConfirmAsync(AppResources.ChangePasswordConfirmation, null, AppResources.Yes, - AppResources.Cancel)) + var confirmed = await DisplayAlert(null, AppResources.ChangePasswordConfirmation, AppResources.Yes, + AppResources.Cancel); + if(!confirmed) { return; } @@ -371,8 +373,9 @@ namespace Bit.App.Pages private async void ChangeEmailCell_Tapped(object sender, EventArgs e) { - if(!await _userDialogs.ConfirmAsync(AppResources.ChangeEmailConfirmation, null, AppResources.Yes, - AppResources.Cancel)) + var confirmed = await DisplayAlert(null, AppResources.ChangeEmailConfirmation, AppResources.Yes, + AppResources.Cancel); + if(!confirmed) { return; } diff --git a/src/App/Pages/Settings/SettingsPinPage.cs b/src/App/Pages/Settings/SettingsPinPage.cs index d453d7cac..e483a7da2 100644 --- a/src/App/Pages/Settings/SettingsPinPage.cs +++ b/src/App/Pages/Settings/SettingsPinPage.cs @@ -1,7 +1,4 @@ using System; -using System.Threading.Tasks; -using Acr.UserDialogs; -using Bit.App.Abstractions; using Bit.App.Resources; using Xamarin.Forms; using XLabs.Ioc; @@ -13,14 +10,12 @@ namespace Bit.App.Pages { public class SettingsPinPage : ExtendedContentPage { - private readonly IUserDialogs _userDialogs; private readonly ISettings _settings; private Action _pinEnteredAction; public SettingsPinPage(Action pinEnteredAction) { _pinEnteredAction = pinEnteredAction; - _userDialogs = Resolver.Resolve(); _settings = Resolver.Resolve(); Init(); diff --git a/src/App/Pages/Tools/ToolsExtensionPage.cs b/src/App/Pages/Tools/ToolsExtensionPage.cs index b6a5d0a97..a46a1f703 100644 --- a/src/App/Pages/Tools/ToolsExtensionPage.cs +++ b/src/App/Pages/Tools/ToolsExtensionPage.cs @@ -14,13 +14,11 @@ namespace Bit.App.Pages { public class ToolsExtensionPage : ExtendedContentPage { - private readonly IUserDialogs _userDialogs; private readonly ISettings _settings; private readonly IGoogleAnalyticsService _googleAnalyticsService; public ToolsExtensionPage() { - _userDialogs = Resolver.Resolve(); _settings = Resolver.Resolve(); _googleAnalyticsService = Resolver.Resolve(); Model = new AppExtensionPageModel(_settings); diff --git a/src/App/Pages/Tools/ToolsPage.cs b/src/App/Pages/Tools/ToolsPage.cs index 441449237..b7be23533 100644 --- a/src/App/Pages/Tools/ToolsPage.cs +++ b/src/App/Pages/Tools/ToolsPage.cs @@ -1,6 +1,4 @@ using System; -using System.Threading.Tasks; -using Acr.UserDialogs; using Bit.App.Abstractions; using Bit.App.Controls; using Bit.App.Resources; @@ -13,13 +11,11 @@ namespace Bit.App.Pages { public class ToolsPage : ExtendedContentPage { - private readonly IUserDialogs _userDialogs; private readonly IGoogleAnalyticsService _googleAnalyticsService; private readonly IDeviceInfoService _deviceInfoService; public ToolsPage() { - _userDialogs = Resolver.Resolve(); _googleAnalyticsService = Resolver.Resolve(); _deviceInfoService = Resolver.Resolve(); @@ -144,8 +140,9 @@ namespace Bit.App.Pages private async void ImportCell_Tapped(object sender, EventArgs e) { - if(!await _userDialogs.ConfirmAsync(AppResources.ImportItemsConfirmation, null, AppResources.Yes, - AppResources.Cancel)) + var confirmed = await DisplayAlert(null, AppResources.ImportItemsConfirmation, AppResources.Yes, + AppResources.Cancel); + if(!confirmed) { return; } diff --git a/src/App/Pages/Vault/VaultAddCipherPage.cs b/src/App/Pages/Vault/VaultAddCipherPage.cs index b56db7dcf..f021333c0 100644 --- a/src/App/Pages/Vault/VaultAddCipherPage.cs +++ b/src/App/Pages/Vault/VaultAddCipherPage.cs @@ -339,7 +339,7 @@ namespace Bit.App.Pages } else { - _userDialogs.Alert(AppResources.AuthenticatorKeyReadError); + await DisplayAlert(null, AppResources.AuthenticatorKeyReadError, AppResources.Ok); } }); }); @@ -772,11 +772,11 @@ namespace Bit.App.Pages } else if(saveTask.Errors.Count() > 0) { - await _userDialogs.AlertAsync(saveTask.Errors.First().Message, AppResources.AnErrorHasOccurred); + await DisplayAlert(AppResources.AnErrorHasOccurred, saveTask.Errors.First().Message, AppResources.Ok); } else { - await _userDialogs.AlertAsync(AppResources.AnErrorHasOccurred); + await DisplayAlert(null, AppResources.AnErrorHasOccurred, AppResources.Ok); } }, ToolbarItemOrder.Default, 0); diff --git a/src/App/Pages/Vault/VaultAttachmentsPage.cs b/src/App/Pages/Vault/VaultAttachmentsPage.cs index 334492c99..943e6c97d 100644 --- a/src/App/Pages/Vault/VaultAttachmentsPage.cs +++ b/src/App/Pages/Vault/VaultAttachmentsPage.cs @@ -162,7 +162,6 @@ namespace Bit.App.Pages _userDialogs.ShowLoading(AppResources.Saving, MaskType.Black); var saveTask = await _cipherService.EncryptAndSaveAttachmentAsync(_cipher, _fileBytes, FileLabel.Text); - _userDialogs.HideLoading(); if(saveTask.Succeeded) @@ -175,11 +174,11 @@ namespace Bit.App.Pages } else if(saveTask.Errors.Count() > 0) { - await _userDialogs.AlertAsync(saveTask.Errors.First().Message, AppResources.AnErrorHasOccurred); + await DisplayAlert(AppResources.AnErrorHasOccurred, saveTask.Errors.First().Message, AppResources.Ok); } else { - await _userDialogs.AlertAsync(AppResources.AnErrorHasOccurred); + await DisplayAlert(null, AppResources.AnErrorHasOccurred, AppResources.Ok); } }, ToolbarItemOrder.Default, 0); @@ -261,7 +260,9 @@ namespace Bit.App.Pages ((ListView)sender).SelectedItem = null; - if(!await _userDialogs.ConfirmAsync(AppResources.DoYouReallyWantToDelete, null, AppResources.Yes, AppResources.No)) + var confirmed = await DisplayAlert(null, AppResources.DoYouReallyWantToDelete, AppResources.Yes, + AppResources.No); + if(!confirmed) { return; } @@ -278,11 +279,11 @@ namespace Bit.App.Pages } else if(saveTask.Errors.Count() > 0) { - await _userDialogs.AlertAsync(saveTask.Errors.First().Message, AppResources.AnErrorHasOccurred); + await DisplayAlert(AppResources.AnErrorHasOccurred, saveTask.Errors.First().Message, AppResources.Ok); } else { - await _userDialogs.AlertAsync(AppResources.AnErrorHasOccurred); + await DisplayAlert(null, AppResources.AnErrorHasOccurred, AppResources.Ok); } } @@ -311,7 +312,7 @@ namespace Bit.App.Pages private async Task ShowUpdateKeyAsync() { - var confirmed = await _userDialogs.ConfirmAsync(AppResources.UpdateKey, AppResources.FeatureUnavailable, + var confirmed = await DisplayAlert(AppResources.FeatureUnavailable, AppResources.UpdateKey, AppResources.LearnMore, AppResources.Cancel); if(confirmed) { diff --git a/src/App/Pages/Vault/VaultAutofillListCiphersPage.cs b/src/App/Pages/Vault/VaultAutofillListCiphersPage.cs index 546c5f3a2..21b9940c4 100644 --- a/src/App/Pages/Vault/VaultAutofillListCiphersPage.cs +++ b/src/App/Pages/Vault/VaultAutofillListCiphersPage.cs @@ -1,7 +1,6 @@ using System; using System.Linq; using System.Threading.Tasks; -using Acr.UserDialogs; using Bit.App.Abstractions; using Bit.App.Controls; using Bit.App.Models.Page; @@ -46,7 +45,6 @@ namespace Bit.App.Pages _deviceInfoService = Resolver.Resolve(); DeviceActionService = Resolver.Resolve(); _settingsService = Resolver.Resolve(); - UserDialogs = Resolver.Resolve(); _appSettingsService = Resolver.Resolve(); GoogleAnalyticsService = Resolver.Resolve(); @@ -61,7 +59,6 @@ namespace Bit.App.Pages private SearchToolBarItem SearchItem { get; set; } private AddCipherToolBarItem AddCipherItem { get; set; } private IGoogleAnalyticsService GoogleAnalyticsService { get; set; } - private IUserDialogs UserDialogs { get; set; } private IDeviceActionService DeviceActionService { get; set; } private string Uri { get; set; } @@ -237,9 +234,9 @@ namespace Bit.App.Pages bool doAutofill = true; if(cipher.Fuzzy) { - doAutofill = await UserDialogs.ConfirmAsync( + doAutofill = await DisplayAlert(null, string.Format(AppResources.BitwardenAutofillServiceMatchConfirm, _name), - okText: AppResources.Yes, cancelText: AppResources.No); + AppResources.Yes, AppResources.No); } if(doAutofill) diff --git a/src/App/Pages/Vault/VaultCustomFieldsPage.cs b/src/App/Pages/Vault/VaultCustomFieldsPage.cs index 0782f2954..505da90c0 100644 --- a/src/App/Pages/Vault/VaultCustomFieldsPage.cs +++ b/src/App/Pages/Vault/VaultCustomFieldsPage.cs @@ -117,7 +117,6 @@ namespace Bit.App.Pages _userDialogs.ShowLoading(AppResources.Saving, MaskType.Black); var saveTask = await _cipherService.SaveAsync(_cipher); - _userDialogs.HideLoading(); if(saveTask.Succeeded) @@ -128,11 +127,11 @@ namespace Bit.App.Pages } else if(saveTask.Errors.Count() > 0) { - await _userDialogs.AlertAsync(saveTask.Errors.First().Message, AppResources.AnErrorHasOccurred); + await DisplayAlert(AppResources.AnErrorHasOccurred, saveTask.Errors.First().Message, AppResources.Ok); } else { - await _userDialogs.AlertAsync(AppResources.AnErrorHasOccurred); + await DisplayAlert(null, AppResources.AnErrorHasOccurred, AppResources.Ok); } }, ToolbarItemOrder.Default, 0); diff --git a/src/App/Pages/Vault/VaultEditCipherPage.cs b/src/App/Pages/Vault/VaultEditCipherPage.cs index b9e58a5af..75c903776 100644 --- a/src/App/Pages/Vault/VaultEditCipherPage.cs +++ b/src/App/Pages/Vault/VaultEditCipherPage.cs @@ -615,7 +615,6 @@ namespace Bit.App.Pages _userDialogs.ShowLoading(AppResources.Saving, MaskType.Black); var saveTask = await _cipherService.SaveAsync(Cipher); - _userDialogs.HideLoading(); if(saveTask.Succeeded) @@ -626,11 +625,11 @@ namespace Bit.App.Pages } else if(saveTask.Errors.Count() > 0) { - await _userDialogs.AlertAsync(saveTask.Errors.First().Message, AppResources.AnErrorHasOccurred); + await DisplayAlert(AppResources.AnErrorHasOccurred, saveTask.Errors.First().Message, AppResources.Ok); } else { - await _userDialogs.AlertAsync(AppResources.AnErrorHasOccurred); + await DisplayAlert(null, AppResources.AnErrorHasOccurred, AppResources.Ok); } }, ToolbarItemOrder.Default, 0); @@ -810,7 +809,7 @@ namespace Bit.App.Pages } else { - _userDialogs.Alert(AppResources.AuthenticatorKeyReadError); + await DisplayAlert(null, AppResources.AuthenticatorKeyReadError, AppResources.Ok); } }); }); @@ -821,7 +820,7 @@ namespace Bit.App.Pages private async void GenerateCell_Tapped(object sender, EventArgs e) { if(!string.IsNullOrWhiteSpace(LoginPasswordCell.Entry.Text) - && !await _userDialogs.ConfirmAsync(AppResources.PasswordOverrideAlert, null, AppResources.Yes, AppResources.No)) + && !(await DisplayAlert(null, AppResources.PasswordOverrideAlert, AppResources.Yes, AppResources.No))) { return; } @@ -854,7 +853,9 @@ namespace Bit.App.Pages return; } - if(!await _userDialogs.ConfirmAsync(AppResources.DoYouReallyWantToDelete, null, AppResources.Yes, AppResources.No)) + var confirmed = await DisplayAlert(null, AppResources.DoYouReallyWantToDelete, AppResources.Yes, + AppResources.No); + if(!confirmed) { return; } @@ -871,11 +872,11 @@ namespace Bit.App.Pages } else if(deleteTask.Errors.Count() > 0) { - await _userDialogs.AlertAsync(deleteTask.Errors.First().Message, AppResources.AnErrorHasOccurred); + await DisplayAlert(AppResources.AnErrorHasOccurred, deleteTask.Errors.First().Message, AppResources.Ok); } else { - await _userDialogs.AlertAsync(AppResources.AnErrorHasOccurred); + await DisplayAlert(null, AppResources.AnErrorHasOccurred, AppResources.Ok); } } diff --git a/src/App/Pages/Vault/VaultListGroupingsPage.cs b/src/App/Pages/Vault/VaultListGroupingsPage.cs index 0caf3707e..01dd39b08 100644 --- a/src/App/Pages/Vault/VaultListGroupingsPage.cs +++ b/src/App/Pages/Vault/VaultListGroupingsPage.cs @@ -1,7 +1,6 @@ using System; using System.Linq; using System.Threading.Tasks; -using Acr.UserDialogs; using Bit.App.Abstractions; using Bit.App.Controls; using Bit.App.Resources; @@ -21,7 +20,6 @@ namespace Bit.App.Pages private readonly IFolderService _folderService; private readonly ICollectionService _collectionService; private readonly ICipherService _cipherService; - private readonly IUserDialogs _userDialogs; private readonly IConnectivity _connectivity; private readonly IDeviceActionService _deviceActionService; private readonly ISyncService _syncService; @@ -39,7 +37,6 @@ namespace Bit.App.Pages _collectionService = Resolver.Resolve(); _cipherService = Resolver.Resolve(); _connectivity = Resolver.Resolve(); - _userDialogs = Resolver.Resolve(); _deviceActionService = Resolver.Resolve(); _syncService = Resolver.Resolve(); _pushNotification = Resolver.Resolve(); @@ -119,7 +116,7 @@ namespace Bit.App.Pages Title = AppResources.MyVault; } - protected override void OnAppearing() + protected async override void OnAppearing() { base.OnAppearing(); MessagingCenter.Subscribe(Application.Current, "SyncCompleted", (sender, success) => @@ -145,29 +142,16 @@ namespace Bit.App.Pages if(Device.RuntimePlatform == Device.iOS) { var pushPromptShow = _settings.GetValueOrDefault(Constants.PushInitialPromptShown, false); - Action registerAction = () => - { - if(!pushPromptShow || DateTime.UtcNow - lastPushRegistration > TimeSpan.FromDays(1)) - { - _pushNotification.Register(); - } - }; - if(!pushPromptShow) { _settings.AddOrUpdateValue(Constants.PushInitialPromptShown, true); - _userDialogs.Alert(new AlertConfig - { - Message = AppResources.PushNotificationAlert, - Title = AppResources.EnableAutomaticSyncing, - OnAction = registerAction, - OkText = AppResources.OkGotIt - }); + await DisplayAlert(AppResources.EnableAutomaticSyncing, AppResources.PushNotificationAlert, + AppResources.OkGotIt); } - else + + if(!pushPromptShow || DateTime.UtcNow - lastPushRegistration > TimeSpan.FromDays(1)) { - // Check push registration once per day - registerAction(); + _pushNotification.Register(); } } else if(Device.RuntimePlatform == Device.Android && diff --git a/src/App/Pages/Vault/VaultViewCipherPage.cs b/src/App/Pages/Vault/VaultViewCipherPage.cs index a5f6fc011..f1286269e 100644 --- a/src/App/Pages/Vault/VaultViewCipherPage.cs +++ b/src/App/Pages/Vault/VaultViewCipherPage.cs @@ -133,11 +133,11 @@ namespace Bit.App.Pages LoginUriCell = new LabeledValueCell(AppResources.Website, button1Image: "launch.png"); LoginUriCell.Value.SetBinding(Label.TextProperty, nameof(VaultViewCipherPageModel.LoginUriHost)); LoginUriCell.Button1.SetBinding(IsVisibleProperty, nameof(VaultViewCipherPageModel.ShowLoginLaunch)); - LoginUriCell.Button1.Command = new Command(() => + LoginUriCell.Button1.Command = new Command(async () => { if(Device.RuntimePlatform == Device.Android && Model.LoginUri.StartsWith("androidapp://")) { - _deviceActionService.LaunchApp(Model.LoginUri); + await _deviceActionService.LaunchAppAsync(Model.LoginUri, this); } else if(Model.LoginUri.StartsWith("http://") || Model.LoginUri.StartsWith("https://")) { @@ -433,7 +433,7 @@ namespace Bit.App.Pages { if(!_tokenService.TokenPremium && !cipher.OrganizationUseTotp) { - _userDialogs.Alert(AppResources.PremiumRequired); + await DisplayAlert(null, AppResources.PremiumRequired, AppResources.Ok); return; } @@ -447,22 +447,23 @@ namespace Bit.App.Pages if(!_deviceActionService.CanOpenFile(attachment.Name)) { - await _userDialogs.AlertAsync(AppResources.UnableToOpenFile, null, AppResources.Ok); + await DisplayAlert(null, AppResources.UnableToOpenFile, AppResources.Ok); return; } _userDialogs.ShowLoading(AppResources.Downloading, MaskType.Black); var data = await _cipherService.DownloadAndDecryptAttachmentAsync(attachment.Url, cipher.OrganizationId); _userDialogs.HideLoading(); + if(data == null) { - await _userDialogs.AlertAsync(AppResources.UnableToDownloadFile, null, AppResources.Ok); + await DisplayAlert(null, AppResources.UnableToDownloadFile, AppResources.Ok); return; } if(!_deviceActionService.OpenFile(data, attachment.Id, attachment.Name)) { - await _userDialogs.AlertAsync(AppResources.UnableToOpenFile, null, AppResources.Ok); + await DisplayAlert(null, AppResources.UnableToOpenFile, AppResources.Ok); return; } } diff --git a/src/App/Utilities/Helpers.cs b/src/App/Utilities/Helpers.cs index 16eeae134..40e0b502e 100644 --- a/src/App/Utilities/Helpers.cs +++ b/src/App/Utilities/Helpers.cs @@ -164,9 +164,8 @@ namespace Bit.App.Utilities public static async void AddCipher(Page page, string folderId) { - var type = await Resolver.Resolve().ActionSheetAsync( - AppResources.SelectTypeAdd, AppResources.Cancel, null, null, AppResources.TypeLogin, - AppResources.TypeCard, AppResources.TypeIdentity, AppResources.TypeSecureNote); + var type = await page.DisplayActionSheet(AppResources.SelectTypeAdd, AppResources.Cancel, null, + AppResources.TypeLogin, AppResources.TypeCard, AppResources.TypeIdentity, AppResources.TypeSecureNote); var selectedType = CipherType.SecureNote; if(type == AppResources.Cancel) diff --git a/src/UWP/MainPage.xaml.cs b/src/UWP/MainPage.xaml.cs index ae1ce6b0a..ac310994f 100644 --- a/src/UWP/MainPage.xaml.cs +++ b/src/UWP/MainPage.xaml.cs @@ -16,12 +16,10 @@ namespace Bit.UWP null, Resolver.Resolve(), Resolver.Resolve(), - Resolver.Resolve(), Resolver.Resolve(), Resolver.Resolve(), Resolver.Resolve(), Resolver.Resolve(), - Resolver.Resolve(), Resolver.Resolve(), Resolver.Resolve(), Resolver.Resolve(), diff --git a/src/iOS/AppDelegate.cs b/src/iOS/AppDelegate.cs index 3a78bbb48..e8e34f6f6 100644 --- a/src/iOS/AppDelegate.cs +++ b/src/iOS/AppDelegate.cs @@ -60,12 +60,10 @@ namespace Bit.iOS null, Resolver.Resolve(), Resolver.Resolve(), - Resolver.Resolve(), Resolver.Resolve(), Resolver.Resolve(), Resolver.Resolve(), _lockService, - Resolver.Resolve(), Resolver.Resolve(), Resolver.Resolve(), Resolver.Resolve(),