aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-02-02 11:29:14 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-02-02 11:29:14 +0000
commitbdf5f07883fad7444207cc49537cd7deba0c9b84 (patch)
tree57cb309ba109f2349bb37e8ad3c1b4955a1f3b4f /app/src/main/java
parent51d7965527d16662499817ff3ab5849c3a8d42b4 (diff)
downloadinfinity-for-reddit-bdf5f07883fad7444207cc49537cd7deba0c9b84.tar
infinity-for-reddit-bdf5f07883fad7444207cc49537cd7deba0c9b84.tar.gz
infinity-for-reddit-bdf5f07883fad7444207cc49537cd7deba0c9b84.tar.bz2
infinity-for-reddit-bdf5f07883fad7444207cc49537cd7deba0c9b84.tar.lz
infinity-for-reddit-bdf5f07883fad7444207cc49537cd7deba0c9b84.tar.xz
infinity-for-reddit-bdf5f07883fad7444207cc49537cd7deba0c9b84.tar.zst
infinity-for-reddit-bdf5f07883fad7444207cc49537cd7deba0c9b84.zip
Lock the bottom app bar.
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java20
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java14
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeLockBottomAppBarEvent.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Settings/GesturesAndButtonsPreferenceFragment.java15
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java1
5 files changed, 50 insertions, 9 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
index 63124d8a..793c90a9 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
@@ -72,6 +72,7 @@ import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubscribedThingsAsyn
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchToAnonymousAccountAsyncTask;
import ml.docilealligator.infinityforreddit.Event.ChangeConfirmToExitEvent;
+import ml.docilealligator.infinityforreddit.Event.ChangeLockBottomAppBarEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
@@ -216,6 +217,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
private boolean isInLazyMode = false;
private boolean showBottomAppBar;
private boolean mConfirmToExit;
+ private boolean mLockBottomAppBar;
@Override
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);
mConfirmToExit = mSharedPreferences.getBoolean(SharedPreferencesUtils.CONFIRM_TO_EXIT, false);
+ mLockBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR, false);
if (savedInstanceState != null) {
mFetchUserInfoSuccess = savedInstanceState.getBoolean(FETCH_USER_INFO_STATE);
@@ -973,17 +976,21 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
public void postScrollUp() {
if (mAccessToken != null) {
- if (showBottomAppBar) {
+ if (showBottomAppBar && !mLockBottomAppBar) {
bottomNavigationView.performShow();
}
- fab.show();
+ if (!(showBottomAppBar && mLockBottomAppBar)) {
+ fab.show();
+ }
}
}
public void postScrollDown() {
if (mAccessToken != null) {
- fab.hide();
- if (showBottomAppBar) {
+ if (!(showBottomAppBar && mLockBottomAppBar)) {
+ fab.hide();
+ }
+ if (showBottomAppBar && !mLockBottomAppBar) {
bottomNavigationView.performHide();
}
}
@@ -1011,6 +1018,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
mConfirmToExit = changeConfirmToExitEvent.confirmToExit;
}
+ @Subscribe
+ public void onChangeLockBottomAppBar(ChangeLockBottomAppBarEvent changeLockBottomAppBarEvent) {
+ mLockBottomAppBar = changeLockBottomAppBarEvent.lockBottomAppBar;
+ }
+
private class SectionsPagerAdapter extends FragmentPagerAdapter {
private PostFragment frontPagePostFragment;
private PostFragment popularPostFragment;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java
index 53631397..77cbe4b9 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java
@@ -145,6 +145,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
private boolean isInLazyMode = false;
private boolean showToast = false;
private boolean showBottomAppBar;
+ private boolean lockBottomAppBar;
private String mMessageFullname;
private String mNewAccountName;
private RequestManager glide;
@@ -272,6 +273,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
setSupportActionBar(toolbar);
showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false);
+ lockBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR, false);
glide = Glide.with(this);
@@ -690,17 +692,21 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
public void postScrollUp() {
if (mAccessToken != null) {
- if (showBottomAppBar) {
+ if (showBottomAppBar && !lockBottomAppBar) {
bottomNavigationView.performShow();
}
- fab.show();
+ if (!(showBottomAppBar && lockBottomAppBar)) {
+ fab.show();
+ }
}
}
public void postScrollDown() {
if (mAccessToken != null) {
- fab.hide();
- if (showBottomAppBar) {
+ if (!(showBottomAppBar && lockBottomAppBar)) {
+ fab.hide();
+ }
+ if (showBottomAppBar && !lockBottomAppBar) {
bottomNavigationView.performHide();
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeLockBottomAppBarEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeLockBottomAppBarEvent.java
new file mode 100644
index 00000000..45d483c6
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeLockBottomAppBarEvent.java
@@ -0,0 +1,9 @@
+package ml.docilealligator.infinityforreddit.Event;
+
+public class ChangeLockBottomAppBarEvent {
+ public boolean lockBottomAppBar;
+
+ public ChangeLockBottomAppBarEvent(boolean lockBottomAppBar) {
+ this.lockBottomAppBar = lockBottomAppBar;
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/GesturesAndButtonsPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/GesturesAndButtonsPreferenceFragment.java
index b9add307..255e8d23 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/GesturesAndButtonsPreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/GesturesAndButtonsPreferenceFragment.java
@@ -11,8 +11,11 @@ import androidx.fragment.app.Fragment;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.SwitchPreference;
+import org.greenrobot.eventbus.EventBus;
+
import javax.inject.Inject;
+import ml.docilealligator.infinityforreddit.Event.ChangeLockBottomAppBarEvent;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
@@ -33,10 +36,12 @@ public class GesturesAndButtonsPreferenceFragment extends PreferenceFragmentComp
SwitchPreference lockJumpToNextTopLevelCommentButtonSwitch =
findPreference(SharedPreferencesUtils.LOCK_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON);
+ SwitchPreference lockBottomAppBarSwitch = findPreference(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR);
SwitchPreference swipeUpToHideJumpToNextTopLevelCommentButtonSwitch =
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) -> {
if ((Boolean) newValue) {
swipeUpToHideJumpToNextTopLevelCommentButtonSwitch.setVisible(false);
@@ -46,6 +51,14 @@ public class GesturesAndButtonsPreferenceFragment extends PreferenceFragmentComp
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)) {
swipeUpToHideJumpToNextTopLevelCommentButtonSwitch.setVisible(true);
}
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 0f7f4eca..3717a6cd 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
@@ -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 SHOW_TOP_LEVEL_COMMENTS_FIRST = "show_top_level_comments_first";
public static final String CONFIRM_TO_EXIT = "confirm_to_exit";
+ public static final String LOCK_BOTTOM_APP_BAR = "lock_bottom_app_bar";
}