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

Add Mastodon Redirect support #4194

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

zacharee
Copy link

@zacharee zacharee commented Dec 26, 2023

Mastodon Redirect is my app that handles redirecting Mastodon links to supported apps, so the apps don't have to maintain their own list of supported instances.

This PR adds auto-detect support for Mastodon Redirect, so Tusky can be chosen for opening Mastodon links.

Addresses #3865

To test:

  1. Download Mastodon Redirect from https://github.com/zacharee/MastodonRedirect.
  2. Install Tusky from this PR's code.
  3. Open and log into Tusky.
  4. Find a random post and copy its link. Paste the link somewhere it'll be clickable, such as in Telegram's "Saved messages" channel.
  5. Remove Tusky from Recents.
  6. Open Mastodon Redirect and select Tusky in the "Discovered" section.
  7. Tap the pasted link. It should launch Tusky and then resolve to the post.
  8. Back out to the main feed in Tusky and go back to the link, without removing Tusky from Recents this time. The link should open Tusky and resolve to the post.

@@ -55,6 +55,7 @@
<activity
android:name=".MainActivity"
android:configChanges="orientation|screenSize|keyboardHidden|screenLayout|smallestScreenSize"
android:launchMode="singleTask"
Copy link
Author

Choose a reason for hiding this comment

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

I needed to add this so Tusky could receive links while it's still running in the background. I don't think it breaks anything, but let me know.

Comment on lines +284 to +316

// Makes sure the Intent opens in the browser instead of something like Mastodon Redirect.
intent.selector = Intent(Intent.ACTION_VIEW, Uri.parse("https://"))
Copy link
Author

Choose a reason for hiding this comment

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

A blank-URL selector guarantees the link won't accidentally open in an app that supports the domain (e.g., Mastodon Redirect, which could cause a launch loop).

@connyduck
Copy link
Collaborator

I fail to test that.
My steps:

  • use an Android Api 34 emulator
  • Install Tusky from this branch
  • Install Mastodon redirect 1.11.0
  • make Android open links from a few domains with Mastodon redirect
  • enable Tusky in Mastodon redirect
  • click a link from one of the enabled domains in Chrome
  • Chrome closes
Failed to deliver inset control state change to w=Window{bb5153c u0 com.android.chrome/com.google.android.apps.chrome.Main EXITING}
android.os.DeadObjectException

similar result on a real device and with Firefox

@zacharee
Copy link
Author

zacharee commented Jan 1, 2024

Try using the "Open Link" share target instead.

Mastodon Redirect has so many domains that it can break whatever API Chrome is using to read where to open links. I've been waiting on an update to instances.social's API for better active-status filtering.

@connyduck
Copy link
Collaborator

Same result with "open link" :(
Seems like Android is unable to cope with an app having so many supported domains

@zacharee
Copy link
Author

zacharee commented Jan 2, 2024

Try revoking any links you enabled for auto-handling. You might also need to try opening a link from something like Keep or Telegram. I want to reduce the number of handled domains in Mastodon Redirect, but I haven't been able to find a better source yet.

@zacharee
Copy link
Author

zacharee commented Jan 5, 2024

I've reduced the number of supported domains by about 1000 in Mastodon Redirect. It's still over 11k total, but it should be less prone to crashing.

@zacharee
Copy link
Author

I also added a new share target for opening links, which uses the same path Mastodon Redirect does.

@tiptoptom
Copy link

Any news here? 🙈

@Lazalatin
Copy link

@zacharee This PR needs to be rebased or have a merge commit from tuskyapp:develop. If you can not afford time for solving this, I can gladly take over. (no tusky maintainer, just want to help getting this done :) )

@tiptoptom
Copy link

@Lazalatin can you bring that forward?

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.

4 participants