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. --- app/src/main/AndroidManifest.xml | 2 +- .../adapters/CommentsRecyclerViewAdapter.java | 29 +++++++++++++++++++--- .../infinityforreddit/multireddit/MultiReddit.java | 2 +- .../subreddit/SubredditWithSelection.java | 1 - .../utils/SharedPreferencesUtils.java | 1 + .../res/layout/item_comment_fully_collapsed.xml | 3 ++- app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/comment_preferences.xml | 5 ++++ 8 files changed, 36 insertions(+), 8 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a9d52b11..3632c4a2 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -26,7 +26,7 @@ 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"; diff --git a/app/src/main/res/layout/item_comment_fully_collapsed.xml b/app/src/main/res/layout/item_comment_fully_collapsed.xml index 5bda1d1f..4e0a0d32 100644 --- a/app/src/main/res/layout/item_comment_fully_collapsed.xml +++ b/app/src/main/res/layout/item_comment_fully_collapsed.xml @@ -22,7 +22,8 @@ android:id="@+id/author_icon_image_view_item_comment_fully_collapsed" android:layout_width="24dp" android:layout_height="24dp" - android:layout_gravity="center_vertical" /> + android:layout_gravity="center_vertical" + android:visibility="gone" /> Hide Comment Awards Show Fewer Toolbar Options Starting From Level %1$d + Hide Author Avatar Cannot get the link diff --git a/app/src/main/res/xml/comment_preferences.xml b/app/src/main/res/xml/comment_preferences.xml index b7736545..76738f73 100644 --- a/app/src/main/res/xml/comment_preferences.xml +++ b/app/src/main/res/xml/comment_preferences.xml @@ -32,6 +32,11 @@ app:key="fully_collapse_comment" android:title="@string/settings_fully_collapse_comment_title" /> + +