mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 23:25:45 +03:00
stub sync page
This commit is contained in:
parent
ff1f895476
commit
879b5ef3aa
5 changed files with 95 additions and 3 deletions
|
@ -41,6 +41,9 @@
|
||||||
<Compile Update="Pages\Generator\GeneratorHistoryPage.xaml.cs">
|
<Compile Update="Pages\Generator\GeneratorHistoryPage.xaml.cs">
|
||||||
<DependentUpon>GeneratorHistoryPage.xaml</DependentUpon>
|
<DependentUpon>GeneratorHistoryPage.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Update="Pages\Settings\SyncPage.xaml.cs">
|
||||||
|
<DependentUpon>SyncPage.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Update="Pages\Vault\AttachmentsPage.xaml.cs">
|
<Compile Update="Pages\Vault\AttachmentsPage.xaml.cs">
|
||||||
<DependentUpon>AttachmentsPage.xaml</DependentUpon>
|
<DependentUpon>AttachmentsPage.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using Bit.App.Resources;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -19,7 +20,7 @@ namespace Bit.App.Pages
|
||||||
_vm.Page = this;
|
_vm.Page = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RowSelected(object sender, SelectedItemChangedEventArgs e)
|
private async void RowSelected(object sender, SelectedItemChangedEventArgs e)
|
||||||
{
|
{
|
||||||
((ListView)sender).SelectedItem = null;
|
((ListView)sender).SelectedItem = null;
|
||||||
if(!DoOnce())
|
if(!DoOnce())
|
||||||
|
@ -31,7 +32,10 @@ namespace Bit.App.Pages
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
if(item.Name == AppResources.Sync)
|
||||||
|
{
|
||||||
|
await Navigation.PushModalAsync(new NavigationPage(new SyncPage()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
20
src/App/Pages/Settings/SyncPage.xaml
Normal file
20
src/App/Pages/Settings/SyncPage.xaml
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<pages:BaseContentPage
|
||||||
|
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
x:Class="Bit.App.Pages.SyncPage"
|
||||||
|
xmlns:pages="clr-namespace:Bit.App.Pages"
|
||||||
|
xmlns:controls="clr-namespace:Bit.App.Controls"
|
||||||
|
xmlns:u="clr-namespace:Bit.App.Utilities"
|
||||||
|
x:DataType="pages:SyncPageViewModel"
|
||||||
|
Title="{Binding PageTitle}">
|
||||||
|
<ContentPage.BindingContext>
|
||||||
|
<pages:SyncPageViewModel />
|
||||||
|
</ContentPage.BindingContext>
|
||||||
|
|
||||||
|
<StackLayout Spacing="0" Padding="10, 5">
|
||||||
|
<Button Text="{u:I18n SyncVaultNow}"
|
||||||
|
Clicked="Sync_Clicked"></Button>
|
||||||
|
</StackLayout>
|
||||||
|
|
||||||
|
</pages:BaseContentPage>
|
24
src/App/Pages/Settings/SyncPage.xaml.cs
Normal file
24
src/App/Pages/Settings/SyncPage.xaml.cs
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Bit.App.Pages
|
||||||
|
{
|
||||||
|
public partial class SyncPage : BaseContentPage
|
||||||
|
{
|
||||||
|
private readonly SyncPageViewModel _vm;
|
||||||
|
|
||||||
|
public SyncPage()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_vm = BindingContext as SyncPageViewModel;
|
||||||
|
_vm.Page = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void Sync_Clicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if(DoOnce())
|
||||||
|
{
|
||||||
|
await _vm.SyncAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
41
src/App/Pages/Settings/SyncPageViewModel.cs
Normal file
41
src/App/Pages/Settings/SyncPageViewModel.cs
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
using Bit.App.Abstractions;
|
||||||
|
using Bit.App.Resources;
|
||||||
|
using Bit.Core.Abstractions;
|
||||||
|
using Bit.Core.Exceptions;
|
||||||
|
using Bit.Core.Utilities;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Bit.App.Pages
|
||||||
|
{
|
||||||
|
public class SyncPageViewModel : BaseViewModel
|
||||||
|
{
|
||||||
|
private readonly IDeviceActionService _deviceActionService;
|
||||||
|
private readonly IPlatformUtilsService _platformUtilsService;
|
||||||
|
private readonly ISyncService _syncService;
|
||||||
|
|
||||||
|
public SyncPageViewModel()
|
||||||
|
{
|
||||||
|
_deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
|
||||||
|
_platformUtilsService = ServiceContainer.Resolve<IPlatformUtilsService>("platformUtilsService");
|
||||||
|
_syncService = ServiceContainer.Resolve<ISyncService>("syncService");
|
||||||
|
|
||||||
|
PageTitle = AppResources.Sync;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task SyncAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _deviceActionService.ShowLoadingAsync(AppResources.Syncing);
|
||||||
|
await _syncService.FullSyncAsync(true);
|
||||||
|
await _deviceActionService.HideLoadingAsync();
|
||||||
|
_platformUtilsService.ShowToast("success", null, AppResources.SyncingComplete);
|
||||||
|
}
|
||||||
|
catch(ApiException e)
|
||||||
|
{
|
||||||
|
await _deviceActionService.HideLoadingAsync();
|
||||||
|
await Page.DisplayAlert(AppResources.AnErrorHasOccurred, e.Error.GetSingleMessage(), AppResources.Ok);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue