mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-07 11:17:25 +01:00
Lock the bottom app bar.
This commit is contained in:
parent
51d7965527
commit
bdf5f07883
@ -72,6 +72,7 @@ import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubscribedThingsAsyn
|
|||||||
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask;
|
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask;
|
||||||
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchToAnonymousAccountAsyncTask;
|
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchToAnonymousAccountAsyncTask;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeConfirmToExitEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeConfirmToExitEvent;
|
||||||
|
import ml.docilealligator.infinityforreddit.Event.ChangeLockBottomAppBarEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent;
|
import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
|
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
|
||||||
@ -216,6 +217,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
private boolean isInLazyMode = false;
|
private boolean isInLazyMode = false;
|
||||||
private boolean showBottomAppBar;
|
private boolean showBottomAppBar;
|
||||||
private boolean mConfirmToExit;
|
private boolean mConfirmToExit;
|
||||||
|
private boolean mLockBottomAppBar;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -317,6 +319,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
|
|
||||||
showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false);
|
showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false);
|
||||||
mConfirmToExit = mSharedPreferences.getBoolean(SharedPreferencesUtils.CONFIRM_TO_EXIT, false);
|
mConfirmToExit = mSharedPreferences.getBoolean(SharedPreferencesUtils.CONFIRM_TO_EXIT, false);
|
||||||
|
mLockBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR, false);
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
mFetchUserInfoSuccess = savedInstanceState.getBoolean(FETCH_USER_INFO_STATE);
|
mFetchUserInfoSuccess = savedInstanceState.getBoolean(FETCH_USER_INFO_STATE);
|
||||||
@ -973,17 +976,21 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
|
|
||||||
public void postScrollUp() {
|
public void postScrollUp() {
|
||||||
if (mAccessToken != null) {
|
if (mAccessToken != null) {
|
||||||
if (showBottomAppBar) {
|
if (showBottomAppBar && !mLockBottomAppBar) {
|
||||||
bottomNavigationView.performShow();
|
bottomNavigationView.performShow();
|
||||||
}
|
}
|
||||||
|
if (!(showBottomAppBar && mLockBottomAppBar)) {
|
||||||
fab.show();
|
fab.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void postScrollDown() {
|
public void postScrollDown() {
|
||||||
if (mAccessToken != null) {
|
if (mAccessToken != null) {
|
||||||
|
if (!(showBottomAppBar && mLockBottomAppBar)) {
|
||||||
fab.hide();
|
fab.hide();
|
||||||
if (showBottomAppBar) {
|
}
|
||||||
|
if (showBottomAppBar && !mLockBottomAppBar) {
|
||||||
bottomNavigationView.performHide();
|
bottomNavigationView.performHide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1011,6 +1018,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
mConfirmToExit = changeConfirmToExitEvent.confirmToExit;
|
mConfirmToExit = changeConfirmToExitEvent.confirmToExit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onChangeLockBottomAppBar(ChangeLockBottomAppBarEvent changeLockBottomAppBarEvent) {
|
||||||
|
mLockBottomAppBar = changeLockBottomAppBarEvent.lockBottomAppBar;
|
||||||
|
}
|
||||||
|
|
||||||
private class SectionsPagerAdapter extends FragmentPagerAdapter {
|
private class SectionsPagerAdapter extends FragmentPagerAdapter {
|
||||||
private PostFragment frontPagePostFragment;
|
private PostFragment frontPagePostFragment;
|
||||||
private PostFragment popularPostFragment;
|
private PostFragment popularPostFragment;
|
||||||
|
@ -145,6 +145,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
private boolean isInLazyMode = false;
|
private boolean isInLazyMode = false;
|
||||||
private boolean showToast = false;
|
private boolean showToast = false;
|
||||||
private boolean showBottomAppBar;
|
private boolean showBottomAppBar;
|
||||||
|
private boolean lockBottomAppBar;
|
||||||
private String mMessageFullname;
|
private String mMessageFullname;
|
||||||
private String mNewAccountName;
|
private String mNewAccountName;
|
||||||
private RequestManager glide;
|
private RequestManager glide;
|
||||||
@ -272,6 +273,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false);
|
showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false);
|
||||||
|
lockBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR, false);
|
||||||
|
|
||||||
glide = Glide.with(this);
|
glide = Glide.with(this);
|
||||||
|
|
||||||
@ -690,17 +692,21 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
|
|
||||||
public void postScrollUp() {
|
public void postScrollUp() {
|
||||||
if (mAccessToken != null) {
|
if (mAccessToken != null) {
|
||||||
if (showBottomAppBar) {
|
if (showBottomAppBar && !lockBottomAppBar) {
|
||||||
bottomNavigationView.performShow();
|
bottomNavigationView.performShow();
|
||||||
}
|
}
|
||||||
|
if (!(showBottomAppBar && lockBottomAppBar)) {
|
||||||
fab.show();
|
fab.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void postScrollDown() {
|
public void postScrollDown() {
|
||||||
if (mAccessToken != null) {
|
if (mAccessToken != null) {
|
||||||
|
if (!(showBottomAppBar && lockBottomAppBar)) {
|
||||||
fab.hide();
|
fab.hide();
|
||||||
if (showBottomAppBar) {
|
}
|
||||||
|
if (showBottomAppBar && !lockBottomAppBar) {
|
||||||
bottomNavigationView.performHide();
|
bottomNavigationView.performHide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
package ml.docilealligator.infinityforreddit.Event;
|
||||||
|
|
||||||
|
public class ChangeLockBottomAppBarEvent {
|
||||||
|
public boolean lockBottomAppBar;
|
||||||
|
|
||||||
|
public ChangeLockBottomAppBarEvent(boolean lockBottomAppBar) {
|
||||||
|
this.lockBottomAppBar = lockBottomAppBar;
|
||||||
|
}
|
||||||
|
}
|
@ -11,8 +11,11 @@ import androidx.fragment.app.Fragment;
|
|||||||
import androidx.preference.PreferenceFragmentCompat;
|
import androidx.preference.PreferenceFragmentCompat;
|
||||||
import androidx.preference.SwitchPreference;
|
import androidx.preference.SwitchPreference;
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.Event.ChangeLockBottomAppBarEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
@ -33,10 +36,12 @@ public class GesturesAndButtonsPreferenceFragment extends PreferenceFragmentComp
|
|||||||
|
|
||||||
SwitchPreference lockJumpToNextTopLevelCommentButtonSwitch =
|
SwitchPreference lockJumpToNextTopLevelCommentButtonSwitch =
|
||||||
findPreference(SharedPreferencesUtils.LOCK_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON);
|
findPreference(SharedPreferencesUtils.LOCK_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON);
|
||||||
|
SwitchPreference lockBottomAppBarSwitch = findPreference(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR);
|
||||||
SwitchPreference swipeUpToHideJumpToNextTopLevelCommentButtonSwitch =
|
SwitchPreference swipeUpToHideJumpToNextTopLevelCommentButtonSwitch =
|
||||||
findPreference(SharedPreferencesUtils.SWIPE_UP_TO_HIDE_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON);
|
findPreference(SharedPreferencesUtils.SWIPE_UP_TO_HIDE_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON);
|
||||||
|
|
||||||
if (lockJumpToNextTopLevelCommentButtonSwitch != null && swipeUpToHideJumpToNextTopLevelCommentButtonSwitch != null) {
|
if (lockJumpToNextTopLevelCommentButtonSwitch != null && lockBottomAppBarSwitch != null &&
|
||||||
|
swipeUpToHideJumpToNextTopLevelCommentButtonSwitch != null) {
|
||||||
lockJumpToNextTopLevelCommentButtonSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
|
lockJumpToNextTopLevelCommentButtonSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||||
if ((Boolean) newValue) {
|
if ((Boolean) newValue) {
|
||||||
swipeUpToHideJumpToNextTopLevelCommentButtonSwitch.setVisible(false);
|
swipeUpToHideJumpToNextTopLevelCommentButtonSwitch.setVisible(false);
|
||||||
@ -46,6 +51,14 @@ public class GesturesAndButtonsPreferenceFragment extends PreferenceFragmentComp
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (sharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false)) {
|
||||||
|
lockBottomAppBarSwitch.setVisible(true);
|
||||||
|
lockBottomAppBarSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||||
|
EventBus.getDefault().post(new ChangeLockBottomAppBarEvent((Boolean) newValue));
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (!sharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON, false)) {
|
if (!sharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON, false)) {
|
||||||
swipeUpToHideJumpToNextTopLevelCommentButtonSwitch.setVisible(true);
|
swipeUpToHideJumpToNextTopLevelCommentButtonSwitch.setVisible(true);
|
||||||
}
|
}
|
||||||
|
@ -73,4 +73,5 @@ public class SharedPreferencesUtils {
|
|||||||
public static final String SWIPE_UP_TO_HIDE_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON = "swipe_up_to_hide_jump_to_next_top_level_comments_button";
|
public static final String SWIPE_UP_TO_HIDE_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON = "swipe_up_to_hide_jump_to_next_top_level_comments_button";
|
||||||
public static final String SHOW_TOP_LEVEL_COMMENTS_FIRST = "show_top_level_comments_first";
|
public static final String SHOW_TOP_LEVEL_COMMENTS_FIRST = "show_top_level_comments_first";
|
||||||
public static final String CONFIRM_TO_EXIT = "confirm_to_exit";
|
public static final String CONFIRM_TO_EXIT = "confirm_to_exit";
|
||||||
|
public static final String LOCK_BOTTOM_APP_BAR = "lock_bottom_app_bar";
|
||||||
}
|
}
|
||||||
|
@ -309,7 +309,8 @@
|
|||||||
<string name="settings_show_divider_in_compact_layout">Show Divider in Compact Layout</string>
|
<string name="settings_show_divider_in_compact_layout">Show Divider in Compact Layout</string>
|
||||||
<string name="settings_swipe_to_go_back_from_post_detail_title">Swipe Right to Go Back From Comments</string>
|
<string name="settings_swipe_to_go_back_from_post_detail_title">Swipe Right to Go Back From Comments</string>
|
||||||
<string name="settings_lock_jump_to_next_top_level_comment_button_title">Lock Jump to Next Top-level Comment Button</string>
|
<string name="settings_lock_jump_to_next_top_level_comment_button_title">Lock Jump to Next Top-level Comment Button</string>
|
||||||
<string name="settings_swipe_up_to_hide_jump_to_next_top_level_comment_button_title">Swipe Up to Hide Jump to Next Top Level Comment Button</string>
|
<string name="settings_lock_bottom_app_bar_title">Lock Bottom Navigation Bar</string>
|
||||||
|
<string name="settings_swipe_up_to_hide_jump_to_next_top_level_comment_button_title">Swipe Up to Hide Jump to Next Top-level Comment Button</string>
|
||||||
<string name="settings_lazy_mode_interval_title">Lazy Mode Interval</string>
|
<string name="settings_lazy_mode_interval_title">Lazy Mode Interval</string>
|
||||||
<string name="settings_font_size_title">Font Size</string>
|
<string name="settings_font_size_title">Font Size</string>
|
||||||
<string name="settings_title_font_size_title">Title Font Size</string>
|
<string name="settings_title_font_size_title">Title Font Size</string>
|
||||||
|
@ -17,6 +17,12 @@
|
|||||||
app:title="@string/settings_swipe_up_to_hide_jump_to_next_top_level_comment_button_title"
|
app:title="@string/settings_swipe_up_to_hide_jump_to_next_top_level_comment_button_title"
|
||||||
app:isPreferenceVisible="false" />
|
app:isPreferenceVisible="false" />
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
app:defaultValue="false"
|
||||||
|
app:key="lock_bottom_app_bar"
|
||||||
|
app:title="@string/settings_lock_bottom_app_bar_title"
|
||||||
|
app:isPreferenceVisible="false" />
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
app:defaultValue="false"
|
app:defaultValue="false"
|
||||||
app:key="volume_keys_navigate_comments"
|
app:key="volume_keys_navigate_comments"
|
||||||
|
Loading…
Reference in New Issue
Block a user