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

Toots and Account Mentions Open in a Browser Instead of App #110

Closed
juliloving opened this issue May 2, 2022 · 19 comments
Closed

Toots and Account Mentions Open in a Browser Instead of App #110

juliloving opened this issue May 2, 2022 · 19 comments
Labels
bug Something isn't working invalid This doesn't seem right

Comments

@juliloving
Copy link

It happens on other instances. I'm unable to log in with that website anyways, so I cannot interact in the in-app browser

@grishka
Copy link
Member

grishka commented May 13, 2022

Toots from links pointing to other servers should open in the browser because we can't possibly know whether the linked server is, indeed, a Mastodon/Fediverse server. Not all Fediverse software has the same URL structure as Mastodon, and not all URLs with matching structure are Fediverse servers.

I don't understand the mentions part.

@grishka grishka added bug Something isn't working invalid This doesn't seem right labels May 13, 2022
@realpixelcode
Copy link

Toots from links pointing to other servers should open in the browser because we can't possibly know whether the linked server is, indeed, a Mastodon/Fediverse server.

Yet, Tusky is perfectly able to open fediverse links in-app – even from remote servers and services other than Mastodon. I have no clue how it's done but it works. 🤷

signal-2022-05-31-06-12-01-075.mp4

@BluePixel4k
Copy link

BluePixel4k commented Jul 16, 2022

I would love to see that feature too!

As @realpixelcode said, in the Tusky app it works great.

For me, a short info always appears at the bottom when I click on a link:

Unfortunately, I don't know how they do it exactly, but I think that in the background they load the page briefly to check if there is a Mastodon server behind it.
If yes, the app open it, if no, the URL is forwarded to the browser.

@BluePixel4k
Copy link

Any update on this issue?
It would be very useful, specially for new users.

I found the original PR at Tusky for this feature: tuskyapp/Tusky#568
Maybe you can implement it similarly? 🙏🏼 That would be amazing. 🔥

@ConorIA
Copy link

ConorIA commented Nov 19, 2022

How does https://github.com/pruvisto/debirdify determine that links are Mastodon profiles? I seems they match against a list of known instances (heck, even my self-hosted single-user instance is discovered). Is there some way to have the app check links against known instances, and open in the app if the url seems to be a mastodon link?

Edit: I see that what I describe seems to be exactly what tusky is doing? I should have read the whole thread before offering my 2 cents.

@Andre601
Copy link

Andre601 commented Dec 1, 2022

Something I wonder (Forgive me if that's stupid thinking, but I'm just not an android dev), can an app read from a site a browser is visiting?
Like when I open a mastodon instance in my mobile browser, can the app read some of the site info from that?

If that would be possible (I doubt it since it offers severe security risks... But it's google after all...) could the Mastodon app perhaps check for certain <meta> tags the instance offers? like <meta name="mastodon:instance" value="mastodon.social"> to get the domain used for this instance.

This could help open the instance in your app rather than in your browser... But again is this probably not a thing, so it's just wishful thinking...

@grishka
Copy link
Member

grishka commented Dec 1, 2022

can an app read from a site a browser is visiting?

The answer depends on your definition of browser.

If it's a web view embedded in the app, then yes, the app has complete access to its content at all times.

If it's in a different app, like Chrome or Firefox, or a web view somewhere else, or a "custom tab", then no. It would've been a security nightmare if that was allowed.

@Andre601
Copy link

Andre601 commented Dec 2, 2022

The answer depends on your definition of browser.

If it's a web view embedded in the app, then yes, the app has complete access to its content at all times.

If it's in a different app, like Chrome or Firefox, or a web view somewhere else, or a "custom tab", then no. It would've been a security nightmare if that was allowed.

That's what I thought. So at least for the web view - given that the app uses that and not a custom tab - could the meta aproach be an idea?

Like the instance could provided the following values depending on if it is a user, post, etc.

  • <meta name="mastodon:instance" value="example.com">
  • <meta name="mastodon:user" value="example">
  • <meta name="mastodon:post" value="1234567890">

That way could the app open those pages in itself as long as you're not opening them on a separate browser that is (And given that it actually doesn't use custom tabs or whatever).

It's just an idea I had, and I obviously don't have android app dev knowledge, so there could be stuff I'm missing.

@BluePixel4k
Copy link

In the meanwhile, the fork Megalodon implemented this feature and it's working really well.

The implementation is easy. These are the commits in the brache "open-urls-in-app":
https://github.com/sk22/megalodon/commits/feature/open-urls-in-app

@grishka @Gargron can you please take a look and implement it in the official Mastodon app? That would be really helpful for all the users. 🚀

Maybe @sk22 can support you. 😊

Thx.

@your-highness
Copy link

Any update here? Fedilab and Tusky support this feature

@sallyFoster
Copy link

This is happening in iOS too

@realpixelcode
Copy link

This is happening in iOS too

You can report that in https://github.com/mastodon/mastodon-ios

