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

Open chat links in regular browser tabs #4198

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

cbs228
Copy link

@cbs228 cbs228 commented Jan 26, 2025

Content

Open web hyperlinks in chat messages in the user's regular, preferred web browser. Fixes bug introduced in v0.6.5.

Closes #3885

Motivation and context

In 5baefd4, a link to a "help" web page was added to the MessagesView. Since this page is essentially part of the app, it should and does open in an "in-app" Chrome Custom Tab, where supported.

Unfortunately, this change affects every link in the messages view, including links sent in chat messages. As of v0.6.5, links in chat messages now open in a Custom Tab instead of the user's configured "full" web browser. This is a UX nuisance.

Separate "regular" links from "help" links with a different callback for each.

  • onLinkClick is modified to use standard browser tabs

  • onHelpLinkClick prefers a Chrome Custom Tab where possible

The LearnMoreConfig.IDENTITY_CHANGE_URL is now presented to onHelpLinkClick(). The regular onLinkClick() is used everywhere else.

Alternatively, the first patch in this PR removes the Custom Tab behavior from MessagesView entirely. This is likely not the preferred end result, however.

Screenshots / GIFs

Before After
Screenshot_20250125-211827_Fennec Screenshot_20250125-211852_Fennec

Tests

  1. Build F-Droid version with

    export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64/
    export GRADLE_OPTS="-Dorg.gradle.jvmargs=-Xmx9g -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError -XX:+UseG1GC -Dkotlin.daemon.jvm.options=-Xmx4g"
    ./gradlew app:assembleFDroidDebug
    
  2. Install on device.

  3. Sign in to Element.

  4. Open a chat room. Find a message which includes an https:// web link.

  5. Tap on the link.

  6. Observe that the link is opened in the "full" web browser with the full browser UI and other tabs. (See screenshots.)

I have not tried to force an identity change to test that the identity change help still loads in a Chrome Custom Tab. I'm not sure what the best way to test that is.

This PR should not introduce any new Android APIs. If API 24 emulator testing is required, can the project recommend an emulator?

Tested devices

  • Physical: Android 14 / LineageOS 21, with f-droid build and the Fennec F-Droid web browser
  • Emulator

Checklist

  • Changes have been tested on an Android device or Android emulator with API 24
  • UI change has been tested on both light and dark themes (N/A, but tested anyway)
  • Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • Pull request is based on the develop branch
  • Pull request title will be used in the release note, it clearly define what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • You've made a self review of your PR

In [1], all hyperlinks within `MessagesNode` switched to using

    activity.openUrlInChromeCustomTab()

instead of with `openUrlInExternalApp()`.

This causes web links in chat messages to open in an "in-app"
Chrome Custom Tab [2] instead of the user's configured "full"
web browser. This is a UX nuisance. Open web links in a full
browser instead.

Closes element-hq#3885 [3].

[1]: 5baefd4 (Identity change: handle click on "learn more")

[2]: https://developer.chrome.com/docs/android/custom-tabs/guide-get-started#opening_a_custom_tab

[3]: element-hq#3885
Some links in the `MessagesView` are part of Element X itself,
such as the help pages in `LearnMoreConfig` [1]. These links
should open in an "in-app" Chrome Custom Tab, because they are
basically part of the app.

Web links from chat messages, on the other hand, should open in
the user's preferred web browser as regular tabs.

Separate "regular" links from "help" links with a different
callback for each:

* `onLinkClick` is modified to use regular browser tabs

* `onHelpLinkClick` prefers a Chrome Custom Tab where possible

[1]: appconfig/src/main/kotlin/io/element/android/appconfig/LearnMoreConfig.kt
@cbs228 cbs228 requested a review from a team as a code owner January 26, 2025 19:02
@cbs228 cbs228 requested review from ganfra and removed request for a team January 26, 2025 19:02
Copy link
Contributor

Thank you for your contribution! Here are a few things to check in the PR to ensure it's reviewed as quickly as possible:

  • Your branch should be based on origin/develop, at least when it was created.
  • The title of the PR will be used for release notes, so it needs to describe the change visible to the user.
  • The test pass locally running ./gradlew test.
  • The code quality check suite pass locally running ./gradlew runQualityChecks.
  • If you modified anything related to the UI, including previews, you'll have to run the Record screenshots GH action in your forked repo: that will generate compatible new screenshots. However, given Github Actions limitations, it will prevent the CI from running temporarily, until you upload a new commit after that one. To do so, just pull the latest changes and push an empty commit.

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.

Links open in in-app browser
1 participant