diff options
5 files changed, 28 insertions, 3 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java index a3e8dbb4..ed4df937 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java @@ -186,6 +186,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy private boolean mDataSavingMode; private boolean mDisableImagePreview; private boolean mOnlyDisablePreviewInVideoAndGifPosts; + private boolean mShowOnlyOneCommentLevelIndicator; private CommentRecyclerViewAdapterCallback mCommentRecyclerViewAdapterCallback; private boolean isInitiallyLoading; private boolean isInitiallyLoadingFailed; @@ -513,6 +514,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy mDisableImagePreview = sharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false); mOnlyDisablePreviewInVideoAndGifPosts = sharedPreferences.getBoolean(SharedPreferencesUtils.ONLY_DISABLE_PREVIEW_IN_VIDEO_AND_GIF_POSTS, false); + mShowOnlyOneCommentLevelIndicator = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ONLY_ONE_COMMENT_LEVEL_INDICATOR, false); + mCommentRecyclerViewAdapterCallback = commentRecyclerViewAdapterCallback; isInitiallyLoading = true; isInitiallyLoadingFailed = false; @@ -1098,6 +1101,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy Utils.getNVotes(mShowAbsoluteNumberOfVotes, comment.getScore() + comment.getVoteType()))); + ((CommentViewHolder) holder).commentIndentationView.setShowOnlyOneDivider(mShowOnlyOneCommentLevelIndicator); ((CommentViewHolder) holder).commentIndentationView.setLevelAndColors(comment.getDepth(), verticalBlockColors); if (comment.getDepth() > depthThreshold) { ((CommentViewHolder) holder).saveButton.setVisibility(View.GONE); @@ -1167,6 +1171,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy } ((CommentFullyCollapsedViewHolder) holder).scoreTextView.setText(mActivity.getString(R.string.top_score, Utils.getNVotes(mShowAbsoluteNumberOfVotes, comment.getScore() + comment.getVoteType()))); + ((CommentViewHolder) holder).commentIndentationView.setShowOnlyOneDivider(mShowOnlyOneCommentLevelIndicator); ((CommentFullyCollapsedViewHolder) holder).commentIndentationView.setLevelAndColors(comment.getDepth(), verticalBlockColors); } } else if (holder instanceof LoadMoreChildCommentsViewHolder) { @@ -1174,6 +1179,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy placeholder = mIsSingleCommentThreadMode ? mVisibleComments.get(holder.getBindingAdapterPosition() - 2) : mVisibleComments.get(holder.getBindingAdapterPosition() - 1); + ((LoadMoreChildCommentsViewHolder) holder).commentIndentationView.setShowOnlyOneDivider(mShowOnlyOneCommentLevelIndicator); ((LoadMoreChildCommentsViewHolder) holder).commentIndentationView.setLevelAndColors(placeholder.getDepth(), verticalBlockColors); if (placeholder.getPlaceholderType() == Comment.PLACEHOLDER_LOAD_MORE_COMMENTS) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/CommentIndentationView.java b/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/CommentIndentationView.java index fc9dba03..bcb5248e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/CommentIndentationView.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/CommentIndentationView.java @@ -22,6 +22,7 @@ public class CommentIndentationView extends LinearLayout { private ArrayList<Integer> startXs; private final int spacing; private final int pathWidth; + private boolean showOnlyOneDivider = false; public CommentIndentationView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); @@ -49,9 +50,16 @@ public class CommentIndentationView extends LinearLayout { protected void onDraw(Canvas canvas) { super.onDraw(canvas); - for (int i = 0; i < startXs.size(); i++) { - paint.setColor(colors[i % 7]); - canvas.drawLine(startXs.get(i), 0, startXs.get(i), getHeight(), paint); + if (showOnlyOneDivider) { + if (startXs.size() > 0) { + paint.setColor(colors[(startXs.size() - 1) % 7]); + canvas.drawLine(startXs.get(startXs.size() - 1), 0, startXs.get(startXs.size() - 1), getHeight(), paint); + } + } else { + for (int i = 0; i < startXs.size(); i++) { + paint.setColor(colors[i % 7]); + canvas.drawLine(startXs.get(i), 0, startXs.get(i), getHeight(), paint); + } } } @@ -89,6 +97,10 @@ public class CommentIndentationView extends LinearLayout { invalidate(); } + public void setShowOnlyOneDivider(boolean showOnlyOneDivider) { + this.showOnlyOneDivider = showOnlyOneDivider; + } + private static class SavedState extends BaseSavedState { ArrayList<Integer> startXs; Integer[] colors; 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 dc585d93..1125d71a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java @@ -177,6 +177,7 @@ public class SharedPreferencesUtils { public static final String NUMBER_OF_COLUMNS_IN_POST_FEED_PORTRAIT_CARD_LAYOUT_2 = "number_of_columns_in_post_feed_portrait_card_layout_2"; public static final String NUMBER_OF_COLUMNS_IN_POST_FEED_LANDSCAPE_CARD_LAYOUT_2 = "number_of_columns_in_post_feed_landscape_card_layout_2"; public static final String DISABLE_NSFW_FOREVER = "disable_nsfw_forever"; + public static final String SHOW_ONLY_ONE_COMMENT_LEVEL_INDICATOR = "show_only_one_comment_level_indicator"; 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 492d8376..c3456e0e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -562,6 +562,7 @@ <string name="settings_crash_reports_title">Crash Reports</string> <string name="settings_nsfw_and_spoiler_dangerous_group_title">Dangerous</string> <string name="settings_disable_nsfw_forever_title">Disable NSFW Forever</string> + <string name="settings_show_only_one_comment_level_indicator">Show Only One Comment Level Indicator</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 2248d7f3..a9510dc5 100644 --- a/app/src/main/res/xml/comment_preferences.xml +++ b/app/src/main/res/xml/comment_preferences.xml @@ -14,6 +14,11 @@ <SwitchPreference app:defaultValue="false" + app:key="show_only_one_comment_level_indicator" + app:title="@string/settings_show_only_one_comment_level_indicator" /> + + <SwitchPreference + app:defaultValue="false" app:key="comment_toolbar_hidden" app:title="@string/settings_comment_toolbar_hidden" /> |