mirror of
https://github.com/bitwarden/android.git
synced 2024-12-24 01:48:25 +03:00
only clear cache if it hasnt been done in a while
This commit is contained in:
parent
352c8ee867
commit
e0c67f87b0
6 changed files with 43 additions and 1 deletions
|
@ -11,6 +11,13 @@ namespace Bit.Android.Services
|
|||
{
|
||||
public class DeviceActionService : IDeviceActionService
|
||||
{
|
||||
private readonly IAppSettingsService _appSettingsService;
|
||||
|
||||
public DeviceActionService(IAppSettingsService appSettingsService)
|
||||
{
|
||||
_appSettingsService = appSettingsService;
|
||||
}
|
||||
|
||||
public void CopyToClipboard(string text)
|
||||
{
|
||||
var clipboardManager = (ClipboardManager)Forms.Context.GetSystemService(Context.ClipboardService);
|
||||
|
@ -86,6 +93,7 @@ namespace Bit.Android.Services
|
|||
try
|
||||
{
|
||||
DeleteDir(CrossCurrentActivity.Current.Activity.CacheDir);
|
||||
_appSettingsService.LastCacheClear = DateTime.UtcNow;
|
||||
}
|
||||
catch(Exception) { }
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace Bit.App.Abstractions
|
|||
{
|
||||
bool Locked { get; set; }
|
||||
DateTime LastActivity { get; set; }
|
||||
DateTime LastCacheClear { get; set; }
|
||||
bool AutofillPersistNotification { get; set; }
|
||||
bool AutofillPasswordField { get; set; }
|
||||
string SecurityStamp { get; set; }
|
||||
|
|
|
@ -113,7 +113,11 @@ namespace Bit.App
|
|||
await Task.Run(() => FullSyncAsync()).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await Task.Run(() => _deviceActionService.ClearCache()).ConfigureAwait(false);
|
||||
if((DateTime.UtcNow - _appSettingsService.LastCacheClear).TotalDays >= 1)
|
||||
{
|
||||
await Task.Run(() => _deviceActionService.ClearCache()).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
Debug.WriteLine("OnStart");
|
||||
}
|
||||
|
||||
|
@ -156,6 +160,13 @@ namespace Bit.App
|
|||
{
|
||||
await Task.Run(() => FullSyncAsync()).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
var now = DateTime.UtcNow;
|
||||
if((now - _appSettingsService.LastCacheClear).TotalDays >= 1
|
||||
&& (now - _appSettingsService.LastActivity).TotalHours >= 1)
|
||||
{
|
||||
await Task.Run(() => _deviceActionService.ClearCache()).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetMainPageFromAutofill()
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
public const string SecurityStamp = "other:securityStamp";
|
||||
public const string LastActivityDate = "other:lastActivityDate";
|
||||
public const string LastCacheClearDate = "other:cacheClearDate";
|
||||
public const string Locked = "other:locked";
|
||||
public const string LastLoginEmail = "other:lastLoginEmail";
|
||||
public const string LastSync = "other:lastSync";
|
||||
|
|
|
@ -38,6 +38,18 @@ namespace Bit.App.Services
|
|||
}
|
||||
}
|
||||
|
||||
public DateTime LastCacheClear
|
||||
{
|
||||
get
|
||||
{
|
||||
return _settings.GetValueOrDefault(Constants.LastCacheClearDate, DateTime.MinValue);
|
||||
}
|
||||
set
|
||||
{
|
||||
_settings.AddOrUpdateValue(Constants.LastCacheClearDate, value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool AutofillPersistNotification
|
||||
{
|
||||
get
|
||||
|
|
|
@ -8,6 +8,13 @@ namespace Bit.iOS.Services
|
|||
{
|
||||
public class DeviceActionService : IDeviceActionService
|
||||
{
|
||||
private readonly IAppSettingsService _appSettingsService;
|
||||
|
||||
public DeviceActionService(IAppSettingsService appSettingsService)
|
||||
{
|
||||
_appSettingsService = appSettingsService;
|
||||
}
|
||||
|
||||
public void CopyToClipboard(string text)
|
||||
{
|
||||
UIPasteboard clipboard = UIPasteboard.General;
|
||||
|
@ -44,6 +51,8 @@ namespace Bit.iOS.Services
|
|||
NSFileManager.DefaultManager.Remove(item, out itemError);
|
||||
}
|
||||
}
|
||||
|
||||
_appSettingsService.LastCacheClear = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
private UIViewController GetVisibleViewController(UIViewController controller = null)
|
||||
|
|
Loading…
Reference in a new issue