aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java7
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/CommentPreferenceFragment.java27
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java1
-rw-r--r--app/src/main/res/values/strings.xml2
-rw-r--r--app/src/main/res/xml/comment_preferences.xml7
6 files changed, 44 insertions, 3 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
index 1f758dfc..a3f45e59 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
@@ -82,6 +82,7 @@ import ml.docilealligator.infinityforreddit.services.EditProfileService;
import ml.docilealligator.infinityforreddit.services.MaterialYouService;
import ml.docilealligator.infinityforreddit.services.SubmitPostService;
import ml.docilealligator.infinityforreddit.settings.AdvancedPreferenceFragment;
+import ml.docilealligator.infinityforreddit.settings.CommentPreferenceFragment;
import ml.docilealligator.infinityforreddit.settings.CrashReportsFragment;
import ml.docilealligator.infinityforreddit.settings.CustomizeBottomAppBarFragment;
import ml.docilealligator.infinityforreddit.settings.CustomizeMainPageTabsFragment;
@@ -292,4 +293,6 @@ public interface AppComponent {
void inject(EditProfileActivity editProfileActivity);
void inject(FontPreferenceFragment fontPreferenceFragment);
+
+ void inject(CommentPreferenceFragment commentPreferenceFragment);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
index 1cd992ad..89d9c58d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
@@ -115,6 +115,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
private boolean mFullyCollapseComment;
private boolean mShowOnlyOneCommentLevelIndicator;
private boolean mHideCommentAwards;
+ private int mDepthThreshold;
private CommentRecyclerViewAdapterCallback mCommentRecyclerViewAdapterCallback;
private boolean isInitiallyLoading;
private boolean isInitiallyLoadingFailed;
@@ -123,7 +124,6 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
private Drawable expandDrawable;
private Drawable collapseDrawable;
- private int depthThreshold = 5;
private int mColorPrimaryLightTheme;
private int mColorAccent;
private int mCircularProgressBarBackgroundColor;
@@ -237,6 +237,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
mFullyCollapseComment = sharedPreferences.getBoolean(SharedPreferencesUtils.FULLY_COLLAPSE_COMMENT, false);
mShowOnlyOneCommentLevelIndicator = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ONLY_ONE_COMMENT_LEVEL_INDICATOR, false);
mHideCommentAwards = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_COMMENT_AWARDS, false);
+ mDepthThreshold = sharedPreferences.getInt(SharedPreferencesUtils.SHOW_FEWER_TOOLBAR_OPTIONS_THRESHOLD, 5);
mCommentRecyclerViewAdapterCallback = commentRecyclerViewAdapterCallback;
isInitiallyLoading = true;
@@ -451,7 +452,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
((CommentViewHolder) holder).commentIndentationView.setShowOnlyOneDivider(mShowOnlyOneCommentLevelIndicator);
((CommentViewHolder) holder).commentIndentationView.setLevelAndColors(comment.getDepth(), verticalBlockColors);
- if (comment.getDepth() > depthThreshold) {
+ if (comment.getDepth() >= mDepthThreshold) {
((CommentViewHolder) holder).saveButton.setVisibility(View.GONE);
((CommentViewHolder) holder).replyButton.setVisibility(View.GONE);
} else {
@@ -1260,7 +1261,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
}
bundle.putString(CommentMoreBottomSheetFragment.EXTRA_COMMENT_MARKDOWN, comment.getCommentMarkdown());
bundle.putBoolean(CommentMoreBottomSheetFragment.EXTRA_IS_NSFW, mPost.isNSFW());
- if (comment.getDepth() > depthThreshold) {
+ if (comment.getDepth() >= mDepthThreshold) {
bundle.putBoolean(CommentMoreBottomSheetFragment.EXTRA_SHOW_REPLY_AND_SAVE_OPTION, true);
}
CommentMoreBottomSheetFragment commentMoreBottomSheetFragment = new CommentMoreBottomSheetFragment();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CommentPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CommentPreferenceFragment.java
index 336d7c62..2baef8f2 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CommentPreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CommentPreferenceFragment.java
@@ -1,18 +1,45 @@
package ml.docilealligator.infinityforreddit.settings;
+import android.content.SharedPreferences;
import android.os.Bundle;
+import androidx.preference.Preference;
+import androidx.preference.SeekBarPreference;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.customviews.CustomFontPreferenceFragmentCompat;
+import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
public class CommentPreferenceFragment extends CustomFontPreferenceFragmentCompat {
+ @Inject
+ @Named("default")
+ SharedPreferences sharedPreferences;
+
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.comment_preferences, rootKey);
+ ((Infinity) activity.getApplication()).getAppComponent().inject(this);
+
if (activity.typeface != null) {
setFont(activity.typeface);
}
+
+ SeekBarPreference showFewerToolbarOptionsThresholdSeekBarPreference = findPreference(SharedPreferencesUtils.SHOW_FEWER_TOOLBAR_OPTIONS_THRESHOLD);
+
+ if (showFewerToolbarOptionsThresholdSeekBarPreference != null) {
+ showFewerToolbarOptionsThresholdSeekBarPreference.setSummary(getString(R.string.settings_show_fewer_toolbar_options_threshold_summary, sharedPreferences.getInt(SharedPreferencesUtils.SHOW_FEWER_TOOLBAR_OPTIONS_THRESHOLD, 5)));
+
+ showFewerToolbarOptionsThresholdSeekBarPreference.setOnPreferenceChangeListener((Preference.OnPreferenceChangeListener) (preference, newValue) -> {
+ showFewerToolbarOptionsThresholdSeekBarPreference.setSummary(
+ getString(R.string.settings_show_fewer_toolbar_options_threshold_summary, (Integer) newValue));
+ return true;
+ });
+ }
}
} \ No newline at end of file
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 7291de2c..6b1a30af 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
@@ -203,6 +203,7 @@ public class SharedPreferencesUtils {
public static final String FIXED_HEIGHT_PREVIEW_IN_CARD = "fixed_height_preview_in_card";
public static final String HIDE_TEXT_POST_CONTENT = "hide_text_post_content";
public static final String HIDE_COMMENT_AWARDS = "hide_comment_awards";
+ public static final String SHOW_FEWER_TOOLBAR_OPTIONS_THRESHOLD = "show_fewer_toolbar_options_threshold";
public static final String DEFAULT_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit_preferences";
public static final String MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.main_page_tabs";
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index c1a9b8c7..167b02eb 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -627,6 +627,8 @@
<string name="settings_fixed_height_preview_in_card_title">Fixed Height in Card</string>
<string name="settings_hide_text_post_content">Hide Text Post Content</string>
<string name="settings_hide_comment_awards_title">Hide Comment Awards</string>
+ <string name="settings_show_fewer_toolbar_options_threshold_title">Show Fewer Toolbar Options Starting From</string>
+ <string name="settings_show_fewer_toolbar_options_threshold_summary">Level %1$d</string>
<string name="no_link_available">Cannot get the link</string>
diff --git a/app/src/main/res/xml/comment_preferences.xml b/app/src/main/res/xml/comment_preferences.xml
index 9455ec35..b7736545 100644
--- a/app/src/main/res/xml/comment_preferences.xml
+++ b/app/src/main/res/xml/comment_preferences.xml
@@ -37,4 +37,11 @@
app:key="hide_comment_awards"
android:title="@string/settings_hide_comment_awards_title" />
+ <ml.docilealligator.infinityforreddit.customviews.CustomFontSeekBarPreference
+ app:defaultValue="5"
+ android:max="10"
+ app:key="show_fewer_toolbar_options_threshold"
+ app:title="@string/settings_show_fewer_toolbar_options_threshold_title"
+ app:singleLineTitle="false" />
+
</PreferenceScreen> \ No newline at end of file