diff --git a/src/App/Pages/Vault/AddEditPage.xaml b/src/App/Pages/Vault/AddEditPage.xaml index c90737121..17baf8a26 100644 --- a/src/App/Pages/Vault/AddEditPage.xaml +++ b/src/App/Pages/Vault/AddEditPage.xaml @@ -15,9 +15,8 @@ - + - @@ -26,6 +25,16 @@ + + @@ -412,9 +421,6 @@ HorizontalOptions="End" /> - diff --git a/src/App/Pages/Vault/AddEditPage.xaml.cs b/src/App/Pages/Vault/AddEditPage.xaml.cs index a6caccfb7..5148bb3bb 100644 --- a/src/App/Pages/Vault/AddEditPage.xaml.cs +++ b/src/App/Pages/Vault/AddEditPage.xaml.cs @@ -36,6 +36,31 @@ namespace Bit.App.Pages { base.OnAppearing(); await LoadOnAppearedAsync(_scrollView, true, () => _vm.LoadAsync()); + if(Device.RuntimePlatform == Device.Android) + { + if(_vm.Cipher.OrganizationId == null) + { + if(ToolbarItems.Contains(_collectionsItem)) + { + ToolbarItems.Remove(_collectionsItem); + } + if(!ToolbarItems.Contains(_shareItem)) + { + ToolbarItems.Insert(2, _shareItem); + } + } + else + { + if(ToolbarItems.Contains(_shareItem)) + { + ToolbarItems.Remove(_shareItem); + } + if(!ToolbarItems.Contains(_collectionsItem)) + { + ToolbarItems.Insert(2, _collectionsItem); + } + } + } } protected override void OnDisappearing() @@ -93,5 +118,13 @@ namespace Bit.App.Pages await _vm.DeleteAsync(); } } + + private void Collections_Clicked(object sender, System.EventArgs e) + { + if(DoOnce()) + { + // TODO + } + } } } diff --git a/src/App/Pages/Vault/ViewPage.xaml b/src/App/Pages/Vault/ViewPage.xaml index 63db64968..5a79dae7b 100644 --- a/src/App/Pages/Vault/ViewPage.xaml +++ b/src/App/Pages/Vault/ViewPage.xaml @@ -16,7 +16,9 @@ - + + + @@ -24,6 +26,16 @@ + + diff --git a/src/App/Pages/Vault/ViewPage.xaml.cs b/src/App/Pages/Vault/ViewPage.xaml.cs index ce476b29d..9e63fe94e 100644 --- a/src/App/Pages/Vault/ViewPage.xaml.cs +++ b/src/App/Pages/Vault/ViewPage.xaml.cs @@ -50,6 +50,31 @@ namespace Bit.App.Pages } }); await LoadOnAppearedAsync(_scrollView, true, () => _vm.LoadAsync(), _mainContent); + if(Device.RuntimePlatform == Device.Android) + { + if(_vm.Cipher.OrganizationId == null) + { + if(ToolbarItems.Contains(_collectionsItem)) + { + ToolbarItems.Remove(_collectionsItem); + } + if(!ToolbarItems.Contains(_shareItem)) + { + ToolbarItems.Insert(1, _shareItem); + } + } + else + { + if(ToolbarItems.Contains(_shareItem)) + { + ToolbarItems.Remove(_shareItem); + } + if(!ToolbarItems.Contains(_collectionsItem)) + { + ToolbarItems.Insert(1, _collectionsItem); + } + } + } } protected override void OnDisappearing() @@ -79,5 +104,38 @@ namespace Bit.App.Pages { EditToolbarItem_Clicked(sender, e); } + + private void Attachments_Clicked(object sender, System.EventArgs e) + { + if(DoOnce()) + { + // await Navigation.PushModalAsync(); + } + } + + private async void Share_Clicked(object sender, System.EventArgs e) + { + if(DoOnce()) + { + var page = new SharePage(_vm.CipherId); + await Navigation.PushModalAsync(new NavigationPage(page)); + } + } + + private async void Delete_Clicked(object sender, System.EventArgs e) + { + if(DoOnce()) + { + await _vm.DeleteAsync(); + } + } + + private void Collections_Clicked(object sender, System.EventArgs e) + { + if(DoOnce()) + { + // TODO + } + } } } diff --git a/src/App/Pages/Vault/ViewPageViewModel.cs b/src/App/Pages/Vault/ViewPageViewModel.cs index f9a1c469c..9ab72ccd7 100644 --- a/src/App/Pages/Vault/ViewPageViewModel.cs +++ b/src/App/Pages/Vault/ViewPageViewModel.cs @@ -2,6 +2,7 @@ using Bit.App.Resources; using Bit.App.Utilities; using Bit.Core.Abstractions; +using Bit.Core.Exceptions; using Bit.Core.Models.View; using Bit.Core.Utilities; using System; @@ -20,6 +21,7 @@ namespace Bit.App.Pages private readonly ITotpService _totpService; private readonly IPlatformUtilsService _platformUtilsService; private readonly IAuditService _auditService; + private readonly IMessagingService _messagingService; private CipherView _cipher; private List _fields; private bool _canAccessPremium; @@ -39,6 +41,7 @@ namespace Bit.App.Pages _totpService = ServiceContainer.Resolve("totpService"); _platformUtilsService = ServiceContainer.Resolve("platformUtilsService"); _auditService = ServiceContainer.Resolve("auditService"); + _messagingService = ServiceContainer.Resolve("messagingService"); CopyCommand = new Command((id) => CopyAsync(id, null)); CopyUriCommand = new Command(CopyUri); CopyFieldCommand = new Command(CopyField); @@ -245,6 +248,31 @@ namespace Bit.App.Pages ShowCardCode = !ShowCardCode; } + public async Task DeleteAsync() + { + var confirmed = await _platformUtilsService.ShowDialogAsync(AppResources.DoYouReallyWantToDelete, + null, AppResources.Yes, AppResources.No); + if(!confirmed) + { + return false; + } + try + { + await _deviceActionService.ShowLoadingAsync(AppResources.Deleting); + await _cipherService.DeleteWithServerAsync(Cipher.Id); + await _deviceActionService.HideLoadingAsync(); + _platformUtilsService.ShowToast("success", null, AppResources.ItemDeleted); + _messagingService.Send("deletedCipher"); + return true; + } + catch(ApiException e) + { + await _deviceActionService.HideLoadingAsync(); + await Page.DisplayAlert(AppResources.AnErrorHasOccurred, e.Error.GetSingleMessage(), AppResources.Ok); + } + return false; + } + private async Task TotpUpdateCodeAsync() { if(Cipher == null || Cipher.Type != Core.Enums.CipherType.Login || Cipher.Login.Totp == null)