From f7dd37baa415af840a5f4d4772770a6018ee7b2c Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Sun, 17 Sep 2023 21:42:40 -0400 Subject: Continue changing vote button icons. --- .../CommentsListingRecyclerViewAdapter.java | 257 +++++++++------- .../adapters/CommentsRecyclerViewAdapter.java | 342 ++++++++++++--------- .../adapters/HistoryPostRecyclerViewAdapter.java | 15 +- .../adapters/PostDetailRecyclerViewAdapter.java | 10 +- .../adapters/PostRecyclerViewAdapter.java | 15 +- .../fragments/CommentsListingFragment.java | 2 +- .../fragments/ViewPostDetailFragment.java | 2 +- 7 files changed, 372 insertions(+), 271 deletions(-) (limited to 'app/src/main/java') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java index 658fd10c..bebeb505 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java @@ -26,6 +26,9 @@ import androidx.recyclerview.widget.DiffUtil; import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.RecyclerView; +import com.google.android.material.button.MaterialButton; +import com.google.android.material.button.MaterialButtonToggleGroup; + import java.util.Locale; import butterknife.BindView; @@ -54,6 +57,7 @@ import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFi import ml.docilealligator.infinityforreddit.customviews.SpoilerOnClickTextView; import ml.docilealligator.infinityforreddit.customviews.SwipeLockInterface; import ml.docilealligator.infinityforreddit.customviews.SwipeLockLinearLayoutManager; +import ml.docilealligator.infinityforreddit.databinding.ItemCommentBinding; import ml.docilealligator.infinityforreddit.markdown.MarkdownUtils; import ml.docilealligator.infinityforreddit.utils.APIUtils; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; @@ -176,7 +180,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter= mDepthThreshold) { - ((CommentViewHolder) holder).saveButton.setVisibility(View.GONE); - ((CommentViewHolder) holder).replyButton.setVisibility(View.GONE); + ((CommentBaseViewHolder) holder).saveButton.setVisibility(View.GONE); + ((CommentBaseViewHolder) holder).replyButton.setVisibility(View.GONE); } else { - ((CommentViewHolder) holder).saveButton.setVisibility(View.VISIBLE); - ((CommentViewHolder) holder).replyButton.setVisibility(View.VISIBLE); + ((CommentBaseViewHolder) holder).saveButton.setVisibility(View.VISIBLE); + ((CommentBaseViewHolder) holder).replyButton.setVisibility(View.VISIBLE); } if (comment.hasReply()) { if (comment.getChildCount() > 0 && (mAlwaysShowChildCommentCount || !comment.isExpanded())) { - ((CommentViewHolder) holder).expandButton.setText("+" + comment.getChildCount()); + ((CommentBaseViewHolder) holder).expandButton.setText("+" + comment.getChildCount()); } if (comment.isExpanded()) { - ((CommentViewHolder) holder).expandButton.setCompoundDrawablesWithIntrinsicBounds(collapseDrawable, null, null, null); + ((CommentBaseViewHolder) holder).expandButton.setCompoundDrawablesWithIntrinsicBounds(collapseDrawable, null, null, null); } else { - ((CommentViewHolder) holder).expandButton.setCompoundDrawablesWithIntrinsicBounds(expandDrawable, null, null, null); + ((CommentBaseViewHolder) holder).expandButton.setCompoundDrawablesWithIntrinsicBounds(expandDrawable, null, null, null); } - ((CommentViewHolder) holder).expandButton.setVisibility(View.VISIBLE); + ((CommentBaseViewHolder) holder).expandButton.setVisibility(View.VISIBLE); } switch (comment.getVoteType()) { case Comment.VOTE_TYPE_UPVOTE: - ((CommentViewHolder) holder).upvoteButton - .setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN); - ((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor); - ((CommentViewHolder) holder).topScoreTextView.setTextColor(mUpvotedColor); + ((CommentBaseViewHolder) holder).upvoteButton.setTextColor(mUpvotedColor); + ((CommentBaseViewHolder) holder).upvoteButton.setIconResource(R.drawable.ic_upvote_filled_24dp); + ((CommentBaseViewHolder) holder).upvoteButton.setIconTint(ColorStateList.valueOf(mUpvotedColor)); + ((CommentBaseViewHolder) holder).topScoreTextView.setTextColor(mUpvotedColor); break; case Comment.VOTE_TYPE_DOWNVOTE: - ((CommentViewHolder) holder).downvoteButton - .setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN); - ((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor); - ((CommentViewHolder) holder).topScoreTextView.setTextColor(mDownvotedColor); + ((CommentBaseViewHolder) holder).downvoteButton.setIconResource(R.drawable.ic_downvote_filled_24dp); + ((CommentBaseViewHolder) holder).downvoteButton.setIconTint(ColorStateList.valueOf(mDownvotedColor)); + ((CommentBaseViewHolder) holder).topScoreTextView.setTextColor(mDownvotedColor); break; } if (mPost.isArchived()) { - ((CommentViewHolder) holder).replyButton - .setColorFilter(mVoteAndReplyUnavailableVoteButtonColor, - PorterDuff.Mode.SRC_IN); - ((CommentViewHolder) holder).upvoteButton - .setColorFilter(mVoteAndReplyUnavailableVoteButtonColor, - PorterDuff.Mode.SRC_IN); - ((CommentViewHolder) holder).downvoteButton + ((CommentBaseViewHolder) holder).replyButton .setColorFilter(mVoteAndReplyUnavailableVoteButtonColor, PorterDuff.Mode.SRC_IN); + ((CommentBaseViewHolder) holder).upvoteButton.setTextColor(mVoteAndReplyUnavailableVoteButtonColor); + ((CommentBaseViewHolder) holder).upvoteButton.setIconTint(ColorStateList.valueOf(mVoteAndReplyUnavailableVoteButtonColor)); + ((CommentBaseViewHolder) holder).downvoteButton.setIconTint(ColorStateList.valueOf(mVoteAndReplyUnavailableVoteButtonColor)); } if (mPost.isLocked()) { - ((CommentViewHolder) holder).replyButton + ((CommentBaseViewHolder) holder).replyButton .setColorFilter(mVoteAndReplyUnavailableVoteButtonColor, PorterDuff.Mode.SRC_IN); } if (comment.isSaved()) { - ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp); + ((CommentBaseViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp); } else { - ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp); + ((CommentBaseViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp); } if (position == mSearchCommentIndex) { @@ -1074,18 +1071,18 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter