bitwarden-mobile/src/App/Pages/Vault/AddEditPage.xaml.cs

400 lines
16 KiB
C#
Raw Normal View History

2022-04-26 17:21:17 +02:00
using System.Collections.Generic;
using System.Threading.Tasks;
using Bit.App.Abstractions;
2019-06-04 05:00:48 +02:00
using Bit.App.Models;
using Bit.App.Resources;
using Bit.App.Utilities;
2019-06-04 05:00:48 +02:00
using Bit.Core.Abstractions;
2019-05-17 18:03:35 +02:00
using Bit.Core.Enums;
2019-06-04 05:00:48 +02:00
using Bit.Core.Utilities;
using Xamarin.Essentials;
2019-05-08 16:42:55 +02:00
using Xamarin.Forms;
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
2019-05-07 17:25:21 +02:00
namespace Bit.App.Pages
{
public partial class AddEditPage : BaseContentPage
{
2019-05-17 18:03:35 +02:00
private readonly AppOptions _appOptions;
Account Switching (#1807) * Account Switching (#1720) * Account switching * WIP * wip * wip * updates to send test logic * fixed Send tests * fixes for theme handling on account switching and re-adding existing account * switch fixes * fixes * fixes * cleanup * vault timeout fixes * account list status enhancements * logout fixes and token handling improvements * merge latest (#1727) * remove duplicate dependency * fix for initial login token storage paradox (#1730) * Fix avatar color update toolbar item issue on iOS for account switching (#1735) * Updated account switching menu UI (#1733) * updated account switching menu UI * additional changes * add key suffix to constant * GetFirstLetters method tweaks * Fix crash on account switching when logging out when having more than user at a time (#1740) * single account migration to multi-account on app update (#1741) * Account Switching Tap to dismiss (#1743) * Added tap to dismiss on the Account switching overlay and improved a bit the code * Fix account switching overlay background transparent on the proper place * Fixed transparent background and the shadow on the account switching overlay * Fix iOS top space on Account switching list overlay after modal (#1746) * Fix top space added to Account switching list overlay after closing modal * Fix top space added to Account switching list overlay after closing modal on lock, login and home views just in case we add modals in the future there as well * Usability: dismiss account list on certain events (#1748) * dismiss account list on certain events * use new FireAndForget method for back button logic * Create and use Account Switching overlay control (#1753) * Added Account switching overlay control and its own ViewModel and refactored accordingly * Fix account switching Accounts list binding update * Implemented dismiss account switching overlay when changing tabs and when selecting the same tab. Also updated the deprecated listener on CustomTabbedRenderer on Android (#1755) * Overriden Equals on AvatarImageSource so it doesn't get set multiple times when it's the same image thus producing blinking on tab chaged (#1756) * Usability improvements for logout on vault timeout (#1781) * accountswitching fixes (#1784) * Fix for invalid PIN lock state when switching accounts (#1792) * fix for pin lock flow * named tuple values and updated async * clear send service cache on account switch (#1796) * Global theme and account removal (#1793) * Global theme and account removal * remove redundant call to hide account list overlay * cleanup and additional tweaks * add try/catch to remove account dialog flow Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
2022-02-23 18:40:17 +01:00
private readonly IStateService _stateService;
2019-06-04 05:00:48 +02:00
private readonly IDeviceActionService _deviceActionService;
private readonly IVaultTimeoutService _vaultTimeoutService;
[KeyConnector] Add support for key connector OTP (#1633) * initial commit - add UsesKeyConnector to UserService - add models - begin work on authentication * finish auth workflow for key connector sso login - finish api call for get user key - start api calls for posts to key connector * Bypass lock page if already unlocked * Move logic to KeyConnectorService, log out if no pin or biometric is set * Disable password reprompt when using key connector * hide password reprompt checkbox when editing or adding cipher * add PostUserKey and PostSetKeyConnector calls * add ConvertMasterPasswordPage * add functionality to RemoveMasterPasswordPage - rename Convert to Remove * Hide Change Master Password button if using key connector * Add OTP verification for export component * Update src/App/Pages/Vault/AddEditPage.xaml.cs Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com> * remove toolbar item "close" * Update src/Core/Models/Request/KeyConnectorUserKeyRequest.cs Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com> * remove new line in resource string - format warning as two labels - set label in code behind for loading simultaneously * implement GetAndSetKey in KeyConnectorService - ignore EnvironmentService call * remove unnecesary orgIdentifier * move RemoveMasterPasswordPage call to LockPage * add spacing to export vault page * log out if no PIN or bio on lock page with key connector * Delete excessive whitespace * Delete excessive whitespace * Change capitalisation of OTP * add default value to models for backwards compatibility * remove this keyword * actually handle exceptions * move RemoveMasterPasswordPage to TabPage using messaging service * add minor improvements * remove 'this.' Co-authored-by: Hinton <oscar@oscarhinton.com> Co-authored-by: Thomas Rittson <trittson@bitwarden.com> Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com>
2021-11-11 02:46:48 +01:00
private readonly IKeyConnectorService _keyConnectorService;
2019-06-04 05:00:48 +02:00
private AddEditPageViewModel _vm;
2019-05-17 21:24:15 +02:00
private bool _fromAutofill;
2019-05-07 17:25:21 +02:00
2019-05-07 18:29:02 +02:00
public AddEditPage(
string cipherId = null,
2019-05-08 16:42:55 +02:00
CipherType? type = null,
2019-05-07 18:29:02 +02:00
string folderId = null,
2019-05-17 18:03:35 +02:00
string collectionId = null,
2019-05-17 21:24:15 +02:00
string name = null,
string uri = null,
bool fromAutofill = false,
AppOptions appOptions = null,
bool cloneMode = false,
ViewPage viewPage = null)
2019-05-07 17:25:21 +02:00
{
Account Switching (#1807) * Account Switching (#1720) * Account switching * WIP * wip * wip * updates to send test logic * fixed Send tests * fixes for theme handling on account switching and re-adding existing account * switch fixes * fixes * fixes * cleanup * vault timeout fixes * account list status enhancements * logout fixes and token handling improvements * merge latest (#1727) * remove duplicate dependency * fix for initial login token storage paradox (#1730) * Fix avatar color update toolbar item issue on iOS for account switching (#1735) * Updated account switching menu UI (#1733) * updated account switching menu UI * additional changes * add key suffix to constant * GetFirstLetters method tweaks * Fix crash on account switching when logging out when having more than user at a time (#1740) * single account migration to multi-account on app update (#1741) * Account Switching Tap to dismiss (#1743) * Added tap to dismiss on the Account switching overlay and improved a bit the code * Fix account switching overlay background transparent on the proper place * Fixed transparent background and the shadow on the account switching overlay * Fix iOS top space on Account switching list overlay after modal (#1746) * Fix top space added to Account switching list overlay after closing modal * Fix top space added to Account switching list overlay after closing modal on lock, login and home views just in case we add modals in the future there as well * Usability: dismiss account list on certain events (#1748) * dismiss account list on certain events * use new FireAndForget method for back button logic * Create and use Account Switching overlay control (#1753) * Added Account switching overlay control and its own ViewModel and refactored accordingly * Fix account switching Accounts list binding update * Implemented dismiss account switching overlay when changing tabs and when selecting the same tab. Also updated the deprecated listener on CustomTabbedRenderer on Android (#1755) * Overriden Equals on AvatarImageSource so it doesn't get set multiple times when it's the same image thus producing blinking on tab chaged (#1756) * Usability improvements for logout on vault timeout (#1781) * accountswitching fixes (#1784) * Fix for invalid PIN lock state when switching accounts (#1792) * fix for pin lock flow * named tuple values and updated async * clear send service cache on account switch (#1796) * Global theme and account removal (#1793) * Global theme and account removal * remove redundant call to hide account list overlay * cleanup and additional tweaks * add try/catch to remove account dialog flow Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
2022-02-23 18:40:17 +01:00
_stateService = ServiceContainer.Resolve<IStateService>("stateService");
2019-06-04 05:00:48 +02:00
_deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
_vaultTimeoutService = ServiceContainer.Resolve<IVaultTimeoutService>("vaultTimeoutService");
[KeyConnector] Add support for key connector OTP (#1633) * initial commit - add UsesKeyConnector to UserService - add models - begin work on authentication * finish auth workflow for key connector sso login - finish api call for get user key - start api calls for posts to key connector * Bypass lock page if already unlocked * Move logic to KeyConnectorService, log out if no pin or biometric is set * Disable password reprompt when using key connector * hide password reprompt checkbox when editing or adding cipher * add PostUserKey and PostSetKeyConnector calls * add ConvertMasterPasswordPage * add functionality to RemoveMasterPasswordPage - rename Convert to Remove * Hide Change Master Password button if using key connector * Add OTP verification for export component * Update src/App/Pages/Vault/AddEditPage.xaml.cs Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com> * remove toolbar item "close" * Update src/Core/Models/Request/KeyConnectorUserKeyRequest.cs Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com> * remove new line in resource string - format warning as two labels - set label in code behind for loading simultaneously * implement GetAndSetKey in KeyConnectorService - ignore EnvironmentService call * remove unnecesary orgIdentifier * move RemoveMasterPasswordPage call to LockPage * add spacing to export vault page * log out if no PIN or bio on lock page with key connector * Delete excessive whitespace * Delete excessive whitespace * Change capitalisation of OTP * add default value to models for backwards compatibility * remove this keyword * actually handle exceptions * move RemoveMasterPasswordPage to TabPage using messaging service * add minor improvements * remove 'this.' Co-authored-by: Hinton <oscar@oscarhinton.com> Co-authored-by: Thomas Rittson <trittson@bitwarden.com> Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com>
2021-11-11 02:46:48 +01:00
_keyConnectorService = ServiceContainer.Resolve<IKeyConnectorService>("keyConnectorService");
2019-05-17 18:03:35 +02:00
_appOptions = appOptions;
2019-05-17 21:24:15 +02:00
_fromAutofill = fromAutofill;
FromAutofillFramework = _appOptions?.FromAutofillFramework ?? false;
2019-05-07 17:25:21 +02:00
InitializeComponent();
_vm = BindingContext as AddEditPageViewModel;
_vm.Page = this;
_vm.CipherId = cipherId;
2019-07-22 16:52:04 +02:00
_vm.FolderId = folderId == "none" ? null : folderId;
_vm.CollectionIds = collectionId != null ? new HashSet<string>(new List<string> { collectionId }) : null;
2019-05-08 16:42:55 +02:00
_vm.Type = type;
2019-05-17 21:24:15 +02:00
_vm.DefaultName = name ?? appOptions?.SaveName;
_vm.DefaultUri = uri ?? appOptions?.Uri;
_vm.CloneMode = cloneMode;
_vm.ViewPage = viewPage;
2019-05-07 18:29:02 +02:00
_vm.Init();
2019-05-07 17:25:21 +02:00
SetActivityIndicator();
if (_vm.EditMode && !_vm.CloneMode && Device.RuntimePlatform == Device.Android)
2019-05-10 20:09:13 +02:00
{
2019-06-14 14:45:28 +02:00
ToolbarItems.Add(_attachmentsItem);
ToolbarItems.Add(_deleteItem);
2019-05-10 20:09:13 +02:00
}
if (Device.RuntimePlatform == Device.iOS)
2019-06-12 03:31:51 +02:00
{
2019-06-14 14:45:28 +02:00
ToolbarItems.Add(_closeItem);
if (_vm.EditMode && !_vm.CloneMode)
2019-06-14 23:31:06 +02:00
{
ToolbarItems.Add(_moreItem);
}
2019-06-24 17:22:34 +02:00
_vm.ShowNotesSeparator = true;
_typePicker.On<iOS>().SetUpdateMode(UpdateMode.WhenFinished);
_ownershipPicker.On<iOS>().SetUpdateMode(UpdateMode.WhenFinished);
2019-06-12 03:31:51 +02:00
}
2019-05-08 05:22:55 +02:00
2019-05-08 20:37:12 +02:00
_typePicker.ItemDisplayBinding = new Binding("Key");
2019-05-08 05:22:55 +02:00
_cardBrandPicker.ItemDisplayBinding = new Binding("Key");
_cardExpMonthPicker.ItemDisplayBinding = new Binding("Key");
_identityTitlePicker.ItemDisplayBinding = new Binding("Key");
2019-05-09 18:18:23 +02:00
_folderPicker.ItemDisplayBinding = new Binding("Key");
_ownershipPicker.ItemDisplayBinding = new Binding("Key");
_loginPasswordEntry.Keyboard = Keyboard.Create(KeyboardFlags.None);
_nameEntry.ReturnType = ReturnType.Next;
_nameEntry.ReturnCommand = new Command(() =>
{
if (_vm.Cipher.Type == CipherType.Login)
{
_loginUsernameEntry.Focus();
}
else if (_vm.Cipher.Type == CipherType.Card)
{
_cardholderNameEntry.Focus();
}
});
_loginUsernameEntry.ReturnType = ReturnType.Next;
_loginUsernameEntry.ReturnCommand = new Command(() => _loginPasswordEntry.Focus());
_loginPasswordEntry.ReturnType = ReturnType.Next;
_loginPasswordEntry.ReturnCommand = new Command(() => _loginTotpEntry.Focus());
_cardholderNameEntry.ReturnType = ReturnType.Next;
_cardholderNameEntry.ReturnCommand = new Command(() => _cardNumberEntry.Focus());
_cardExpYearEntry.ReturnType = ReturnType.Next;
_cardExpYearEntry.ReturnCommand = new Command(() => _cardCodeEntry.Focus());
_identityFirstNameEntry.ReturnType = ReturnType.Next;
_identityFirstNameEntry.ReturnCommand = new Command(() => _identityMiddleNameEntry.Focus());
_identityMiddleNameEntry.ReturnType = ReturnType.Next;
_identityMiddleNameEntry.ReturnCommand = new Command(() => _identityLastNameEntry.Focus());
_identityLastNameEntry.ReturnType = ReturnType.Next;
_identityLastNameEntry.ReturnCommand = new Command(() => _identityUsernameEntry.Focus());
_identityUsernameEntry.ReturnType = ReturnType.Next;
_identityUsernameEntry.ReturnCommand = new Command(() => _identityCompanyEntry.Focus());
_identityCompanyEntry.ReturnType = ReturnType.Next;
_identityCompanyEntry.ReturnCommand = new Command(() => _identitySsnEntry.Focus());
_identitySsnEntry.ReturnType = ReturnType.Next;
_identitySsnEntry.ReturnCommand = new Command(() => _identityPassportNumberEntry.Focus());
_identityPassportNumberEntry.ReturnType = ReturnType.Next;
_identityPassportNumberEntry.ReturnCommand = new Command(() => _identityLicenseNumberEntry.Focus());
_identityLicenseNumberEntry.ReturnType = ReturnType.Next;
_identityLicenseNumberEntry.ReturnCommand = new Command(() => _identityEmailEntry.Focus());
_identityEmailEntry.ReturnType = ReturnType.Next;
_identityEmailEntry.ReturnCommand = new Command(() => _identityPhoneEntry.Focus());
_identityPhoneEntry.ReturnType = ReturnType.Next;
_identityPhoneEntry.ReturnCommand = new Command(() => _identityAddress1Entry.Focus());
_identityAddress1Entry.ReturnType = ReturnType.Next;
_identityAddress1Entry.ReturnCommand = new Command(() => _identityAddress2Entry.Focus());
_identityAddress2Entry.ReturnType = ReturnType.Next;
_identityAddress2Entry.ReturnCommand = new Command(() => _identityAddress3Entry.Focus());
_identityAddress3Entry.ReturnType = ReturnType.Next;
_identityAddress3Entry.ReturnCommand = new Command(() => _identityCityEntry.Focus());
_identityCityEntry.ReturnType = ReturnType.Next;
_identityCityEntry.ReturnCommand = new Command(() => _identityStateEntry.Focus());
_identityStateEntry.ReturnType = ReturnType.Next;
_identityStateEntry.ReturnCommand = new Command(() => _identityPostalCodeEntry.Focus());
_identityPostalCodeEntry.ReturnType = ReturnType.Next;
_identityPostalCodeEntry.ReturnCommand = new Command(() => _identityCountryEntry.Focus());
2019-05-07 17:25:21 +02:00
}
2019-05-17 21:24:15 +02:00
public bool FromAutofillFramework { get; set; }
public AddEditPageViewModel ViewModel => _vm;
2019-05-17 21:24:15 +02:00
2019-05-07 17:25:21 +02:00
protected override async void OnAppearing()
{
base.OnAppearing();
if (!await AppHelpers.IsVaultTimeoutImmediateAsync())
{
await _vaultTimeoutService.CheckVaultTimeoutAsync();
}
if (await _vaultTimeoutService.IsLockedAsync())
{
return;
}
2019-05-30 14:40:10 +02:00
await LoadOnAppearedAsync(_scrollView, true, async () =>
{
2019-06-02 04:44:15 +02:00
var success = await _vm.LoadAsync(_appOptions);
if (!success)
2019-05-30 14:40:10 +02:00
{
await Navigation.PopModalAsync();
2019-06-05 23:25:12 +02:00
return;
2019-05-30 14:40:10 +02:00
}
2019-06-05 23:25:12 +02:00
AdjustToolbar();
await ShowAlertsAsync();
if (!_vm.EditMode && string.IsNullOrWhiteSpace(_vm.Cipher?.Name))
{
RequestFocus(_nameEntry);
}
2019-05-30 14:40:10 +02:00
});
[KeyConnector] Add support for key connector OTP (#1633) * initial commit - add UsesKeyConnector to UserService - add models - begin work on authentication * finish auth workflow for key connector sso login - finish api call for get user key - start api calls for posts to key connector * Bypass lock page if already unlocked * Move logic to KeyConnectorService, log out if no pin or biometric is set * Disable password reprompt when using key connector * hide password reprompt checkbox when editing or adding cipher * add PostUserKey and PostSetKeyConnector calls * add ConvertMasterPasswordPage * add functionality to RemoveMasterPasswordPage - rename Convert to Remove * Hide Change Master Password button if using key connector * Add OTP verification for export component * Update src/App/Pages/Vault/AddEditPage.xaml.cs Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com> * remove toolbar item "close" * Update src/Core/Models/Request/KeyConnectorUserKeyRequest.cs Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com> * remove new line in resource string - format warning as two labels - set label in code behind for loading simultaneously * implement GetAndSetKey in KeyConnectorService - ignore EnvironmentService call * remove unnecesary orgIdentifier * move RemoveMasterPasswordPage call to LockPage * add spacing to export vault page * log out if no PIN or bio on lock page with key connector * Delete excessive whitespace * Delete excessive whitespace * Change capitalisation of OTP * add default value to models for backwards compatibility * remove this keyword * actually handle exceptions * move RemoveMasterPasswordPage to TabPage using messaging service * add minor improvements * remove 'this.' Co-authored-by: Hinton <oscar@oscarhinton.com> Co-authored-by: Thomas Rittson <trittson@bitwarden.com> Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com>
2021-11-11 02:46:48 +01:00
// Hide password reprompt option if using key connector
_passwordPrompt.IsVisible = !await _keyConnectorService.GetUsesKeyConnector();
2019-05-07 17:25:21 +02:00
}
protected override void OnDisappearing()
{
base.OnDisappearing();
}
2019-05-17 21:24:15 +02:00
protected override bool OnBackButtonPressed()
{
if (FromAutofillFramework)
2019-05-17 21:24:15 +02:00
{
Xamarin.Forms.Application.Current.MainPage = new TabsPage();
2019-05-17 21:24:15 +02:00
return true;
}
return base.OnBackButtonPressed();
}
2019-05-07 17:25:21 +02:00
private async void PasswordHistory_Tapped(object sender, System.EventArgs e)
{
if (DoOnce())
2019-05-07 17:25:21 +02:00
{
await Navigation.PushModalAsync(
new Xamarin.Forms.NavigationPage(new PasswordHistoryPage(_vm.CipherId)));
2019-05-07 17:25:21 +02:00
}
}
2019-05-07 18:29:02 +02:00
private async void Save_Clicked(object sender, System.EventArgs e)
{
if (DoOnce())
2019-05-07 18:29:02 +02:00
{
await _vm.SubmitAsync();
}
}
2019-05-08 22:49:32 +02:00
private void NewUri_Clicked(object sender, System.EventArgs e)
{
_vm.AddUri();
}
2019-05-09 05:13:10 +02:00
private void NewField_Clicked(object sender, System.EventArgs e)
{
_vm.AddField();
}
2019-05-11 05:43:35 +02:00
private async void Attachments_Clicked(object sender, System.EventArgs e)
{
if (DoOnce())
{
2019-05-11 05:43:35 +02:00
var page = new AttachmentsPage(_vm.CipherId);
await Navigation.PushModalAsync(new Xamarin.Forms.NavigationPage(page));
}
}
2019-05-10 19:22:35 +02:00
private async void Share_Clicked(object sender, System.EventArgs e)
{
if (DoOnce())
2019-05-10 19:22:35 +02:00
{
var page = new SharePage(_vm.CipherId);
await Navigation.PushModalAsync(new Xamarin.Forms.NavigationPage(page));
2019-05-10 19:22:35 +02:00
}
}
private async void Delete_Clicked(object sender, System.EventArgs e)
{
if (DoOnce())
2019-05-10 19:22:35 +02:00
{
if (await _vm.DeleteAsync())
2019-05-30 14:35:50 +02:00
{
await Navigation.PopModalAsync();
}
2019-05-10 19:22:35 +02:00
}
}
2019-05-10 19:47:59 +02:00
2019-05-10 20:28:17 +02:00
private async void Collections_Clicked(object sender, System.EventArgs e)
2019-05-10 19:47:59 +02:00
{
if (DoOnce())
2019-05-10 19:47:59 +02:00
{
2019-05-10 20:28:17 +02:00
var page = new CollectionsPage(_vm.CipherId);
await Navigation.PushModalAsync(new Xamarin.Forms.NavigationPage(page));
2019-05-10 19:47:59 +02:00
}
}
2019-05-23 03:10:04 +02:00
private async void ScanTotp_Clicked(object sender, System.EventArgs e)
{
if (DoOnce())
2019-05-23 03:10:04 +02:00
{
var cameraPermission = await PermissionManager.CheckAndRequestPermissionAsync(new Permissions.Camera());
if (cameraPermission != PermissionStatus.Granted)
{
return;
}
2019-05-23 03:10:04 +02:00
var page = new ScanPage(key =>
{
Device.BeginInvokeOnMainThread(async () =>
{
await Navigation.PopModalAsync();
await _vm.UpdateTotpKeyAsync(key);
});
});
await Navigation.PushModalAsync(new Xamarin.Forms.NavigationPage(page));
2019-05-23 03:10:04 +02:00
}
}
2019-06-05 23:25:12 +02:00
2019-06-14 14:45:28 +02:00
private async void More_Clicked(object sender, System.EventArgs e)
{
if (!DoOnce())
2019-06-14 14:45:28 +02:00
{
return;
}
var options = new List<string> { AppResources.Attachments };
if (_vm.EditMode)
2019-06-14 14:45:28 +02:00
{
options.Add(_vm.Cipher.OrganizationId == null ? AppResources.MoveToOrganization : AppResources.Collections);
2019-06-14 14:45:28 +02:00
}
var selection = await DisplayActionSheet(AppResources.Options, AppResources.Cancel,
(_vm.EditMode && !_vm.CloneMode) ? AppResources.Delete : null, options.ToArray());
if (selection == AppResources.Delete)
2019-06-14 14:45:28 +02:00
{
if (await _vm.DeleteAsync())
2019-06-14 14:45:28 +02:00
{
await Navigation.PopModalAsync();
}
}
else if (selection == AppResources.Attachments)
2019-06-14 14:45:28 +02:00
{
var page = new AttachmentsPage(_vm.CipherId);
await Navigation.PushModalAsync(new Xamarin.Forms.NavigationPage(page));
2019-06-14 14:45:28 +02:00
}
else if (selection == AppResources.Collections)
2019-06-14 14:45:28 +02:00
{
var page = new CollectionsPage(_vm.CipherId);
await Navigation.PushModalAsync(new Xamarin.Forms.NavigationPage(page));
2019-06-14 14:45:28 +02:00
}
else if (selection == AppResources.MoveToOrganization)
2019-06-14 14:45:28 +02:00
{
var page = new SharePage(_vm.CipherId);
await Navigation.PushModalAsync(new Xamarin.Forms.NavigationPage(page));
2019-06-14 14:45:28 +02:00
}
}
2019-06-12 03:31:51 +02:00
private async void Close_Clicked(object sender, System.EventArgs e)
{
if (DoOnce())
2019-06-12 03:31:51 +02:00
{
await Navigation.PopModalAsync();
}
}
2019-06-05 23:25:12 +02:00
private async Task ShowAlertsAsync()
{
if (!_vm.EditMode)
2019-06-05 23:25:12 +02:00
{
if (_vm.Cipher == null)
2019-06-05 23:25:12 +02:00
{
return;
}
Account Switching (#1807) * Account Switching (#1720) * Account switching * WIP * wip * wip * updates to send test logic * fixed Send tests * fixes for theme handling on account switching and re-adding existing account * switch fixes * fixes * fixes * cleanup * vault timeout fixes * account list status enhancements * logout fixes and token handling improvements * merge latest (#1727) * remove duplicate dependency * fix for initial login token storage paradox (#1730) * Fix avatar color update toolbar item issue on iOS for account switching (#1735) * Updated account switching menu UI (#1733) * updated account switching menu UI * additional changes * add key suffix to constant * GetFirstLetters method tweaks * Fix crash on account switching when logging out when having more than user at a time (#1740) * single account migration to multi-account on app update (#1741) * Account Switching Tap to dismiss (#1743) * Added tap to dismiss on the Account switching overlay and improved a bit the code * Fix account switching overlay background transparent on the proper place * Fixed transparent background and the shadow on the account switching overlay * Fix iOS top space on Account switching list overlay after modal (#1746) * Fix top space added to Account switching list overlay after closing modal * Fix top space added to Account switching list overlay after closing modal on lock, login and home views just in case we add modals in the future there as well * Usability: dismiss account list on certain events (#1748) * dismiss account list on certain events * use new FireAndForget method for back button logic * Create and use Account Switching overlay control (#1753) * Added Account switching overlay control and its own ViewModel and refactored accordingly * Fix account switching Accounts list binding update * Implemented dismiss account switching overlay when changing tabs and when selecting the same tab. Also updated the deprecated listener on CustomTabbedRenderer on Android (#1755) * Overriden Equals on AvatarImageSource so it doesn't get set multiple times when it's the same image thus producing blinking on tab chaged (#1756) * Usability improvements for logout on vault timeout (#1781) * accountswitching fixes (#1784) * Fix for invalid PIN lock state when switching accounts (#1792) * fix for pin lock flow * named tuple values and updated async * clear send service cache on account switch (#1796) * Global theme and account removal (#1793) * Global theme and account removal * remove redundant call to hide account list overlay * cleanup and additional tweaks * add try/catch to remove account dialog flow Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
2022-02-23 18:40:17 +01:00
var addLoginShown = await _stateService.GetAddSitePromptShownAsync();
if (_vm.Cipher.Type == CipherType.Login && !_fromAutofill && !addLoginShown.GetValueOrDefault())
2019-06-05 23:25:12 +02:00
{
Account Switching (#1807) * Account Switching (#1720) * Account switching * WIP * wip * wip * updates to send test logic * fixed Send tests * fixes for theme handling on account switching and re-adding existing account * switch fixes * fixes * fixes * cleanup * vault timeout fixes * account list status enhancements * logout fixes and token handling improvements * merge latest (#1727) * remove duplicate dependency * fix for initial login token storage paradox (#1730) * Fix avatar color update toolbar item issue on iOS for account switching (#1735) * Updated account switching menu UI (#1733) * updated account switching menu UI * additional changes * add key suffix to constant * GetFirstLetters method tweaks * Fix crash on account switching when logging out when having more than user at a time (#1740) * single account migration to multi-account on app update (#1741) * Account Switching Tap to dismiss (#1743) * Added tap to dismiss on the Account switching overlay and improved a bit the code * Fix account switching overlay background transparent on the proper place * Fixed transparent background and the shadow on the account switching overlay * Fix iOS top space on Account switching list overlay after modal (#1746) * Fix top space added to Account switching list overlay after closing modal * Fix top space added to Account switching list overlay after closing modal on lock, login and home views just in case we add modals in the future there as well * Usability: dismiss account list on certain events (#1748) * dismiss account list on certain events * use new FireAndForget method for back button logic * Create and use Account Switching overlay control (#1753) * Added Account switching overlay control and its own ViewModel and refactored accordingly * Fix account switching Accounts list binding update * Implemented dismiss account switching overlay when changing tabs and when selecting the same tab. Also updated the deprecated listener on CustomTabbedRenderer on Android (#1755) * Overriden Equals on AvatarImageSource so it doesn't get set multiple times when it's the same image thus producing blinking on tab chaged (#1756) * Usability improvements for logout on vault timeout (#1781) * accountswitching fixes (#1784) * Fix for invalid PIN lock state when switching accounts (#1792) * fix for pin lock flow * named tuple values and updated async * clear send service cache on account switch (#1796) * Global theme and account removal (#1793) * Global theme and account removal * remove redundant call to hide account list overlay * cleanup and additional tweaks * add try/catch to remove account dialog flow Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
2022-02-23 18:40:17 +01:00
await _stateService.SetAddSitePromptShownAsync(true);
if (Device.RuntimePlatform == Device.iOS)
2019-06-05 23:25:12 +02:00
{
if (_deviceActionService.SystemMajorVersion() < 12)
2019-06-05 23:25:12 +02:00
{
await DisplayAlert(AppResources.BitwardenAppExtension,
AppResources.BitwardenAppExtensionAlert2, AppResources.Ok);
}
else
{
await DisplayAlert(AppResources.PasswordAutofill,
AppResources.BitwardenAutofillAlert2, AppResources.Ok);
}
}
else if (Device.RuntimePlatform == Device.Android &&
2019-06-05 23:25:12 +02:00
!_deviceActionService.AutofillAccessibilityServiceRunning() &&
!_deviceActionService.AutofillServiceEnabled())
{
await DisplayAlert(AppResources.BitwardenAutofillService,
AppResources.BitwardenAutofillServiceAlert2, AppResources.Ok);
}
}
}
}
private void AdjustToolbar()
{
if ((_vm.EditMode || _vm.CloneMode) && Device.RuntimePlatform == Device.Android)
2019-06-05 23:25:12 +02:00
{
if (_vm.Cipher == null)
2019-06-05 23:25:12 +02:00
{
return;
}
if (_vm.Cipher.OrganizationId == null)
2019-06-05 23:25:12 +02:00
{
if (ToolbarItems.Contains(_collectionsItem))
2019-06-05 23:25:12 +02:00
{
ToolbarItems.Remove(_collectionsItem);
}
if (!ToolbarItems.Contains(_shareItem) && !_vm.CloneMode)
2019-06-05 23:25:12 +02:00
{
ToolbarItems.Insert(2, _shareItem);
}
}
else
{
if (ToolbarItems.Contains(_shareItem))
2019-06-05 23:25:12 +02:00
{
ToolbarItems.Remove(_shareItem);
}
if (!ToolbarItems.Contains(_collectionsItem))
2019-06-05 23:25:12 +02:00
{
ToolbarItems.Insert(2, _collectionsItem);
}
}
}
}
private void PasswordPrompt_Toggled(object sender, ToggledEventArgs e)
{
_vm.Cipher.Reprompt = e.Value ? CipherRepromptType.Password : CipherRepromptType.None;
}
2019-05-07 17:25:21 +02:00
}
}