diff options
author | Thomas <github_ANoFA@itrooz.fr> | 2023-04-24 14:14:27 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-24 14:14:27 +0000 |
commit | 44a553efac0c39407059f8795a3133040259da99 (patch) | |
tree | 64a32cc137e7dfa2a892bde576082c67de188448 /app/src | |
parent | abb9acb4d8228cee6be245dcccfb12b4062b9d9a (diff) | |
download | infinity-for-reddit-44a553efac0c39407059f8795a3133040259da99.tar infinity-for-reddit-44a553efac0c39407059f8795a3133040259da99.tar.gz infinity-for-reddit-44a553efac0c39407059f8795a3133040259da99.tar.bz2 infinity-for-reddit-44a553efac0c39407059f8795a3133040259da99.tar.lz infinity-for-reddit-44a553efac0c39407059f8795a3133040259da99.tar.xz infinity-for-reddit-44a553efac0c39407059f8795a3133040259da99.tar.zst infinity-for-reddit-44a553efac0c39407059f8795a3133040259da99.zip |
Show if comments are edited (#1388)
Diffstat (limited to '')
6 files changed, 42 insertions, 2 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 de67008f..fa34151b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java @@ -459,6 +459,16 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi } else { ((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); @@ -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) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/comment/Comment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/comment/Comment.java index 67249175..8d981a44 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/comment/Comment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/comment/Comment.java @@ -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; + } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/comment/ParseComment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/comment/ParseComment.java index 3dc73765..55f9d872 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/comment/ParseComment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/comment/ParseComment.java @@ -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 diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/JSONUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/JSONUtils.java index 2726311a..7bd43af2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/JSONUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/JSONUtils.java @@ -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"; diff --git a/app/src/main/res/layout/item_comment.xml b/app/src/main/res/layout/item_comment.xml index 06ac8c02..cfe48e6f 100644 --- a/app/src/main/res/layout/item_comment.xml +++ b/app/src/main/res/layout/item_comment.xml @@ -69,6 +69,18 @@ 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" android:layout_height="wrap_content" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2b77b298..c46f1f3d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -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> |