From 4ac1cec9e8a355127a2780c6edb1dd28da37d3a3 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Thu, 1 Apr 2021 12:26:28 +0800 Subject: Handle more post links. --- .../infinityforreddit/activities/LinkResolverActivity.java | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'app/src') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java index a4de701f..10de74cc 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java @@ -33,6 +33,7 @@ public class LinkResolverActivity extends AppCompatActivity { private static final String POST_PATTERN = "/r/[\\w-]+/comments/\\w+/?\\w+/?"; private static final String POST_PATTERN_2 = "/(u|U|user)/[\\w-]+/comments/\\w+/?\\w+/?"; + private static final String POST_PATTERN_3 = "/[\\w-]+$"; private static final String COMMENT_PATTERN = "/(r|u|U|user)/[\\w-]+/comments/\\w+/?[\\w-]+/\\w+/?"; private static final String SUBREDDIT_PATTERN = "/[rR]/[\\w-]+/?"; private static final String USER_PATTERN = "/(u|U|user)/[\\w-]+/?"; @@ -137,6 +138,12 @@ public class LinkResolverActivity extends AppCompatActivity { } else { deepLinkError(uri); } + } else if (path.matches(POST_PATTERN_3)) { + Intent intent = new Intent(this, ViewPostDetailActivity.class); + intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, path.substring(1)); + intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname); + intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName); + startActivity(intent); } else if (path.matches(COMMENT_PATTERN)) { int commentsIndex = segments.lastIndexOf("comments"); if (commentsIndex >= 0 && commentsIndex < segments.size() - 1) { -- cgit v1.2.3