-
Notifications
You must be signed in to change notification settings - Fork 176
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
base: develop
Are you sure you want to change the base?
Open chat links in regular browser tabs #4198
Conversation
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
Thank you for your contribution! Here are a few things to check in the PR to ensure it's reviewed as quickly as possible:
|
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.
Thanks for the proposal. I think it makes sense to open links using the default browser since we do not have specific action like sharing like the X app may have.
Can you handle my remark about the lambda parameter? I believe it will do the same thing but with less change on the codebase.
@@ -112,6 +112,7 @@ fun MessagesView( | |||
onEventContentClick: (event: TimelineItem.Event) -> Boolean, | |||
onUserDataClick: (UserId) -> Unit, | |||
onLinkClick: (String) -> Unit, | |||
onHelpLinkClick: (String) -> Unit, |
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.
It was maybe simpler to add a Boolean parameter to the lambda onLinkClick: (String) -> Unit,
to allow the usage of CustomTab if true.
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.
We definitely save a few lines of code this way. It might be more expressive to use an enum here—it's kind of hard to tell what the Boolean does when you're deep in the call tree—but that would definitely add complexity.
Ready for re-review.
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 "custom tab" links with a new parameter `onLinkClick(..., customTab)`. If true, the link opens in a custom tab. Links within `TimelineView` are always opened in a normal tab. [1]: appconfig/src/main/kotlin/io/element/android/appconfig/LearnMoreConfig.kt
ed7d5a5
to
ebdd945
Compare
@bmarty, I think I've worked through all the comments and checklists. I don't have permission to run CI. Is there anything more I need to do for this PR? |
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.
Thanks for the update, it looks good to me. I have triggered the CI.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4198 +/- ##
===========================================
- Coverage 83.35% 83.34% -0.02%
===========================================
Files 1886 1886
Lines 49403 49403
Branches 5804 5804
===========================================
- Hits 41180 41175 -5
- Misses 6134 6135 +1
- Partials 2089 2093 +4 ☔ View full report in Codecov by Sentry. |
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 "custom tab" links with a new parameter
onLinkClick(..., customTab)
. If true, the link opens in a custom tab.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
Tests
Build F-Droid version with
Install on device.
Sign in to Element.
Open a chat room. Find a message which includes an
https://
web link.Tap on the link.
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
Checklist