mirror of
https://github.com/bitwarden/android.git
synced 2026-05-21 11:56:35 -05:00
64 lines
2.0 KiB
C#
64 lines
2.0 KiB
C#
using Bit.Core;
|
|
using Bit.Core.Abstractions;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Bit.App.Services
|
|
{
|
|
public class MobileStorageService : IStorageService
|
|
{
|
|
private readonly IStorageService _preferencesStorageService;
|
|
private readonly IStorageService _liteDbStorageService;
|
|
|
|
private readonly HashSet<string> _preferenceStorageKeys = new HashSet<string>
|
|
{
|
|
Constants.LockOptionKey,
|
|
Constants.ThemeKey,
|
|
Constants.DefaultUriMatch,
|
|
Constants.DisableAutoTotpCopyKey,
|
|
Constants.DisableFaviconKey,
|
|
Constants.ClearClipboardKey,
|
|
Constants.AccessibilityAutofillPasswordFieldKey,
|
|
Constants.AccessibilityAutofillPersistNotificationKey,
|
|
Constants.LastActiveKey,
|
|
Constants.PushInitialPromptShownKey,
|
|
Constants.LastFileCacheClearKey
|
|
};
|
|
|
|
public MobileStorageService(
|
|
IStorageService preferenceStorageService,
|
|
IStorageService liteDbStorageService)
|
|
{
|
|
_preferencesStorageService = preferenceStorageService;
|
|
_liteDbStorageService = liteDbStorageService;
|
|
}
|
|
|
|
public Task<T> GetAsync<T>(string key)
|
|
{
|
|
if(_preferenceStorageKeys.Contains(key))
|
|
{
|
|
return _preferencesStorageService.GetAsync<T>(key);
|
|
}
|
|
return _liteDbStorageService.GetAsync<T>(key);
|
|
}
|
|
|
|
public Task SaveAsync<T>(string key, T obj)
|
|
{
|
|
if(_preferenceStorageKeys.Contains(key))
|
|
{
|
|
return _preferencesStorageService.SaveAsync(key, obj);
|
|
}
|
|
return _liteDbStorageService.SaveAsync(key, obj);
|
|
}
|
|
|
|
public Task RemoveAsync(string key)
|
|
{
|
|
if(_preferenceStorageKeys.Contains(key))
|
|
{
|
|
return _preferencesStorageService.RemoveAsync(key);
|
|
}
|
|
return _liteDbStorageService.RemoveAsync(key);
|
|
}
|
|
}
|
|
}
|