-
-
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
Add support for Android 12 and for requesting SMS permission #262
Conversation
src/main/java/org/medicmobile/webapp/mobile/AppUrlVerifier.java
Outdated
Show resolved
Hide resolved
src/main/java/org/medicmobile/webapp/mobile/AppUrlVerifier.java
Outdated
Show resolved
Hide resolved
Hi @jkuester can you please review? And thanks a lot for all the reviews and suggestions, I've learned tons! 🤩 |
…205-Android_12 � Conflicts: � src/main/java/org/medicmobile/webapp/mobile/SettingsDialogActivity.java
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.
I have not finished here yet, but I have looked through all the SMS logic (not tests) and wanted to submit what I have so far.
Couple of questions I have after this initial look:
- Do I need to do anything special to get the app to ask for the SMS permission? I thought all I would need to do was send a message from the
Messages
tab, but that did not trigger it. (Maybe I need some special config on my CHT instance?) - What is the actual problem we are trying to solve with the new URL code? (What was not working before?)
This isn't from Message tab but from Reports tab(Enketo form), it took me awhile to partially figure it out. Edit: You should be able to see the disclosure page after saving the form and sending it as sms, and if the permission isn't granted yet.
Remove backslash at the end of the AppURL, this is a bug that we didn't catch while removing the
Because Gamma Dev's url has a blackslash, I'll put this details in the PR description for QA. |
Thanks for the pointers here! This makes so much more sense now. For the record, I got really curious about this and dug in long enough to figure out how to get the SMS to send!
This will trigger SMS messages to be sent to the gateway number when submitting a form using the Android app. (Note that the gateway number cannot be the number of the phone that the app is running on (seems that you cannot sent SMS to yourself..)). For more info: https://docs.communityhealthtoolkit.org/apps/guides/forms/app-form-sms/ |
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.
Okay, made it though the rest of the implementation code. Still need to look at the tests....
executor.execute(() -> { | ||
try { | ||
final R result = callable.call(); | ||
handler.post(() -> callback.onComplete(result)); |
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.
Okay, just want to be sure I am understanding what is going on here! After we execute the callable (asynchronously in a new Thread), this handler will trigger the callback to be run back on the main thread. Is that right?
src/main/java/org/medicmobile/webapp/mobile/AppUrlVerifier.java
Outdated
Show resolved
Hide resolved
src/main/java/org/medicmobile/webapp/mobile/AppUrlVerifier.java
Outdated
Show resolved
Hide resolved
return false; | ||
} | ||
|
||
return getAppUrl().equals(url.trim().replaceAll("/$", "")); |
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.
Is this what is actually causing the bug around the "Connection Error Page"? Is it just a race condition between hitting the UrlHandler.onReceivedError
before the AppUrlVerifier task could save the cleaned URL?
@@ -11,7 +11,7 @@ | |||
<exclude name="AvoidDuplicateLiterals"/> | |||
<exclude name="AvoidDuplicateLiterals"/> | |||
<exclude name="AvoidFieldNameMatchingMethodName"/> | |||
<exclude name="MissingBreakInSwitch"/> | |||
<exclude name="ImplicitSwitchFallThrough"/> |
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.
Name changed in the new version of PMD
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.
Awesome work @jkuester and @latin-panda !
Description
This PR:
Upgrades to Android 12
Upgrades dependencies that support Android 12
Fixes url validation for the Connexion Error page and adds a test case to cover this validation.
/medic/_design/medic/_rewrite/
from AppURL in this PR. I discovered the problem when testing the Connection Error Page and using Gamma Dev. Because Gamma Dev's url has a slash, https://gamma.dev.medicmobile.org/ then it wasn't passing the validation and the Connection Error Page didn't display.Fixes deprecated attributes (backup strategy) in the manifest.
Adds
SEND_SMS
permission in the manifest, because when sending reports as SMS I was getting this error:java.lang.SecurityException: Sending SMS message: uid 10655 does not have android.permission.SEND_SMS
SEND_SMS
when sending the form as sms and if the permission isn't granted, at the moment you should be able to see the prominent disclosure.Adds prominent disclosure when requesting
SEND_SMS
permission and adds unit tests that cover this scenario.Fixed deprecation from SmsSender, where it gets the SmsManager from the activity context.
Fixed deprecation in Alert's vibrator (form)
Removed unused spinner code in the Utils class, this spinner was used in the PhotoGrabber the old library for image picker.
Fixed deprecation of AsynTask by creating a TaskRunner that is used when validating the app url in the Settings Dialog page.
Closes #205
License
The software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.