From c265bbecf9b613285de56cd0643ec94e364d4f5e Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Sat, 5 Feb 2022 15:19:18 +0800 Subject: New option: Settings->Interface->Comment->Hide Author Avatar. Fix Application ClassCastException in MainActivity. Don't show the number of child comments in expanded comments. --- .../adapters/CommentsRecyclerViewAdapter.java | 29 +++++++++++++++++++--- .../infinityforreddit/multireddit/MultiReddit.java | 2 +- .../subreddit/SubredditWithSelection.java | 1 - .../utils/SharedPreferencesUtils.java | 1 + 4 files changed, 27 insertions(+), 6 deletions(-) (limited to 'app/src/main/java/ml') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java index 89d9c58d..90626e4d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java @@ -115,6 +115,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter 0) { + if (comment.getChildCount() > 0 && !comment.isExpanded()) { ((CommentViewHolder) holder).expandButton.setText("+" + comment.getChildCount()); } if (comment.isExpanded()) { @@ -936,8 +938,9 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter { + authorTextView.performClick(); + }); + expandButton.setOnClickListener(view -> { if (expandButton.getVisibility() == View.VISIBLE) { int commentPosition = mIsSingleCommentThreadMode ? getBindingAdapterPosition() - 1 : getBindingAdapterPosition(); @@ -1523,6 +1534,9 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter 0) { + expandButton.setText("+" + comment.getChildCount()); + } expandButton.setCompoundDrawablesWithIntrinsicBounds(expandDrawable, null, null, null); } else { comment.setExpanded(true); @@ -1536,6 +1550,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter { int commentPosition = mIsSingleCommentThreadMode ? getBindingAdapterPosition() - 1 : getBindingAdapterPosition(); if (commentPosition >= 0 && commentPosition < mVisibleComments.size()) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/multireddit/MultiReddit.java b/app/src/main/java/ml/docilealligator/infinityforreddit/multireddit/MultiReddit.java index b010f9d2..518ee945 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/multireddit/MultiReddit.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/multireddit/MultiReddit.java @@ -253,6 +253,6 @@ public class MultiReddit implements Parcelable { parcel.writeByte((byte) (over18 ? 1 : 0)); parcel.writeByte((byte) (isSubscriber ? 1 : 0)); parcel.writeByte((byte) (isFavorite ? 1 : 0)); - parcel.writeStringList(subreddits); + parcel.writeList(subreddits); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditWithSelection.java b/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditWithSelection.java index 68eddfa1..8578d8c7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditWithSelection.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditWithSelection.java @@ -22,7 +22,6 @@ public class SubredditWithSelection implements Parcelable { } protected SubredditWithSelection(Parcel in) { - super(); name = in.readString(); iconUrl = in.readString(); selected = in.readByte() != 0; 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 6b1a30af..9c20f2f6 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java @@ -204,6 +204,7 @@ public class SharedPreferencesUtils { public static final String HIDE_TEXT_POST_CONTENT = "hide_text_post_content"; public static final String HIDE_COMMENT_AWARDS = "hide_comment_awards"; public static final String SHOW_FEWER_TOOLBAR_OPTIONS_THRESHOLD = "show_fewer_toolbar_options_threshold"; + public static final String SHOW_AUTHOR_AVATAR = "show_author_avatar"; 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