diff --git a/src/App/Pages/Accounts/HintPageViewModel.cs b/src/App/Pages/Accounts/HintPageViewModel.cs index 894017f17..983b0cdcc 100644 --- a/src/App/Pages/Accounts/HintPageViewModel.cs +++ b/src/App/Pages/Accounts/HintPageViewModel.cs @@ -11,11 +11,13 @@ namespace Bit.App.Pages public class HintPageViewModel : BaseViewModel { private readonly IDeviceActionService _deviceActionService; + private readonly IPlatformUtilsService _platformUtilsService; private readonly IApiService _apiService; public HintPageViewModel() { _deviceActionService = ServiceContainer.Resolve("deviceActionService"); + _platformUtilsService = ServiceContainer.Resolve("platformUtilsService"); _apiService = ServiceContainer.Resolve("apiService"); PageTitle = AppResources.PasswordHint; @@ -27,6 +29,12 @@ namespace Bit.App.Pages public async Task SubmitAsync() { + if(Xamarin.Essentials.Connectivity.NetworkAccess == Xamarin.Essentials.NetworkAccess.None) + { + await _platformUtilsService.ShowDialogAsync(AppResources.InternetConnectionRequiredMessage, + AppResources.InternetConnectionRequiredTitle); + return; + } if(string.IsNullOrWhiteSpace(Email)) { await Page.DisplayAlert(AppResources.AnErrorHasOccurred, diff --git a/src/App/Pages/Accounts/LoginPageViewModel.cs b/src/App/Pages/Accounts/LoginPageViewModel.cs index a923f7012..e4aeed361 100644 --- a/src/App/Pages/Accounts/LoginPageViewModel.cs +++ b/src/App/Pages/Accounts/LoginPageViewModel.cs @@ -17,6 +17,7 @@ namespace Bit.App.Pages private readonly IAuthService _authService; private readonly ISyncService _syncService; private readonly IStorageService _storageService; + private readonly IPlatformUtilsService _platformUtilsService; private bool _showPassword; private string _email; @@ -28,6 +29,7 @@ namespace Bit.App.Pages _authService = ServiceContainer.Resolve("authService"); _syncService = ServiceContainer.Resolve("syncService"); _storageService = ServiceContainer.Resolve("storageService"); + _platformUtilsService = ServiceContainer.Resolve("platformUtilsService"); PageTitle = AppResources.Bitwarden; TogglePasswordCommand = new Command(TogglePassword); @@ -73,6 +75,12 @@ namespace Bit.App.Pages public async Task LogInAsync() { + if(Xamarin.Essentials.Connectivity.NetworkAccess == Xamarin.Essentials.NetworkAccess.None) + { + await _platformUtilsService.ShowDialogAsync(AppResources.InternetConnectionRequiredMessage, + AppResources.InternetConnectionRequiredTitle); + return; + } if(string.IsNullOrWhiteSpace(Email)) { await Page.DisplayAlert(AppResources.AnErrorHasOccurred, diff --git a/src/App/Pages/Accounts/RegisterPageViewModel.cs b/src/App/Pages/Accounts/RegisterPageViewModel.cs index 1a6cfd14b..24bc75f89 100644 --- a/src/App/Pages/Accounts/RegisterPageViewModel.cs +++ b/src/App/Pages/Accounts/RegisterPageViewModel.cs @@ -15,6 +15,7 @@ namespace Bit.App.Pages private readonly IDeviceActionService _deviceActionService; private readonly IApiService _apiService; private readonly ICryptoService _cryptoService; + private readonly IPlatformUtilsService _platformUtilsService; private bool _showPassword; @@ -23,6 +24,7 @@ namespace Bit.App.Pages _deviceActionService = ServiceContainer.Resolve("deviceActionService"); _apiService = ServiceContainer.Resolve("apiService"); _cryptoService = ServiceContainer.Resolve("cryptoService"); + _platformUtilsService = ServiceContainer.Resolve("platformUtilsService"); PageTitle = AppResources.Bitwarden; TogglePasswordCommand = new Command(TogglePassword); @@ -52,6 +54,12 @@ namespace Bit.App.Pages public async Task SubmitAsync() { + if(Xamarin.Essentials.Connectivity.NetworkAccess == Xamarin.Essentials.NetworkAccess.None) + { + await _platformUtilsService.ShowDialogAsync(AppResources.InternetConnectionRequiredMessage, + AppResources.InternetConnectionRequiredTitle); + return; + } if(string.IsNullOrWhiteSpace(Email)) { await Page.DisplayAlert(AppResources.AnErrorHasOccurred, diff --git a/src/App/Pages/Accounts/TwoFactorPageViewModel.cs b/src/App/Pages/Accounts/TwoFactorPageViewModel.cs index 0ce54fe97..6f03b3bfc 100644 --- a/src/App/Pages/Accounts/TwoFactorPageViewModel.cs +++ b/src/App/Pages/Accounts/TwoFactorPageViewModel.cs @@ -173,11 +173,18 @@ namespace Bit.App.Pages { return; } + if(Xamarin.Essentials.Connectivity.NetworkAccess == Xamarin.Essentials.NetworkAccess.None) + { + await _platformUtilsService.ShowDialogAsync(AppResources.InternetConnectionRequiredMessage, + AppResources.InternetConnectionRequiredTitle); + return; + } if(string.IsNullOrWhiteSpace(Token)) { await _platformUtilsService.ShowDialogAsync( string.Format(AppResources.ValidationFieldRequired, AppResources.VerificationCode), AppResources.AnErrorHasOccurred); + return; } if(SelectedProviderType == TwoFactorProviderType.Email || SelectedProviderType == TwoFactorProviderType.Authenticator) @@ -233,6 +240,12 @@ namespace Bit.App.Pages { return false; } + if(Xamarin.Essentials.Connectivity.NetworkAccess == Xamarin.Essentials.NetworkAccess.None) + { + await _platformUtilsService.ShowDialogAsync(AppResources.InternetConnectionRequiredMessage, + AppResources.InternetConnectionRequiredTitle); + return false; + } try { if(showLoading) diff --git a/src/App/Pages/Settings/FolderAddEditPageViewModel.cs b/src/App/Pages/Settings/FolderAddEditPageViewModel.cs index 3b90300b4..b8587786f 100644 --- a/src/App/Pages/Settings/FolderAddEditPageViewModel.cs +++ b/src/App/Pages/Settings/FolderAddEditPageViewModel.cs @@ -57,6 +57,12 @@ namespace Bit.App.Pages public async Task SubmitAsync() { + if(Xamarin.Essentials.Connectivity.NetworkAccess == Xamarin.Essentials.NetworkAccess.None) + { + await _platformUtilsService.ShowDialogAsync(AppResources.InternetConnectionRequiredMessage, + AppResources.InternetConnectionRequiredTitle); + return false; + } if(string.IsNullOrWhiteSpace(Folder.Name)) { await Page.DisplayAlert(AppResources.AnErrorHasOccurred, @@ -87,6 +93,12 @@ namespace Bit.App.Pages public async Task DeleteAsync() { + if(Xamarin.Essentials.Connectivity.NetworkAccess == Xamarin.Essentials.NetworkAccess.None) + { + await _platformUtilsService.ShowDialogAsync(AppResources.InternetConnectionRequiredMessage, + AppResources.InternetConnectionRequiredTitle); + return false; + } var confirmed = await _platformUtilsService.ShowDialogAsync(AppResources.DoYouReallyWantToDelete, null, AppResources.Yes, AppResources.No); if(!confirmed) diff --git a/src/App/Pages/Settings/SyncPageViewModel.cs b/src/App/Pages/Settings/SyncPageViewModel.cs index 87ae4bae9..8077a8192 100644 --- a/src/App/Pages/Settings/SyncPageViewModel.cs +++ b/src/App/Pages/Settings/SyncPageViewModel.cs @@ -46,6 +46,12 @@ namespace Bit.App.Pages public async Task SyncAsync() { + if(Xamarin.Essentials.Connectivity.NetworkAccess == Xamarin.Essentials.NetworkAccess.None) + { + await _platformUtilsService.ShowDialogAsync(AppResources.InternetConnectionRequiredMessage, + AppResources.InternetConnectionRequiredTitle); + return; + } try { await _deviceActionService.ShowLoadingAsync(AppResources.Syncing); diff --git a/src/App/Pages/Vault/AddEditPageViewModel.cs b/src/App/Pages/Vault/AddEditPageViewModel.cs index d6aac2553..d4a695e8e 100644 --- a/src/App/Pages/Vault/AddEditPageViewModel.cs +++ b/src/App/Pages/Vault/AddEditPageViewModel.cs @@ -367,6 +367,12 @@ namespace Bit.App.Pages public async Task SubmitAsync() { + if(Xamarin.Essentials.Connectivity.NetworkAccess == Xamarin.Essentials.NetworkAccess.None) + { + await _platformUtilsService.ShowDialogAsync(AppResources.InternetConnectionRequiredMessage, + AppResources.InternetConnectionRequiredTitle); + return false; + } if(string.IsNullOrWhiteSpace(Cipher.Name)) { await Page.DisplayAlert(AppResources.AnErrorHasOccurred, @@ -428,6 +434,12 @@ namespace Bit.App.Pages public async Task DeleteAsync() { + if(Xamarin.Essentials.Connectivity.NetworkAccess == Xamarin.Essentials.NetworkAccess.None) + { + await _platformUtilsService.ShowDialogAsync(AppResources.InternetConnectionRequiredMessage, + AppResources.InternetConnectionRequiredTitle); + return false; + } var confirmed = await _platformUtilsService.ShowDialogAsync(AppResources.DoYouReallyWantToDelete, null, AppResources.Yes, AppResources.Cancel); if(!confirmed) diff --git a/src/App/Pages/Vault/AttachmentsPageViewModel.cs b/src/App/Pages/Vault/AttachmentsPageViewModel.cs index f7f241786..6e196ed6e 100644 --- a/src/App/Pages/Vault/AttachmentsPageViewModel.cs +++ b/src/App/Pages/Vault/AttachmentsPageViewModel.cs @@ -83,6 +83,12 @@ namespace Bit.App.Pages public async Task SubmitAsync() { + if(Xamarin.Essentials.Connectivity.NetworkAccess == Xamarin.Essentials.NetworkAccess.None) + { + await _platformUtilsService.ShowDialogAsync(AppResources.InternetConnectionRequiredMessage, + AppResources.InternetConnectionRequiredTitle); + return false; + } if(!_hasUpdatedKey) { await _platformUtilsService.ShowDialogAsync(AppResources.UpdateKey, @@ -130,6 +136,12 @@ namespace Bit.App.Pages private async void DeleteAsync(AttachmentView attachment) { + if(Xamarin.Essentials.Connectivity.NetworkAccess == Xamarin.Essentials.NetworkAccess.None) + { + await _platformUtilsService.ShowDialogAsync(AppResources.InternetConnectionRequiredMessage, + AppResources.InternetConnectionRequiredTitle); + return; + } var confirmed = await _platformUtilsService.ShowDialogAsync(AppResources.DoYouReallyWantToDelete, null, AppResources.Yes, AppResources.No); if(!confirmed) diff --git a/src/App/Pages/Vault/AutofillCiphersPageViewModel.cs b/src/App/Pages/Vault/AutofillCiphersPageViewModel.cs index bf7b46afe..495708f03 100644 --- a/src/App/Pages/Vault/AutofillCiphersPageViewModel.cs +++ b/src/App/Pages/Vault/AutofillCiphersPageViewModel.cs @@ -112,7 +112,8 @@ namespace Bit.App.Pages if(fuzzy) { var options = new List { AppResources.Yes }; - if(cipher.Type == CipherType.Login) + if(cipher.Type == CipherType.Login && + Xamarin.Essentials.Connectivity.NetworkAccess != Xamarin.Essentials.NetworkAccess.None) { options.Add(AppResources.YesAndSave); } diff --git a/src/App/Pages/Vault/CiphersPageViewModel.cs b/src/App/Pages/Vault/CiphersPageViewModel.cs index ab7fcb82f..f9c0cbbad 100644 --- a/src/App/Pages/Vault/CiphersPageViewModel.cs +++ b/src/App/Pages/Vault/CiphersPageViewModel.cs @@ -119,7 +119,8 @@ namespace Bit.App.Pages if(!string.IsNullOrWhiteSpace(AutofillUrl)) { var options = new List { AppResources.Autofill }; - if(cipher.Type == CipherType.Login) + if(cipher.Type == CipherType.Login && + Xamarin.Essentials.Connectivity.NetworkAccess != Xamarin.Essentials.NetworkAccess.None) { options.Add(AppResources.AutofillAndSave); } @@ -162,7 +163,7 @@ namespace Bit.App.Pages } if(_deviceActionService.SystemMajorVersion() < 21) { - // TODO + await Utilities.AppHelpers.CipherListOptions(Page, cipher); } else { diff --git a/src/App/Pages/Vault/CollectionsPageViewModel.cs b/src/App/Pages/Vault/CollectionsPageViewModel.cs index b854a6402..a57a0be24 100644 --- a/src/App/Pages/Vault/CollectionsPageViewModel.cs +++ b/src/App/Pages/Vault/CollectionsPageViewModel.cs @@ -64,6 +64,12 @@ namespace Bit.App.Pages AppResources.Ok); return false; } + if(Xamarin.Essentials.Connectivity.NetworkAccess == Xamarin.Essentials.NetworkAccess.None) + { + await _platformUtilsService.ShowDialogAsync(AppResources.InternetConnectionRequiredMessage, + AppResources.InternetConnectionRequiredTitle); + return false; + } _cipherDomain.CollectionIds = new HashSet( Collections.Where(c => c.Checked).Select(c => c.Collection.Id)); diff --git a/src/App/Pages/Vault/GroupingsPage/GroupingsPageViewModel.cs b/src/App/Pages/Vault/GroupingsPage/GroupingsPageViewModel.cs index 47c21f297..62a4717a4 100644 --- a/src/App/Pages/Vault/GroupingsPage/GroupingsPageViewModel.cs +++ b/src/App/Pages/Vault/GroupingsPage/GroupingsPageViewModel.cs @@ -270,6 +270,12 @@ namespace Bit.App.Pages public async Task SyncAsync() { + if(Xamarin.Essentials.Connectivity.NetworkAccess == Xamarin.Essentials.NetworkAccess.None) + { + await _platformUtilsService.ShowDialogAsync(AppResources.InternetConnectionRequiredMessage, + AppResources.InternetConnectionRequiredTitle); + return; + } await _deviceActionService.ShowLoadingAsync(AppResources.Syncing); await _syncService.FullSyncAsync(false); await _deviceActionService.HideLoadingAsync(); diff --git a/src/App/Pages/Vault/SharePageViewModel.cs b/src/App/Pages/Vault/SharePageViewModel.cs index 9af5eaa4f..f57f9eec3 100644 --- a/src/App/Pages/Vault/SharePageViewModel.cs +++ b/src/App/Pages/Vault/SharePageViewModel.cs @@ -92,6 +92,12 @@ namespace Bit.App.Pages AppResources.Ok); return false; } + if(Xamarin.Essentials.Connectivity.NetworkAccess == Xamarin.Essentials.NetworkAccess.None) + { + await _platformUtilsService.ShowDialogAsync(AppResources.InternetConnectionRequiredMessage, + AppResources.InternetConnectionRequiredTitle); + return false; + } var cipherDomain = await _cipherService.GetAsync(CipherId); var cipherView = await cipherDomain.DecryptAsync(); diff --git a/src/App/Pages/Vault/ViewPageViewModel.cs b/src/App/Pages/Vault/ViewPageViewModel.cs index 903450c63..53d148e29 100644 --- a/src/App/Pages/Vault/ViewPageViewModel.cs +++ b/src/App/Pages/Vault/ViewPageViewModel.cs @@ -255,6 +255,12 @@ namespace Bit.App.Pages public async Task DeleteAsync() { + if(Xamarin.Essentials.Connectivity.NetworkAccess == Xamarin.Essentials.NetworkAccess.None) + { + await _platformUtilsService.ShowDialogAsync(AppResources.InternetConnectionRequiredMessage, + AppResources.InternetConnectionRequiredTitle); + return false; + } var confirmed = await _platformUtilsService.ShowDialogAsync(AppResources.DoYouReallyWantToDelete, null, AppResources.Yes, AppResources.Cancel); if(!confirmed) @@ -329,6 +335,12 @@ namespace Bit.App.Pages { return; } + if(Xamarin.Essentials.Connectivity.NetworkAccess == Xamarin.Essentials.NetworkAccess.None) + { + await _platformUtilsService.ShowDialogAsync(AppResources.InternetConnectionRequiredMessage, + AppResources.InternetConnectionRequiredTitle); + return; + } await _deviceActionService.ShowLoadingAsync(AppResources.CheckingPassword); var matches = await _auditService.PasswordLeakedAsync(Cipher.Login.Password); await _deviceActionService.HideLoadingAsync(); @@ -349,6 +361,12 @@ namespace Bit.App.Pages { return; } + if(Xamarin.Essentials.Connectivity.NetworkAccess == Xamarin.Essentials.NetworkAccess.None) + { + await _platformUtilsService.ShowDialogAsync(AppResources.InternetConnectionRequiredMessage, + AppResources.InternetConnectionRequiredTitle); + return; + } if(Cipher.OrganizationId == null && !CanAccessPremium) { await _platformUtilsService.ShowDialogAsync(AppResources.PremiumRequired);