diff options
Diffstat (limited to 'app/src/main/java')
6 files changed, 93 insertions, 33 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SettingsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SettingsActivity.java index 5abda777..d36a72aa 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SettingsActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SettingsActivity.java @@ -41,17 +41,6 @@ public class SettingsActivity extends BaseActivity implements ButterKnife.bind(this); - /*if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - Window window = getWindow(); - if ((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { - window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); - } - TypedValue typedValue = new TypedValue(); - getTheme().resolveAttribute(R.attr.navBarColor, typedValue, true); - int navBarColor = typedValue.data; - window.setNavigationBarColor(navBarColor); - }*/ - setSupportActionBar(toolbar); if (savedInstanceState == null) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java index c5dfed9f..e0c48770 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java @@ -173,6 +173,8 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS private boolean isSortingComments = false; private boolean mVolumeKeysNavigateComments; private boolean mIsSmoothScrolling = false; + private boolean mLockFab; + private boolean mSwipeUpToHideFab; private LinearLayoutManager mLinearLayoutManager; private CommentAndPostRecyclerViewAdapter mAdapter; private RecyclerView.SmoothScroller mSmoothScroller; @@ -253,6 +255,8 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS mVoteButtonsOnTheRight = mSharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false); mShowElapsedTime = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false); mVolumeKeysNavigateComments = mSharedPreferences.getBoolean(SharedPreferencesUtils.VOLUME_KEYS_NAVIGATE_COMMENTS, false); + mLockFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON, false); + mSwipeUpToHideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_UP_TO_HIDE_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON, false); mGlide = Glide.with(this); mLocale = getResources().getConfiguration().locale; @@ -265,11 +269,19 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS @Override public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); - if (!mIsSmoothScrolling) { + if (!mIsSmoothScrolling && !mLockFab) { if (dy > 0) { - fab.hide(); + if (mSwipeUpToHideFab) { + fab.show(); + } else { + fab.hide(); + } } else { - fab.show(); + if (mSwipeUpToHideFab) { + fab.hide(); + } else { + fab.show(); + } } } @@ -296,11 +308,19 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS @Override public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); - if (!mIsSmoothScrolling) { + if (!mIsSmoothScrolling && !mLockFab) { if (dy > 0) { - fab.hide(); + if (mSwipeUpToHideFab) { + fab.show(); + } else { + fab.hide(); + } } else { - fab.show(); + if (mSwipeUpToHideFab) { + fab.hide(); + } else { + fab.show(); + } } } } @@ -634,11 +654,19 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS @Override public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); - if (!mIsSmoothScrolling) { + if (!mIsSmoothScrolling && !mLockFab) { if (dy > 0) { - fab.hide(); + if (mSwipeUpToHideFab) { + fab.show(); + } else { + fab.hide(); + } } else { - fab.show(); + if (mSwipeUpToHideFab) { + fab.hide(); + } else { + fab.show(); + } } } @@ -722,11 +750,19 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS @Override public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); - if (!mIsSmoothScrolling) { + if (!mIsSmoothScrolling && !mLockFab) { if (dy > 0) { - fab.hide(); + if (mSwipeUpToHideFab) { + fab.show(); + } else { + fab.hide(); + } } else { - fab.show(); + if (mSwipeUpToHideFab) { + fab.hide(); + } else { + fab.show(); + } } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java index b7fe4a79..e9a8adb2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java @@ -41,6 +41,7 @@ import ml.docilealligator.infinityforreddit.Fragment.SubredditListingFragment; import ml.docilealligator.infinityforreddit.Fragment.SubscribedSubredditsListingFragment; import ml.docilealligator.infinityforreddit.Fragment.UserListingFragment; import ml.docilealligator.infinityforreddit.Service.SubmitPostService; +import ml.docilealligator.infinityforreddit.Settings.GesturesAndButtonsPreferenceFragment; import ml.docilealligator.infinityforreddit.Settings.MainPreferenceFragment; import ml.docilealligator.infinityforreddit.Settings.NotificationPreferenceFragment; @@ -128,4 +129,6 @@ public interface AppComponent { void inject(ViewSidebarActivity viewSidebarActivity); void inject(ViewVideoActivity viewVideoActivity); + + void inject(GesturesAndButtonsPreferenceFragment gesturesAndButtonsPreferenceFragment); } 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 39e6874d..b9add307 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/GesturesAndButtonsPreferenceFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/GesturesAndButtonsPreferenceFragment.java @@ -1,20 +1,60 @@ package ml.docilealligator.infinityforreddit.Settings; +import android.app.Activity; +import android.content.Context; +import android.content.SharedPreferences; import android.os.Bundle; +import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import androidx.preference.PreferenceFragmentCompat; +import androidx.preference.SwitchPreference; +import javax.inject.Inject; + +import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; /** * A simple {@link Fragment} subclass. */ public class GesturesAndButtonsPreferenceFragment extends PreferenceFragmentCompat { + @Inject + SharedPreferences sharedPreferences; + private Activity activity; + @Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { setPreferencesFromResource(R.xml.gestures_and_buttons_preference, rootKey); + ((Infinity) activity.getApplication()).getAppComponent().inject(this); + + SwitchPreference lockJumpToNextTopLevelCommentButtonSwitch = + findPreference(SharedPreferencesUtils.LOCK_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON); + SwitchPreference swipeUpToHideJumpToNextTopLevelCommentButtonSwitch = + findPreference(SharedPreferencesUtils.SWIPE_UP_TO_HIDE_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON); + + if (lockJumpToNextTopLevelCommentButtonSwitch != null && swipeUpToHideJumpToNextTopLevelCommentButtonSwitch != null) { + lockJumpToNextTopLevelCommentButtonSwitch.setOnPreferenceChangeListener((preference, newValue) -> { + if ((Boolean) newValue) { + swipeUpToHideJumpToNextTopLevelCommentButtonSwitch.setVisible(false); + } else { + swipeUpToHideJumpToNextTopLevelCommentButtonSwitch.setVisible(true); + } + return true; + }); + + if (!sharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON, false)) { + swipeUpToHideJumpToNextTopLevelCommentButtonSwitch.setVisible(true); + } + } + } + + @Override + public void onAttach(@NonNull Context context) { + super.onAttach(context); + activity = (Activity) context; } } 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 e3f9893e..e4b64d27 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/InterfacePreferenceFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/InterfacePreferenceFragment.java @@ -1,12 +1,9 @@ package ml.docilealligator.infinityforreddit.Settings; -import android.app.Activity; -import android.content.Context; import android.os.Build; import android.os.Bundle; -import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import androidx.preference.ListPreference; import androidx.preference.PreferenceFragmentCompat; @@ -26,7 +23,6 @@ import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; * A simple {@link Fragment} subclass. */ public class InterfacePreferenceFragment extends PreferenceFragmentCompat { - private Activity activity; @Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { @@ -86,10 +82,4 @@ public class InterfacePreferenceFragment extends PreferenceFragmentCompat { }); } } - - @Override - public void onAttach(@NonNull Context context) { - super.onAttach(context); - activity = (Activity) context; - } } 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 4a8dad83..6f065d5e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java @@ -69,4 +69,6 @@ public class SharedPreferencesUtils { public static final String VOLUME_KEYS_NAVIGATE_POSTS = "volume_keys_navigate_posts"; public static final String MUTE_VIDEO = "mute_video"; public static final String OPEN_LINK_IN_APP = "open_link_in_app"; + public static final String LOCK_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON = "lock_jump_to_next_top_level_comment_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"; } |