-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fixed starting activities #4878
Conversation
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 looking really good! I still need to go through the new widget intent launchers, but I've got a few tweaks that we could make that I'll just share now so that I'm not holding you up!
androidshared/src/main/java/org/odk/collect/androidshared/utils/IntentLauncherImpl.kt
Outdated
Show resolved
Hide resolved
androidshared/src/test/java/org/odk/collect/androidshared/utils/IntentLauncherImplTest.kt
Outdated
Show resolved
Hide resolved
androidshared/src/test/java/org/odk/collect/androidshared/utils/IntentLauncherImplTest.kt
Outdated
Show resolved
Hide resolved
androidshared/src/test/java/org/odk/collect/androidshared/utils/IntentLauncherImplTest.kt
Outdated
Show resolved
Hide resolved
androidshared/src/test/java/org/odk/collect/androidshared/utils/IntentLauncherImplTest.kt
Outdated
Show resolved
Hide resolved
androidshared/src/test/java/org/odk/collect/androidshared/utils/IntentLauncherImplTest.kt
Outdated
Show resolved
Hide resolved
androidshared/src/test/java/org/odk/collect/androidshared/utils/IntentLauncherImplTest.kt
Outdated
Show resolved
Hide resolved
androidshared/src/main/java/org/odk/collect/androidshared/utils/IntentLauncherImpl.kt
Outdated
Show resolved
Hide resolved
testshared/src/main/java/org/odk/collect/testshared/FakeIntentLauncher.kt
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.
I think we can maybe revise the naming for the external widget intent launchers to follow the existing external data interfaces we have like GeoDataRequester
. For instance ExFileWidgetIntentLauncher
could be FileRequester
.
I also think we could simplify the interfaces a little for these by giving the implementations constructors (and making them class
not object
). Right now we have to pass dependencies like IntentLauncher
into the widgets (increasing reliance on the class hierarchy here) whereas really they could be detached through these interfaces. For example, ExStringWidgetIntentLauncher#launch
could just take a FormEntryPrompt
and the onError
callback (and I think the request code) while the other dependencies could be passed in at construction in WidgetFactory
.
Thoughts?
I agree with that and it's now implemented. |
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.
One tweak but this is great!
collect_app/src/main/java/org/odk/collect/android/widgets/QuestionWidget.java
Outdated
Show resolved
Hide resolved
…d StringReuqester via constructor
e00cdb8
to
3d77e28
Compare
@grzesiek2010, I checked external widgets on a separate page without CollectAnswerProvider installed and I see unexpected message in toast. Form to test: external_widgets or
|
@mmarciniak90 The problem should be solved now. |
Tested with success! Tested cases:
|
Tested with success on Android versions: 8.1, 10.0 |
Closes #4876
What has been done to verify that this works as intended?
I have tested staring some external apps.
Why is this the best possible solution? Were any other approaches considered?
I had to reimplement the way we check if an activity we want to star is available. Before we used our ActivityAvailability which used
queryIntentActivities()
. According to https://developer.android.com/about/versions/11/privacy/package-visibility?authuser=2 that method will return an empty array on android 11 if we don't declare in our AndroidManifest.xml like https://stackoverflow.com/a/63246789We could do that but that would open a lot of room for error since we can easily forget something so we agreed that a better option would be to get rid of it and just try to start activities and catch exceptions that are thrown if they are not available.
How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
Please test:
plus please test the behavior when an external app is not available (there should be a toast in most cases).
It's difficult to list everything so basically everything that is related to staring external apps might be affected.
Do we need any specific form for testing your changes? If so, please attach one.
No.
Does this change require updates to documentation? If so, please file an issue here and include the link below.
No.
Before submitting this PR, please make sure you have:
./gradlew checkAll
and confirmed all checks still pass OR confirm CircleCI build passes and run./gradlew connectedDebugAndroidTest
locally.