mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 23:25:45 +03:00
settings shim with ios group id
This commit is contained in:
parent
19c62d3320
commit
341b66f44f
4 changed files with 72 additions and 32 deletions
|
@ -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)
|
||||
{
|
||||
if(_sharedName != null)
|
||||
{
|
||||
Xamarin.Essentials.Preferences.Set(key, value, _sharedName);
|
||||
}
|
||||
else
|
||||
{
|
||||
Xamarin.Essentials.Preferences.Set(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddOrUpdateValue(string key, DateTime 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)
|
||||
{
|
||||
if(_sharedName != null)
|
||||
{
|
||||
Xamarin.Essentials.Preferences.Set(key, value, _sharedName);
|
||||
}
|
||||
else
|
||||
{
|
||||
Xamarin.Essentials.Preferences.Set(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddOrUpdateValue(string key, long 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)
|
||||
{
|
||||
if(_sharedName != null)
|
||||
{
|
||||
Xamarin.Essentials.Preferences.Set(key, value, _sharedName);
|
||||
}
|
||||
else
|
||||
{
|
||||
Xamarin.Essentials.Preferences.Set(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
public void Remove(string key)
|
||||
{
|
||||
if(_sharedName != null)
|
||||
{
|
||||
Xamarin.Essentials.Preferences.Remove(key, _sharedName);
|
||||
}
|
||||
else
|
||||
{
|
||||
Xamarin.Essentials.Preferences.Remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
|
||||
|
|
|
@ -245,7 +245,7 @@ namespace Bit.iOS
|
|||
|
||||
// Migration services
|
||||
ServiceContainer.Register<ILogService>("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<App.Migration.Abstractions.IOldSecureStorageService>(
|
||||
|
@ -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;
|
||||
|
|
|
@ -181,24 +181,12 @@
|
|||
<Project>{4b8a8c41-9820-4341-974c-41e65b7f4366}</Project>
|
||||
<Name>Core</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\iOS.Autofill\iOS.Autofill.csproj">
|
||||
<Project>{8a3ecd75-3ec8-4cb3-b3a2-a73a724c279a}</Project>
|
||||
<Name>iOS.Autofill</Name>
|
||||
<IsAppExtension>true</IsAppExtension>
|
||||
<IsWatchApp>false</IsWatchApp>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\iOS.Core\iOS.Core.csproj">
|
||||
<Project>{e71f3053-056c-4381-9638-048ed73bdff6}</Project>
|
||||
<Name>iOS.Core</Name>
|
||||
<IsAppExtension>false</IsAppExtension>
|
||||
<IsWatchApp>false</IsWatchApp>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\iOS.Extension\iOS.Extension.csproj">
|
||||
<Project>{324be76c-38fa-4f11-8bb1-95c7b3b1b545}</Project>
|
||||
<Name>iOS.Extension</Name>
|
||||
<IsAppExtension>true</IsAppExtension>
|
||||
<IsWatchApp>false</IsWatchApp>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BundleResource Include="Resources\autofill-kb.png" />
|
||||
|
|
Loading…
Reference in a new issue