diff options
author | Alex Ning <chineseperson5@gmail.com> | 2022-02-05 07:19:18 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2022-02-05 07:19:18 +0000 |
commit | c265bbecf9b613285de56cd0643ec94e364d4f5e (patch) | |
tree | 6a53384e3c8e29270ba8350c701c13af2df3bc24 | |
parent | 101525ae334b55cfcad887a64811c3b31ac8753a (diff) | |
download | infinity-for-reddit-c265bbecf9b613285de56cd0643ec94e364d4f5e.tar infinity-for-reddit-c265bbecf9b613285de56cd0643ec94e364d4f5e.tar.gz infinity-for-reddit-c265bbecf9b613285de56cd0643ec94e364d4f5e.tar.bz2 infinity-for-reddit-c265bbecf9b613285de56cd0643ec94e364d4f5e.tar.lz infinity-for-reddit-c265bbecf9b613285de56cd0643ec94e364d4f5e.tar.xz infinity-for-reddit-c265bbecf9b613285de56cd0643ec94e364d4f5e.tar.zst infinity-for-reddit-c265bbecf9b613285de56cd0643ec94e364d4f5e.zip |
New option: Settings->Interface->Comment->Hide Author Avatar. Fix Application ClassCastException in MainActivity. Don't show the number of child comments in expanded comments.
Diffstat (limited to '')
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 @@ <application android:name="ml.docilealligator.infinityforreddit.Infinity" - android:allowBackup="true" + android:allowBackup="false" android:icon="@mipmap/ic_launcher" android:label="@string/application_name" android:roundIcon="@mipmap/ic_launcher_round" 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<RecyclerVi private boolean mFullyCollapseComment; private boolean mShowOnlyOneCommentLevelIndicator; private boolean mHideCommentAwards; + private boolean mShowAuthorAvatar; private int mDepthThreshold; private CommentRecyclerViewAdapterCallback mCommentRecyclerViewAdapterCallback; private boolean isInitiallyLoading; @@ -237,6 +238,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi mFullyCollapseComment = sharedPreferences.getBoolean(SharedPreferencesUtils.FULLY_COLLAPSE_COMMENT, false); mShowOnlyOneCommentLevelIndicator = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ONLY_ONE_COMMENT_LEVEL_INDICATOR, false); mHideCommentAwards = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_COMMENT_AWARDS, false); + mShowAuthorAvatar = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_AUTHOR_AVATAR, false); mDepthThreshold = sharedPreferences.getInt(SharedPreferencesUtils.SHOW_FEWER_TOOLBAR_OPTIONS_THRESHOLD, 5); mCommentRecyclerViewAdapterCallback = commentRecyclerViewAdapterCallback; @@ -461,7 +463,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi } if (comment.hasReply()) { - if (comment.getChildCount() > 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<RecyclerVi public void initiallyLoading() { resetCommentSearchIndex(); - notifyItemRangeRemoved(0, getItemCount()); + int removedItemCount = getItemCount(); mVisibleComments.clear(); + notifyItemRangeRemoved(0, removedItemCount); isInitiallyLoading = true; isInitiallyLoadingFailed = false; notifyItemInserted(0); @@ -1224,7 +1227,12 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi commentMarkdownView.setTypeface(mActivity.contentTypeface); } - authorIconImageView.setVisibility(View.VISIBLE); + if (mShowAuthorAvatar) { + authorIconImageView.setVisibility(View.VISIBLE); + } else { + ((ConstraintLayout.LayoutParams) authorTextView.getLayoutParams()).leftMargin = 0; + ((ConstraintLayout.LayoutParams) authorFlairTextView.getLayoutParams()).leftMargin = 0; + } itemView.setBackgroundColor(mCommentBackgroundColor); authorTextView.setTextColor(mUsernameColor); @@ -1341,7 +1349,6 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi Utils.getNVotes(mShowAbsoluteNumberOfVotes, comment.getScore() + comment.getVoteType()))); - int position = getBindingAdapterPosition(); VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() { @Override public void onVoteThingSuccess(int position) { @@ -1516,6 +1523,10 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi } }); + authorIconImageView.setOnClickListener(view -> { + 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<RecyclerVi if (comment != null) { if (mVisibleComments.get(commentPosition).isExpanded()) { collapseChildren(commentPosition); + if (comment.getChildCount() > 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<RecyclerVi } else { notifyItemRangeInserted(commentPosition + 1, newList.size()); } + expandButton.setText(""); expandButton.setCompoundDrawablesWithIntrinsicBounds(collapseDrawable, null, null, null); } } @@ -1665,6 +1680,12 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi commentDivider.setVisibility(View.VISIBLE); } + if (mShowAuthorAvatar) { + authorIconImageView.setVisibility(View.VISIBLE); + } else { + usernameTextView.setPaddingRelative(0, usernameTextView.getPaddingTop(), usernameTextView.getPaddingEnd(), usernameTextView.getPaddingBottom()); + } + itemView.setOnClickListener(view -> { 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" /> <TextView android:id="@+id/user_name_text_view_item_comment_fully_collapsed" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 167b02eb..bcb4d083 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -629,6 +629,7 @@ <string name="settings_hide_comment_awards_title">Hide Comment Awards</string> <string name="settings_show_fewer_toolbar_options_threshold_title">Show Fewer Toolbar Options Starting From</string> <string name="settings_show_fewer_toolbar_options_threshold_summary">Level %1$d</string> + <string name="settings_show_author_avatar_title">Hide Author Avatar</string> <string name="no_link_available">Cannot get the link</string> 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 @@ -34,6 +34,11 @@ <ml.docilealligator.infinityforreddit.customviews.CustomFontSwitchPreference app:defaultValue="false" + app:key="show_author_avatar" + android:title="@string/settings_show_author_avatar_title" /> + + <ml.docilealligator.infinityforreddit.customviews.CustomFontSwitchPreference + app:defaultValue="false" app:key="hide_comment_awards" android:title="@string/settings_hide_comment_awards_title" /> |