mirror of
https://github.com/bitwarden/android.git
synced 2024-12-24 01:48:25 +03:00
secondary menu on groupings page
This commit is contained in:
parent
67970afc1e
commit
3f8f29dfe7
6 changed files with 94 additions and 1 deletions
|
@ -101,6 +101,10 @@ namespace Bit.Droid
|
|||
{
|
||||
RestartApp();
|
||||
}
|
||||
else if(message.Command == "exit")
|
||||
{
|
||||
ExitApp();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -283,5 +287,11 @@ namespace Bit.Droid
|
|||
alarmManager.Set(AlarmType.Rtc, triggerMs, pendingIntent);
|
||||
Java.Lang.JavaSystem.Exit(0);
|
||||
}
|
||||
|
||||
private void ExitApp()
|
||||
{
|
||||
FinishAffinity();
|
||||
Java.Lang.JavaSystem.Exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,13 @@
|
|||
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
<ToolbarItem x:Name="_syncItem" x:Key="syncItem" Text="{u:I18n Sync}"
|
||||
Clicked="Sync_Clicked" Order="Secondary" />
|
||||
<ToolbarItem x:Name="_lockItem" x:Key="lockItem" Text="{u:I18n Lock}"
|
||||
Clicked="Lock_Clicked" Order="Secondary" />
|
||||
<ToolbarItem x:Name="_exitItem" x:Key="exitItem" Text="{u:I18n Exit}"
|
||||
Clicked="Exit_Clicked" Order="Secondary" />
|
||||
|
||||
<DataTemplate x:Key="cipherTemplate"
|
||||
x:DataType="pages:GroupingsPageListItem">
|
||||
<controls:CipherViewCell
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace Bit.App.Pages
|
|||
private readonly ISyncService _syncService;
|
||||
private readonly IPushNotificationService _pushNotificationService;
|
||||
private readonly IStorageService _storageService;
|
||||
private readonly ILockService _lockService;
|
||||
private readonly GroupingsPageViewModel _vm;
|
||||
private readonly string _pageName;
|
||||
|
||||
|
@ -29,6 +30,7 @@ namespace Bit.App.Pages
|
|||
_syncService = ServiceContainer.Resolve<ISyncService>("syncService");
|
||||
_pushNotificationService = ServiceContainer.Resolve<IPushNotificationService>("pushNotificationService");
|
||||
_storageService = ServiceContainer.Resolve<IStorageService>("storageService");
|
||||
_lockService = ServiceContainer.Resolve<ILockService>("lockService");
|
||||
_vm = BindingContext as GroupingsPageViewModel;
|
||||
_vm.Page = this;
|
||||
_vm.MainPage = mainPage;
|
||||
|
@ -47,6 +49,9 @@ namespace Bit.App.Pages
|
|||
else
|
||||
{
|
||||
_fab.Clicked = AddButton_Clicked;
|
||||
ToolbarItems.Add(_syncItem);
|
||||
ToolbarItems.Add(_lockItem);
|
||||
ToolbarItems.Add(_exitItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -149,6 +154,21 @@ namespace Bit.App.Pages
|
|||
}
|
||||
}
|
||||
|
||||
private async void Sync_Clicked(object sender, System.EventArgs e)
|
||||
{
|
||||
await _vm.SyncAsync();
|
||||
}
|
||||
|
||||
private async void Lock_Clicked(object sender, System.EventArgs e)
|
||||
{
|
||||
await _lockService.LockAsync(true);
|
||||
}
|
||||
|
||||
private async void Exit_Clicked(object sender, System.EventArgs e)
|
||||
{
|
||||
await _vm.ExitAsync();
|
||||
}
|
||||
|
||||
private async void AddButton_Clicked(object sender, System.EventArgs e)
|
||||
{
|
||||
var page = new AddEditPage(null, _vm.Type, _vm.FolderId, _vm.CollectionId);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Bit.App.Resources;
|
||||
using Bit.App.Abstractions;
|
||||
using Bit.App.Resources;
|
||||
using Bit.App.Utilities;
|
||||
using Bit.Core.Abstractions;
|
||||
using Bit.Core.Enums;
|
||||
|
@ -32,6 +33,9 @@ namespace Bit.App.Pages
|
|||
private readonly IFolderService _folderService;
|
||||
private readonly ICollectionService _collectionService;
|
||||
private readonly ISyncService _syncService;
|
||||
private readonly IDeviceActionService _deviceActionService;
|
||||
private readonly IPlatformUtilsService _platformUtilsService;
|
||||
private readonly IMessagingService _messagingService;
|
||||
|
||||
public GroupingsPageViewModel()
|
||||
{
|
||||
|
@ -39,6 +43,9 @@ namespace Bit.App.Pages
|
|||
_folderService = ServiceContainer.Resolve<IFolderService>("folderService");
|
||||
_collectionService = ServiceContainer.Resolve<ICollectionService>("collectionService");
|
||||
_syncService = ServiceContainer.Resolve<ISyncService>("syncService");
|
||||
_deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
|
||||
_platformUtilsService = ServiceContainer.Resolve<IPlatformUtilsService>("platformUtilsService");
|
||||
_messagingService = ServiceContainer.Resolve<IMessagingService>("messagingService");
|
||||
|
||||
Loading = true;
|
||||
PageTitle = AppResources.MyVault;
|
||||
|
@ -248,6 +255,31 @@ namespace Bit.App.Pages
|
|||
await Page.Navigation.PushAsync(page);
|
||||
}
|
||||
|
||||
public async Task ExitAsync()
|
||||
{
|
||||
var confirmed = await _platformUtilsService.ShowDialogAsync(AppResources.ExitConfirmation,
|
||||
AppResources.Exit, AppResources.Yes, AppResources.Cancel);
|
||||
if(confirmed)
|
||||
{
|
||||
_messagingService.Send("exit");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task SyncAsync()
|
||||
{
|
||||
await _deviceActionService.ShowLoadingAsync(AppResources.Syncing);
|
||||
var success = await _syncService.FullSyncAsync(false);
|
||||
await _deviceActionService.HideLoadingAsync();
|
||||
if(success)
|
||||
{
|
||||
_platformUtilsService.ShowToast("success", null, AppResources.SyncingComplete);
|
||||
}
|
||||
else
|
||||
{
|
||||
await Page.DisplayAlert(null, AppResources.SyncingFailed, AppResources.Ok);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task LoadDataAsync()
|
||||
{
|
||||
NoDataText = AppResources.NoItems;
|
||||
|
|
18
src/App/Resources/AppResources.Designer.cs
generated
18
src/App/Resources/AppResources.Designer.cs
generated
|
@ -1401,6 +1401,24 @@ namespace Bit.App.Resources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Exit.
|
||||
/// </summary>
|
||||
public static string Exit {
|
||||
get {
|
||||
return ResourceManager.GetString("Exit", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Are you sure you want to exit Bitwarden?.
|
||||
/// </summary>
|
||||
public static string ExitConfirmation {
|
||||
get {
|
||||
return ResourceManager.GetString("ExitConfirmation", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Re-enable App Extension.
|
||||
/// </summary>
|
||||
|
|
|
@ -1567,4 +1567,10 @@
|
|||
<data name="CopyNotes" xml:space="preserve">
|
||||
<value>Copy Notes</value>
|
||||
</data>
|
||||
<data name="Exit" xml:space="preserve">
|
||||
<value>Exit</value>
|
||||
</data>
|
||||
<data name="ExitConfirmation" xml:space="preserve">
|
||||
<value>Are you sure you want to exit Bitwarden?</value>
|
||||
</data>
|
||||
</root>
|
Loading…
Reference in a new issue