From a651935fa57d26a9a035d82a3936b198625740bd Mon Sep 17 00:00:00 2001 From: andrewrasch Date: Tue, 21 Sep 2021 20:37:41 -0400 Subject: [PATCH 1/2] 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 ++++++++ .../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 From 97d630392cd8161c1428d1451f1690ee2a667830 Mon Sep 17 00:00:00 2001 From: andrewrasch Date: Tue, 21 Sep 2021 23:29:49 -0400 Subject: [PATCH 2/2] Change the go to top icon Changed to use a double up arrow icon --- .../infinityforreddit/activities/MainActivity.java | 2 +- .../activities/ViewSubredditDetailActivity.java | 2 +- .../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 @@ + + + +