New option: Settings->Interface->Comment->Hide Author Avatar. Fix Application ClassCastException in MainActivity. Don't show the number of child comments in expanded comments.

This commit is contained in:
Alex Ning 2022-02-05 15:19:18 +08:00
parent 101525ae33
commit c265bbecf9
8 changed files with 36 additions and 8 deletions

View File

@ -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"

View File

@ -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);
}
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()) {

View File

@ -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);
}
}

View File

@ -22,7 +22,6 @@ public class SubredditWithSelection implements Parcelable {
}
protected SubredditWithSelection(Parcel in) {
super();
name = in.readString();
iconUrl = in.readString();
selected = in.readByte() != 0;

View File

@ -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";

View File

@ -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"

View File

@ -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>

View File

@ -32,6 +32,11 @@
app:key="fully_collapse_comment"
android:title="@string/settings_fully_collapse_comment_title" />
<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"