diff options
author | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2022-11-14 11:01:31 +0000 |
---|---|---|
committer | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2022-11-14 11:01:31 +0000 |
commit | 67b6906ead02ceb7d7e46f28ae5c27a510956038 (patch) | |
tree | cbbcf9558131b8d276ef177d21513f4bb04004ce /app/src/main | |
parent | af870c157bd542b776bf16ff36527b80af5f92d3 (diff) | |
download | infinity-for-reddit-67b6906ead02ceb7d7e46f28ae5c27a510956038.tar infinity-for-reddit-67b6906ead02ceb7d7e46f28ae5c27a510956038.tar.gz infinity-for-reddit-67b6906ead02ceb7d7e46f28ae5c27a510956038.tar.bz2 infinity-for-reddit-67b6906ead02ceb7d7e46f28ae5c27a510956038.tar.lz infinity-for-reddit-67b6906ead02ceb7d7e46f28ae5c27a510956038.tar.xz infinity-for-reddit-67b6906ead02ceb7d7e46f28ae5c27a510956038.tar.zst infinity-for-reddit-67b6906ead02ceb7d7e46f28ae5c27a510956038.zip |
New option: Settings->Interface->Comment->Comment Divider Type.
Diffstat (limited to 'app/src/main')
6 files changed, 66 insertions, 6 deletions
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 5e66a671..55517b4e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java @@ -74,6 +74,9 @@ import ml.docilealligator.infinityforreddit.utils.Utils; import retrofit2.Retrofit; public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { + public static final int DIVIDER_NORMAL = 0; + public static final int DIVIDER_PARENT = 1; + private static final int VIEW_TYPE_FIRST_LOADING = 9; private static final int VIEW_TYPE_FIRST_LOADING_FAILED = 10; private static final int VIEW_TYPE_NO_COMMENT_PLACEHOLDER = 11; @@ -107,6 +110,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi private boolean mCommentToolbarHideOnClick; private boolean mSwapTapAndLong; private boolean mShowCommentDivider; + private int mDividerType; private boolean mShowAbsoluteNumberOfVotes; private boolean mFullyCollapseComment; private boolean mShowOnlyOneCommentLevelIndicator; @@ -221,6 +225,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi mCommentToolbarHideOnClick = sharedPreferences.getBoolean(SharedPreferencesUtils.COMMENT_TOOLBAR_HIDE_ON_CLICK, true); mSwapTapAndLong = sharedPreferences.getBoolean(SharedPreferencesUtils.SWAP_TAP_AND_LONG_COMMENTS, false); mShowCommentDivider = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_COMMENT_DIVIDER, false); + mDividerType = Integer.parseInt(sharedPreferences.getString(SharedPreferencesUtils.COMMENT_DIVIDER_TYPE, "0")); mShowAbsoluteNumberOfVotes = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ABSOLUTE_NUMBER_OF_VOTES, true); mFullyCollapseComment = sharedPreferences.getBoolean(SharedPreferencesUtils.FULLY_COLLAPSE_COMMENT, false); mShowOnlyOneCommentLevelIndicator = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ONLY_ONE_COMMENT_LEVEL_INDICATOR, false); @@ -525,6 +530,13 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi if (position == mSearchCommentIndex) { holder.itemView.setBackgroundColor(Color.parseColor("#03A9F4")); } + + if (mShowCommentDivider) { + if (mDividerType == DIVIDER_PARENT && comment.getDepth() == 0) { + RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) holder.itemView.getLayoutParams(); + params.setMargins(0, (int) Utils.convertDpToPixel(16, mActivity), 0, 0); + } + } } } else if (holder instanceof CommentFullyCollapsedViewHolder) { Comment comment = getCurrentComment(position); @@ -574,6 +586,13 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi } ((CommentFullyCollapsedViewHolder) holder).commentIndentationView.setShowOnlyOneDivider(mShowOnlyOneCommentLevelIndicator); ((CommentFullyCollapsedViewHolder) holder).commentIndentationView.setLevelAndColors(comment.getDepth(), verticalBlockColors); + + if (mShowCommentDivider) { + if (mDividerType == DIVIDER_PARENT && comment.getDepth() == 0) { + RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) holder.itemView.getLayoutParams(); + params.setMargins(0, (int) Utils.convertDpToPixel(16, mActivity), 0, 0); + } + } } } else if (holder instanceof LoadMoreChildCommentsViewHolder) { Comment placeholder; @@ -1128,6 +1147,8 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi ((CommentViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN); ((CommentViewHolder) holder).expandButton.setText(""); ((CommentViewHolder) holder).replyButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN); + RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) holder.itemView.getLayoutParams(); + params.setMargins(0, 0, 0, 0); } } @@ -1246,8 +1267,10 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi } if (mShowCommentDivider) { - commentDivider.setBackgroundColor(mDividerColor); - commentDivider.setVisibility(View.VISIBLE); + if (mDividerType == DIVIDER_NORMAL) { + commentDivider.setBackgroundColor(mDividerColor); + commentDivider.setVisibility(View.VISIBLE); + } } if (mActivity.typeface != null) { @@ -1749,8 +1772,10 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi commentTimeTextView.setTextColor(mSecondaryTextColor); if (mShowCommentDivider) { - commentDivider.setBackgroundColor(mDividerColor); - commentDivider.setVisibility(View.VISIBLE); + if (mDividerType == DIVIDER_NORMAL) { + commentDivider.setBackgroundColor(mDividerColor); + commentDivider.setVisibility(View.VISIBLE); + } } if (mShowAuthorAvatar) { @@ -1801,7 +1826,10 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi ButterKnife.bind(this, itemView); if (mShowCommentDivider) { - commentDivider.setVisibility(View.VISIBLE); + if (mDividerType == DIVIDER_NORMAL) { + commentDivider.setBackgroundColor(mDividerColor); + commentDivider.setVisibility(View.VISIBLE); + } } if (mActivity.typeface != null) { @@ -1809,7 +1837,6 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi } itemView.setBackgroundColor(mCommentBackgroundColor); placeholderTextView.setTextColor(mPrimaryTextColor); - commentDivider.setBackgroundColor(mDividerColor); } } 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 2c350305..386e2827 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CommentPreferenceFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CommentPreferenceFragment.java @@ -3,7 +3,9 @@ package ml.docilealligator.infinityforreddit.settings; import android.content.SharedPreferences; import android.os.Bundle; +import androidx.preference.ListPreference; import androidx.preference.SeekBarPreference; +import androidx.preference.SwitchPreference; import javax.inject.Inject; import javax.inject.Named; @@ -25,8 +27,18 @@ public class CommentPreferenceFragment extends CustomFontPreferenceFragmentCompa ((Infinity) activity.getApplication()).getAppComponent().inject(this); + SwitchPreference showCommentDividerSwitchPreference = findPreference(SharedPreferencesUtils.SHOW_COMMENT_DIVIDER); + ListPreference commentDividerTypeListPreference = findPreference(SharedPreferencesUtils.COMMENT_DIVIDER_TYPE); SeekBarPreference showFewerToolbarOptionsThresholdSeekBarPreference = findPreference(SharedPreferencesUtils.SHOW_FEWER_TOOLBAR_OPTIONS_THRESHOLD); + if (showCommentDividerSwitchPreference != null && commentDividerTypeListPreference != null) { + commentDividerTypeListPreference.setVisible(sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_COMMENT_DIVIDER, false)); + showCommentDividerSwitchPreference.setOnPreferenceChangeListener((preference, newValue) -> { + commentDividerTypeListPreference.setVisible((Boolean) newValue); + return true; + }); + } + if (showFewerToolbarOptionsThresholdSeekBarPreference != null) { showFewerToolbarOptionsThresholdSeekBarPreference.setSummary(getString(R.string.settings_show_fewer_toolbar_options_threshold_summary, sharedPreferences.getInt(SharedPreferencesUtils.SHOW_FEWER_TOOLBAR_OPTIONS_THRESHOLD, 5))); 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 0cf4ba52..389bcf83 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java @@ -215,6 +215,7 @@ public class SharedPreferencesUtils { public static final String REDDIT_VIDEO_DEFAULT_RESOLUTION = "reddit_video_default_resolution"; public static final String EASIER_TO_WATCH_IN_FULL_SCREEN = "easier_to_watch_in_full_screen"; public static final String HIDE_THE_NUMBER_OF_VOTES_IN_COMMENTS = "hide_the_number_of_votes_in_comments"; + public static final String COMMENT_DIVIDER_TYPE = "comment_divider_type"; 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/arrays.xml b/app/src/main/res/values/arrays.xml index 51015180..62ec7430 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -669,4 +669,14 @@ <item>144</item> </string-array> + <string-array name="settings_comment_divider_type"> + <item>Normal</item> + <item>Only on top-level comments</item> + </string-array> + + <string-array name="settings_comment_divider_type_values"> + <item>0</item> + <item>1</item> + </string-array> + </resources> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bdcba30e..41c1bcb2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -647,6 +647,7 @@ <string name="settings_reddit_video_default_resolution">Reddit Video Default Resolution</string> <string name="settings_easier_to_watch_in_full_screen_title">Easier to Watch in Full Screen</string> <string name="settings_hide_fab_in_post_feed">Hide FAB in Post Feed</string> + <string name="settings_comment_divider_type">Comment Divider Type</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 c38eb2f1..caf95e8f 100644 --- a/app/src/main/res/xml/comment_preferences.xml +++ b/app/src/main/res/xml/comment_preferences.xml @@ -12,6 +12,15 @@ app:key="show_comment_divider" app:title="@string/settings_show_comment_divider_title" /> + <ml.docilealligator.infinityforreddit.customviews.CustomFontListPreference + app:defaultValue="0" + app:key="comment_divider_type" + android:title="@string/settings_comment_divider_type" + app:entries="@array/settings_comment_divider_type" + app:entryValues="@array/settings_comment_divider_type_values" + app:useSimpleSummaryProvider="true" + app:isPreferenceVisible="false" /> + <ml.docilealligator.infinityforreddit.customviews.CustomFontSwitchPreference app:defaultValue="false" app:key="show_only_one_comment_level_indicator" |