@BluePixel4k
Copy link

It looks like this feature was finally added in version 2.2.1 last year 🎉

@grishka grishka closed this as completed Feb 13, 2024
@cookieguru
Copy link

@BluePixel4k curious why you think this is resolved? Either it never was or it regressed.

Inspecting the 2.2.4 APK, confirming that my APK is indeed 2.2.4

$ aapt dump badging Mastodon\ v2.2.4.apk | grep -i versionName
package: name='org.joinmastodon.android' versionCode='80' versionName='2.2.4' compileSdkVersion='33' compileSdkVersionCodename='13'

we can confirm that the AndroidManifest.xml only contains two hostnames for which the app is able to open URLs for (truncated output shown for berevity):

$ aapt dump xmltree Mastodon\ v2.2.4.apk AndroidManifest.xml
N: android=http://schemas.android.com/apk/res/android
  E: manifest (line=2)
    E: application (line=35)
      E: activity (line=45)
        E: intent-filter (line=56)
          A: android:autoVerify(0x010104ee)=(type 0x12)0xffffffff
          E: action (line=57)
            A: android:name(0x01010003)="android.intent.action.VIEW" (Raw: "android.intent.action.VIEW")
          E: category (line=59)
            A: android:name(0x01010003)="android.intent.category.BROWSABLE" (Raw: "android.intent.category.BROWSABLE")
          E: category (line=60)
            A: android:name(0x01010003)="android.intent.category.DEFAULT" (Raw: "android.intent.category.DEFAULT")
          E: data (line=62)
            A: android:scheme(0x01010027)="https" (Raw: "https")
            A: android:host(0x01010028)="mastodon.social" (Raw: "mastodon.social") 👈
            A: android:pathPrefix(0x0101002b)="/@" (Raw: "/@")
        E: intent-filter (line=67)
          A: android:autoVerify(0x010104ee)=(type 0x12)0xffffffff
          E: action (line=68)
            A: android:name(0x01010003)="android.intent.action.VIEW" (Raw: "android.intent.action.VIEW")
          E: category (line=70)
            A: android:name(0x01010003)="android.intent.category.BROWSABLE" (Raw: "android.intent.category.BROWSABLE")
          E: category (line=71)
            A: android:name(0x01010003)="android.intent.category.DEFAULT" (Raw: "android.intent.category.DEFAULT")
          E: data (line=73)
            A: android:scheme(0x01010027)="https" (Raw: "https")
            A: android:host(0x01010028)="mastodon.online" (Raw: "mastodon.online") 👈
            A: android:pathPrefix(0x0101002b)="/@" (Raw: "/@")

This information can also be seen from the app's settings: Open system settings, Apps, Mastodon, scroll to "Open by default" section. There are only 2 verified links: mastodon.online and mastodon.social.

We can also verify by opening this issue in a browser.

This link will open in the app:
https://mastodon.social/@Mastodon/111873035357008811
This link will open in the browser:
https://floss.social/@BluePixel4k/109729426343480230

Please re-open this issue since it was not added, or is not working

@cookieguru
Copy link

CC @grishka

@grishka
Copy link
Member

grishka commented Feb 13, 2024

I closed this because when you click a link in app, the app first tries to resolve it as an ActivityPub object. If that succeeds, the resulting profile/post opens in app.

It is not technically possible to do this system-wide. Intent filters work such that supported domains must be hardcoded. It would not be feasible to hardcode all existing Mastodon/ActivityPub servers (there's around 25000 right now).

CC @grishka

I already receive notifications, please don't do this.

@cookieguru
Copy link

I closed this because when you click a link in app, the app first tries to resolve it as an ActivityPub object. If that succeeds, the resulting profile/post opens in app.

That's completely unrelated to what the issue is about. Have you read the issue's description?

It is not technically possible to do this system-wide.

Seems to be: #110 (comment)

I already receive notifications, please don't do this.

Until GitHub provides a way to show who receives notifications I have no way of knowing this. Please do not chastise me for not knowing something that is impossible to know.

@grishka
Copy link
Member

grishka commented Feb 13, 2024

That's completely unrelated to what the issue is about. Have you read the issue's description?

Uh sorry? This is exactly what this issue is about.

Screen_recording_20240214_020651.mp4

@prirai
Copy link

prirai commented May 9, 2024

Hey! For all who has had issues with opening links of other instances in the Mastodon app or any other thrid party app for that matter. Griska's comments are actually correct, you cannot do link opening in newer Android versions since 12.

However there is a solution for Android which is slightly involving but gets the work done.

Download the MastodonRedirect app from here and install it.

If you are rooted, simply choose setup links using shizuku and select your favorite mastodon app.

If you are not rooted, download linksheet from here and enable all the links for the app MastodonRedirect (it's single click unlike the Android settings where you manually click on every link). Then select your favorite mastodon app.

Boom! Problem solved. Thank @zacharee for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

10 participants