A simple suite of apps for automatically launching fediverse links in your preferred Mastodon or Lemmy client.
Mastodon and Lemmy are both examples of federated social media. This is mostly a good thing, for a whole host of reasons, but it does have one notable disadvantage: deep linking support.
When you tap a Twitter link in your browser and your phone opens the Twitter app instead of the Twitter website to view the post, that's an example of deep linking. The trouble with federated social media is three-fold:
- There are a lot of different instances at different addresses running the same or interoperable software.
- Android only lets app developers declare supported deep link domains at compile time: users can't add custom domains, and domains can only be added through app updates. Many developers understandably don't want to maintain a list of thousands of domains.
- Android really isn't set up for a single app to support more than a few different domains for deep links.
Fediverse Redirect aims to solve the first two issues and somewhat solve the third.
By using Fediverse Observer as a data source, Fediverse Redirect can maintain an up-to-date list of active domains.
Once you download the app, you can choose your client app and then enable all supported domains, so that when you tap a recognized link, it gets passed to the proper Fediverse Redirect variant.
The Fediverse Redirect variant then sends the link directly to the chosen client app for it to handle.
Since the point of Fediverse Redirect is only to change where supported links open, the maintenance of supported domains isn't extra busywork that has to be done in addition to other features and fixes; it's literally all the app does.
Client developers do need to do some work for Fediverse Redirect to support them, but it's a one-time thing, and instructions are available below.
Fediverse Redirect has different variants depending on which social media network you want to use. Download the appropriate APK for your desired social network below.
Currently, most domains on Fediverse Observer are supported.
Fediverse Redirect supports most active and alive instances, but excludes dead instances and instances that haven't had any activity recently. This is to keep the list as short as possible and avoid crashes.
Fediverse Redirect also supports the web+activity+http
, web+activity+https
, and web+ap
URL schemes. The expectation is that the full post or profile URL will follow.
Examples:
// Post
web+ap://androiddev.social/@wander1236/110699242324667418
// Profile
web+ap://androiddev.social/@wander1236
If any domains aren't enabled for handling by the Fediverse Redirect variant, the app will let you know and provide you buttons for enabling them.
Enabling each supported domain one at a time is possible, but tedious. Instead, Fediverse Redirect can use Shizuku to automatically enable all links at once. The setup for Shizuku is a little complex, but can be done completely on-device on Android 11 and later. It is also only needed once for the initial setup or for enabling domains added in app updates.
Alternatively, you can use LinkSheet to have supported domains open in Fediverse Redirect. LinkSheet needs to be set as your default browser and then acts as a much more comprehensive and usable version of Android's built-in link handling options.
Open the chosen Fediverse Redirect variant and select your preferred client.
Unfortunately, many Fediverse clients don't have a way for Fediverse Redirect to interface with them.
Fediverse Redirect relies on clients having a link sharing target that can parse and open fediverse links.
Clients such as Tusky do have share targets, but they can only be used to create new posts, with the shared link as the content. Other clients have no share targets at all.
Mastodon Redirect currently supports the following clients:
- Elk (PWA: Stable or Canary).
- Fedilab (F-Droid or Play Store).
- Mastodon.
- Megalodon.
- Moshidon (Stable or Nightly).
- Phanpy (PWA: Stable or Dev).
- Subway Tooter.
- Tooot.
- Trunks (Native or Web).
Lemmy Redirect currently supports the following clients:
And the following auto-discovery clients:
PeerTube Redirect currently supports the following clients:
Fedilab (F-Droid or Play Store)(Currently disabled as link handling is broken).Grayjay (Stable, Unstable, or Play Store)(Currently disabled as the PeerTube plugin only respects Grayjay's instance domain and also uses the wrong URL format to check for compatibility).- NewPipe (Release or Debug-Main).
- Tubular (Release or Debug-Main).
If your favorite client isn't on the list, consider creating an issue on their code repository or issue tracker linking to the section below, but please search through the existing issues first, including ones that have been closed. Pestering developers won't help anyone.
If you're the developer of a Fediverse client and want to add support for Fediverse Redirect into your app, here's how.
You can let Fediverse Redirect automatically discover your app by filtering for a custom Intent and parsing the data as a URL.
In your AndroidManifest.xml
, add the following intent filter inside the relevant Activity tag:
Mastodon Redirect:
<intent-filter>
<action android:name="dev.zwander.mastodonredirect.intent.action.OPEN_FEDI_LINK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Lemmy Redirect:
<intent-filter>
<action android:name="dev.zwander.lemmyredirect.intent.action.OPEN_FEDI_LINK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
PeerTube Redirect:
<intent-filter>
<action android:name="dev.zwander.peertuberedirect.intent.action.OPEN_FEDI_LINK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Inside the Activity itself:
override fun onCreate(savedInstanceState: Bundle?) {
// ...
val url = intent?.data?.toString()
// Validate `url`.
// Pass it to your internal link parser to find the post ID and such.
// Open in your thread/profile viewer component.
}
The high level process is pretty simple: expose some way for your app to be launched that accepts a URL and tries to parse it as a fediverse link to open as a post or profile. There are a few ways you can do this.
Once you've implemented support, feel free to open an issue or PR to have it added to Fediverse Redirect.
Note: this will cause your app to appear in the share menu when a user chooses to share any text, not just links. If your app already has a share target for pasting the shared text into a new post draft, it might make sense to reuse that target with an option to open the shared link instead of only creating a new post.
Check out Moshidon for an example.
In your AndroidManifest.xml
, add the following intent filter inside the relevant Activity tag:
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/*"/>
</intent-filter>
Inside the Activity itself:
override fun onCreate(savedInstanceState: Bundle?) {
// ...
if (intent?.action == Intent.ACTION_SHARE) {
val sharedText = intent.getStringExtra(Intent.EXTRA_TEXT)
// Validate that `sharedText` is a URL.
// Pass it to your internal link parser to find the post ID and such.
// Open in your thread/profile viewer component.
}
}
This is similar to the share target, but won't show up to users directly in the share menu.
In your AndroidManifest.xml
, add the following intent filter inside the relevant Activity tag:
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="https" />
<data android:scheme="http" />
<data android:host="*" />
</intent-filter>
Inside the Activity itself:
override fun onCreate(savedInstanceState: Bundle?) {
// ...
val url = intent?.data?.toString()
// Validate `url`.
// Pass it to your internal link parser to find the post ID and such.
// Open in your thread/profile viewer component.
}
In order to build Fediverse Redirect, you'll need two things:
- The latest Android Studio Canary build.
A modified Android SDK with hidden APIs exposed.
Download the modified SDK corresponding to Fediverse Redirect's current compile.sdk
value (found in gradle.properties) and follow the instructions provided in the link above to install it.
If you want to add support for another app:
- Find the
LaunchStrategy.kt
file for the relevant variant. For example, if you want to add support for an app to Lemmy Redirect, openlemmyredirect/src/main/java/dev/zwander/lemmyredirect/util/LaunchStrategy.kt
. - Go to the
strings.xml
file for the variant and add the name of the app there. - Create a new data object extending the relevant
LaunchStrategyRootGroup
class (for Lemmy, it would beLemmyLaunchStrategyRootGroup
). The argument the base class takes is a reference to the string resource you added. - Nested in that object, create another object extending the relevant
LaunchStrategy
class. This takes a key (unique to the app) and a variant label reference. - Override the
createIntents()
function and return a list of Intents to attempt to launch. Usually, only one Intent is needed. - Make sure to annotate both objects with
@Keep
.
Fediverse Redirect will automatically pick up the new class and show it as an option.
Check out the other objects in the file for examples.
Fediverse Redirect uses Bugsnag for error reporting.