diff options
author | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2022-11-03 14:31:44 +0000 |
---|---|---|
committer | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2022-11-03 14:31:44 +0000 |
commit | eb40bad3efcef20e24ba3109923ae1a4703ea430 (patch) | |
tree | c6f25384ceb848407f3453e0bf992352882744ed /app/src/main/java/ml | |
parent | 4abadb78c4f56b2b8d61bd7130073ca2bb712545 (diff) | |
download | infinity-for-reddit-eb40bad3efcef20e24ba3109923ae1a4703ea430.tar infinity-for-reddit-eb40bad3efcef20e24ba3109923ae1a4703ea430.tar.gz infinity-for-reddit-eb40bad3efcef20e24ba3109923ae1a4703ea430.tar.bz2 infinity-for-reddit-eb40bad3efcef20e24ba3109923ae1a4703ea430.tar.lz infinity-for-reddit-eb40bad3efcef20e24ba3109923ae1a4703ea430.tar.xz infinity-for-reddit-eb40bad3efcef20e24ba3109923ae1a4703ea430.tar.zst infinity-for-reddit-eb40bad3efcef20e24ba3109923ae1a4703ea430.zip |
New option: Settings->Interface->Hide FAB in Post Feed.
Diffstat (limited to 'app/src/main/java/ml')
7 files changed, 58 insertions, 14 deletions
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 194ddd0f..c9cbcd45 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java @@ -94,12 +94,13 @@ import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed; import ml.docilealligator.infinityforreddit.customviews.NavigationWrapper; import ml.docilealligator.infinityforreddit.events.ChangeDisableSwipingBetweenTabsEvent; +import ml.docilealligator.infinityforreddit.events.ChangeHideFabInPostFeedEvent; +import ml.docilealligator.infinityforreddit.events.ChangeHideKarmaEvent; import ml.docilealligator.infinityforreddit.events.ChangeInboxCountEvent; import ml.docilealligator.infinityforreddit.events.ChangeLockBottomAppBarEvent; import ml.docilealligator.infinityforreddit.events.ChangeNSFWEvent; import ml.docilealligator.infinityforreddit.events.ChangeRequireAuthToAccountSectionEvent; import ml.docilealligator.infinityforreddit.events.ChangeShowAvatarOnTheRightInTheNavigationDrawerEvent; -import ml.docilealligator.infinityforreddit.events.ChangeHideKarmaEvent; import ml.docilealligator.infinityforreddit.events.RecreateActivityEvent; import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.fragments.PostFragment; @@ -214,6 +215,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb private boolean mDrawerOnAccountSwitch = false; private String mMessageFullname; private String mNewAccountName; + private boolean hideFab; private boolean showBottomAppBar; private int mBackButtonAction; private boolean mLockBottomAppBar; @@ -239,6 +241,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb ButterKnife.bind(this); + hideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_FAB_IN_POST_FEED, false); showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false); navigationWrapper = new NavigationWrapper(findViewById(R.id.bottom_app_bar_bottom_app_bar), findViewById(R.id.linear_layout_bottom_app_bar), @@ -739,7 +742,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb fabMoreOptionsBottomSheetFragment.show(getSupportFragmentManager(), fabMoreOptionsBottomSheetFragment.getTag()); return true; }); - navigationWrapper.floatingActionButton.setVisibility(View.VISIBLE); + navigationWrapper.floatingActionButton.setVisibility(hideFab ? View.GONE : View.VISIBLE); adapter = new NavigationDrawerRecyclerViewMergedAdapter(this, mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mNavigationDrawerSharedPreferences, mSecuritySharedPreferences, @@ -910,7 +913,9 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb if (showBottomAppBar) { navigationWrapper.showNavigation(); } - navigationWrapper.showFab(); + if (!hideFab) { + navigationWrapper.showFab(); + } sectionsPagerAdapter.displaySortTypeInToolbar(); } }); @@ -1195,14 +1200,14 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb if (showBottomAppBar && !mLockBottomAppBar) { navigationWrapper.showNavigation(); } - if (!(showBottomAppBar && mLockBottomAppBar)) { + if (!(showBottomAppBar && mLockBottomAppBar) && !hideFab) { navigationWrapper.showFab(); } } @Override public void contentScrollDown() { - if (!(showBottomAppBar && mLockBottomAppBar)) { + if (!(showBottomAppBar && mLockBottomAppBar) && !hideFab) { navigationWrapper.hideFab(); } if (showBottomAppBar && !mLockBottomAppBar) { @@ -1283,6 +1288,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb } } + @Subscribe + public void onChangeHideFabInPostFeed(ChangeHideFabInPostFeedEvent event) { + hideFab = event.hideFabInPostFeed; + navigationWrapper.floatingActionButton.setVisibility(hideFab ? View.GONE : View.VISIBLE); + } + @Override public void onLongPress() { if (sectionsPagerAdapter != null) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java index bf21ef7d..de0a22c7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java @@ -137,6 +137,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT private String multiPath; private Fragment mFragment; private int fabOption; + private boolean hideFab; private boolean showBottomAppBar; private boolean lockBottomAppBar; private Call<String> subredditAutocompleteCall; @@ -159,6 +160,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT EventBus.getDefault().register(this); + hideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_FAB_IN_POST_FEED, false); showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false); navigationWrapper = new NavigationWrapper(findViewById(R.id.bottom_app_bar_bottom_app_bar), findViewById(R.id.linear_layout_bottom_app_bar), @@ -229,6 +231,8 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT initializeFragment(); } + navigationWrapper.floatingActionButton.setVisibility(hideFab ? View.GONE : View.VISIBLE); + if (showBottomAppBar) { int optionCount = mBottomAppBarSharedPreference.getInt((mAccessToken == null ? "-" : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_COUNT, 4); int option1 = mBottomAppBarSharedPreference.getInt((mAccessToken == null ? "-" : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_1, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_HOME); @@ -975,14 +979,14 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT if (showBottomAppBar && !lockBottomAppBar) { navigationWrapper.showNavigation(); } - if (!(showBottomAppBar && lockBottomAppBar)) { + if (!(showBottomAppBar && lockBottomAppBar) && !hideFab) { navigationWrapper.showFab(); } } @Override public void contentScrollDown() { - if (!(showBottomAppBar && lockBottomAppBar)) { + if (!(showBottomAppBar && lockBottomAppBar) && !hideFab) { navigationWrapper.hideFab(); } if (showBottomAppBar && !lockBottomAppBar) { 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 e22d1538..c9013735 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java @@ -211,6 +211,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp private boolean isNsfwSubreddit = false; private boolean subscriptionReady = false; private boolean showToast = false; + private boolean hideFab; private boolean showBottomAppBar; private boolean lockBottomAppBar; private String mMessageFullname; @@ -238,6 +239,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp ButterKnife.bind(this); + hideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_FAB_IN_POST_FEED, false); showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false); navigationWrapper = new NavigationWrapper(findViewById(R.id.bottom_app_bar_bottom_app_bar), findViewById(R.id.linear_layout_bottom_app_bar), findViewById(R.id.option_1_bottom_app_bar), findViewById(R.id.option_2_bottom_app_bar), @@ -930,7 +932,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp fabMoreOptionsBottomSheetFragment.show(getSupportFragmentManager(), fabMoreOptionsBottomSheetFragment.getTag()); return true; }); - navigationWrapper.floatingActionButton.setVisibility(View.VISIBLE); + navigationWrapper.floatingActionButton.setVisibility(hideFab ? View.GONE : View.VISIBLE); subscribeSubredditChip.setOnClickListener(view -> { if (mAccessToken == null) { @@ -1049,7 +1051,9 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp if (showBottomAppBar) { navigationWrapper.showNavigation(); } - navigationWrapper.showFab(); + if (!hideFab) { + navigationWrapper.showFab(); + } sectionsPagerAdapter.displaySortTypeInToolbar(); } }); @@ -1280,14 +1284,14 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp if (showBottomAppBar && !lockBottomAppBar) { navigationWrapper.showNavigation(); } - if (!(showBottomAppBar && lockBottomAppBar)) { + if (!(showBottomAppBar && lockBottomAppBar) && !hideFab) { navigationWrapper.showFab(); } } @Override public void contentScrollDown() { - if (!(showBottomAppBar && lockBottomAppBar)) { + if (!(showBottomAppBar && lockBottomAppBar) && !hideFab) { navigationWrapper.hideFab(); } if (showBottomAppBar && !lockBottomAppBar) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java index 2361793d..5afb8617 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java @@ -221,6 +221,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele private int subscribedColor; private int fabOption; private boolean showToast = false; + private boolean hideFab; private boolean showBottomAppBar; private boolean lockBottomAppBar; private String mMessageFullname; @@ -239,6 +240,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele ButterKnife.bind(this); + hideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_FAB_IN_POST_FEED, false); showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false); navigationWrapper = new NavigationWrapper(findViewById(R.id.bottom_app_bar_bottom_app_bar), findViewById(R.id.linear_layout_bottom_app_bar), @@ -688,7 +690,9 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele if (showBottomAppBar) { navigationWrapper.showNavigation(); } - navigationWrapper.showFab(); + if (!hideFab) { + navigationWrapper.showFab(); + } sectionsPagerAdapter.displaySortTypeInToolbar(); } @@ -710,6 +714,8 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele }); } + navigationWrapper.floatingActionButton.setVisibility(hideFab ? View.GONE : View.VISIBLE); + if (showBottomAppBar) { int optionCount = mBottomAppBarSharedPreference.getInt((mAccessToken == null ? "-" : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_COUNT, 4); int option1 = mBottomAppBarSharedPreference.getInt((mAccessToken == null ? "-" : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_1, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_HOME); @@ -1483,14 +1489,14 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele if (showBottomAppBar && !lockBottomAppBar) { navigationWrapper.showNavigation(); } - if (!(showBottomAppBar && lockBottomAppBar)) { + if (!(showBottomAppBar && lockBottomAppBar) && !hideFab) { navigationWrapper.showFab(); } } @Override public void contentScrollDown() { - if (!(showBottomAppBar && lockBottomAppBar)) { + if (!(showBottomAppBar && lockBottomAppBar) && !hideFab) { navigationWrapper.hideFab(); } if (showBottomAppBar && !lockBottomAppBar) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHideFabInPostFeedEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHideFabInPostFeedEvent.java new file mode 100644 index 00000000..e5cf9312 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHideFabInPostFeedEvent.java @@ -0,0 +1,9 @@ +package ml.docilealligator.infinityforreddit.events; + +public class ChangeHideFabInPostFeedEvent { + public boolean hideFabInPostFeed; + + public ChangeHideFabInPostFeedEvent(boolean hideFabInPostFeed) { + this.hideFabInPostFeed = hideFabInPostFeed; + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/InterfacePreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/InterfacePreferenceFragment.java index dc735462..bec65447 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/InterfacePreferenceFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/InterfacePreferenceFragment.java @@ -11,6 +11,7 @@ import org.greenrobot.eventbus.EventBus; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.customviews.CustomFontPreferenceFragmentCompat; +import ml.docilealligator.infinityforreddit.events.ChangeHideFabInPostFeedEvent; import ml.docilealligator.infinityforreddit.events.ChangeVoteButtonsPositionEvent; import ml.docilealligator.infinityforreddit.events.RecreateActivityEvent; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; @@ -21,6 +22,7 @@ public class InterfacePreferenceFragment extends CustomFontPreferenceFragmentCom setPreferencesFromResource(R.xml.interface_preferences, rootKey); Preference immersiveInterfaceEntryPreference = findPreference(SharedPreferencesUtils.IMMERSIVE_INTERFACE_ENTRY_KEY); + SwitchPreference hideFabInPostFeedSwitchPreference = findPreference(SharedPreferencesUtils.HIDE_FAB_IN_POST_FEED); SwitchPreference bottomAppBarSwitch = findPreference(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY); SwitchPreference voteButtonsOnTheRightSwitch = findPreference(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY); @@ -28,6 +30,13 @@ public class InterfacePreferenceFragment extends CustomFontPreferenceFragmentCom immersiveInterfaceEntryPreference.setVisible(true); } + if (hideFabInPostFeedSwitchPreference != null) { + hideFabInPostFeedSwitchPreference.setOnPreferenceChangeListener((preference, newValue) -> { + EventBus.getDefault().post(new ChangeHideFabInPostFeedEvent((Boolean) newValue)); + return true; + }); + } + if (bottomAppBarSwitch != null) { bottomAppBarSwitch.setOnPreferenceChangeListener((preference, newValue) -> { EventBus.getDefault().post(new RecreateActivityEvent()); 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 cabf8de6..6f246348 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java @@ -44,6 +44,7 @@ public class SharedPreferencesUtils { public static final String CUSTOM_TITLE_FONT_FAMILY_KEY = "custom_title_font_family"; public static final String CUSTOM_CONTENT_FONT_FAMILY_KEY = "custom_content_font_family"; public static final String REDDIT_USER_AGREEMENT_KEY = "reddit_user_agreement"; + public static final String HIDE_FAB_IN_POST_FEED = "hide_fab_in_post_feed"; public static final String SORT_TYPE_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.sort_type"; public static final String SORT_TYPE_BEST_POST = "sort_type_best_post"; |