diff --git a/src/App/Migration/SettingsShim.cs b/src/App/Migration/SettingsShim.cs index cf88a3caa..f72c6643e 100644 --- a/src/App/Migration/SettingsShim.cs +++ b/src/App/Migration/SettingsShim.cs @@ -4,64 +4,119 @@ namespace Bit.App.Migration { public class SettingsShim { + private readonly string _sharedName; + + public SettingsShim(string sharedName = null) + { + _sharedName = sharedName; + } + public bool Contains(string key) { - return Xamarin.Essentials.Preferences.ContainsKey(key); + return _sharedName != null ? Xamarin.Essentials.Preferences.ContainsKey(key, _sharedName) : + Xamarin.Essentials.Preferences.ContainsKey(key); } public string GetValueOrDefault(string key, string defaultValue) { - return Xamarin.Essentials.Preferences.Get(key, defaultValue); + return _sharedName != null ? Xamarin.Essentials.Preferences.Get(key, defaultValue, _sharedName) : + Xamarin.Essentials.Preferences.Get(key, defaultValue); } public DateTime GetValueOrDefault(string key, DateTime defaultValue) { - return Xamarin.Essentials.Preferences.Get(key, defaultValue); + return _sharedName != null ? Xamarin.Essentials.Preferences.Get(key, defaultValue, _sharedName) : + Xamarin.Essentials.Preferences.Get(key, defaultValue); } public bool GetValueOrDefault(string key, bool defaultValue) { - return Xamarin.Essentials.Preferences.Get(key, defaultValue); + return _sharedName != null ? Xamarin.Essentials.Preferences.Get(key, defaultValue, _sharedName) : + Xamarin.Essentials.Preferences.Get(key, defaultValue); } public int GetValueOrDefault(string key, int defaultValue) { - return Xamarin.Essentials.Preferences.Get(key, defaultValue); + return _sharedName != null ? Xamarin.Essentials.Preferences.Get(key, defaultValue, _sharedName) : + Xamarin.Essentials.Preferences.Get(key, defaultValue); } public long GetValueOrDefault(string key, long defaultValue) { - return Xamarin.Essentials.Preferences.Get(key, defaultValue); + return _sharedName != null ? Xamarin.Essentials.Preferences.Get(key, defaultValue, _sharedName) : + Xamarin.Essentials.Preferences.Get(key, defaultValue); } public void AddOrUpdateValue(string key, string value) { - Xamarin.Essentials.Preferences.Set(key, value); + if(_sharedName != null) + { + Xamarin.Essentials.Preferences.Set(key, value, _sharedName); + } + else + { + Xamarin.Essentials.Preferences.Set(key, value); + } } public void AddOrUpdateValue(string key, DateTime value) { - Xamarin.Essentials.Preferences.Set(key, value); + if(_sharedName != null) + { + Xamarin.Essentials.Preferences.Set(key, value, _sharedName); + } + else + { + Xamarin.Essentials.Preferences.Set(key, value); + } } public void AddOrUpdateValue(string key, bool value) { - Xamarin.Essentials.Preferences.Set(key, value); + if(_sharedName != null) + { + Xamarin.Essentials.Preferences.Set(key, value, _sharedName); + } + else + { + Xamarin.Essentials.Preferences.Set(key, value); + } } public void AddOrUpdateValue(string key, long value) { - Xamarin.Essentials.Preferences.Set(key, value); + if(_sharedName != null) + { + Xamarin.Essentials.Preferences.Set(key, value, _sharedName); + } + else + { + Xamarin.Essentials.Preferences.Set(key, value); + } } public void AddOrUpdateValue(string key, int value) { - Xamarin.Essentials.Preferences.Set(key, value); + if(_sharedName != null) + { + Xamarin.Essentials.Preferences.Set(key, value, _sharedName); + } + else + { + Xamarin.Essentials.Preferences.Set(key, value); + } } public void Remove(string key) { - Xamarin.Essentials.Preferences.Remove(key); + if(_sharedName != null) + { + Xamarin.Essentials.Preferences.Remove(key, _sharedName); + } + else + { + Xamarin.Essentials.Preferences.Remove(key); + } } } } diff --git a/src/iOS.Core/Utilities/iOSCoreHelpers.cs b/src/iOS.Core/Utilities/iOSCoreHelpers.cs index 0a939ee53..be1a04a76 100644 --- a/src/iOS.Core/Utilities/iOSCoreHelpers.cs +++ b/src/iOS.Core/Utilities/iOSCoreHelpers.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; +using System.IO; using System.Threading.Tasks; using Bit.App.Abstractions; using Bit.App.Services; @@ -20,6 +16,8 @@ namespace Bit.iOS.Core.Utilities public static class iOSCoreHelpers { public static string AppId = "com.8bit.bitwarden"; + public static string AppAutofillId = "com.8bit.bitwarden.autofill"; + public static string AppExtensionId = "com.8bit.bitwarden.find-login-action-extension"; public static string AppGroupId = "group.com.8bit.bitwarden"; public static string AccessGroup = "LTZ2PFU5D6.com.8bit.bitwarden"; diff --git a/src/iOS/AppDelegate.cs b/src/iOS/AppDelegate.cs index a3dc123ec..bc67adf46 100644 --- a/src/iOS/AppDelegate.cs +++ b/src/iOS/AppDelegate.cs @@ -245,7 +245,7 @@ namespace Bit.iOS // Migration services ServiceContainer.Register("logService", new ConsoleLogService()); - ServiceContainer.Register("settingsShim", new App.Migration.SettingsShim()); + ServiceContainer.Register("settingsShim", new App.Migration.SettingsShim(iOSCoreHelpers.AppGroupId)); if(App.Migration.MigrationHelpers.NeedsMigration()) { ServiceContainer.Register( @@ -418,8 +418,7 @@ namespace Bit.iOS { CompletionHandler = (activityType, completed) => { - extensionPageViewModel.EnabledExtension( - completed && activityType == "com.8bit.bitwarden.find-login-action-extension"); + extensionPageViewModel.EnabledExtension(completed && activityType == iOSCoreHelpers.AppExtensionId); } }; var modal = UIApplication.SharedApplication.KeyWindow.RootViewController.ModalViewController; diff --git a/src/iOS/iOS.csproj b/src/iOS/iOS.csproj index a02a40b84..c3cfd8aff 100644 --- a/src/iOS/iOS.csproj +++ b/src/iOS/iOS.csproj @@ -181,24 +181,12 @@ {4b8a8c41-9820-4341-974c-41e65b7f4366} Core - - {8a3ecd75-3ec8-4cb3-b3a2-a73a724c279a} - iOS.Autofill - true - false - {e71f3053-056c-4381-9638-048ed73bdff6} iOS.Core false false - - {324be76c-38fa-4f11-8bb1-95c7b3b1b545} - iOS.Extension - true - false -