[PR #1914] [MERGED] [EC-325] Settings option to allow screen capture on Android #3217

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

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/1914
Author: @darochapires
Created: 5/19/2022
Status: Merged
Merged: 7/15/2022
Merged by: @vvolkgang

Base: masterHead: feature/screen_capture


📝 Commits (5)

  • d2db981 settings option to allow screen capture on Android
  • 92be2ec Merge branch 'master' into feature/screen_capture
  • f48c6fb Improved code on Screen Capture and added prompt to the user to allow screen capture
  • 03eadd4 EC-325 Merged master into feature/screen_capture and adapted for new SettingsViewModel command execution approach
  • afd7a6b EC-325 Removed async on OnCreate of MainActivity given that's not necessary anymore

📊 Changes

13 files changed (+3495 additions, -1347 deletions)

View changed files

📝 src/Android/MainActivity.cs (+3 -2)
📝 src/Android/Services/DeviceActionService.cs (+16 -0)
📝 src/App/Abstractions/IDeviceActionService.cs (+1 -0)
📝 src/App/Pages/Settings/SettingsPage/SettingsPageViewModel.cs (+40 -1)
📝 src/App/Pages/Vault/GroupingsPage/GroupingsPageViewModel.cs (+3 -1)
📝 src/App/Resources/AppResources.Designer.cs (+3373 -1342)
📝 src/App/Resources/AppResources.resx (+6 -0)
📝 src/Core/Abstractions/IStateService.cs (+2 -0)
📝 src/Core/Models/Domain/Account.cs (+2 -0)
📝 src/Core/Services/StateMigrationService.cs (+1 -1)
📝 src/Core/Services/StateService.cs (+23 -0)
📝 src/Core/Utilities/CoreHelpers.cs (+19 -0)
📝 src/iOS.Core/Services/DeviceActionService.cs (+6 -0)

📄 Description

Type of change

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

Objective

Code changes

  • Created an async Task on IDeviceActionService, called SetScreenCaptureAllowedAsync. On Android, it adds/removes the secure flag in order to allow/prevent screen capturing. On iOS, it does nothing.
  • On Android, SetScreenCaptureAllowedAsync is called on MainActivity in OnCreate. Since this is an async Task, I had to make OnCreate async.
  • On SettingsPageViewModel, I'm checking if the app is running on Android and, if so, add a new item to securityItems that toggles the allow screen capture feature. In order to prevent thread concurrency issues accessing SetScreenCaptureAllowedAsync, the state is affected by the item state itself, guaranteeing that the state that the user is seeing on the device screen is the one that's being saved.
  • Since the app supports multiple accounts, added the flag ScreenCaptureAllowed to the Account model to save the state for each account. The state is saved and loaded on StateService and StateMigrationService.
  • I'm calling _deviceActionService.SetScreenCaptureAllowedAsync() on GroupingsPageViewModel LoadAsync to keep consistency.
  • Added a static method on AppResources.Designer that returns the string "Allow Screen Capture", that will be used to display the item on the respective page. I left a TODO there to add this string to the resources. Please help me with this task.
  • Disabled in Debug.
  • Also, tested iOS to make sure it didn't suffer any changes from the code updates.

Screenshots

Screenshot1

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/1914 **Author:** [@darochapires](https://github.com/darochapires) **Created:** 5/19/2022 **Status:** ✅ Merged **Merged:** 7/15/2022 **Merged by:** [@vvolkgang](https://github.com/vvolkgang) **Base:** `master` ← **Head:** `feature/screen_capture` --- ### 📝 Commits (5) - [`d2db981`](https://github.com/bitwarden/android/commit/d2db98195013d00e71291cad6a7254091bbd6055) settings option to allow screen capture on Android - [`92be2ec`](https://github.com/bitwarden/android/commit/92be2ecc414ce17166f249e224cd27725faae679) Merge branch 'master' into feature/screen_capture - [`f48c6fb`](https://github.com/bitwarden/android/commit/f48c6fb65fae2ea8a5c9643c07bc5e465be45a61) Improved code on Screen Capture and added prompt to the user to allow screen capture - [`03eadd4`](https://github.com/bitwarden/android/commit/03eadd48832582d4732f7f6358b0c2e9df229429) EC-325 Merged master into feature/screen_capture and adapted for new SettingsViewModel command execution approach - [`afd7a6b`](https://github.com/bitwarden/android/commit/afd7a6bd9d7d455525bb1c5d3175e974b685017b) EC-325 Removed async on OnCreate of MainActivity given that's not necessary anymore ### 📊 Changes **13 files changed** (+3495 additions, -1347 deletions) <details> <summary>View changed files</summary> 📝 `src/Android/MainActivity.cs` (+3 -2) 📝 `src/Android/Services/DeviceActionService.cs` (+16 -0) 📝 `src/App/Abstractions/IDeviceActionService.cs` (+1 -0) 📝 `src/App/Pages/Settings/SettingsPage/SettingsPageViewModel.cs` (+40 -1) 📝 `src/App/Pages/Vault/GroupingsPage/GroupingsPageViewModel.cs` (+3 -1) 📝 `src/App/Resources/AppResources.Designer.cs` (+3373 -1342) 📝 `src/App/Resources/AppResources.resx` (+6 -0) 📝 `src/Core/Abstractions/IStateService.cs` (+2 -0) 📝 `src/Core/Models/Domain/Account.cs` (+2 -0) 📝 `src/Core/Services/StateMigrationService.cs` (+1 -1) 📝 `src/Core/Services/StateService.cs` (+23 -0) 📝 `src/Core/Utilities/CoreHelpers.cs` (+19 -0) 📝 `src/iOS.Core/Services/DeviceActionService.cs` (+6 -0) </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 - Giving the user the option to enable/disable the possibility to capture the screen, either by screen sharing, screenshots or screen recording, by pressing on a toggle on the setting page. - https://community.bitwarden.com/t/option-to-allow-screenshots/317 - It only concerns the Android platform. ## 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--> - Created an async `Task` on `IDeviceActionService`, called `SetScreenCaptureAllowedAsync`. On Android, it adds/removes the secure flag in order to allow/prevent screen capturing. On iOS, it does nothing. - On Android, `SetScreenCaptureAllowedAsync` is called on `MainActivity` in `OnCreate`. Since this is an `async Task`, I had to make `OnCreate` `async`. - On `SettingsPageViewModel`, I'm checking if the app is running on Android and, if so, add a new item to `securityItems` that toggles the allow screen capture feature. In order to prevent thread concurrency issues accessing `SetScreenCaptureAllowedAsync`, the state is affected by the item state itself, guaranteeing that the state that the user is seeing on the device screen is the one that's being saved. - Since the app supports multiple accounts, added the flag `ScreenCaptureAllowed` to the `Account` model to save the state for each account. The state is saved and loaded on `StateService` and `StateMigrationService`. - I'm calling `_deviceActionService.SetScreenCaptureAllowedAsync()` on `GroupingsPageViewModel` `LoadAsync` to keep consistency. - Added a static method on `AppResources.Designer` that returns the string "Allow Screen Capture", that will be used to display the item on the respective page. I left a `TODO` there to add this string to the resources. Please help me with this task. - Disabled in Debug. - Also, tested iOS to make sure it didn't suffer any changes from the code updates. ## Screenshots <!--Required for any UI changes. Delete if not applicable--> ![Screenshot1](https://user-images.githubusercontent.com/3696035/169279194-46f58f7d-8976-4913-95d4-d15c543a3cbc.png) ## 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 2025-11-26 23:29:50 -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#3217