Skip to content

Conversation

@joshliebe
Copy link
Contributor

@joshliebe joshliebe commented Jun 2, 2021

Task/Issue URL: https://app.asana.com/0/72649045549333/1199533149091655/f
Tech Design URL: https://app.asana.com/0/481882893211075/1200311072033594
CC:

Description:
This PR adds handling of App Links.

When a user taps an app link they will be prompted to open the link in the corresponding app (By tapping the "Yes" button) or view the content in the browser (By tapping the "No" button"). If there are multiple apps that can handle the link, then a chooser is shown.

The feature can be enabled/disabled in settings. It is enabled by default.

Screenshots:

Dialog Chooser Setting
Screenshot_1623242574 Screenshot_1623242681 Screenshot_1623242587

Steps to test this PR:

  1. Search for "Google Maps".
  2. Tap the first link.
  3. Select "Yes" from the dialog and it should navigate to the Google Maps app.
  4. Go back and tap the link again and select "No" from the dialog. It should open the link in the browser.
  5. Go to settings, disable "Open Links in Associated Apps".
  6. Tap the link again and verify that the dialog does not show and that link is opened in the browser.
  7. Enable the setting again.
  8. Install multiple apps that can handle a link: Twitter and Twitter Lite.
  9. Search for "Twitter DuckDuckGo".
  10. Tap the first link and choose "Yes" from the dialog.
  11. Verify that the chooser is shown with associated apps.
  12. Type in a URL associated with an app, such as maps.google.com. Verify that the link is navigated to in the browser.

Internal references:

Software Engineering Expectations
Technical Design Template

@joshliebe joshliebe marked this pull request as ready for review June 9, 2021 13:36
Copy link
Contributor

@malmstein malmstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job @joshliebe. Left a few comments but feel free to ignore what you don't agree with.

@joshliebe
Copy link
Contributor Author

Good job @joshliebe. Left a few comments but feel free to ignore what you don't agree with.

Thanks for reviewing @malmstein, will address the comments 👍

Copy link
Contributor

@cmonfortep cmonfortep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @joshliebe. This looks great, I left some minor comments, feel free to skip them.

I've tested this on my device and it works as described 👍


override fun handleNonHttpAppLink(isRedirect: Boolean, launchNonHttpAppLink: () -> Unit): Boolean {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && isRedirect && appLinkOpenedInBrowser) {
return true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've noticed handleAppLink and handleNonHttpAppLink both return Boolean, but the same boolean can have different meanings. E.g: here when NonHttpAppLink not handled we return true, but in handleAppLink we return false.

is there any specific reason why return true in this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For non-HTTP links, like market:// or intent://, true is returned so that they are ignored. If false is returned for those links, they will open in the browser and the user will see the WebView error page because they can't be handled. false is returned for HTTP app links since the WebView can open those.

@joshliebe
Copy link
Contributor Author

Thanks for reviewing @cmonfortep 🙂

@joshliebe joshliebe merged commit 9ffdf3c into develop Jun 15, 2021
@joshliebe joshliebe deleted the feature/josh/detect-app-links branch June 15, 2021 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants