mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-02-05 14:14:47 +01:00
Show if comments are edited (#1388)
This commit is contained in:
parent
abb9acb4d8
commit
44a553efac
@ -460,6 +460,16 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
||||
((CommentViewHolder) holder).scoreTextView.setText(mActivity.getString(R.string.vote));
|
||||
}
|
||||
|
||||
if(comment.isEdited()){
|
||||
((CommentViewHolder) holder).editedView.setText(R.string.edited);
|
||||
((CommentViewHolder) holder).editedView.setOnClickListener(view -> {
|
||||
Toast.makeText(view.getContext(), view.getContext().getString(R.string.edited_time, mShowElapsedTime ?
|
||||
Utils.getElapsedTime(mActivity, comment.getEditedTimeMillis()) :
|
||||
Utils.getFormattedTime(mLocale, comment.getEditedTimeMillis(), mTimeFormatPattern)
|
||||
), Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
}
|
||||
|
||||
((CommentViewHolder) holder).commentIndentationView.setShowOnlyOneDivider(mShowOnlyOneCommentLevelIndicator);
|
||||
((CommentViewHolder) holder).commentIndentationView.setLevelAndColors(comment.getDepth(), verticalBlockColors);
|
||||
if (comment.getDepth() >= mDepthThreshold) {
|
||||
@ -1181,6 +1191,8 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
||||
TextView awardsTextView;
|
||||
@BindView(R.id.comment_markdown_view_item_post_comment)
|
||||
RecyclerView commentMarkdownView;
|
||||
@BindView(R.id.edited_text_view_item_post_comment)
|
||||
TextView editedView;
|
||||
@BindView(R.id.bottom_constraint_layout_item_post_comment)
|
||||
ConstraintLayout bottomConstraintLayout;
|
||||
@BindView(R.id.up_vote_button_item_post_comment)
|
||||
|
@ -58,6 +58,7 @@ public class Comment implements Parcelable {
|
||||
private int placeholderType;
|
||||
private boolean isLoadingMoreChildren;
|
||||
private boolean loadMoreChildrenFailed;
|
||||
private long editedTimeMillis;
|
||||
|
||||
public Comment(String id, String fullName, String author, String authorFlair,
|
||||
String authorFlairHTML, String linkAuthor,
|
||||
@ -65,7 +66,7 @@ public class Comment implements Parcelable {
|
||||
String linkId, String subredditName, String parentId, int score,
|
||||
int voteType, boolean isSubmitter, String distinguished, String permalink,
|
||||
String awards, int depth, boolean collapsed, boolean hasReply,
|
||||
boolean scoreHidden, boolean saved) {
|
||||
boolean scoreHidden, boolean saved, long edited) {
|
||||
this.id = id;
|
||||
this.fullName = fullName;
|
||||
this.author = author;
|
||||
@ -91,6 +92,7 @@ public class Comment implements Parcelable {
|
||||
this.saved = saved;
|
||||
this.isExpanded = false;
|
||||
this.hasExpandedBefore = false;
|
||||
this.editedTimeMillis = edited;
|
||||
placeholderType = NOT_PLACEHOLDER;
|
||||
}
|
||||
|
||||
@ -435,4 +437,11 @@ public class Comment implements Parcelable {
|
||||
parcel.writeByte((byte) (isLoadingMoreChildren ? 1 : 0));
|
||||
parcel.writeByte((byte) (loadMoreChildrenFailed ? 1 : 0));
|
||||
}
|
||||
|
||||
public boolean isEdited() {
|
||||
return editedTimeMillis != 0;
|
||||
}
|
||||
public long getEditedTimeMillis() {
|
||||
return editedTimeMillis;
|
||||
}
|
||||
}
|
||||
|
@ -305,10 +305,13 @@ public class ParseComment {
|
||||
boolean collapsed = singleCommentData.getBoolean(JSONUtils.COLLAPSED_KEY);
|
||||
boolean hasReply = !(singleCommentData.get(JSONUtils.REPLIES_KEY) instanceof String);
|
||||
|
||||
// this key can either be a bool (false) or a long (edited timestamp)
|
||||
long edited = singleCommentData.optLong(JSONUtils.EDITED_KEY) * 1000;
|
||||
|
||||
return new Comment(id, fullName, author, authorFlair, authorFlairHTMLBuilder.toString(),
|
||||
linkAuthor, submitTime, commentMarkdown, commentRawText,
|
||||
linkId, subredditName, parentId, score, voteType, isSubmitter, distinguished,
|
||||
permalink, awardingsBuilder.toString(), depth, collapsed, hasReply, scoreHidden, saved);
|
||||
permalink, awardingsBuilder.toString(), depth, collapsed, hasReply, scoreHidden, saved, edited);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -92,6 +92,7 @@ public class JSONUtils {
|
||||
public static final String TEXT_EDITABLE_KEY = "text_editable";
|
||||
public static final String SUBJECT_KEY = "subject";
|
||||
public static final String CONTEXT_KEY = "context";
|
||||
public static final String EDITED_KEY = "edited";
|
||||
public static final String DISTINGUISHED_KEY = "distinguished";
|
||||
public static final String WAS_COMMENT_KEY = "was_comment";
|
||||
public static final String NEW_KEY = "new";
|
||||
|
@ -68,6 +68,18 @@
|
||||
app:layout_constraintTop_toBottomOf="@id/author_text_view_item_post_comment"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/edited_text_view_item_post_comment"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:gravity="end"
|
||||
android:textSize="?attr/font_default"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/top_score_text_view_item_post_comment"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/top_score_text_view_item_post_comment"
|
||||
android:layout_width="0dp"
|
||||
|
@ -1084,6 +1084,9 @@
|
||||
<string name="give_award_success">Award given</string>
|
||||
<string name="give_award_failed">Failed</string>
|
||||
|
||||
<string name="edited">Edited</string>
|
||||
<string name="edited_time">Edited on %s</string>
|
||||
|
||||
<string name="warning">Warning</string>
|
||||
<string name="this_is_a_nsfw_subreddit">This is a NSFW subreddit.</string>
|
||||
<string name="this_user_has_nsfw_content">This user has NSFW content</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user