aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2021-05-10 04:00:51 +0000
committerAlex Ning <chineseperson5@gmail.com>2021-05-10 04:00:51 +0000
commitb21eb89271d5818721e56b8198ddcddcc9875a61 (patch)
tree9e902222f4442d810a6e4cbefd832bca0315a849 /app/src/main/java
parent39291be2e90b823d42fa83197ebf5783a2d3f04d (diff)
downloadinfinity-for-reddit-b21eb89271d5818721e56b8198ddcddcc9875a61.tar
infinity-for-reddit-b21eb89271d5818721e56b8198ddcddcc9875a61.tar.gz
infinity-for-reddit-b21eb89271d5818721e56b8198ddcddcc9875a61.tar.bz2
infinity-for-reddit-b21eb89271d5818721e56b8198ddcddcc9875a61.tar.lz
infinity-for-reddit-b21eb89271d5818721e56b8198ddcddcc9875a61.tar.xz
infinity-for-reddit-b21eb89271d5818721e56b8198ddcddcc9875a61.tar.zst
infinity-for-reddit-b21eb89271d5818721e56b8198ddcddcc9875a61.zip
New option: Show Only One Comment Level Indicator.
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/customviews/CommentIndentationView.java18
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java1
3 files changed, 22 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";