aboutsummaryrefslogtreecommitdiff
path: root/app
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
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')
-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
-rw-r--r--app/src/main/res/values/strings.xml3
-rw-r--r--app/src/main/res/xml/gestures_and_buttons_preference.xml6
7 files changed, 58 insertions, 10 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";
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 6a287783..686029d1 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -309,7 +309,8 @@
<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_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_font_size_title">Font Size</string>
<string name="settings_title_font_size_title">Title Font Size</string>
diff --git a/app/src/main/res/xml/gestures_and_buttons_preference.xml b/app/src/main/res/xml/gestures_and_buttons_preference.xml
index ad675bca..4d111187 100644
--- a/app/src/main/res/xml/gestures_and_buttons_preference.xml
+++ b/app/src/main/res/xml/gestures_and_buttons_preference.xml
@@ -19,6 +19,12 @@
<SwitchPreference
app:defaultValue="false"
+ app:key="lock_bottom_app_bar"
+ app:title="@string/settings_lock_bottom_app_bar_title"
+ app:isPreferenceVisible="false" />
+
+ <SwitchPreference
+ app:defaultValue="false"
app:key="volume_keys_navigate_comments"
app:title="@string/settings_volume_keys_navigate_comments_title" />