diff options
Diffstat (limited to 'app/src/main/java')
4 files changed, 27 insertions, 6 deletions
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"; |