diff options
author | Hermes Junior <ohermesjunior@gmail.com> | 2020-05-10 23:16:31 +0000 |
---|---|---|
committer | OHermesJunior <ohermesjunior@gmail.com> | 2020-05-10 23:16:31 +0000 |
commit | f27f7c12a8ae712d48623af87f1b8aff7fa61425 (patch) | |
tree | 5b88e91819477545bb033ec5acc8056626dcfa14 /app/src | |
parent | c705292bf8f8568621e2831f58e9200479706e31 (diff) | |
download | infinity-for-reddit-f27f7c12a8ae712d48623af87f1b8aff7fa61425.tar infinity-for-reddit-f27f7c12a8ae712d48623af87f1b8aff7fa61425.tar.gz infinity-for-reddit-f27f7c12a8ae712d48623af87f1b8aff7fa61425.tar.bz2 infinity-for-reddit-f27f7c12a8ae712d48623af87f1b8aff7fa61425.tar.lz infinity-for-reddit-f27f7c12a8ae712d48623af87f1b8aff7fa61425.tar.xz infinity-for-reddit-f27f7c12a8ae712d48623af87f1b8aff7fa61425.tar.zst infinity-for-reddit-f27f7c12a8ae712d48623af87f1b8aff7fa61425.zip |
Handle Reddit app links.
Diffstat (limited to '')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java | 9 |
1 files changed, 8 insertions, 1 deletions
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<String> segments = uri.getPathSegments(); int commentsIndex = segments.lastIndexOf("comments"); if (commentsIndex >= 0 && commentsIndex < segments.size() - 1) { |