From 5172ae96a7b919532ea6054c2f3d98c5fe1ec4f7 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Tue, 17 Sep 2019 16:56:04 +0800 Subject: Change the color of the comment's vertical bar. Long press the comment to expand or collapse. Version 1.0.9. --- .idea/caches/build_file_checksums.ser | Bin 533 -> 533 bytes .idea/caches/gradle_models.ser | Bin 309044 -> 309044 bytes app/build.gradle | 4 +- .../CommentAndPostRecyclerViewAdapter.java | 89 +++++++++++++++++++-- app/src/main/res/values/colors.xml | 8 ++ 5 files changed, 91 insertions(+), 10 deletions(-) diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 395f790d..b153b848 100644 Binary files a/.idea/caches/build_file_checksums.ser and b/.idea/caches/build_file_checksums.ser differ diff --git a/.idea/caches/gradle_models.ser b/.idea/caches/gradle_models.ser index 85cca904..aff67652 100644 Binary files a/.idea/caches/gradle_models.ser and b/.idea/caches/gradle_models.ser differ diff --git a/app/build.gradle b/app/build.gradle index 31d92b75..ef840dfd 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,8 +6,8 @@ android { applicationId "ml.docilealligator.infinityforreddit" minSdkVersion 21 targetSdkVersion 29 - versionCode 9 - versionName "1.0.8" + versionCode 10 + versionName "1.0.9" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java index 158e48a0..b68628fb 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java @@ -515,6 +515,36 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter 0) { + switch (comment.getDepth() % 7) { + case 0: + ((CommentViewHolder) holder).verticalBlock + .setBackgroundColor(ContextCompat.getColor(mActivity, R.color.commentVerticalBar7)); + break; + case 1: + ((CommentViewHolder) holder).verticalBlock + .setBackgroundColor(ContextCompat.getColor(mActivity, R.color.commentVerticalBar1)); + break; + case 2: + ((CommentViewHolder) holder).verticalBlock + .setBackgroundColor(ContextCompat.getColor(mActivity, R.color.commentVerticalBar2)); + break; + case 3: + ((CommentViewHolder) holder).verticalBlock + .setBackgroundColor(ContextCompat.getColor(mActivity, R.color.commentVerticalBar3)); + break; + case 4: + ((CommentViewHolder) holder).verticalBlock + .setBackgroundColor(ContextCompat.getColor(mActivity, R.color.commentVerticalBar4)); + break; + case 5: + ((CommentViewHolder) holder).verticalBlock + .setBackgroundColor(ContextCompat.getColor(mActivity, R.color.commentVerticalBar5)); + break; + case 6: + ((CommentViewHolder) holder).verticalBlock + .setBackgroundColor(ContextCompat.getColor(mActivity, R.color.commentVerticalBar6)); + break; + } ViewGroup.LayoutParams params = ((CommentViewHolder) holder).verticalBlock.getLayoutParams(); params.width = 16; ((CommentViewHolder) holder).verticalBlock.setLayoutParams(params); @@ -724,6 +754,37 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter 0) { + switch (placeholder.getDepth() % 7) { + case 0: + ((LoadMoreChildCommentsViewHolder) holder).verticalBlock + .setBackgroundColor(ContextCompat.getColor(mActivity, R.color.commentVerticalBar7)); + break; + case 1: + ((LoadMoreChildCommentsViewHolder) holder).verticalBlock + .setBackgroundColor(ContextCompat.getColor(mActivity, R.color.commentVerticalBar1)); + break; + case 2: + ((LoadMoreChildCommentsViewHolder) holder).verticalBlock + .setBackgroundColor(ContextCompat.getColor(mActivity, R.color.commentVerticalBar2)); + break; + case 3: + ((LoadMoreChildCommentsViewHolder) holder).verticalBlock + .setBackgroundColor(ContextCompat.getColor(mActivity, R.color.commentVerticalBar3)); + break; + case 4: + ((LoadMoreChildCommentsViewHolder) holder).verticalBlock + .setBackgroundColor(ContextCompat.getColor(mActivity, R.color.commentVerticalBar4)); + break; + case 5: + ((LoadMoreChildCommentsViewHolder) holder).verticalBlock + .setBackgroundColor(ContextCompat.getColor(mActivity, R.color.commentVerticalBar5)); + break; + case 6: + ((LoadMoreChildCommentsViewHolder) holder).verticalBlock + .setBackgroundColor(ContextCompat.getColor(mActivity, R.color.commentVerticalBar6)); + break; + } + ViewGroup.LayoutParams params = ((LoadMoreChildCommentsViewHolder) holder).verticalBlock.getLayoutParams(); params.width = 16; ((LoadMoreChildCommentsViewHolder) holder).verticalBlock.setLayoutParams(params); @@ -1286,16 +1347,28 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter { - int commentPosition = mIsSingleCommentThreadMode ? getAdapterPosition() - 2 : getAdapterPosition() - 1; - if(mVisibleComments.get(commentPosition).isExpanded()) { - collapseChildren(commentPosition); - expandButton.setImageResource(R.drawable.ic_expand_more_black_20dp); - } else { - expandChildren(commentPosition); - mVisibleComments.get(commentPosition).setExpanded(true); - expandButton.setImageResource(R.drawable.ic_expand_less_black_20dp); + if(expandButton.getVisibility() == View.VISIBLE) { + int commentPosition = mIsSingleCommentThreadMode ? getAdapterPosition() - 2 : getAdapterPosition() - 1; + if(mVisibleComments.get(commentPosition).isExpanded()) { + collapseChildren(commentPosition); + expandButton.setImageResource(R.drawable.ic_expand_more_black_20dp); + } else { + expandChildren(commentPosition); + mVisibleComments.get(commentPosition).setExpanded(true); + expandButton.setImageResource(R.drawable.ic_expand_less_black_20dp); + } } }); + + commentMarkdownView.setOnLongClickListener(view -> { + expandButton.performClick(); + return true; + }); + + itemView.setOnLongClickListener(view -> { + expandButton.performClick(); + return true; + }); } } diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 6c8a40b5..82afbe60 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -61,4 +61,12 @@ @color/colorPrimary #8A000000 + + #1565C0 + #EE02BE + #02DFEE + #EED502 + #EE0220 + #02EE6E + #EE4602 -- cgit v1.2.3