[PR #1971] [MERGED] [EC-259] Added Account Switching to Share extension on iOS #3261

Closed
opened 2025-11-26 23:30:25 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/1971
Author: @fedemkr
Created: 6/30/2022
Status: Merged
Merged: 7/12/2022
Merged by: @fedemkr

Base: masterHead: EC-259-account-switching-share-extension-ios


📝 Commits (9)

  • 01139a6 EC-259 Added Account switching on share extension on iOS, also improved performance for this and exception handling
  • c33489c Merge branch 'master' into EC-259-account-switching-share-extension-ios
  • 5d04a3a EC-259 code formatting
  • 7461c34 EC-259 Added account switching to Share extension Send view
  • 01b1be8 EC-259 Fixed navigation on share extension when a forms page is already presented
  • 068861b EC-259 Fix send text UI update when going from the iOS extension
  • 42d7511 Merge branch 'master' into EC-259-account-switching-share-extension-ios
  • f7074c8 Merge branch 'master' into EC-259-account-switching-share-extension-ios
  • 5887b50 EC-259 Improved DateTimeViewModel with helper property to easily setup date and time at the same time and applied on usage

📊 Changes

28 files changed (+1510 additions, -424 deletions)

View changed files

📝 src/Android/MainApplication.cs (+4 -1)
📝 src/App/App.csproj (+2 -9)
📝 src/App/Controls/AccountViewCell/AccountViewCellViewModel.cs (+2 -1)
📝 src/App/Controls/AvatarImageSource.cs (+54 -35)
src/App/Controls/AvatarImageSourcePool.cs (+33 -0)
src/App/Controls/DateTime/DateTimePicker.xaml (+20 -0)
src/App/Controls/DateTime/DateTimePicker.xaml.cs (+34 -0)
src/App/Controls/DateTime/DateTimeViewModel.cs (+70 -0)
📝 src/App/Pages/Send/SendAddEditPage.xaml (+5 -5)
📝 src/App/Pages/Send/SendAddEditPage.xaml.cs (+1 -9)
📝 src/App/Pages/Send/SendAddEditPageViewModel.cs (+50 -71)
src/App/Pages/Send/SendAddOnlyOptionsView.xaml (+183 -0)
src/App/Pages/Send/SendAddOnlyOptionsView.xaml.cs (+91 -0)
src/App/Pages/Send/SendAddOnlyPage.xaml (+190 -0)
src/App/Pages/Send/SendAddOnlyPage.xaml.cs (+178 -0)
📝 src/App/Utilities/AccountManagement/AccountsManager.cs (+39 -37)
📝 src/iOS.Core/Controllers/BaseLockPasswordViewController.cs (+58 -30)
📝 src/iOS.Core/Controllers/ExtendedUIViewController.cs (+25 -9)
📝 src/iOS.Core/Controllers/LockPasswordViewController.cs (+1 -1)
📝 src/iOS.Core/Utilities/AccountSwitchingOverlayHelper.cs (+9 -7)

...and 8 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 Account Switching to Share extension on iOS and focused on improving memory usage so that the extension doesn't crash.

Code changes

  • MainApplication.cs: Registering AvatarImageSourcePool
  • AccountViewCellViewModel.cs: Adapted to use the AvatarImageSourcePool
  • AvatarImageSource.cs: Added usings to correct disposal of resources
  • AvatarImageSourcePool.cs: Added this pool to reuse instance of AvatarImageSource across the app
  • DateTimePicker.xaml, DateTimePicker.xaml.cs: Control that combines date and time picking, also added the lazy way of inserting it to avoid memory spike.
  • DateTimeViewModel.cs: ViewModel to be used alongside DateTimePicker
  • SendAddEditPage.xaml: Adapted for ...DateTimeViewModel
  • SendAddEditPage.xaml.cs: Removed OnClose Action given that now a different page is used by the extension
  • SendAddEditPageViewModel.cs: Added DeletionDateTimeViewModel and ExpirationDateTimeViewModel to handle date and time and use the DateTimePicker lazily.
  • SendAddOnlyOptionsView.xaml, SendAddOnlyOptionsView.xaml.cs: Added this view to be used lazily by SendAddOnlyPage so avoid memory spiking when loading the page. It's basically the Options part that can be shown/hidden by the button in the SendAddOnlyPage, given that's lazy, it's only going to be loaded the first time the user wants to show the options.
  • SendAddOnlyPage.xaml, SendAddOnlyPage.xaml.cs: Alike SendAddEditPage but it only has add mode and controls that are used only on adding and specifically for the iOS share extension. With this we remove code and the memory usage decreases. Also, it just loads the view directly instead of using LoadOnAppearedAsync given that the load time is almost nothing, therefore the loading indicator is not seen and this doesn't make sense, therefore we save some memory and cpu time here as well.
  • AccountsManager.cs: Added logging, exception handling and improved invoking on main thread to be awaited properly
  • BaseLockPasswordViewController.cs: Added properly disposal of resources and also changed some references to be weak so that things can be garbage collected in the correct moment.
  • ExtendedUIViewController.cs: Added method to apply theme to a UINavigationBar and not only to the current NavigationController
  • AccountSwitchingOverlayHelper.cs: Improved image disposal
  • iOSCoreHelpers.cs: Registering AvatarImageSourcePool and added InitApp<T>(...) method to be reused on the iOS extensions.
  • ExtensionNavigationController.cs: Added proper disposal of controllers when navigating.
  • LoadingViewController.cs: Added account switching, changed navigation controller to use the ExtensionNavigationController for proper disposal of controllers, improved get provider type and improved navigations to dispose resources appropriately.
  • LockPasswordViewController.cs: Added account switching and improved memory usage by disposing resources correctly.
  • MainInterface.storyboard: Refactored to use less navigation controllers and add account switching on lock controller.

Screenshots

Lock with Account Switching Lock with Account Switching open Sendwith Account Switching open

Before you submit

  • I have checked for formatting errors (dotnet tool run dotnet-format --check) (required)
  • 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/1971 **Author:** [@fedemkr](https://github.com/fedemkr) **Created:** 6/30/2022 **Status:** ✅ Merged **Merged:** 7/12/2022 **Merged by:** [@fedemkr](https://github.com/fedemkr) **Base:** `master` ← **Head:** `EC-259-account-switching-share-extension-ios` --- ### 📝 Commits (9) - [`01139a6`](https://github.com/bitwarden/android/commit/01139a638ef582bb493ce3f89ffa32266d0e386f) EC-259 Added Account switching on share extension on iOS, also improved performance for this and exception handling - [`c33489c`](https://github.com/bitwarden/android/commit/c33489c5c391ae5b19759b7195a5b14d61de529c) Merge branch 'master' into EC-259-account-switching-share-extension-ios - [`5d04a3a`](https://github.com/bitwarden/android/commit/5d04a3a8ffebc2973e383d7d1aa04d627202f4db) EC-259 code formatting - [`7461c34`](https://github.com/bitwarden/android/commit/7461c341a5d483586d8a760de17c8b18cfe3e9e7) EC-259 Added account switching to Share extension Send view - [`01b1be8`](https://github.com/bitwarden/android/commit/01b1be8967148bc1fe3384dce4f210edd0063899) EC-259 Fixed navigation on share extension when a forms page is already presented - [`068861b`](https://github.com/bitwarden/android/commit/068861b0d198e60051faa92126e1e34b96bcb804) EC-259 Fix send text UI update when going from the iOS extension - [`42d7511`](https://github.com/bitwarden/android/commit/42d75119c5b16201f742126b554edf6a00cfc3fe) Merge branch 'master' into EC-259-account-switching-share-extension-ios - [`f7074c8`](https://github.com/bitwarden/android/commit/f7074c83b7da555add1e73a0821d255ea43895c1) Merge branch 'master' into EC-259-account-switching-share-extension-ios - [`5887b50`](https://github.com/bitwarden/android/commit/5887b50837bf4d5828fe043ce3cc4e6a4f5b518d) EC-259 Improved DateTimeViewModel with helper property to easily setup date and time at the same time and applied on usage ### 📊 Changes **28 files changed** (+1510 additions, -424 deletions) <details> <summary>View changed files</summary> 📝 `src/Android/MainApplication.cs` (+4 -1) 📝 `src/App/App.csproj` (+2 -9) 📝 `src/App/Controls/AccountViewCell/AccountViewCellViewModel.cs` (+2 -1) 📝 `src/App/Controls/AvatarImageSource.cs` (+54 -35) ➕ `src/App/Controls/AvatarImageSourcePool.cs` (+33 -0) ➕ `src/App/Controls/DateTime/DateTimePicker.xaml` (+20 -0) ➕ `src/App/Controls/DateTime/DateTimePicker.xaml.cs` (+34 -0) ➕ `src/App/Controls/DateTime/DateTimeViewModel.cs` (+70 -0) 📝 `src/App/Pages/Send/SendAddEditPage.xaml` (+5 -5) 📝 `src/App/Pages/Send/SendAddEditPage.xaml.cs` (+1 -9) 📝 `src/App/Pages/Send/SendAddEditPageViewModel.cs` (+50 -71) ➕ `src/App/Pages/Send/SendAddOnlyOptionsView.xaml` (+183 -0) ➕ `src/App/Pages/Send/SendAddOnlyOptionsView.xaml.cs` (+91 -0) ➕ `src/App/Pages/Send/SendAddOnlyPage.xaml` (+190 -0) ➕ `src/App/Pages/Send/SendAddOnlyPage.xaml.cs` (+178 -0) 📝 `src/App/Utilities/AccountManagement/AccountsManager.cs` (+39 -37) 📝 `src/iOS.Core/Controllers/BaseLockPasswordViewController.cs` (+58 -30) 📝 `src/iOS.Core/Controllers/ExtendedUIViewController.cs` (+25 -9) 📝 `src/iOS.Core/Controllers/LockPasswordViewController.cs` (+1 -1) 📝 `src/iOS.Core/Utilities/AccountSwitchingOverlayHelper.cs` (+9 -7) _...and 8 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 Account Switching to Share extension on iOS and focused on improving memory usage so that the extension doesn't crash. ## 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--> * **MainApplication.cs:** Registering `AvatarImageSourcePool` * **AccountViewCellViewModel.cs:** Adapted to use the `AvatarImageSourcePool` * **AvatarImageSource.cs:** Added usings to correct disposal of resources * **AvatarImageSourcePool.cs:** Added this pool to reuse instance of `AvatarImageSource` across the app * **DateTimePicker.xaml, DateTimePicker.xaml.cs:** Control that combines date and time picking, also added the lazy way of inserting it to avoid memory spike. * **DateTimeViewModel.cs:** ViewModel to be used alongside `DateTimePicker` * **SendAddEditPage.xaml:** Adapted for ...DateTimeViewModel * **SendAddEditPage.xaml.cs:** Removed `OnClose` Action given that now a different page is used by the extension * **SendAddEditPageViewModel.cs:** Added `DeletionDateTimeViewModel` and `ExpirationDateTimeViewModel` to handle date and time and use the `DateTimePicker` lazily. * **SendAddOnlyOptionsView.xaml, SendAddOnlyOptionsView.xaml.cs:** Added this view to be used lazily by `SendAddOnlyPage` so avoid memory spiking when loading the page. It's basically the `Options` part that can be shown/hidden by the button in the `SendAddOnlyPage`, given that's lazy, it's only going to be loaded the first time the user wants to show the options. * **SendAddOnlyPage.xaml, SendAddOnlyPage.xaml.cs:** Alike `SendAddEditPage` but it only has add mode and controls that are used only on adding and specifically for the iOS share extension. With this we remove code and the memory usage decreases. Also, it just loads the view directly instead of using `LoadOnAppearedAsync` given that the load time is almost nothing, therefore the loading indicator is not seen and this doesn't make sense, therefore we save some memory and cpu time here as well. * **AccountsManager.cs:** Added logging, exception handling and improved invoking on main thread to be awaited properly * **BaseLockPasswordViewController.cs:** Added properly disposal of resources and also changed some references to be weak so that things can be garbage collected in the correct moment. * **ExtendedUIViewController.cs:** Added method to apply theme to a `UINavigationBar` and not only to the current `NavigationController` * **AccountSwitchingOverlayHelper.cs:** Improved image disposal * **iOSCoreHelpers.cs:** Registering `AvatarImageSourcePool` and added `InitApp<T>(...)` method to be reused on the iOS extensions. * **ExtensionNavigationController.cs:** Added proper disposal of controllers when navigating. * **LoadingViewController.cs:** Added account switching, changed navigation controller to use the `ExtensionNavigationController` for proper disposal of controllers, improved get provider type and improved navigations to dispose resources appropriately. * **LockPasswordViewController.cs:** Added account switching and improved memory usage by disposing resources correctly. * **MainInterface.storyboard:** Refactored to use less navigation controllers and add account switching on lock controller. ## Screenshots <!--Required for any UI changes. Delete if not applicable--> <img width="314" alt="Lock with Account Switching" src="https://user-images.githubusercontent.com/15682323/171961233-1a60378e-8823-402b-96be-210a18863ce6.png"> <img width="312" alt="Lock with Account Switching open" src="https://user-images.githubusercontent.com/15682323/171961386-6f92c61d-1a52-4b5a-87d3-d4788fe85068.png"> <img width="312" alt="Sendwith Account Switching open" src="https://user-images.githubusercontent.com/15682323/177198807-fabb0913-ef03-45a9-83d2-be30b2dfc5ae.jpeg"> ## Before you submit - [X] I have checked for formatting errors (`dotnet tool run dotnet-format --check`) (required) - [ ] 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 2025-11-26 23:30:25 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/android#3261