mirror of
https://github.com/bitwarden/android.git
synced 2024-12-20 00:02:58 +03:00
More sync operations with broadcast refreshes of listing pages
This commit is contained in:
parent
acfe0032ef
commit
8fd4e09b78
9 changed files with 117 additions and 6120 deletions
|
@ -26,6 +26,7 @@ namespace Bit.Android
|
||||||
LoadApplication(new App.App(
|
LoadApplication(new App.App(
|
||||||
Resolver.Resolve<IAuthService>(),
|
Resolver.Resolve<IAuthService>(),
|
||||||
Resolver.Resolve<IDatabaseService>(),
|
Resolver.Resolve<IDatabaseService>(),
|
||||||
|
Resolver.Resolve<ISyncService>(),
|
||||||
Resolver.Resolve<IFingerprint>(),
|
Resolver.Resolve<IFingerprint>(),
|
||||||
Resolver.Resolve<ISettings>()));
|
Resolver.Resolve<ISettings>()));
|
||||||
}
|
}
|
||||||
|
|
6191
src/Android/Resources/Resource.Designer.cs
generated
6191
src/Android/Resources/Resource.Designer.cs
generated
File diff suppressed because it is too large
Load diff
|
@ -16,6 +16,7 @@ namespace Bit.App
|
||||||
public class App : Application
|
public class App : Application
|
||||||
{
|
{
|
||||||
private readonly IDatabaseService _databaseService;
|
private readonly IDatabaseService _databaseService;
|
||||||
|
private readonly ISyncService _syncService;
|
||||||
private readonly IAuthService _authService;
|
private readonly IAuthService _authService;
|
||||||
private readonly IFingerprint _fingerprint;
|
private readonly IFingerprint _fingerprint;
|
||||||
private readonly ISettings _settings;
|
private readonly ISettings _settings;
|
||||||
|
@ -23,10 +24,12 @@ namespace Bit.App
|
||||||
public App(
|
public App(
|
||||||
IAuthService authService,
|
IAuthService authService,
|
||||||
IDatabaseService databaseService,
|
IDatabaseService databaseService,
|
||||||
|
ISyncService syncService,
|
||||||
IFingerprint fingerprint,
|
IFingerprint fingerprint,
|
||||||
ISettings settings)
|
ISettings settings)
|
||||||
{
|
{
|
||||||
_databaseService = databaseService;
|
_databaseService = databaseService;
|
||||||
|
_syncService = syncService;
|
||||||
_authService = authService;
|
_authService = authService;
|
||||||
_fingerprint = fingerprint;
|
_fingerprint = fingerprint;
|
||||||
_settings = settings;
|
_settings = settings;
|
||||||
|
@ -42,6 +45,13 @@ namespace Bit.App
|
||||||
MainPage = new HomePage();
|
MainPage = new HomePage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MessagingCenter.Subscribe<Application, bool>(Current, "Resumed", async (sender, args) =>
|
||||||
|
{
|
||||||
|
var syncTask = _syncService.IncrementalSyncAsync();
|
||||||
|
await CheckLockAsync(args);
|
||||||
|
await syncTask;
|
||||||
|
});
|
||||||
|
|
||||||
MessagingCenter.Subscribe<Application, bool>(Current, "Lock", async (sender, args) =>
|
MessagingCenter.Subscribe<Application, bool>(Current, "Lock", async (sender, args) =>
|
||||||
{
|
{
|
||||||
await CheckLockAsync(args);
|
await CheckLockAsync(args);
|
||||||
|
@ -51,8 +61,9 @@ namespace Bit.App
|
||||||
protected override void OnStart()
|
protected override void OnStart()
|
||||||
{
|
{
|
||||||
// Handle when your app starts
|
// Handle when your app starts
|
||||||
CheckLockAsync(false);
|
var lockTask = CheckLockAsync(false);
|
||||||
_databaseService.CreateTables();
|
_databaseService.CreateTables();
|
||||||
|
var syncTask = _syncService.FullSyncAsync();
|
||||||
|
|
||||||
Debug.WriteLine("OnStart");
|
Debug.WriteLine("OnStart");
|
||||||
}
|
}
|
||||||
|
@ -75,7 +86,7 @@ namespace Bit.App
|
||||||
|
|
||||||
if(Device.OS == TargetPlatform.Android)
|
if(Device.OS == TargetPlatform.Android)
|
||||||
{
|
{
|
||||||
CheckLockAsync(false);
|
var task = CheckLockAsync(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
var lockPinPage = Current.MainPage.Navigation.ModalStack.LastOrDefault() as LockPinPage;
|
var lockPinPage = Current.MainPage.Navigation.ModalStack.LastOrDefault() as LockPinPage;
|
||||||
|
|
|
@ -67,7 +67,7 @@ namespace Bit.App.Pages
|
||||||
|
|
||||||
if(_checkFingerprintImmediately)
|
if(_checkFingerprintImmediately)
|
||||||
{
|
{
|
||||||
CheckFingerprintAsync();
|
var task = CheckFingerprintAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ namespace Bit.App.Pages
|
||||||
private IDeviceInfo _deviceInfo;
|
private IDeviceInfo _deviceInfo;
|
||||||
private IAppIdService _appIdService;
|
private IAppIdService _appIdService;
|
||||||
private IUserDialogs _userDialogs;
|
private IUserDialogs _userDialogs;
|
||||||
|
private ISyncService _syncService;
|
||||||
|
|
||||||
public LoginPage()
|
public LoginPage()
|
||||||
{
|
{
|
||||||
|
@ -27,6 +28,7 @@ namespace Bit.App.Pages
|
||||||
_deviceInfo = Resolver.Resolve<IDeviceInfo>();
|
_deviceInfo = Resolver.Resolve<IDeviceInfo>();
|
||||||
_appIdService = Resolver.Resolve<IAppIdService>();
|
_appIdService = Resolver.Resolve<IAppIdService>();
|
||||||
_userDialogs = Resolver.Resolve<IUserDialogs>();
|
_userDialogs = Resolver.Resolve<IUserDialogs>();
|
||||||
|
_syncService = Resolver.Resolve<ISyncService>();
|
||||||
|
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
@ -125,6 +127,7 @@ namespace Bit.App.Pages
|
||||||
_authService.Token = response.Result.Token;
|
_authService.Token = response.Result.Token;
|
||||||
_authService.UserId = response.Result.Profile.Id;
|
_authService.UserId = response.Result.Profile.Id;
|
||||||
|
|
||||||
|
var syncTask = _syncService.FullSyncAsync();
|
||||||
Application.Current.MainPage = new MainPage();
|
Application.Current.MainPage = new MainPage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,11 @@ namespace Bit.App.Pages
|
||||||
|
|
||||||
private void Init()
|
private void Init()
|
||||||
{
|
{
|
||||||
|
MessagingCenter.Subscribe<Application>(Application.Current, "SyncCompleted", async (sender) =>
|
||||||
|
{
|
||||||
|
await LoadFoldersAsync();
|
||||||
|
});
|
||||||
|
|
||||||
if(!_favorites)
|
if(!_favorites)
|
||||||
{
|
{
|
||||||
ToolbarItems.Add(new AddSiteToolBarItem(this));
|
ToolbarItems.Add(new AddSiteToolBarItem(this));
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace Bit.App.Repositories
|
||||||
var requestMessage = new TokenHttpRequestMessage()
|
var requestMessage = new TokenHttpRequestMessage()
|
||||||
{
|
{
|
||||||
Method = HttpMethod.Get,
|
Method = HttpMethod.Get,
|
||||||
RequestUri = new Uri(Client.BaseAddress, string.Concat(ApiRoute, "?since=", since)),
|
RequestUri = new Uri(Client.BaseAddress, string.Concat(ApiRoute, "/history", "?since=", since)),
|
||||||
};
|
};
|
||||||
|
|
||||||
var response = await Client.SendAsync(requestMessage);
|
var response = await Client.SendAsync(requestMessage);
|
||||||
|
|
|
@ -6,6 +6,7 @@ using Bit.App.Models.Data;
|
||||||
using Plugin.Settings.Abstractions;
|
using Plugin.Settings.Abstractions;
|
||||||
using Bit.App.Models.Api;
|
using Bit.App.Models.Api;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
|
||||||
namespace Bit.App.Services
|
namespace Bit.App.Services
|
||||||
{
|
{
|
||||||
|
@ -82,6 +83,7 @@ namespace Bit.App.Services
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BroadcastSyncCompleted();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,6 +95,7 @@ namespace Bit.App.Services
|
||||||
}
|
}
|
||||||
|
|
||||||
await _folderRepository.DeleteAsync(id);
|
await _folderRepository.DeleteAsync(id);
|
||||||
|
BroadcastSyncCompleted();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +107,7 @@ namespace Bit.App.Services
|
||||||
}
|
}
|
||||||
|
|
||||||
await _siteRepository.DeleteAsync(id);
|
await _siteRepository.DeleteAsync(id);
|
||||||
|
BroadcastSyncCompleted();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,6 +135,7 @@ namespace Bit.App.Services
|
||||||
}
|
}
|
||||||
|
|
||||||
_settings.AddOrUpdateValue(LastSyncKey, now);
|
_settings.AddOrUpdateValue(LastSyncKey, now);
|
||||||
|
BroadcastSyncCompleted();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,6 +170,7 @@ namespace Bit.App.Services
|
||||||
}
|
}
|
||||||
|
|
||||||
_settings.AddOrUpdateValue(LastSyncKey, now);
|
_settings.AddOrUpdateValue(LastSyncKey, now);
|
||||||
|
BroadcastSyncCompleted();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,5 +244,10 @@ namespace Bit.App.Services
|
||||||
}
|
}
|
||||||
await Task.WhenAll(tasks);
|
await Task.WhenAll(tasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void BroadcastSyncCompleted()
|
||||||
|
{
|
||||||
|
MessagingCenter.Send(Application.Current, "SyncCompleted");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ namespace Bit.iOS
|
||||||
LoadApplication(new App.App(
|
LoadApplication(new App.App(
|
||||||
Resolver.Resolve<IAuthService>(),
|
Resolver.Resolve<IAuthService>(),
|
||||||
Resolver.Resolve<IDatabaseService>(),
|
Resolver.Resolve<IDatabaseService>(),
|
||||||
|
Resolver.Resolve<ISyncService>(),
|
||||||
Resolver.Resolve<IFingerprint>(),
|
Resolver.Resolve<IFingerprint>(),
|
||||||
Resolver.Resolve<ISettings>()));
|
Resolver.Resolve<ISettings>()));
|
||||||
|
|
||||||
|
@ -112,7 +113,7 @@ namespace Bit.iOS
|
||||||
|
|
||||||
public override void WillEnterForeground(UIApplication uiApplication)
|
public override void WillEnterForeground(UIApplication uiApplication)
|
||||||
{
|
{
|
||||||
SendLockMessage();
|
SendResumedMessage();
|
||||||
base.WillEnterForeground(uiApplication);
|
base.WillEnterForeground(uiApplication);
|
||||||
Debug.WriteLine("WillEnterForeground");
|
Debug.WriteLine("WillEnterForeground");
|
||||||
}
|
}
|
||||||
|
@ -159,9 +160,9 @@ namespace Bit.iOS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SendLockMessage()
|
private void SendResumedMessage()
|
||||||
{
|
{
|
||||||
MessagingCenter.Send(Xamarin.Forms.Application.Current, "Lock", false);
|
MessagingCenter.Send(Xamarin.Forms.Application.Current, "Resumed", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetIoc()
|
private void SetIoc()
|
||||||
|
|
Loading…
Reference in a new issue