Slion / Fulguris

⚡Web Browser
http://fulguris.slions.net
Other
455 stars 48 forks source link

Twitter t.co links don't load directly in new tab #628

Open gkrishnaks opened 2 months ago

gkrishnaks commented 2 months ago

Description

Links posted in tweets become t.co short links. On tap of link and if fulguris is chosen, it fills the t.co link in current tab and expects user to hit enter key which it then loads in new tab.

This behaviour is not seen for other links for example from bluesky app where links are not shortened. For this case the new link intent is directly launched in new tab.

Environment

To reproduce

  1. Install from f-droid. Default settings.
  2. Install Twitter PWA or app and click on a link in a tweet and choose fulguris
  3. Observe t.co link fills current tab address bar and waits for user to click enter key
  4. On tap of enter key in soft keyboard, it loads in a new tab

Expected behaviour

Browser should directly launch incoming links in a new tab and shouldn't wait for user input (enter key) For comparison, repeat same steps with bluesky app or any other app.

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here.

Slion commented 2 months ago

Please provide actual links to reproduce your issue without having to guess. Links to the apps your are using and links to be tested with them. Also device OS, Fulguris and WebView version, thanks.

gkrishnaks commented 2 months ago

Additional details : I am to replicate this behaviour with any link in any tweet, but not if I copy the t.co link in a chat app then click on it, which results in expected behavior what I mentioned in description.

If you open this tweet in twitter PWA or app, https://x.com/HeyPuter/status/1774247524653527041 And the link in this tweet is a t.co shortened link (https://t.co/Mb3h5WJc2n), if you click on it, then the issue is reproducible. I will share a screen recording.

Samsung M51, Android 13, webview version : 123.0.6312.40, Fulguris version 1.9.30 from f-droid.

gkrishnaks commented 2 months ago
  1. This is the tweet opened in Twitter PWA (installed PWA using Firefox Android) Shared tweet link in previous comment. To install Twitter PWA, open Firefox Android, go to twitter.com, login then choose to install the app when it pops up in browser. This will install the PWA to home screen. (open any tweet that has link in it)
  2. Long press on the link in a tweet, choose Share link, Screenshot_20240407_122214_Firefox Nightly
  3. Choose Share link and in the OS tray, select Fulguris Screenshot_20240407_122222_Firefox Nightly
  4. It filled up the address bar and waited till pressing enter key. ( Perhaps the issue is due to long press and share link to Fulguris?) Screenshot_20240407_122238_Fulguris
gkrishnaks commented 2 months ago

I looked into the code and found the root cause.

In TabsManager.kt, when you long press on a link in another app and share to Fulguris, it is ACTION_SEND Intent and type is text/plain. So it does setAddressBarText and waits for user to hit enter key.

Fix would be to check if 'clue' here is a network URL and load it in a new tab directly. Other webview based browser apps and regular browser apps behave as expected here for this "long press a link and share to browser" case.

fun onNewIntent(intent: Intent?) = doOnceAfterInitialization { val url = if (intent?.action == Intent.ACTION_WEB_SEARCH) { extractSearchFromIntent(intent) } else if (intent?.action == Intent.ACTION_SEND) { // User shared text with our app if ("text/plain" == intent.type) { // Get shared text val clue = intent.getStringExtra(Intent.EXTRA_TEXT) // Put it in the address bar if any clue?.let { iWebBrowser.setAddressBarText(it) } } // Cancel other operation as we won't open a tab here null } else { intent?.dataString }

Slion commented 2 months ago

I see, I'm pretty sure it was intended to work like that so that you can review the URL before loading it.

gkrishnaks commented 2 months ago

I reported this as other browser apps handle this long press share case, and in the same function 'onNewIntent' there's logic to automatically launch new tab and focus it (this will handle when user tap on link [instead of long press] in another app and choose Fulguris)

If this is an expected behaviour for Fulguris, this bug and the related PR can be closed.

Slion commented 2 months ago

Thanks, great work you did on that one. I'll need to take a closer look at that at some point. One solution could be to have a settings option to toggle between just show URL and open new tab directly.