-
-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
148 - Prominent disclosure for storage permission #250
Conversation
Hey @jkuester, this is a draft, I still need to work the test coverage and see compatibility with older android devices. The flow is like this: The feature(s) makes a regular startActivityForResult, this is to connect with the old code. Then our new activity will display a disclosure explaining why we need the permission and if the user agrees then it launches another activity to request permissions, once the permission is granted it will execute the callback contract (we're saving 1 request code by doing this). The callback will resolve the activity and give control back to the EmbeddedBrowserActivity, the old code, to determine how it resumes the action . EmbeddedBrowserActivity extends from a very basic Activity class, that doesn't support callback contracts, I'm suggesting to change this later, so we can control better the resume of actions by using callbacks and reduce the usage of request code. When looking into this solution, I tried to keep the "resume of the action" inside the feature class (CHTExternalAppHandler, FilePickerHandler) by making the feature an action, but I couldn't find a way of passing objects as intent extras, I wanted to pass these parameters. And since the feature action's intent needs to be started by EmbeddedBrowserActivity, it was becoming too much structure, so I decided to drop it for now. |
I've tested the solution in devices with Android 6, 9 and 11. Working fine! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Chaining the intents via the PermissionActivity classes cleans up the logic flow a lot.
Just a few minor suggestions/questions inline.
src/main/java/org/medicmobile/webapp/mobile/RequestStoragePermissionActivity.java
Outdated
Show resolved
Hide resolved
src/main/java/org/medicmobile/webapp/mobile/FilePickerHandler.java
Outdated
Show resolved
Hide resolved
src/main/java/org/medicmobile/webapp/mobile/RequestLocationPermissionActivity.java
Outdated
Show resolved
Hide resolved
src/main/java/org/medicmobile/webapp/mobile/EmbeddedBrowserActivity.java
Outdated
Show resolved
Hide resolved
src/main/java/org/medicmobile/webapp/mobile/FilePickerHandler.java
Outdated
Show resolved
Hide resolved
@jkuester can you please have a look again? Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! Just a couple more minor suggestions/questions. I made it through all the impl code, but have not looked at the tests yet.
src/main/java/org/medicmobile/webapp/mobile/RequestLocationPermissionActivity.java
Outdated
Show resolved
Hide resolved
src/main/java/org/medicmobile/webapp/mobile/RequestLocationPermissionActivity.java
Outdated
Show resolved
Hide resolved
src/main/java/org/medicmobile/webapp/mobile/RequestLocationPermissionActivity.java
Show resolved
Hide resolved
src/main/java/org/medicmobile/webapp/mobile/RequestLocationPermissionActivity.java
Outdated
Show resolved
Hide resolved
src/main/java/org/medicmobile/webapp/mobile/RequestStoragePermissionActivity.java
Outdated
Show resolved
Hide resolved
src/main/java/org/medicmobile/webapp/mobile/RequestStoragePermissionActivity.java
Outdated
Show resolved
Hide resolved
src/main/java/org/medicmobile/webapp/mobile/RequestStoragePermissionActivity.java
Show resolved
Hide resolved
src/main/java/org/medicmobile/webapp/mobile/RequestLocationPermissionActivity.java
Outdated
Show resolved
Hide resolved
src/main/java/org/medicmobile/webapp/mobile/EmbeddedBrowserActivity.java
Show resolved
Hide resolved
src/main/java/org/medicmobile/webapp/mobile/EmbeddedBrowserActivity.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests look great! Very thorough. This is ready to go (pending what you want to do with the SettingsStore changes). 🚀
Ticket: medic#148 This commit: - Adds a prominent disclosure for when requesting storage permission - Updates location prominent disclosure to use intent's callback contracts. - Handle "never ask again" or when permission is denied for second time or when the permission is denied from the App's Settings page, at this point we can't request the grant automatically so the user is redirected to the app's settings to manually grant the permission.
Description
This PR:
Tested in: Android 6, 9 and 11.
Ticket: #148
Screenshots
Location prominent disclosure looks the same:
New storage prominent disclosure:
Redirection to app's settings when we can't get the permission grant automatically:
License
The software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.