Added go to top of page option.

Added Main + Other Activity bottom bar option to go to the top of a page.
This commit is contained in:
andrewrasch 2021-09-21 20:37:41 -04:00
parent d6c3bfddd7
commit a651935fa5
5 changed files with 21 additions and 0 deletions

View File

@ -523,6 +523,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
startActivity(intent); startActivity(intent);
break; break;
} }
case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_GO_TO_TOP: {
if (sectionsPagerAdapter != null) {
sectionsPagerAdapter.goBackToTop();
}
break;
}
default: default:
PostTypeBottomSheetFragment postTypeBottomSheetFragment = new PostTypeBottomSheetFragment(); PostTypeBottomSheetFragment postTypeBottomSheetFragment = new PostTypeBottomSheetFragment();
postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag()); postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag());
@ -569,6 +575,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
return R.drawable.ic_outline_bookmarks_24dp; return R.drawable.ic_outline_bookmarks_24dp;
case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_GILDED: case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_GILDED:
return R.drawable.ic_star_border_24dp; 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: default:
return R.drawable.ic_account_circle_24dp; return R.drawable.ic_account_circle_24dp;
} }

View File

@ -698,6 +698,12 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
startActivity(intent); startActivity(intent);
break; break;
} }
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_GO_TO_TOP: {
if (sectionsPagerAdapter != null) {
sectionsPagerAdapter.goBackToTop();
}
break;
}
default: default:
PostTypeBottomSheetFragment postTypeBottomSheetFragment = new PostTypeBottomSheetFragment(); PostTypeBottomSheetFragment postTypeBottomSheetFragment = new PostTypeBottomSheetFragment();
postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag()); postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag());
@ -745,6 +751,8 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
return R.drawable.ic_outline_bookmarks_24dp; return R.drawable.ic_outline_bookmarks_24dp;
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_GILDED: case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_GILDED:
return R.drawable.ic_star_border_24dp; 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: default:
return R.drawable.ic_account_circle_24dp; return R.drawable.ic_account_circle_24dp;
} }

View File

@ -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_HIDDEN = 16;
public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_SAVED = 17; 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_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_SUBMIT_POSTS = 0;
public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_REFRESH = 1; 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_HIDDEN = 17;
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SAVED = 18; 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_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_SUBMIT_POSTS = 0;
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_REFRESH = 1; public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_REFRESH = 1;

View File

@ -283,6 +283,7 @@
<item>@string/hidden</item> <item>@string/hidden</item>
<item>@string/saved</item> <item>@string/saved</item>
<item>@string/gilded</item> <item>@string/gilded</item>
<item>@string/go_to_top</item>
</string-array> </string-array>
<string-array name="settings_other_activities_bottom_app_bar_options"> <string-array name="settings_other_activities_bottom_app_bar_options">
@ -306,6 +307,7 @@
<item>@string/hidden</item> <item>@string/hidden</item>
<item>@string/saved</item> <item>@string/saved</item>
<item>@string/gilded</item> <item>@string/gilded</item>
<item>@string/go_to_top</item>
</string-array> </string-array>
<string-array name="settings_bottom_app_bar_fab_options"> <string-array name="settings_bottom_app_bar_fab_options">

View File

@ -1190,5 +1190,6 @@
<string name="app_lock_timeout_6_hours">6 hours</string> <string name="app_lock_timeout_6_hours">6 hours</string>
<string name="app_lock_timeout_12_hours">12 hours</string> <string name="app_lock_timeout_12_hours">12 hours</string>
<string name="app_lock_timeout_24_hours">24 hours</string> <string name="app_lock_timeout_24_hours">24 hours</string>
<string name="go_to_top">Go To Top</string>
</resources> </resources>