diff --git a/src/App/App.xaml.cs b/src/App/App.xaml.cs index cc7eb2c0d..3d5a9455a 100644 --- a/src/App/App.xaml.cs +++ b/src/App/App.xaml.cs @@ -162,6 +162,7 @@ namespace Bit.App { System.Diagnostics.Debug.WriteLine("XF App: OnStart"); await ClearCacheIfNeededAsync(); + await TryClearCiphersCacheAsync(); Prime(); if(string.IsNullOrWhiteSpace(_appOptions.Uri)) { @@ -185,7 +186,7 @@ namespace Bit.App await HandleLockingAsync(); } - protected async override void OnResume() + protected override void OnResume() { System.Diagnostics.Debug.WriteLine("XF App: OnResume"); if(Device.RuntimePlatform == Device.Android) @@ -198,6 +199,7 @@ namespace Bit.App { _messagingService.Send("cancelLockTimer"); await ClearCacheIfNeededAsync(); + await TryClearCiphersCacheAsync(); Prime(); SyncIfNeeded(); if(Current.MainPage is NavigationPage navPage && navPage.CurrentPage is LockPage lockPage) @@ -356,5 +358,19 @@ namespace Bit.App } }); } + + private async Task TryClearCiphersCacheAsync() + { + if(Device.RuntimePlatform != Device.iOS) + { + return; + } + var clearCache = await _storageService.GetAsync(Constants.ClearCiphersCacheKey); + if(clearCache.GetValueOrDefault()) + { + _cipherService.ClearCache(); + await _storageService.RemoveAsync(Constants.ClearCiphersCacheKey); + } + } } } diff --git a/src/App/Pages/Vault/AddEditPage.xaml.cs b/src/App/Pages/Vault/AddEditPage.xaml.cs index f194d947e..833726745 100644 --- a/src/App/Pages/Vault/AddEditPage.xaml.cs +++ b/src/App/Pages/Vault/AddEditPage.xaml.cs @@ -8,6 +8,8 @@ using Bit.Core.Utilities; using System.Collections.Generic; using System.Threading.Tasks; using Xamarin.Forms; +using Xamarin.Forms.PlatformConfiguration; +using Xamarin.Forms.PlatformConfiguration.iOSSpecific; namespace Bit.App.Pages { @@ -59,6 +61,9 @@ namespace Bit.App.Pages ToolbarItems.Add(_moreItem); } _vm.ShowNotesSeparator = true; + + _typePicker.On().SetUpdateMode(UpdateMode.WhenFinished); + _ownershipPicker.On().SetUpdateMode(UpdateMode.WhenFinished); } _typePicker.ItemDisplayBinding = new Binding("Key"); @@ -156,7 +161,7 @@ namespace Bit.App.Pages { if(FromAutofillFramework) { - Application.Current.MainPage = new TabsPage(); + Xamarin.Forms.Application.Current.MainPage = new TabsPage(); return true; } return base.OnBackButtonPressed(); @@ -166,7 +171,8 @@ namespace Bit.App.Pages { if(DoOnce()) { - await Navigation.PushModalAsync(new NavigationPage(new PasswordHistoryPage(_vm.CipherId))); + await Navigation.PushModalAsync( + new Xamarin.Forms.NavigationPage(new PasswordHistoryPage(_vm.CipherId))); } } @@ -193,7 +199,7 @@ namespace Bit.App.Pages if(DoOnce()) { var page = new AttachmentsPage(_vm.CipherId); - await Navigation.PushModalAsync(new NavigationPage(page)); + await Navigation.PushModalAsync(new Xamarin.Forms.NavigationPage(page)); } } @@ -202,7 +208,7 @@ namespace Bit.App.Pages if(DoOnce()) { var page = new SharePage(_vm.CipherId); - await Navigation.PushModalAsync(new NavigationPage(page)); + await Navigation.PushModalAsync(new Xamarin.Forms.NavigationPage(page)); } } @@ -222,7 +228,7 @@ namespace Bit.App.Pages if(DoOnce()) { var page = new CollectionsPage(_vm.CipherId); - await Navigation.PushModalAsync(new NavigationPage(page)); + await Navigation.PushModalAsync(new Xamarin.Forms.NavigationPage(page)); } } @@ -238,7 +244,7 @@ namespace Bit.App.Pages await _vm.UpdateTotpKeyAsync(key); }); }); - await Navigation.PushModalAsync(new NavigationPage(page)); + await Navigation.PushModalAsync(new Xamarin.Forms.NavigationPage(page)); } } @@ -265,17 +271,17 @@ namespace Bit.App.Pages else if(selection == AppResources.Attachments) { var page = new AttachmentsPage(_vm.CipherId); - await Navigation.PushModalAsync(new NavigationPage(page)); + await Navigation.PushModalAsync(new Xamarin.Forms.NavigationPage(page)); } else if(selection == AppResources.Collections) { var page = new CollectionsPage(_vm.CipherId); - await Navigation.PushModalAsync(new NavigationPage(page)); + await Navigation.PushModalAsync(new Xamarin.Forms.NavigationPage(page)); } else if(selection == AppResources.Share) { var page = new SharePage(_vm.CipherId); - await Navigation.PushModalAsync(new NavigationPage(page)); + await Navigation.PushModalAsync(new Xamarin.Forms.NavigationPage(page)); } } diff --git a/src/App/Services/MobileStorageService.cs b/src/App/Services/MobileStorageService.cs index 99cfbcf7f..e81f144fe 100644 --- a/src/App/Services/MobileStorageService.cs +++ b/src/App/Services/MobileStorageService.cs @@ -31,6 +31,7 @@ namespace Bit.App.Services Constants.MigratedFromV1, Constants.MigratedFromV1AutofillPromptShown, Constants.TriedV1Resync, + Constants.ClearCiphersCacheKey, }; public MobileStorageService( diff --git a/src/Core/Constants.cs b/src/Core/Constants.cs index 7e1cfd2f5..cf4339f70 100644 --- a/src/Core/Constants.cs +++ b/src/Core/Constants.cs @@ -28,6 +28,7 @@ public static string LastBuildKey = "lastBuild"; public static string OldUserIdKey = "userId"; public static string AddSitePromptShownKey = "addSitePromptShown"; + public static string ClearCiphersCacheKey = "clearCiphersCache"; public static string MigratedFromV1 = "migratedFromV1"; public static string MigratedFromV1AutofillPromptShown = "migratedV1AutofillPromptShown"; public static string TriedV1Resync = "triedV1Resync"; diff --git a/src/iOS.Core/Controllers/LoginAddViewController.cs b/src/iOS.Core/Controllers/LoginAddViewController.cs index 57843a091..5f3edac44 100644 --- a/src/iOS.Core/Controllers/LoginAddViewController.cs +++ b/src/iOS.Core/Controllers/LoginAddViewController.cs @@ -20,6 +20,7 @@ namespace Bit.iOS.Core.Controllers { private ICipherService _cipherService; private IFolderService _folderService; + private IStorageService _storageService; private IEnumerable _folders; public LoginAddViewController(IntPtr handle) @@ -47,6 +48,7 @@ namespace Bit.iOS.Core.Controllers { _cipherService = ServiceContainer.Resolve("cipherService"); _folderService = ServiceContainer.Resolve("folderService"); + _storageService = ServiceContainer.Resolve("storageService"); BaseNavItem.Title = AppResources.AddItem; BaseCancelButton.Title = AppResources.Cancel; @@ -168,6 +170,7 @@ namespace Bit.iOS.Core.Controllers var cipherDomain = await _cipherService.EncryptAsync(cipher); await _cipherService.SaveWithServerAsync(cipherDomain); await loadingAlert.DismissViewControllerAsync(true); + await _storageService.SaveAsync(Bit.Core.Constants.ClearCiphersCacheKey, true); if(await ASHelpers.IdentitiesCanIncremental()) { var identity = await ASHelpers.GetCipherIdentityAsync(cipherDomain.Id);