aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SettingsActivity.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java60
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Settings/GesturesAndButtonsPreferenceFragment.java40
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Settings/InterfacePreferenceFragment.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java2
-rw-r--r--app/src/main/res/layout/fragment_post_type_bottom_sheet.xml4
-rw-r--r--app/src/main/res/values/strings.xml2
-rw-r--r--app/src/main/res/xml/gestures_and_buttons_preference.xml11
9 files changed, 108 insertions, 35 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";
}
diff --git a/app/src/main/res/layout/fragment_post_type_bottom_sheet.xml b/app/src/main/res/layout/fragment_post_type_bottom_sheet.xml
index ee526c00..a21d1a21 100644
--- a/app/src/main/res/layout/fragment_post_type_bottom_sheet.xml
+++ b/app/src/main/res/layout/fragment_post_type_bottom_sheet.xml
@@ -55,7 +55,7 @@
android:paddingBottom="16dp"
android:paddingStart="32dp"
android:paddingEnd="32dp"
- android:text="@string/bottom_sheet_post_link"
+ android:text="@string/bottom_sheet_post_video"
android:textColor="@color/primaryTextColor"
android:textSize="?attr/font_default"
android:drawableStart="@drawable/ic_outline_video_24dp"
@@ -73,7 +73,7 @@
android:paddingBottom="16dp"
android:paddingStart="32dp"
android:paddingEnd="32dp"
- android:text="@string/bottom_sheet_post_video"
+ android:text="@string/bottom_sheet_post_image"
android:textColor="@color/primaryTextColor"
android:textSize="?attr/font_default"
android:drawableStart="@drawable/ic_image_24dp"
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 82681a40..8ca45ac6 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -306,6 +306,8 @@
<string name="settings_default_post_layout">Default Post 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_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_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 2f15e6be..ad675bca 100644
--- a/app/src/main/res/xml/gestures_and_buttons_preference.xml
+++ b/app/src/main/res/xml/gestures_and_buttons_preference.xml
@@ -8,6 +8,17 @@
<SwitchPreference
app:defaultValue="false"
+ app:key="lock_jump_to_next_top_level_comment_button"
+ app:title="@string/settings_lock_jump_to_next_top_level_comment_button_title" />
+
+ <SwitchPreference
+ app:defaultValue="false"
+ app:key="swipe_up_to_hide_jump_to_next_top_level_comments_button"
+ app:title="@string/settings_swipe_up_to_hide_jump_to_next_top_level_comment_button_title"
+ app:isPreferenceVisible="false" />
+
+ <SwitchPreference
+ app:defaultValue="false"
app:key="volume_keys_navigate_comments"
app:title="@string/settings_volume_keys_navigate_comments_title" />