[PR #1720] [MERGED] Account Switching #15823

Closed
opened 2026-04-15 01:55:09 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/1720
Author: @mpbw2
Created: 1/18/2022
Status: Merged
Merged: 1/21/2022
Merged by: @mpbw2

Base: accountswitchingHead: feature-accountswitch


📝 Commits (10+)

  • ebae258 Account switching
  • d1ece79 Merge branch 'master' into feature-accountswitch
  • 120fb70 WIP
  • 6573948 wip
  • e3a8d3b Merge branch 'master' into feature-accountswitch
  • e20ae26 wip
  • f6d4b0a updates to send test logic
  • 6aa96b8 Merge branch 'master' into feature-accountswitch
  • 1c6a896 fixed Send tests
  • ed2bb9b fixes for theme handling on account switching and re-adding existing account

📊 Changes

130 files changed (+4001 additions, -1593 deletions)

View changed files

📝 src/Android/Accessibility/AccessibilityService.cs (+5 -6)
📝 src/Android/Android.csproj (+2 -1)
📝 src/Android/Autofill/AutofillService.cs (+8 -9)
📝 src/Android/Autofill/Parser.cs (+2 -2)
📝 src/Android/MainActivity.cs (+4 -4)
📝 src/Android/MainApplication.cs (+6 -8)
📝 src/Android/Push/FirebaseMessagingService.cs (+2 -2)
📝 src/Android/Receivers/PackageReplacedReceiver.cs (+5 -5)
src/Android/Resources/drawable/cog_environment.xml (+9 -0)
📝 src/Android/Resources/drawable/cog_settings.xml (+0 -0)
📝 src/Android/Services/AndroidPushNotificationService.cs (+6 -7)
📝 src/Android/Services/ClipboardService.cs (+4 -4)
📝 src/Android/Services/DeviceActionService.cs (+6 -7)
📝 src/Android/Tiles/AutofillTileService.cs (+4 -5)
📝 src/Android/Utilities/AppCenterHelper.cs (+4 -4)
📝 src/App/App.csproj (+5 -1)
📝 src/App/App.xaml.cs (+72 -23)
src/App/Controls/AccountViewCell/AccountViewCell.xaml (+101 -0)
src/App/Controls/AccountViewCell/AccountViewCell.xaml.cs (+35 -0)
src/App/Controls/AccountViewCell/AccountViewCellViewModel.cs (+31 -0)

...and 80 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 using multiple simultaneous accounts in the mobile client.

Code changes

  • StateService.cs/State.cs: The official replacement for UserService and the new gateway for all storage queries. While this started out as a 1:1 mirror of the version in jslib, it morphed into something slightly different to accommodate mobile environments by only storing the info necessary to decrypt each user's data and performing said decryption upon switching accounts, only keeping the current account data in cache. Practically speaking this means unlimited accounts, though the loading/saving of the account list (state) would likely start to suffer after a fashion (varies by device, maybe 40-60 accounts or so). That can be optimized further but I'm not sure it's necessary.
  • Account.cs/AccountView.cs: The container for an individual account, but only the data needed to show a list of users and decrypt each user's data when becoming the active account.
  • AvatarImageSource.cs: The icon used to represent the active account in the Toolbar. The color is generated using a duplicate of our web algorithm. (Currently color is only observed on Android, see known issues in iOS above)
  • AuthenticationStatus.cs: Enum used for each user's state in account list
  • StorageOptions.cs/StorageLocation.cs: Used for driving data management within StateService
  • OrganizationService.cs: A dedicated service for handling organization data which was previously handled by UserService
  • CustomNavigationRenderer.cs/ExtendedToolbarItem.cs: Used for avatar visual customizations in the iOS Toolbar
  • cog_environment/cog_settings: Replacement images for cog since it's used in the toolbar now and differs from the Settings cog (in iOS; The same image with a different color is used in Android)
  • Xamarin.Forms: Updated to 5.0.0.2291
  • Xamarin.CommunityToolkit: Added 1.3.2 for account switching list drop Shadow
  • SkiaSharp.Views.Forms: Added 2.80.3 for drawing Avatar image
  • Everything else: Since StateService is used for all storage requests now, nearly everything was touched in order to point to the new service and uses a nearly identical pattern (via dedicated methods modeled after this new interface instead of generic storage requests that we had before).

Screenshots

Screen Shot 2022-01-20 at 10 30 31 AM

Testing requirements

  • Account management (adding, switching, deleting)
  • Vault Timeout (locking, logging out)
  • Autofill (making sure only data from the active account is used)
  • Full Regression (this feature required a system-wide change to the way we store data)

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/1720 **Author:** [@mpbw2](https://github.com/mpbw2) **Created:** 1/18/2022 **Status:** ✅ Merged **Merged:** 1/21/2022 **Merged by:** [@mpbw2](https://github.com/mpbw2) **Base:** `accountswitching` ← **Head:** `feature-accountswitch` --- ### 📝 Commits (10+) - [`ebae258`](https://github.com/bitwarden/android/commit/ebae2585f6364ae4d7fe06802c65eae9f2557e56) Account switching - [`d1ece79`](https://github.com/bitwarden/android/commit/d1ece79d2e2023bb27ddd4bd632ed3e8d1c70bde) Merge branch 'master' into feature-accountswitch - [`120fb70`](https://github.com/bitwarden/android/commit/120fb700394c0617082ebac8217d54febecddf49) WIP - [`6573948`](https://github.com/bitwarden/android/commit/65739489a79e3bb7933c951a26a1f65c8fd04222) wip - [`e3a8d3b`](https://github.com/bitwarden/android/commit/e3a8d3bb55df3849fa1df32d050b20a025cc4c79) Merge branch 'master' into feature-accountswitch - [`e20ae26`](https://github.com/bitwarden/android/commit/e20ae26808fd5576beeb39c293c7bf2d1be6b7be) wip - [`f6d4b0a`](https://github.com/bitwarden/android/commit/f6d4b0a443f32bcd5d71256d51a97dbe5845f560) updates to send test logic - [`6aa96b8`](https://github.com/bitwarden/android/commit/6aa96b89641eb1df5cbd4596b1f3f22068f83f68) Merge branch 'master' into feature-accountswitch - [`1c6a896`](https://github.com/bitwarden/android/commit/1c6a8964fed6e936d2b63037b85d2f68519ea459) fixed Send tests - [`ed2bb9b`](https://github.com/bitwarden/android/commit/ed2bb9b94e4b64a24fd994ab9475921f4cb2a117) fixes for theme handling on account switching and re-adding existing account ### 📊 Changes **130 files changed** (+4001 additions, -1593 deletions) <details> <summary>View changed files</summary> 📝 `src/Android/Accessibility/AccessibilityService.cs` (+5 -6) 📝 `src/Android/Android.csproj` (+2 -1) 📝 `src/Android/Autofill/AutofillService.cs` (+8 -9) 📝 `src/Android/Autofill/Parser.cs` (+2 -2) 📝 `src/Android/MainActivity.cs` (+4 -4) 📝 `src/Android/MainApplication.cs` (+6 -8) 📝 `src/Android/Push/FirebaseMessagingService.cs` (+2 -2) 📝 `src/Android/Receivers/PackageReplacedReceiver.cs` (+5 -5) ➕ `src/Android/Resources/drawable/cog_environment.xml` (+9 -0) 📝 `src/Android/Resources/drawable/cog_settings.xml` (+0 -0) 📝 `src/Android/Services/AndroidPushNotificationService.cs` (+6 -7) 📝 `src/Android/Services/ClipboardService.cs` (+4 -4) 📝 `src/Android/Services/DeviceActionService.cs` (+6 -7) 📝 `src/Android/Tiles/AutofillTileService.cs` (+4 -5) 📝 `src/Android/Utilities/AppCenterHelper.cs` (+4 -4) 📝 `src/App/App.csproj` (+5 -1) 📝 `src/App/App.xaml.cs` (+72 -23) ➕ `src/App/Controls/AccountViewCell/AccountViewCell.xaml` (+101 -0) ➕ `src/App/Controls/AccountViewCell/AccountViewCell.xaml.cs` (+35 -0) ➕ `src/App/Controls/AccountViewCell/AccountViewCellViewModel.cs` (+31 -0) _...and 80 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 using multiple simultaneous accounts in the mobile client. ## 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--> * **StateService.cs/State.cs:** The official replacement for `UserService` and the new gateway for all storage queries. While this started out as a 1:1 mirror of the version in jslib, it morphed into something slightly different to accommodate mobile environments by only storing the info necessary to decrypt each user's data and performing said decryption upon switching accounts, only keeping the current account data in cache. Practically speaking this means unlimited accounts, though the loading/saving of the account list (state) would likely start to suffer after a fashion (varies by device, maybe 40-60 accounts or so). That can be optimized further but I'm not sure it's necessary. * **Account.cs/AccountView.cs:** The container for an individual account, but only the data needed to show a list of users and decrypt each user's data when becoming the active account. * **AvatarImageSource.cs:** The icon used to represent the active account in the Toolbar. The color is generated using a duplicate of our [web algorithm](https://github.com/bitwarden/jslib/blob/ddcfe2336740549c97523d9d75e602f905f0431c/angular/src/components/avatar.component.ts#L81). (Currently color is only observed on Android, see known issues in iOS above) * **AuthenticationStatus.cs:** Enum used for each user's state in account list * **StorageOptions.cs/StorageLocation.cs:** Used for driving data management within `StateService` * **OrganizationService.cs:** A dedicated service for handling organization data which was previously handled by `UserService` * **CustomNavigationRenderer.cs/ExtendedToolbarItem.cs:** Used for avatar visual customizations in the iOS Toolbar * **cog_environment/cog_settings:** Replacement images for `cog` since it's used in the toolbar now and differs from the `Settings` cog (in iOS; The same image with a different color is used in Android) * **Xamarin.Forms:** Updated to `5.0.0.2291` * **Xamarin.CommunityToolkit:** Added `1.3.2` for account switching list drop Shadow * **SkiaSharp.Views.Forms:** Added `2.80.3` for drawing Avatar image * **Everything else:** Since `StateService` is used for all storage requests now, nearly everything was touched in order to point to the new service and uses a nearly identical pattern (via dedicated methods modeled after [this new interface](https://github.com/bitwarden/jslib/blob/master/common/src/abstractions/state.service.ts) instead of generic storage requests that we had before). ## Screenshots <!--Required for any UI changes. Delete if not applicable--> <img width="784" alt="Screen Shot 2022-01-20 at 10 30 31 AM" src="https://user-images.githubusercontent.com/59324545/150375322-2f603a73-f09e-473f-a028-00de2b2cbfa2.png"> ## Testing requirements <!--What functionality requires testing by QA? This includes testing new behavior and regression testing--> - Account management (adding, switching, deleting) - Vault Timeout (locking, logging out) - Autofill (making sure only data from the active account is used) - Full Regression (this feature required a system-wide change to the way we store data) ## Before you submit - [ ] I have added **unit tests** where it makes sense to do so (encouraged but not required) - [X] 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-04-15 01:55:09 -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#15823