New option: Settings->Interface->Hide FAB in Post Feed.

This commit is contained in:
Docile-Alligator 2022-11-04 01:31:44 +11:00
parent 4abadb78c4
commit eb40bad3ef
9 changed files with 64 additions and 14 deletions

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -0,0 +1,9 @@
package ml.docilealligator.infinityforreddit.events;
public class ChangeHideFabInPostFeedEvent {
public boolean hideFabInPostFeed;
public ChangeHideFabInPostFeedEvent(boolean hideFabInPostFeed) {
this.hideFabInPostFeed = hideFabInPostFeed;
}
}

View File

@ -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());

View File

@ -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";

View File

@ -646,6 +646,7 @@
<string name="settings_post_feed_max_resolution_title">Post Feed Preview Max Resolution (Width * Height)</string>
<string name="settings_reddit_video_default_resolution">Reddit Video Default Resolution</string>
<string name="settings_easier_to_watch_in_full_screen_title">Easier to Watch in Full Screen</string>
<string name="settings_hide_fab_in_post_feed">Hide FAB in Post Feed</string>
<string name="no_link_available">Cannot get the link</string>

View File

@ -24,6 +24,11 @@
app:title="@string/settings_customize_bottom_app_bar_title"
app:fragment="ml.docilealligator.infinityforreddit.settings.CustomizeBottomAppBarFragment" />
<ml.docilealligator.infinityforreddit.customviews.CustomFontSwitchPreference
app:defaultValue="false"
app:key="hide_fab_in_post_feed"
app:title="@string/settings_hide_fab_in_post_feed" />
<ml.docilealligator.infinityforreddit.customviews.CustomFontSwitchPreference
app:defaultValue="false"
app:key="bottom_app_bar"