Skip to content
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

Merged
merged 52 commits into from
Nov 3, 2021
Merged

Conversation

grzesiek2010
Copy link
Member

@grzesiek2010 grzesiek2010 commented Oct 26, 2021

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/63246789

We 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:

  • taking pictures
  • recording videos
  • recording audio
  • attaching arbitrary files
  • opening media files in Collect (recorded using our widgets but also media files attached to questions)
  • starting external widgets
  • choosing files (fore example qr codes for configuring the app)

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:

  • run ./gradlew checkAll and confirmed all checks still pass OR confirm CircleCI build passes and run ./gradlew connectedDebugAndroidTest locally.
  • verified that any code or assets from external sources are properly credited in comments and/or in the about file.
  • verified that any new UI elements use theme colors. UI Components Style guidelines

@grzesiek2010 grzesiek2010 changed the title Collect 4876 Fixed starting activities Oct 27, 2021
@grzesiek2010 grzesiek2010 marked this pull request as ready for review October 27, 2021 09:42
@grzesiek2010 grzesiek2010 requested a review from seadowg October 27, 2021 09:42
Copy link
Member

@seadowg seadowg left a 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!

Copy link
Member

@seadowg seadowg left a 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?

@grzesiek2010
Copy link
Member Author

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.

I agree with that and it's now implemented.

@grzesiek2010 grzesiek2010 requested a review from seadowg October 27, 2021 18:18
Copy link
Member

@seadowg seadowg left a 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!

@mmarciniak90
Copy link
Contributor

@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 All widgets

incorrect toast expected toast
Screenshot_20211102-113758_ODK Collect Screenshot_20211102-113835_ODK Collect

@grzesiek2010
Copy link
Member Author

@mmarciniak90 The problem should be solved now.

@kkrawczyk123
Copy link
Contributor

Tested with success!
Verified on Androids: 5.1, 9.0 and 11

Tested cases:

  • video widget: attach, record, play
  • image widget: attach, take a picture
  • selfie widgets
  • audio widget
  • draw widget
  • signature widget
  • annotate widget
  • barcode widget
  • file widget
  • URL widget
  • use external widgets with app
  • toasts when there is no external app have been fixed
  • numerical widget with video attachment
  • play audio and video attachments in form
  • Collect counter app
  • Collect Tester app
  • edited project via imported QR code file
  • added new project via imported QR code file

@mmarciniak90
Copy link
Contributor

Tested with success on Android versions: 8.1, 10.0

@grzesiek2010 grzesiek2010 merged commit 7f2afb3 into getodk:master Nov 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to play video attached to form on Android 11
4 participants