From f27f7c12a8ae712d48623af87f1b8aff7fa61425 Mon Sep 17 00:00:00 2001 From: Hermes Junior Date: Mon, 11 May 2020 01:16:31 +0200 Subject: Handle Reddit app links. --- .../infinityforreddit/Activity/LinkResolverActivity.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java index f932427f..ff39b7f3 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java @@ -56,6 +56,10 @@ public class LinkResolverActivity extends AppCompatActivity { ((Infinity) getApplication()).getAppComponent().inject(this); Uri uri = getIntent().getData(); + handleUri(uri); + } + + private void handleUri(Uri uri) { if (uri == null) { Toast.makeText(this, R.string.no_link_available, Toast.LENGTH_SHORT).show(); finish(); @@ -73,7 +77,10 @@ public class LinkResolverActivity extends AppCompatActivity { String authority = uri.getAuthority(); if (authority != null && (authority.contains("reddit.com") || authority.contains("redd.it") || authority.contains("reddit.app"))) { - if (path.matches(POST_PATTERN)) { + if (authority.equals("reddit.app.link") && path.isEmpty()) { + String redirect = uri.getQueryParameter("$og_redirect"); + handleUri(Uri.parse(redirect)); + } else if (path.matches(POST_PATTERN)) { List segments = uri.getPathSegments(); int commentsIndex = segments.lastIndexOf("comments"); if (commentsIndex >= 0 && commentsIndex < segments.size() - 1) { -- cgit v1.2.3