Skip to content

Commit 5172ae9

Browse files
Change the color of the comment's vertical bar. Long press the comment to expand or collapse. Version 1.0.9.
1 parent ee5fc0a commit 5172ae9

File tree

5 files changed

+91
-10
lines changed

5 files changed

+91
-10
lines changed
0 Bytes
Binary file not shown.

.idea/caches/gradle_models.ser

0 Bytes
Binary file not shown.

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ android {
66
applicationId "ml.docilealligator.infinityforreddit"
77
minSdkVersion 21
88
targetSdkVersion 29
9-
versionCode 9
10-
versionName "1.0.8"
9+
versionCode 10
10+
versionName "1.0.9"
1111
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1212
}
1313
buildTypes {

app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java

Lines changed: 81 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,36 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi
515515

516516
((CommentViewHolder) holder).itemView.setPadding(comment.getDepth() * 16, 0, 0, 0);
517517
if(comment.getDepth() > 0) {
518+
switch (comment.getDepth() % 7) {
519+
case 0:
520+
((CommentViewHolder) holder).verticalBlock
521+
.setBackgroundColor(ContextCompat.getColor(mActivity, R.color.commentVerticalBar7));
522+
break;
523+
case 1:
524+
((CommentViewHolder) holder).verticalBlock
525+
.setBackgroundColor(ContextCompat.getColor(mActivity, R.color.commentVerticalBar1));
526+
break;
527+
case 2:
528+
((CommentViewHolder) holder).verticalBlock
529+
.setBackgroundColor(ContextCompat.getColor(mActivity, R.color.commentVerticalBar2));
530+
break;
531+
case 3:
532+
((CommentViewHolder) holder).verticalBlock
533+
.setBackgroundColor(ContextCompat.getColor(mActivity, R.color.commentVerticalBar3));
534+
break;
535+
case 4:
536+
((CommentViewHolder) holder).verticalBlock
537+
.setBackgroundColor(ContextCompat.getColor(mActivity, R.color.commentVerticalBar4));
538+
break;
539+
case 5:
540+
((CommentViewHolder) holder).verticalBlock
541+
.setBackgroundColor(ContextCompat.getColor(mActivity, R.color.commentVerticalBar5));
542+
break;
543+
case 6:
544+
((CommentViewHolder) holder).verticalBlock
545+
.setBackgroundColor(ContextCompat.getColor(mActivity, R.color.commentVerticalBar6));
546+
break;
547+
}
518548
ViewGroup.LayoutParams params = ((CommentViewHolder) holder).verticalBlock.getLayoutParams();
519549
params.width = 16;
520550
((CommentViewHolder) holder).verticalBlock.setLayoutParams(params);
@@ -724,6 +754,37 @@ public void onVoteThingFail(int position1) { }
724754

725755
((LoadMoreChildCommentsViewHolder) holder).itemView.setPadding(placeholder.getDepth() * 16, 0, 0, 0);
726756
if(placeholder.getDepth() > 0) {
757+
switch (placeholder.getDepth() % 7) {
758+
case 0:
759+
((LoadMoreChildCommentsViewHolder) holder).verticalBlock
760+
.setBackgroundColor(ContextCompat.getColor(mActivity, R.color.commentVerticalBar7));
761+
break;
762+
case 1:
763+
((LoadMoreChildCommentsViewHolder) holder).verticalBlock
764+
.setBackgroundColor(ContextCompat.getColor(mActivity, R.color.commentVerticalBar1));
765+
break;
766+
case 2:
767+
((LoadMoreChildCommentsViewHolder) holder).verticalBlock
768+
.setBackgroundColor(ContextCompat.getColor(mActivity, R.color.commentVerticalBar2));
769+
break;
770+
case 3:
771+
((LoadMoreChildCommentsViewHolder) holder).verticalBlock
772+
.setBackgroundColor(ContextCompat.getColor(mActivity, R.color.commentVerticalBar3));
773+
break;
774+
case 4:
775+
((LoadMoreChildCommentsViewHolder) holder).verticalBlock
776+
.setBackgroundColor(ContextCompat.getColor(mActivity, R.color.commentVerticalBar4));
777+
break;
778+
case 5:
779+
((LoadMoreChildCommentsViewHolder) holder).verticalBlock
780+
.setBackgroundColor(ContextCompat.getColor(mActivity, R.color.commentVerticalBar5));
781+
break;
782+
case 6:
783+
((LoadMoreChildCommentsViewHolder) holder).verticalBlock
784+
.setBackgroundColor(ContextCompat.getColor(mActivity, R.color.commentVerticalBar6));
785+
break;
786+
}
787+
727788
ViewGroup.LayoutParams params = ((LoadMoreChildCommentsViewHolder) holder).verticalBlock.getLayoutParams();
728789
params.width = 16;
729790
((LoadMoreChildCommentsViewHolder) holder).verticalBlock.setLayoutParams(params);
@@ -1286,16 +1347,28 @@ class CommentViewHolder extends RecyclerView.ViewHolder {
12861347
});
12871348

12881349
expandButton.setOnClickListener(view -> {
1289-
int commentPosition = mIsSingleCommentThreadMode ? getAdapterPosition() - 2 : getAdapterPosition() - 1;
1290-
if(mVisibleComments.get(commentPosition).isExpanded()) {
1291-
collapseChildren(commentPosition);
1292-
expandButton.setImageResource(R.drawable.ic_expand_more_black_20dp);
1293-
} else {
1294-
expandChildren(commentPosition);
1295-
mVisibleComments.get(commentPosition).setExpanded(true);
1296-
expandButton.setImageResource(R.drawable.ic_expand_less_black_20dp);
1350+
if(expandButton.getVisibility() == View.VISIBLE) {
1351+
int commentPosition = mIsSingleCommentThreadMode ? getAdapterPosition() - 2 : getAdapterPosition() - 1;
1352+
if(mVisibleComments.get(commentPosition).isExpanded()) {
1353+
collapseChildren(commentPosition);
1354+
expandButton.setImageResource(R.drawable.ic_expand_more_black_20dp);
1355+
} else {
1356+
expandChildren(commentPosition);
1357+
mVisibleComments.get(commentPosition).setExpanded(true);
1358+
expandButton.setImageResource(R.drawable.ic_expand_less_black_20dp);
1359+
}
12971360
}
12981361
});
1362+
1363+
commentMarkdownView.setOnLongClickListener(view -> {
1364+
expandButton.performClick();
1365+
return true;
1366+
});
1367+
1368+
itemView.setOnLongClickListener(view -> {
1369+
expandButton.performClick();
1370+
return true;
1371+
});
12991372
}
13001373
}
13011374

app/src/main/res/values/colors.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,12 @@
6161
<color name="notificationIconColor">@color/colorPrimary</color>
6262

6363
<color name="defaultTextColor">#8A000000</color>
64+
65+
<color name="commentVerticalBar1">#1565C0</color>
66+
<color name="commentVerticalBar2">#EE02BE</color>
67+
<color name="commentVerticalBar3">#02DFEE</color>
68+
<color name="commentVerticalBar4">#EED502</color>
69+
<color name="commentVerticalBar5">#EE0220</color>
70+
<color name="commentVerticalBar6">#02EE6E</color>
71+
<color name="commentVerticalBar7">#EE4602</color>
6472
</resources>

0 commit comments

Comments
 (0)