aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml/docilealligator/infinityforreddit
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/comment/Comment.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/comment/ParseComment.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/JSONUtils.java1
4 files changed, 27 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";