mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-29 04:17:12 +01:00
Fully collapsing comments is now available (barebone).
This commit is contained in:
parent
9a4edde8fb
commit
4f8b313b3c
@ -121,10 +121,11 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
private static final int VIEW_TYPE_FIRST_LOADING_FAILED = 8;
|
private static final int VIEW_TYPE_FIRST_LOADING_FAILED = 8;
|
||||||
private static final int VIEW_TYPE_NO_COMMENT_PLACEHOLDER = 9;
|
private static final int VIEW_TYPE_NO_COMMENT_PLACEHOLDER = 9;
|
||||||
private static final int VIEW_TYPE_COMMENT = 10;
|
private static final int VIEW_TYPE_COMMENT = 10;
|
||||||
private static final int VIEW_TYPE_LOAD_MORE_CHILD_COMMENTS = 11;
|
private static final int VIEW_TYPE_COMMENT_FULLY_COLLAPSED = 11;
|
||||||
private static final int VIEW_TYPE_IS_LOADING_MORE_COMMENTS = 12;
|
private static final int VIEW_TYPE_LOAD_MORE_CHILD_COMMENTS = 12;
|
||||||
private static final int VIEW_TYPE_LOAD_MORE_COMMENTS_FAILED = 13;
|
private static final int VIEW_TYPE_IS_LOADING_MORE_COMMENTS = 13;
|
||||||
private static final int VIEW_TYPE_VIEW_ALL_COMMENTS = 14;
|
private static final int VIEW_TYPE_LOAD_MORE_COMMENTS_FAILED = 14;
|
||||||
|
private static final int VIEW_TYPE_VIEW_ALL_COMMENTS = 15;
|
||||||
|
|
||||||
private AppCompatActivity mActivity;
|
private AppCompatActivity mActivity;
|
||||||
private Retrofit mRetrofit;
|
private Retrofit mRetrofit;
|
||||||
@ -156,6 +157,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
private boolean mAutoplay = false;
|
private boolean mAutoplay = false;
|
||||||
private boolean mAutoplayNsfwVideos;
|
private boolean mAutoplayNsfwVideos;
|
||||||
private boolean mMuteAutoplayingVideos;
|
private boolean mMuteAutoplayingVideos;
|
||||||
|
private boolean mFullyCollapseComment;
|
||||||
private CommentRecyclerViewAdapterCallback mCommentRecyclerViewAdapterCallback;
|
private CommentRecyclerViewAdapterCallback mCommentRecyclerViewAdapterCallback;
|
||||||
private boolean isInitiallyLoading;
|
private boolean isInitiallyLoading;
|
||||||
private boolean isInitiallyLoadingFailed;
|
private boolean isInitiallyLoadingFailed;
|
||||||
@ -322,6 +324,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
}
|
}
|
||||||
mAutoplayNsfwVideos = sharedPreferences.getBoolean(SharedPreferencesUtils.AUTOPLAY_NSFW_VIDEOS, true);
|
mAutoplayNsfwVideos = sharedPreferences.getBoolean(SharedPreferencesUtils.AUTOPLAY_NSFW_VIDEOS, true);
|
||||||
mMuteAutoplayingVideos = sharedPreferences.getBoolean(SharedPreferencesUtils.MUTE_AUTOPLAYING_VIDEOS, true);
|
mMuteAutoplayingVideos = sharedPreferences.getBoolean(SharedPreferencesUtils.MUTE_AUTOPLAYING_VIDEOS, true);
|
||||||
|
mFullyCollapseComment = sharedPreferences.getBoolean(SharedPreferencesUtils.FULLY_COLLAPSE_COMMENT, false);
|
||||||
|
|
||||||
mCommentRecyclerViewAdapterCallback = commentRecyclerViewAdapterCallback;
|
mCommentRecyclerViewAdapterCallback = commentRecyclerViewAdapterCallback;
|
||||||
isInitiallyLoading = true;
|
isInitiallyLoading = true;
|
||||||
@ -442,6 +445,9 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
|
|
||||||
CommentData comment = mVisibleComments.get(position - 2);
|
CommentData comment = mVisibleComments.get(position - 2);
|
||||||
if (!comment.isPlaceHolder()) {
|
if (!comment.isPlaceHolder()) {
|
||||||
|
if (mFullyCollapseComment && comment.hasReply() && !comment.isExpanded() && comment.hasExpandedBefore()) {
|
||||||
|
return VIEW_TYPE_COMMENT_FULLY_COLLAPSED;
|
||||||
|
}
|
||||||
return VIEW_TYPE_COMMENT;
|
return VIEW_TYPE_COMMENT;
|
||||||
} else {
|
} else {
|
||||||
return VIEW_TYPE_LOAD_MORE_CHILD_COMMENTS;
|
return VIEW_TYPE_LOAD_MORE_CHILD_COMMENTS;
|
||||||
@ -457,6 +463,9 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
|
|
||||||
CommentData comment = mVisibleComments.get(position - 1);
|
CommentData comment = mVisibleComments.get(position - 1);
|
||||||
if (!comment.isPlaceHolder()) {
|
if (!comment.isPlaceHolder()) {
|
||||||
|
if (mFullyCollapseComment && comment.hasReply() && !comment.isExpanded() && comment.hasExpandedBefore()) {
|
||||||
|
return VIEW_TYPE_COMMENT_FULLY_COLLAPSED;
|
||||||
|
}
|
||||||
return VIEW_TYPE_COMMENT;
|
return VIEW_TYPE_COMMENT;
|
||||||
} else {
|
} else {
|
||||||
return VIEW_TYPE_LOAD_MORE_CHILD_COMMENTS;
|
return VIEW_TYPE_LOAD_MORE_CHILD_COMMENTS;
|
||||||
@ -488,6 +497,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
return new NoCommentViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_no_comment_placeholder, parent, false));
|
return new NoCommentViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_no_comment_placeholder, parent, false));
|
||||||
case VIEW_TYPE_COMMENT:
|
case VIEW_TYPE_COMMENT:
|
||||||
return new CommentViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_comment, parent, false));
|
return new CommentViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_comment, parent, false));
|
||||||
|
case VIEW_TYPE_COMMENT_FULLY_COLLAPSED:
|
||||||
|
return new CommentFullyCollapsedViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_comment_fully_collapsed, parent, false));
|
||||||
case VIEW_TYPE_LOAD_MORE_CHILD_COMMENTS:
|
case VIEW_TYPE_LOAD_MORE_CHILD_COMMENTS:
|
||||||
return new LoadMoreChildCommentsViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_load_more_comments_placeholder, parent, false));
|
return new LoadMoreChildCommentsViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_load_more_comments_placeholder, parent, false));
|
||||||
case VIEW_TYPE_IS_LOADING_MORE_COMMENTS:
|
case VIEW_TYPE_IS_LOADING_MORE_COMMENTS:
|
||||||
@ -883,6 +894,59 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
} else {
|
} else {
|
||||||
((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
||||||
}
|
}
|
||||||
|
} else if (holder instanceof CommentFullyCollapsedViewHolder) {
|
||||||
|
CommentData comment;
|
||||||
|
if (mIsSingleCommentThreadMode) {
|
||||||
|
comment = mVisibleComments.get(holder.getAdapterPosition() - 2);
|
||||||
|
} else {
|
||||||
|
comment = mVisibleComments.get(holder.getAdapterPosition() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
String authorWithPrefix = "u/" + comment.getAuthor();
|
||||||
|
((CommentFullyCollapsedViewHolder) holder).usernameTextView.setText(authorWithPrefix);
|
||||||
|
if (comment.getMoreChildrenFullnames() != null) {
|
||||||
|
((CommentFullyCollapsedViewHolder) holder).nMoreRepliesTextView.setText(Integer.toString(1 + comment.getMoreChildrenFullnames().size()));
|
||||||
|
} else {
|
||||||
|
((CommentFullyCollapsedViewHolder) holder).nMoreRepliesTextView.setText(Integer.toString(1));
|
||||||
|
}
|
||||||
|
((CommentFullyCollapsedViewHolder) holder).scoreTextView.setText(Integer.toString(comment.getScore()));
|
||||||
|
|
||||||
|
((CommentFullyCollapsedViewHolder) holder).itemView.setPadding(comment.getDepth() * 8, 0, 0, 0);
|
||||||
|
if (comment.getDepth() > 0) {
|
||||||
|
switch (comment.getDepth() % 7) {
|
||||||
|
case 0:
|
||||||
|
((CommentFullyCollapsedViewHolder) holder).verticalBlock
|
||||||
|
.setBackgroundColor(mCommentVerticalBarColor7);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
((CommentFullyCollapsedViewHolder) holder).verticalBlock
|
||||||
|
.setBackgroundColor(mCommentVerticalBarColor1);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
((CommentFullyCollapsedViewHolder) holder).verticalBlock
|
||||||
|
.setBackgroundColor(mCommentVerticalBarColor2);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
((CommentFullyCollapsedViewHolder) holder).verticalBlock
|
||||||
|
.setBackgroundColor(mCommentVerticalBarColor3);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
((CommentFullyCollapsedViewHolder) holder).verticalBlock
|
||||||
|
.setBackgroundColor(mCommentVerticalBarColor4);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
((CommentFullyCollapsedViewHolder) holder).verticalBlock
|
||||||
|
.setBackgroundColor(mCommentVerticalBarColor5);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
((CommentFullyCollapsedViewHolder) holder).verticalBlock
|
||||||
|
.setBackgroundColor(mCommentVerticalBarColor6);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ViewGroup.LayoutParams params = ((CommentFullyCollapsedViewHolder) holder).verticalBlock.getLayoutParams();
|
||||||
|
params.width = 8;
|
||||||
|
((CommentFullyCollapsedViewHolder) holder).verticalBlock.setLayoutParams(params);
|
||||||
|
}
|
||||||
} else if (holder instanceof LoadMoreChildCommentsViewHolder) {
|
} else if (holder instanceof LoadMoreChildCommentsViewHolder) {
|
||||||
CommentData placeholder;
|
CommentData placeholder;
|
||||||
placeholder = mIsSingleCommentThreadMode ? mVisibleComments.get(holder.getAdapterPosition() - 2)
|
placeholder = mIsSingleCommentThreadMode ? mVisibleComments.get(holder.getAdapterPosition() - 2)
|
||||||
@ -1251,8 +1315,14 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
|
|
||||||
mVisibleComments.subList(position + 1, position + 1 + allChildrenSize).clear();
|
mVisibleComments.subList(position + 1, position + 1 + allChildrenSize).clear();
|
||||||
if (mIsSingleCommentThreadMode) {
|
if (mIsSingleCommentThreadMode) {
|
||||||
|
if (mFullyCollapseComment) {
|
||||||
|
notifyItemChanged(position + 2);
|
||||||
|
}
|
||||||
notifyItemRangeRemoved(position + 3, allChildrenSize);
|
notifyItemRangeRemoved(position + 3, allChildrenSize);
|
||||||
} else {
|
} else {
|
||||||
|
if (mFullyCollapseComment) {
|
||||||
|
notifyItemChanged(position + 1);
|
||||||
|
}
|
||||||
notifyItemRangeRemoved(position + 2, allChildrenSize);
|
notifyItemRangeRemoved(position + 2, allChildrenSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1490,6 +1560,11 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
((CommentViewHolder) holder).verticalBlock.setLayoutParams(params);
|
((CommentViewHolder) holder).verticalBlock.setLayoutParams(params);
|
||||||
((CommentViewHolder) holder).itemView.setPadding(0, 0, 0, 0);
|
((CommentViewHolder) holder).itemView.setPadding(0, 0, 0, 0);
|
||||||
((CommentViewHolder) holder).itemView.setBackgroundColor(mCommentBackgroundColor);
|
((CommentViewHolder) holder).itemView.setBackgroundColor(mCommentBackgroundColor);
|
||||||
|
} else if (holder instanceof CommentFullyCollapsedViewHolder) {
|
||||||
|
ViewGroup.LayoutParams params = ((CommentFullyCollapsedViewHolder) holder).verticalBlock.getLayoutParams();
|
||||||
|
params.width = 0;
|
||||||
|
((CommentFullyCollapsedViewHolder) holder).verticalBlock.setLayoutParams(params);
|
||||||
|
((CommentFullyCollapsedViewHolder) holder).itemView.setPadding(0, 0, 0, 0);
|
||||||
} else if (holder instanceof PostDetailBaseViewHolder) {
|
} else if (holder instanceof PostDetailBaseViewHolder) {
|
||||||
((PostDetailBaseViewHolder) holder).mUpvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((PostDetailBaseViewHolder) holder).mUpvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((PostDetailBaseViewHolder) holder).mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
((PostDetailBaseViewHolder) holder).mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
||||||
@ -2724,7 +2799,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
authorFlairTextView.setOnClickListener(view -> authorTextView.performClick());
|
authorFlairTextView.setOnClickListener(view -> authorTextView.performClick());
|
||||||
|
|
||||||
moreButton.setOnClickListener(view -> {
|
moreButton.setOnClickListener(view -> {
|
||||||
CommentData comment = getCurrentComment();
|
CommentData comment = getCurrentComment(this);
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
if (!mPost.isArchived() && !mPost.isLocked() && comment.getAuthor().equals(mAccountName)) {
|
if (!mPost.isArchived() && !mPost.isLocked() && comment.getAuthor().equals(mAccountName)) {
|
||||||
bundle.putString(CommentMoreBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
bundle.putString(CommentMoreBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||||
@ -2756,7 +2831,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommentData comment = getCurrentComment();
|
CommentData comment = getCurrentComment(this);
|
||||||
|
|
||||||
Intent intent = new Intent(mActivity, CommentActivity.class);
|
Intent intent = new Intent(mActivity, CommentActivity.class);
|
||||||
intent.putExtra(CommentActivity.EXTRA_PARENT_DEPTH_KEY, comment.getDepth() + 1);
|
intent.putExtra(CommentActivity.EXTRA_PARENT_DEPTH_KEY, comment.getDepth() + 1);
|
||||||
@ -2781,7 +2856,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommentData comment = getCurrentComment();
|
CommentData comment = getCurrentComment(this);
|
||||||
int previousVoteType = comment.getVoteType();
|
int previousVoteType = comment.getVoteType();
|
||||||
String newVoteType;
|
String newVoteType;
|
||||||
|
|
||||||
@ -2843,7 +2918,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommentData comment = getCurrentComment();
|
CommentData comment = getCurrentComment(this);
|
||||||
int previousVoteType = comment.getVoteType();
|
int previousVoteType = comment.getVoteType();
|
||||||
String newVoteType;
|
String newVoteType;
|
||||||
|
|
||||||
@ -2895,7 +2970,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
});
|
});
|
||||||
|
|
||||||
saveButton.setOnClickListener(view -> {
|
saveButton.setOnClickListener(view -> {
|
||||||
CommentData comment = getCurrentComment();
|
CommentData comment = getCurrentComment(this);
|
||||||
if (comment.isSaved()) {
|
if (comment.isSaved()) {
|
||||||
comment.setSaved(false);
|
comment.setSaved(false);
|
||||||
SaveThing.unsaveThing(mOauthRetrofit, mAccessToken, comment.getFullName(), new SaveThing.SaveThingListener() {
|
SaveThing.unsaveThing(mOauthRetrofit, mAccessToken, comment.getFullName(), new SaveThing.SaveThingListener() {
|
||||||
@ -2935,7 +3010,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
|
|
||||||
authorTextView.setOnClickListener(view -> {
|
authorTextView.setOnClickListener(view -> {
|
||||||
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
|
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
|
||||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, getCurrentComment().getAuthor());
|
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, getCurrentComment(this).getAuthor());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -2943,7 +3018,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
if (expandButton.getVisibility() == View.VISIBLE) {
|
if (expandButton.getVisibility() == View.VISIBLE) {
|
||||||
int commentPosition = mIsSingleCommentThreadMode ? getAdapterPosition() - 2 : getAdapterPosition() - 1;
|
int commentPosition = mIsSingleCommentThreadMode ? getAdapterPosition() - 2 : getAdapterPosition() - 1;
|
||||||
if (commentPosition >= 0 && commentPosition < mVisibleComments.size()) {
|
if (commentPosition >= 0 && commentPosition < mVisibleComments.size()) {
|
||||||
CommentData comment = getCurrentComment();
|
CommentData comment = getCurrentComment(this);
|
||||||
if (mVisibleComments.get(commentPosition).isExpanded()) {
|
if (mVisibleComments.get(commentPosition).isExpanded()) {
|
||||||
collapseChildren(commentPosition);
|
collapseChildren(commentPosition);
|
||||||
expandButton.setImageResource(R.drawable.ic_expand_more_grey_24dp);
|
expandButton.setImageResource(R.drawable.ic_expand_more_grey_24dp);
|
||||||
@ -3005,17 +3080,65 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private CommentData getCurrentComment() {
|
private CommentData getCurrentComment(RecyclerView.ViewHolder holder) {
|
||||||
CommentData comment;
|
CommentData comment;
|
||||||
if (mIsSingleCommentThreadMode) {
|
if (mIsSingleCommentThreadMode) {
|
||||||
comment = mVisibleComments.get(getAdapterPosition() - 2);
|
comment = mVisibleComments.get(holder.getAdapterPosition() - 2);
|
||||||
} else {
|
} else {
|
||||||
comment = mVisibleComments.get(getAdapterPosition() - 1);
|
comment = mVisibleComments.get(holder.getAdapterPosition() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return comment;
|
return comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class CommentFullyCollapsedViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
@BindView(R.id.vertical_block_item_comment_fully_collapsed)
|
||||||
|
View verticalBlock;
|
||||||
|
@BindView(R.id.user_name_text_view_item_comment_fully_collapsed)
|
||||||
|
TextView usernameTextView;
|
||||||
|
@BindView(R.id.score_text_view_item_comment_fully_collapsed)
|
||||||
|
TextView scoreTextView;
|
||||||
|
@BindView(R.id.more_count_text_view_item_comment_fully_collapsed)
|
||||||
|
TextView nMoreRepliesTextView;
|
||||||
|
@BindView(R.id.divider_item_load_comment_fully_collapsed)
|
||||||
|
View commentDivider;
|
||||||
|
|
||||||
|
public CommentFullyCollapsedViewHolder(@NonNull View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
ButterKnife.bind(this, itemView);
|
||||||
|
|
||||||
|
if (mShowCommentDivider) {
|
||||||
|
commentDivider.setBackgroundColor(mDividerColor);
|
||||||
|
commentDivider.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
itemView.setOnClickListener(view -> {
|
||||||
|
int commentPosition = mIsSingleCommentThreadMode ? getAdapterPosition() - 2 : getAdapterPosition() - 1;
|
||||||
|
if (commentPosition >= 0 && commentPosition < mVisibleComments.size()) {
|
||||||
|
CommentData comment = getCurrentComment(this);
|
||||||
|
comment.setExpanded(true);
|
||||||
|
ArrayList<CommentData> newList = new ArrayList<>();
|
||||||
|
expandChildren(mVisibleComments.get(commentPosition).getChildren(), newList, 0);
|
||||||
|
mVisibleComments.get(commentPosition).setExpanded(true);
|
||||||
|
mVisibleComments.addAll(commentPosition + 1, newList);
|
||||||
|
|
||||||
|
if (mIsSingleCommentThreadMode) {
|
||||||
|
notifyItemChanged(commentPosition + 2);
|
||||||
|
notifyItemRangeInserted(commentPosition + 3, newList.size());
|
||||||
|
} else {
|
||||||
|
notifyItemChanged(commentPosition + 1);
|
||||||
|
notifyItemRangeInserted(commentPosition + 2, newList.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
itemView.setOnLongClickListener(view -> {
|
||||||
|
itemView.performClick();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadMoreChildCommentsViewHolder extends RecyclerView.ViewHolder {
|
class LoadMoreChildCommentsViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
@ -46,6 +46,7 @@ public class CommentData implements Parcelable {
|
|||||||
private boolean scoreHidden;
|
private boolean scoreHidden;
|
||||||
private boolean saved;
|
private boolean saved;
|
||||||
private boolean isExpanded;
|
private boolean isExpanded;
|
||||||
|
private boolean hasExpandedBefore;
|
||||||
private ArrayList<CommentData> children;
|
private ArrayList<CommentData> children;
|
||||||
private ArrayList<String> moreChildrenFullnames;
|
private ArrayList<String> moreChildrenFullnames;
|
||||||
private int moreChildrenStartingIndex;
|
private int moreChildrenStartingIndex;
|
||||||
@ -84,6 +85,7 @@ public class CommentData implements Parcelable {
|
|||||||
this.scoreHidden = scoreHidden;
|
this.scoreHidden = scoreHidden;
|
||||||
this.saved = saved;
|
this.saved = saved;
|
||||||
this.isExpanded = false;
|
this.isExpanded = false;
|
||||||
|
this.hasExpandedBefore = false;
|
||||||
moreChildrenStartingIndex = 0;
|
moreChildrenStartingIndex = 0;
|
||||||
isPlaceHolder = false;
|
isPlaceHolder = false;
|
||||||
}
|
}
|
||||||
@ -120,6 +122,7 @@ public class CommentData implements Parcelable {
|
|||||||
hasReply = in.readByte() != 0;
|
hasReply = in.readByte() != 0;
|
||||||
scoreHidden = in.readByte() != 0;
|
scoreHidden = in.readByte() != 0;
|
||||||
isExpanded = in.readByte() != 0;
|
isExpanded = in.readByte() != 0;
|
||||||
|
hasExpandedBefore = in.readByte() != 0;
|
||||||
children = in.readArrayList(CommentData.class.getClassLoader());
|
children = in.readArrayList(CommentData.class.getClassLoader());
|
||||||
moreChildrenFullnames = in.readArrayList(CommentData.class.getClassLoader());
|
moreChildrenFullnames = in.readArrayList(CommentData.class.getClassLoader());
|
||||||
moreChildrenStartingIndex = in.readInt();
|
moreChildrenStartingIndex = in.readInt();
|
||||||
@ -250,6 +253,13 @@ public class CommentData implements Parcelable {
|
|||||||
|
|
||||||
public void setExpanded(boolean isExpanded) {
|
public void setExpanded(boolean isExpanded) {
|
||||||
this.isExpanded = isExpanded;
|
this.isExpanded = isExpanded;
|
||||||
|
if (isExpanded && !hasExpandedBefore) {
|
||||||
|
hasExpandedBefore = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasExpandedBefore() {
|
||||||
|
return hasExpandedBefore;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getVoteType() {
|
public int getVoteType() {
|
||||||
@ -365,6 +375,7 @@ public class CommentData implements Parcelable {
|
|||||||
parcel.writeByte((byte) (hasReply ? 1 : 0));
|
parcel.writeByte((byte) (hasReply ? 1 : 0));
|
||||||
parcel.writeByte((byte) (scoreHidden ? 1 : 0));
|
parcel.writeByte((byte) (scoreHidden ? 1 : 0));
|
||||||
parcel.writeByte((byte) (isExpanded ? 1 : 0));
|
parcel.writeByte((byte) (isExpanded ? 1 : 0));
|
||||||
|
parcel.writeByte((byte) (hasExpandedBefore ? 1 : 0));
|
||||||
parcel.writeList(children);
|
parcel.writeList(children);
|
||||||
parcel.writeList(moreChildrenFullnames);
|
parcel.writeList(moreChildrenFullnames);
|
||||||
parcel.writeInt(moreChildrenStartingIndex);
|
parcel.writeInt(moreChildrenStartingIndex);
|
||||||
|
@ -99,6 +99,7 @@ public class SharedPreferencesUtils {
|
|||||||
public static final String LOCK_BOTTOM_APP_BAR = "lock_bottom_app_bar";
|
public static final String LOCK_BOTTOM_APP_BAR = "lock_bottom_app_bar";
|
||||||
public static final String COMMENT_TOOLBAR_HIDDEN = "comment_toolbar_hidden";
|
public static final String COMMENT_TOOLBAR_HIDDEN = "comment_toolbar_hidden";
|
||||||
public static final String COMMENT_TOOLBAR_HIDE_ON_CLICK = "comment_toolbar_hide_on_click";
|
public static final String COMMENT_TOOLBAR_HIDE_ON_CLICK = "comment_toolbar_hide_on_click";
|
||||||
|
public static final String FULLY_COLLAPSE_COMMENT = "fully_collapse_comment";
|
||||||
public static final String SHOW_COMMENT_DIVIDER = "show_comment_divider";
|
public static final String SHOW_COMMENT_DIVIDER = "show_comment_divider";
|
||||||
public static final String SHOW_ABSOLUTE_NUMBER_OF_VOTES = "show_absolute_number_of_votes";
|
public static final String SHOW_ABSOLUTE_NUMBER_OF_VOTES = "show_absolute_number_of_votes";
|
||||||
public static final String CUSTOMIZE_LIGHT_THEME = "customize_light_theme";
|
public static final String CUSTOMIZE_LIGHT_THEME = "customize_light_theme";
|
||||||
|
@ -121,6 +121,7 @@
|
|||||||
android:text="@string/see_removed_comment"
|
android:text="@string/see_removed_comment"
|
||||||
android:textColor="?attr/primaryTextColor"
|
android:textColor="?attr/primaryTextColor"
|
||||||
android:textSize="?attr/font_default"
|
android:textSize="?attr/font_default"
|
||||||
|
android:fontFamily="?attr/font_family"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
56
app/src/main/res/layout/item_comment_fully_collapsed.xml
Normal file
56
app/src/main/res/layout/item_comment_fully_collapsed.xml
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/vertical_block_item_comment_fully_collapsed"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/user_name_text_view_item_comment_fully_collapsed"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:paddingTop="8dp"
|
||||||
|
android:paddingBottom="8dp"
|
||||||
|
android:paddingStart="16dp"
|
||||||
|
android:paddingEnd="8dp"
|
||||||
|
android:textSize="?attr/font_default"
|
||||||
|
android:fontFamily="?attr/font_family" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/score_text_view_item_comment_fully_collapsed"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:textSize="?attr/font_default"
|
||||||
|
android:fontFamily="?attr/font_family" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/more_count_text_view_item_comment_fully_collapsed"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="end"
|
||||||
|
android:paddingTop="8dp"
|
||||||
|
android:paddingBottom="8dp"
|
||||||
|
android:paddingStart="8dp"
|
||||||
|
android:paddingEnd="16dp"
|
||||||
|
android:textSize="?attr/font_default"
|
||||||
|
android:fontFamily="?attr/font_family" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/divider_item_load_comment_fully_collapsed"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -352,6 +352,7 @@
|
|||||||
<string name="settings_show_top_level_comments_first_title">Show Top-level Comments First</string>
|
<string name="settings_show_top_level_comments_first_title">Show Top-level Comments First</string>
|
||||||
<string name="settings_show_comment_divider_title">Show Comment Divider</string>
|
<string name="settings_show_comment_divider_title">Show Comment Divider</string>
|
||||||
<string name="settings_comment_toolbar_hide_on_click">Click to Show/Hide Comment Toolbar</string>
|
<string name="settings_comment_toolbar_hide_on_click">Click to Show/Hide Comment Toolbar</string>
|
||||||
|
<string name="settings_fully_collapse_comment_title">Fully Collapse Comment</string>
|
||||||
<string name="settings_comment_toolbar_hidden">Comment Toolbar Hidden by Default</string>
|
<string name="settings_comment_toolbar_hidden">Comment Toolbar Hidden by Default</string>
|
||||||
<string name="settings_show_absolute_number_of_votes_title">Show Absolute Number of Votes</string>
|
<string name="settings_show_absolute_number_of_votes_title">Show Absolute Number of Votes</string>
|
||||||
<string name="settings_show_elapsed_time">Show Elapsed Time in Posts and Comments</string>
|
<string name="settings_show_elapsed_time">Show Elapsed Time in Posts and Comments</string>
|
||||||
|
@ -69,6 +69,11 @@
|
|||||||
app:key="comment_toolbar_hide_on_click"
|
app:key="comment_toolbar_hide_on_click"
|
||||||
app:title="@string/settings_comment_toolbar_hide_on_click" />
|
app:title="@string/settings_comment_toolbar_hide_on_click" />
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
app:defaultValue="false"
|
||||||
|
app:key="fully_collapse_comment"
|
||||||
|
android:title="@string/settings_fully_collapse_comment_title" />
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
app:defaultValue="true"
|
app:defaultValue="true"
|
||||||
app:key="show_absolute_number_of_votes"
|
app:key="show_absolute_number_of_votes"
|
||||||
|
Loading…
Reference in New Issue
Block a user