From a651935fa57d26a9a035d82a3936b198625740bd Mon Sep 17 00:00:00 2001 From: andrewrasch Date: Tue, 21 Sep 2021 20:37:41 -0400 Subject: Added go to top of page option. Added Main + Other Activity bottom bar option to go to the top of a page. --- .../infinityforreddit/activities/MainActivity.java | 8 ++++++++ .../infinityforreddit/activities/ViewSubredditDetailActivity.java | 8 ++++++++ .../infinityforreddit/utils/SharedPreferencesUtils.java | 2 ++ app/src/main/res/values/arrays.xml | 2 ++ app/src/main/res/values/strings.xml | 1 + 5 files changed, 21 insertions(+) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java index 430d7bc0..f2b4b21c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java @@ -523,6 +523,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb startActivity(intent); break; } + case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_GO_TO_TOP: { + if (sectionsPagerAdapter != null) { + sectionsPagerAdapter.goBackToTop(); + } + break; + } default: PostTypeBottomSheetFragment postTypeBottomSheetFragment = new PostTypeBottomSheetFragment(); postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag()); @@ -569,6 +575,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb return R.drawable.ic_outline_bookmarks_24dp; case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_GILDED: return R.drawable.ic_star_border_24dp; + case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_GO_TO_TOP: + return R.drawable.ic_home_black_24dp; default: return R.drawable.ic_account_circle_24dp; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java index 4096a96b..7371f5d3 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java @@ -698,6 +698,12 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp startActivity(intent); break; } + case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_GO_TO_TOP: { + if (sectionsPagerAdapter != null) { + sectionsPagerAdapter.goBackToTop(); + } + break; + } default: PostTypeBottomSheetFragment postTypeBottomSheetFragment = new PostTypeBottomSheetFragment(); postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag()); @@ -745,6 +751,8 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp return R.drawable.ic_outline_bookmarks_24dp; case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_GILDED: return R.drawable.ic_star_border_24dp; + case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_GO_TO_TOP: + return R.drawable.ic_home_black_24dp; default: return R.drawable.ic_account_circle_24dp; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java index 27e6a0b4..1d5838e1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java @@ -249,6 +249,7 @@ public class SharedPreferencesUtils { public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_HIDDEN = 16; public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_SAVED = 17; public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_GILDED = 18; + public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_GO_TO_TOP = 19; public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_SUBMIT_POSTS = 0; public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_REFRESH = 1; @@ -281,6 +282,7 @@ public class SharedPreferencesUtils { public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_HIDDEN = 17; public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SAVED = 18; public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_GILDED = 19; + public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_GO_TO_TOP = 20; public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_SUBMIT_POSTS = 0; public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_REFRESH = 1; diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index f8097c33..50c7b6c6 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -283,6 +283,7 @@ @string/hidden @string/saved @string/gilded + @string/go_to_top @@ -306,6 +307,7 @@ @string/hidden @string/saved @string/gilded + @string/go_to_top diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 68ab820b..b94cac10 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1190,5 +1190,6 @@ 6 hours 12 hours 24 hours + Go To Top -- cgit v1.2.3 From 1fb3ba6e3fa57904bdde486d5f6bb793be788f71 Mon Sep 17 00:00:00 2001 From: andrewrasch Date: Tue, 21 Sep 2021 22:10:38 -0400 Subject: Update link handling for amp and v.redd.it Added manifest entries for google.com amp links (reddit only) and v.redd.it. Updated handling of google amp links in LinkResolverActivity. --- app/src/main/AndroidManifest.xml | 7 +++++++ .../infinityforreddit/activities/LinkResolverActivity.java | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 78090f43..f17f60e8 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -276,6 +276,13 @@ + + 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 a6596edb..a9049cfb 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java @@ -50,6 +50,7 @@ public class LinkResolverActivity extends AppCompatActivity { private static final String IMGUR_IMAGE_PATTERN = "/\\w+/?"; private static final String RPAN_BROADCAST_PATTERN = "/rpan/r/[\\w-]+/\\w+/?\\w+/?"; private static final String WIKI_PATTERN = "/[rR]/[\\w-]+/(wiki|w)/?\\w+"; + private static final String GOOGLE_AMP_PATTERN = "/amp/s/amp.reddit.com/.*"; @Inject @Named("default") @@ -266,6 +267,13 @@ public class LinkResolverActivity extends AppCompatActivity { } else { deepLinkError(uri); } + } else if (authority.contains("google.com") ){ + if ( path.matches(GOOGLE_AMP_PATTERN) ) { + String url = path.substring(11, path.length()); // skipping past amp straight to reddit + handleUri(Uri.parse("https://" + url)); + } else { + deepLinkError(uri); + } } else { deepLinkError(uri); } -- cgit v1.2.3 From 5cfe8a601645383d0068f9acded1e99aa5f28459 Mon Sep 17 00:00:00 2001 From: andrewrasch Date: Tue, 21 Sep 2021 23:01:17 -0400 Subject: Added API call for generic wiki page. Updated old wiki-only call to cascade to new generic. --- .../infinityforreddit/activities/WikiActivity.java | 1 + .../java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java index f4cc17fa..b6fc29af 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java @@ -71,6 +71,7 @@ import retrofit2.Retrofit; public class WikiActivity extends BaseActivity { public static final String EXTRA_SUBREDDIT_NAME = "ESN"; + public static final String WIKI_PATH = "WP"; private static final String WIKI_MARKDOWN_STATE = "WMS"; @BindView(R.id.coordinator_layout_comment_wiki_activity) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java b/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java index 91b96c70..a7c67893 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java @@ -294,8 +294,12 @@ public interface RedditAPI { @GET("/api/trending_searches_v1.json?withAds=0&raw_json=1&gilding_detail=1") Call getTrendingSearches(@HeaderMap Map headers); - @GET("/r/{subredditName}/wiki/index.json?raw_json=1") - Call getWiki(@Path("subredditName") String subredditName); + default Call getWiki(@Path("subredditName") String subredditName) { + return getWikiPage(subredditName, "index"); + }; + + @GET("/r/{subredditName}/wiki/{wikiPage}.json?raw_json=1") + Call getWikiPage(@Path("subredditName") String subredditName, @Path("wikiPage") String wikiPage); @GET("{sortType}?raw_json=1") ListenableFuture> getBestPostsListenableFuture(@Path("sortType") String sortType, @Query("after") String lastItem, @HeaderMap Map headers); -- cgit v1.2.3 From 97d630392cd8161c1428d1451f1690ee2a667830 Mon Sep 17 00:00:00 2001 From: andrewrasch Date: Tue, 21 Sep 2021 23:29:49 -0400 Subject: Change the go to top icon Changed to use a double up arrow icon --- .../infinityforreddit/activities/MainActivity.java | 2 +- .../activities/ViewSubredditDetailActivity.java | 2 +- .../main/res/drawable/ic_keyboard_double_arrow_up_24.xml | 13 +++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 app/src/main/res/drawable/ic_keyboard_double_arrow_up_24.xml diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java index f2b4b21c..40ae887f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java @@ -576,7 +576,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_GILDED: return R.drawable.ic_star_border_24dp; case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_GO_TO_TOP: - return R.drawable.ic_home_black_24dp; + return R.drawable.ic_keyboard_double_arrow_up_24; default: return R.drawable.ic_account_circle_24dp; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java index 7371f5d3..54267df9 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java @@ -752,7 +752,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_GILDED: return R.drawable.ic_star_border_24dp; case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_GO_TO_TOP: - return R.drawable.ic_home_black_24dp; + return R.drawable.ic_keyboard_double_arrow_up_24; default: return R.drawable.ic_account_circle_24dp; } diff --git a/app/src/main/res/drawable/ic_keyboard_double_arrow_up_24.xml b/app/src/main/res/drawable/ic_keyboard_double_arrow_up_24.xml new file mode 100644 index 00000000..fd6c2ac9 --- /dev/null +++ b/app/src/main/res/drawable/ic_keyboard_double_arrow_up_24.xml @@ -0,0 +1,13 @@ + + + + -- cgit v1.2.3 From 2d5829830e062d5cef8ca3ffa55e7dab607b84a7 Mon Sep 17 00:00:00 2001 From: andrewrasch Date: Tue, 21 Sep 2021 23:50:30 -0400 Subject: Fixed handling of wiki pages LinkResolverActivity now handles wiki pages other than index and their subpages. --- .../infinityforreddit/activities/LinkResolverActivity.java | 4 +++- .../ml/docilealligator/infinityforreddit/activities/WikiActivity.java | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) 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 a6596edb..a4668cc5 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java @@ -49,7 +49,7 @@ public class LinkResolverActivity extends AppCompatActivity { private static final String IMGUR_ALBUM_PATTERN = "/(album|a)/\\w+/?"; private static final String IMGUR_IMAGE_PATTERN = "/\\w+/?"; private static final String RPAN_BROADCAST_PATTERN = "/rpan/r/[\\w-]+/\\w+/?\\w+/?"; - private static final String WIKI_PATTERN = "/[rR]/[\\w-]+/(wiki|w)/?\\w+"; + private static final String WIKI_PATTERN = "/[rR]/[\\w-]+/(wiki|w)?(?:/\\w+)+"; @Inject @Named("default") @@ -173,8 +173,10 @@ public class LinkResolverActivity extends AppCompatActivity { deepLinkError(uri); } } else if (path.matches(WIKI_PATTERN)) { + final String wikiPage = path.substring(path.lastIndexOf("/wiki/") + 6); Intent intent = new Intent(this, WikiActivity.class); intent.putExtra(WikiActivity.EXTRA_SUBREDDIT_NAME, segments.get(1)); + intent.putExtra(WikiActivity.EXTRA_WIKI_PATH, wikiPage); startActivity(intent); } else if (path.matches(SUBREDDIT_PATTERN)) { Intent intent = new Intent(this, ViewSubredditDetailActivity.class); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java index b6fc29af..372d3c6f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java @@ -71,7 +71,7 @@ import retrofit2.Retrofit; public class WikiActivity extends BaseActivity { public static final String EXTRA_SUBREDDIT_NAME = "ESN"; - public static final String WIKI_PATH = "WP"; + public static final String EXTRA_WIKI_PATH = "EWP"; private static final String WIKI_MARKDOWN_STATE = "WMS"; @BindView(R.id.coordinator_layout_comment_wiki_activity) @@ -282,7 +282,7 @@ public class WikiActivity extends BaseActivity { Glide.with(this).clear(mFetchWikiInfoImageView); mFetchWikiInfoLinearLayout.setVisibility(View.GONE); - retrofit.create(RedditAPI.class).getWiki(getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME)).enqueue(new Callback() { + retrofit.create(RedditAPI.class).getWikiPage(getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME), getIntent().getStringExtra(EXTRA_WIKI_PATH)).enqueue(new Callback() { @Override public void onResponse(@NonNull Call call, @NonNull Response response) { if (response.isSuccessful()) { -- cgit v1.2.3 From 0ca6bc25af02b52ce7b89b1c895a3d00e307d821 Mon Sep 17 00:00:00 2001 From: andrewrasch Date: Wed, 22 Sep 2021 00:04:21 -0400 Subject: Added link to wiki in subreddit Subreddit details menu now has a link to its wiki. Subs without a wiki will show the "this subreddit has no wiki" page. --- .../infinityforreddit/activities/ViewSubredditDetailActivity.java | 6 ++++++ app/src/main/res/menu/view_subreddit_detail_activity.xml | 6 ++++++ app/src/main/res/values/strings.xml | 1 + 3 files changed, 13 insertions(+) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java index 4096a96b..11d19e16 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java @@ -1180,6 +1180,12 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp Toast.makeText(this, R.string.no_app, Toast.LENGTH_SHORT).show(); } return true; + } else if (itemId == R.id.action_go_to_wiki_activity ) { + Intent wikiIntent = new Intent(this, WikiActivity.class); + wikiIntent.putExtra(WikiActivity.EXTRA_SUBREDDIT_NAME, subredditName); + wikiIntent.putExtra(WikiActivity.EXTRA_WIKI_PATH, "index"); + startActivity(wikiIntent); + return true; } return false; } diff --git a/app/src/main/res/menu/view_subreddit_detail_activity.xml b/app/src/main/res/menu/view_subreddit_detail_activity.xml index c1631814..cb92de44 100644 --- a/app/src/main/res/menu/view_subreddit_detail_activity.xml +++ b/app/src/main/res/menu/view_subreddit_detail_activity.xml @@ -58,4 +58,10 @@ android:orderInCategory="9" android:title="@string/action_share" app:showAsAction="never" /> + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 68ab820b..08ce7077 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1190,5 +1190,6 @@ 6 hours 12 hours 24 hours + Go to Wiki -- cgit v1.2.3 From cac32b4394c6b924ff44e06da3e190520cb8cd48 Mon Sep 17 00:00:00 2001 From: andrewrasch Date: Wed, 22 Sep 2021 01:00:53 -0400 Subject: Added path patterns to other links Fixes bug where only google amp links open in Infinity --- app/src/main/AndroidManifest.xml | 71 ++++++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 24 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f17f60e8..e709293f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -272,77 +272,100 @@ + android:scheme="https" + android:pathPattern=".*"/> + android:scheme="https" + android:pathPattern=".*" /> + android:pathPattern="/amp/s/amp.reddit.com/.*" /> + android:scheme="https" + android:pathPattern=".*" /> + android:scheme="https" + android:pathPattern=".*" /> + android:scheme="https" + android:pathPattern=".*" /> + android:scheme="https" + android:pathPattern=".*" /> + android:scheme="https" + android:pathPattern=".*" /> + android:scheme="https" + android:pathPattern=".*" /> + android:scheme="https" + android:pathPattern=".*" /> + android:scheme="https" + android:pathPattern=".*" /> + android:scheme="https" + android:pathPattern=".*" /> + android:scheme="https" + android:pathPattern=".*" /> + android:scheme="http" + android:pathPattern=".*" /> + android:scheme="http" + android:pathPattern=".*" /> + android:scheme="http" + android:pathPattern=".*" /> + android:scheme="http" + android:pathPattern=".*" /> + android:scheme="http" + android:pathPattern=".*" /> + android:scheme="http" + android:pathPattern=".*" /> + android:scheme="http" + android:pathPattern=".*" /> + android:scheme="http" + android:pathPattern=".*" /> + android:scheme="http" + android:pathPattern=".*" /> + android:scheme="http" + android:pathPattern=".*" /> + android:scheme="http" + android:pathPattern=".*" />