From 547cd4e8281ab918d0e55b9cbd54fc948529671b Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 15 May 2019 13:26:55 -0400 Subject: [PATCH] various settings --- src/App/Pages/Settings/SettingsPage.xaml.cs | 28 ++++++++ .../Pages/Settings/SettingsPageViewModel.cs | 72 +++++++++++++++++++ src/App/Resources/AppResources.Designer.cs | 18 +++++ src/App/Resources/AppResources.resx | 6 ++ 4 files changed, 124 insertions(+) diff --git a/src/App/Pages/Settings/SettingsPage.xaml.cs b/src/App/Pages/Settings/SettingsPage.xaml.cs index 91489e7f1..9bae64cfa 100644 --- a/src/App/Pages/Settings/SettingsPage.xaml.cs +++ b/src/App/Pages/Settings/SettingsPage.xaml.cs @@ -56,6 +56,34 @@ namespace Bit.App.Pages { _vm.Rate(); } + else if(item.Name == AppResources.ImportItems) + { + _vm.Import(); + } + else if(item.Name == AppResources.ExportVault) + { + _vm.Export(); + } + else if(item.Name == AppResources.ShareVault) + { + await _vm.ShareAsync(); + } + else if(item.Name == AppResources.WebVault) + { + _vm.WebVault(); + } + else if(item.Name == AppResources.ChangeMasterPassword) + { + await _vm.ChangePasswordAsync(); + } + else if(item.Name == AppResources.TwoStepLogin) + { + await _vm.TwoStepAsync(); + } + else if(item.Name == AppResources.LogOut) + { + await _vm.LogOutAsync(); + } } } } diff --git a/src/App/Pages/Settings/SettingsPageViewModel.cs b/src/App/Pages/Settings/SettingsPageViewModel.cs index 55f1b1f03..8e2bc50e8 100644 --- a/src/App/Pages/Settings/SettingsPageViewModel.cs +++ b/src/App/Pages/Settings/SettingsPageViewModel.cs @@ -15,6 +15,8 @@ namespace Bit.App.Pages private readonly ICryptoService _cryptoService; private readonly IUserService _userService; private readonly IDeviceActionService _deviceActionService; + private readonly IEnvironmentService _environmentService; + private readonly IMessagingService _messagingService; public SettingsPageViewModel() { @@ -22,6 +24,8 @@ namespace Bit.App.Pages _cryptoService = ServiceContainer.Resolve("cryptoService"); _userService = ServiceContainer.Resolve("userService"); _deviceActionService = ServiceContainer.Resolve("deviceActionService"); + _environmentService = ServiceContainer.Resolve("environmentService"); + _messagingService = ServiceContainer.Resolve("messagingService"); PageTitle = AppResources.Settings; BuildList(); @@ -65,6 +69,66 @@ namespace Bit.App.Pages _deviceActionService.RateApp(); } + public void Import() + { + _platformUtilsService.LaunchUri("https://help.bitwarden.com/article/import-data/"); + } + + public void Export() + { + _platformUtilsService.LaunchUri("https://help.bitwarden.com/article/export-your-data/"); + } + + public void WebVault() + { + var url = _environmentService.GetWebVaultUrl(); + if(url == null) + { + url = "https://vault.bitwarden.com"; + } + _platformUtilsService.LaunchUri(url); + } + + public async Task ShareAsync() + { + var confirmed = await _platformUtilsService.ShowDialogAsync(AppResources.ShareVaultConfirmation, + AppResources.ShareVault, AppResources.Yes, AppResources.Cancel); + if(confirmed) + { + _platformUtilsService.LaunchUri("https://help.bitwarden.com/article/what-is-an-organization/"); + } + } + + public async Task TwoStepAsync() + { + var confirmed = await _platformUtilsService.ShowDialogAsync(AppResources.TwoStepLoginConfirmation, + AppResources.TwoStepLogin, AppResources.Yes, AppResources.Cancel); + if(confirmed) + { + _platformUtilsService.LaunchUri("https://help.bitwarden.com/article/setup-two-step-login/"); + } + } + + public async Task ChangePasswordAsync() + { + var confirmed = await _platformUtilsService.ShowDialogAsync(AppResources.ChangePasswordConfirmation, + AppResources.ChangeMasterPassword, AppResources.Yes, AppResources.Cancel); + if(confirmed) + { + _platformUtilsService.LaunchUri("https://help.bitwarden.com/article/change-your-master-password/"); + } + } + + public async Task LogOutAsync() + { + var confirmed = await _platformUtilsService.ShowDialogAsync(AppResources.LogoutConfirmation, + AppResources.LogOut, AppResources.Yes, AppResources.Cancel); + if(confirmed) + { + _messagingService.Send("logout"); + } + } + private void BuildList() { var doUpper = Device.RuntimePlatform != Device.Android; @@ -87,6 +151,13 @@ namespace Bit.App.Pages new SettingsPageListItem { Name = AppResources.FingerprintPhrase }, new SettingsPageListItem { Name = AppResources.LogOut } }; + var toolsItems = new List + { + new SettingsPageListItem { Name = AppResources.ImportItems }, + new SettingsPageListItem { Name = AppResources.ExportVault }, + new SettingsPageListItem { Name = AppResources.ShareVault }, + new SettingsPageListItem { Name = AppResources.WebVault } + }; var otherItems = new List { new SettingsPageListItem { Name = AppResources.Options }, @@ -99,6 +170,7 @@ namespace Bit.App.Pages new SettingsPageListGroup(manageItems, AppResources.Manage, doUpper), new SettingsPageListGroup(securityItems, AppResources.Security, doUpper), new SettingsPageListGroup(accountItems, AppResources.Account, doUpper), + new SettingsPageListGroup(toolsItems, AppResources.Tools, doUpper), new SettingsPageListGroup(otherItems, AppResources.Other, doUpper) }; } diff --git a/src/App/Resources/AppResources.Designer.cs b/src/App/Resources/AppResources.Designer.cs index f42c9f772..004b93636 100644 --- a/src/App/Resources/AppResources.Designer.cs +++ b/src/App/Resources/AppResources.Designer.cs @@ -1383,6 +1383,15 @@ namespace Bit.App.Resources { } } + /// + /// Looks up a localized string similar to Export Vault. + /// + public static string ExportVault { + get { + return ResourceManager.GetString("ExportVault", resourceCulture); + } + } + /// /// Looks up a localized string similar to Extension Activated!. /// @@ -3192,6 +3201,15 @@ namespace Bit.App.Resources { } } + /// + /// Looks up a localized string similar to Bitwarden allows you to share your vault with others by using an organization account. Would you like to visit the bitwarden.com website to learn more?. + /// + public static string ShareVaultConfirmation { + get { + return ResourceManager.GetString("ShareVaultConfirmation", resourceCulture); + } + } + /// /// Looks up a localized string similar to Create an organization to securely share your items with other users.. /// diff --git a/src/App/Resources/AppResources.resx b/src/App/Resources/AppResources.resx index 383ddc23f..7b4fba2d4 100644 --- a/src/App/Resources/AppResources.resx +++ b/src/App/Resources/AppResources.resx @@ -1475,4 +1475,10 @@ Your account's fingerprint phrase A 'fingerprint phrase' is a unique word phrase (similar to a passphrase) that a user can use to authenticate their public key with another user, for the purposes of sharing. + + Bitwarden allows you to share your vault with others by using an organization account. Would you like to visit the bitwarden.com website to learn more? + + + Export Vault + \ No newline at end of file