[PR #1826] [MERGED] Support for lock/logout/remove accounts from account list #51375

Closed
opened 2026-05-01 15:05:18 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/1826
Author: @mpbw2
Created: 3/4/2022
Status: Merged
Merged: 3/7/2022
Merged by: @mpbw2

Base: masterHead: accountswitching-longpress


📝 Commits (4)

  • af52d81 Support for lock/logout/remove accounts via long-press
  • f2a6ba5 establish and set listview height before showing
  • 423a06d Merge branch 'master' into accountswitching-longpress
  • 6e6e359 undo modification

📊 Changes

24 files changed (+342 additions, -69 deletions)

View changed files

📝 src/Android/Android.csproj (+1 -1)
📝 src/App/App.csproj (+3 -3)
📝 src/App/App.xaml.cs (+28 -22)
📝 src/App/Controls/AccountSwitchingOverlay/AccountSwitchingOverlayView.xaml (+5 -3)
📝 src/App/Controls/AccountSwitchingOverlay/AccountSwitchingOverlayView.xaml.cs (+59 -8)
📝 src/App/Controls/AccountSwitchingOverlay/AccountSwitchingOverlayViewModel.cs (+18 -1)
📝 src/App/Controls/AccountViewCell/AccountViewCell.xaml (+10 -4)
📝 src/App/Controls/AccountViewCell/AccountViewCell.xaml.cs (+20 -1)
📝 src/App/Controls/AccountViewCell/AccountViewCellViewModel.cs (+15 -0)
📝 src/App/Pages/Accounts/HomePage.xaml (+2 -0)
📝 src/App/Pages/Accounts/LockPage.xaml (+2 -0)
📝 src/App/Pages/Accounts/LoginPage.xaml (+2 -0)
📝 src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml (+1 -0)
📝 src/App/Resources/AppResources.Designer.cs (+24 -0)
📝 src/App/Resources/AppResources.resx (+9 -0)
📝 src/App/Utilities/AppHelpers.cs (+74 -3)
📝 src/Core/Abstractions/IStateService.cs (+1 -0)
📝 src/Core/Abstractions/IVaultTimeoutService.cs (+2 -0)
📝 src/Core/Services/EnvironmentService.cs (+1 -0)
📝 src/Core/Services/StateService.cs (+17 -9)

...and 4 more files

📄 Description

Type of change

  • Bug fix
  • New feature development
  • Tech debt (refactoring, code cleanup, dependency upgrades, etc)
  • Build/deploy pipeline (DevOps)
  • Other

Objective

Added support for lock/logout/remove accounts from the account list via long-press.

Code changes

  • AccountSwitchingOverlay.xaml/xaml.cs/ViewModel.cs: Replaced ItemSelected with custom commands for selection and long-press that makes use of TouchEffect from the Xamarin Community Toolkit
  • AccountViewCell.xaml/xaml.cs/ViewModel.cs: Added TouchEffect bindings and added new *AndNotActive states for the auth status so the original states can be utilized for more than just UI visibility
  • Homepage/LockPage/LoginPage/GroupingsPage.xaml: Added MainPage property for command routing
  • AppHelpers.cs: Added AccountListOptions method to generate options list, same pattern as the overflow menus for Ciphers and Sends
  • App.xaml.cs: Added ability to include userId to "locked" message, made SetMainPageAsync smarter using new methods from VaultTimeoutService
  • StateService.cs: Added IsActiveAccount to discern if the userId passed in is the active account (the null-check followed by comparison with the stored active userId was becoming repetitive), made RefreshAccountViewsAsync smarter using new methods from VaultTimeoutService
  • VaultTimeoutService.cs: Changed _lockedCallback to Tuple (same pattern as _loggedOutCallback) for inclusion of userId string, added new ShouldLockAsync and ShouldLogOutByTimeoutAsync methods so code trying to figure that out elsewhere becomes more readable, and added active account awareness to LockAsync
  • ServiceContainer.cs: Added extras to lockedCallback when constructing VaultTimeoutService
  • .csproj files: Updated Xamarin CommunityToolkit, Essentials, and Forms

Screenshots

1: Two accounts listed (one on cloud, one on-prem)

Screen Shot 2022-03-04 at 10 07 39 AM

2: Long-pressed first (cloud) account, able to Lock and Log Out

Screen Shot 2022-03-04 at 10 18 09 AM

3: Selected "Lock", re-opened account list, first (cloud) account is now locked

Screen Shot 2022-03-04 at 10 19 05 AM

4: Long-pressed first (cloud) account again, only option is to Log Out

Screen Shot 2022-03-04 at 10 19 27 AM

5: Asked to confirm Log Out

Screen Shot 2022-03-04 at 10 19 47 AM

6: Re-opened account list, cloud account has been logged out (fully, since this was user-initiated and not a vault timeout)

Screen Shot 2022-03-04 at 10 20 16 AM

7: Added a second on-prem account with vault timeout action set to Log Out immediately and switched back to first on-prem account

Screen Shot 2022-03-04 at 10 22 22 AM

8: Long-pressed second (logged out) account, only option is to Remove Account

Screen Shot 2022-03-04 at 10 22 39 AM

9: Asked to confirm Remove Account

Screen Shot 2022-03-04 at 10 22 55 AM

Testing requirements

https://app.asana.com/0/1201803072708593/1201853426906088

Before you submit

  • I have added unit tests where it makes sense to do so (encouraged but not required)
  • This change requires a documentation update (notify the documentation team)
  • This change has particular deployment requirements (notify the DevOps team)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/bitwarden/android/pull/1826 **Author:** [@mpbw2](https://github.com/mpbw2) **Created:** 3/4/2022 **Status:** ✅ Merged **Merged:** 3/7/2022 **Merged by:** [@mpbw2](https://github.com/mpbw2) **Base:** `master` ← **Head:** `accountswitching-longpress` --- ### 📝 Commits (4) - [`af52d81`](https://github.com/bitwarden/android/commit/af52d81148d7b38b7ea04be2a4c29322c5e7747b) Support for lock/logout/remove accounts via long-press - [`f2a6ba5`](https://github.com/bitwarden/android/commit/f2a6ba5d7e46d658985ae5e31b200ed35b8b5b12) establish and set listview height before showing - [`423a06d`](https://github.com/bitwarden/android/commit/423a06d74cc5178fe2851777972c14e35263773b) Merge branch 'master' into accountswitching-longpress - [`6e6e359`](https://github.com/bitwarden/android/commit/6e6e359c2ea363030f6a837d5323fc861b6c08be) undo modification ### 📊 Changes **24 files changed** (+342 additions, -69 deletions) <details> <summary>View changed files</summary> 📝 `src/Android/Android.csproj` (+1 -1) 📝 `src/App/App.csproj` (+3 -3) 📝 `src/App/App.xaml.cs` (+28 -22) 📝 `src/App/Controls/AccountSwitchingOverlay/AccountSwitchingOverlayView.xaml` (+5 -3) 📝 `src/App/Controls/AccountSwitchingOverlay/AccountSwitchingOverlayView.xaml.cs` (+59 -8) 📝 `src/App/Controls/AccountSwitchingOverlay/AccountSwitchingOverlayViewModel.cs` (+18 -1) 📝 `src/App/Controls/AccountViewCell/AccountViewCell.xaml` (+10 -4) 📝 `src/App/Controls/AccountViewCell/AccountViewCell.xaml.cs` (+20 -1) 📝 `src/App/Controls/AccountViewCell/AccountViewCellViewModel.cs` (+15 -0) 📝 `src/App/Pages/Accounts/HomePage.xaml` (+2 -0) 📝 `src/App/Pages/Accounts/LockPage.xaml` (+2 -0) 📝 `src/App/Pages/Accounts/LoginPage.xaml` (+2 -0) 📝 `src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml` (+1 -0) 📝 `src/App/Resources/AppResources.Designer.cs` (+24 -0) 📝 `src/App/Resources/AppResources.resx` (+9 -0) 📝 `src/App/Utilities/AppHelpers.cs` (+74 -3) 📝 `src/Core/Abstractions/IStateService.cs` (+1 -0) 📝 `src/Core/Abstractions/IVaultTimeoutService.cs` (+2 -0) 📝 `src/Core/Services/EnvironmentService.cs` (+1 -0) 📝 `src/Core/Services/StateService.cs` (+17 -9) _...and 4 more files_ </details> ### 📄 Description ## Type of change - [ ] Bug fix - [X] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [ ] Other ## Objective <!--Describe what the purpose of this PR is. For example: what bug you're fixing or what new feature you're adding--> Added support for lock/logout/remove accounts from the account list via long-press. ## Code changes <!--Explain the changes you've made to each file or major component. This should help the reviewer understand your changes--> <!--Also refer to any related changes or PRs in other repositories--> * **AccountSwitchingOverlay.xaml/xaml.cs/ViewModel.cs:** Replaced `ItemSelected` with custom commands for selection and long-press that makes use of `TouchEffect` from the Xamarin Community Toolkit * **AccountViewCell.xaml/xaml.cs/ViewModel.cs:** Added `TouchEffect` bindings and added new `*AndNotActive` states for the auth status so the original states can be utilized for more than just UI visibility * **Homepage/LockPage/LoginPage/GroupingsPage.xaml:** Added `MainPage` property for command routing * **AppHelpers.cs:** Added `AccountListOptions` method to generate options list, same pattern as the overflow menus for Ciphers and Sends * **App.xaml.cs:** Added ability to include `userId` to "locked" message, made `SetMainPageAsync` smarter using new methods from `VaultTimeoutService` * **StateService.cs:** Added `IsActiveAccount` to discern if the userId passed in is the active account (the null-check followed by comparison with the stored active userId was becoming repetitive), made `RefreshAccountViewsAsync` smarter using new methods from `VaultTimeoutService` * **VaultTimeoutService.cs:** Changed `_lockedCallback` to Tuple (same pattern as `_loggedOutCallback`) for inclusion of userId string, added new `ShouldLockAsync` and `ShouldLogOutByTimeoutAsync` methods so code trying to figure that out elsewhere becomes more readable, and added active account awareness to `LockAsync` * **ServiceContainer.cs:** Added extras to `lockedCallback` when constructing `VaultTimeoutService` * **.csproj files:** Updated Xamarin CommunityToolkit, Essentials, and Forms ## Screenshots <!--Required for any UI changes. Delete if not applicable--> 1: Two accounts listed (one on cloud, one on-prem) <img width="777" alt="Screen Shot 2022-03-04 at 10 07 39 AM" src="https://user-images.githubusercontent.com/59324545/156793300-3506587f-fbb2-4791-a94f-2ca381727dd6.png"> 2: Long-pressed first (cloud) account, able to Lock and Log Out <img width="775" alt="Screen Shot 2022-03-04 at 10 18 09 AM" src="https://user-images.githubusercontent.com/59324545/156793305-5fac9a18-c2d2-495c-91b7-d328b383732b.png"> 3: Selected "Lock", re-opened account list, first (cloud) account is now locked <img width="768" alt="Screen Shot 2022-03-04 at 10 19 05 AM" src="https://user-images.githubusercontent.com/59324545/156793311-6bcc358f-d5cc-4542-8bdb-9bc7dc9630ba.png"> 4: Long-pressed first (cloud) account again, only option is to Log Out <img width="770" alt="Screen Shot 2022-03-04 at 10 19 27 AM" src="https://user-images.githubusercontent.com/59324545/156793318-9ddd3a7c-2028-4e52-89b8-e2851a8c13c5.png"> 5: Asked to confirm Log Out <img width="768" alt="Screen Shot 2022-03-04 at 10 19 47 AM" src="https://user-images.githubusercontent.com/59324545/156793321-d351f12c-e3b9-4364-82c5-429a8c2d8202.png"> 6: Re-opened account list, cloud account has been logged out (fully, since this was user-initiated and not a vault timeout) <img width="770" alt="Screen Shot 2022-03-04 at 10 20 16 AM" src="https://user-images.githubusercontent.com/59324545/156793767-4e4c7b81-29d5-4755-baf2-9017b6ac8dba.png"> 7: Added a second on-prem account with vault timeout action set to Log Out immediately and switched back to first on-prem account <img width="772" alt="Screen Shot 2022-03-04 at 10 22 22 AM" src="https://user-images.githubusercontent.com/59324545/156793326-c3a26315-473a-4f26-adf7-5ae6edc717ab.png"> 8: Long-pressed second (logged out) account, only option is to Remove Account <img width="769" alt="Screen Shot 2022-03-04 at 10 22 39 AM" src="https://user-images.githubusercontent.com/59324545/156793331-07db8bbb-4863-427b-94ec-41b71e8fed87.png"> 9: Asked to confirm Remove Account <img width="770" alt="Screen Shot 2022-03-04 at 10 22 55 AM" src="https://user-images.githubusercontent.com/59324545/156793335-8dbad4fa-40a9-4ef5-8113-a31e3e35935c.png"> ## Testing requirements <!--What functionality requires testing by QA? This includes testing new behavior and regression testing--> https://app.asana.com/0/1201803072708593/1201853426906088 ## Before you submit - [ ] I have added **unit tests** where it makes sense to do so (encouraged but not required) - [ ] This change requires a **documentation update** (notify the documentation team) - [ ] This change has particular **deployment requirements** (notify the DevOps team) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-01 15:05:18 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/android#51375