From b21eb89271d5818721e56b8198ddcddcc9875a61 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Mon, 10 May 2021 12:00:51 +0800 Subject: New option: Show Only One Comment Level Indicator. --- .../adapters/CommentAndPostRecyclerViewAdapter.java | 6 ++++++ .../customviews/CommentIndentationView.java | 18 +++++++++++++++--- .../utils/SharedPreferencesUtils.java | 1 + 3 files changed, 22 insertions(+), 3 deletions(-) (limited to 'app/src/main/java') 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 depthThreshold) { ((CommentViewHolder) holder).saveButton.setVisibility(View.GONE); @@ -1167,6 +1171,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter 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 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"; -- cgit v1.2.3