aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/comment/Comment.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java48
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java17
6 files changed, 72 insertions, 23 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java
index db7abf03..c9b5af10 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java
@@ -164,6 +164,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
private int mPostTypeTextColor;
private int mSubredditColor;
private int mUsernameColor;
+ private int mModeratorColor;
private int mSpoilerBackgroundColor;
private int mSpoilerTextColor;
private int mFlairBackgroundColor;
@@ -306,6 +307,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
mPostTypeTextColor = customThemeWrapper.getPostTypeTextColor();
mSubredditColor = customThemeWrapper.getSubreddit();
mUsernameColor = customThemeWrapper.getUsername();
+ mModeratorColor = customThemeWrapper.getModerator();
mSpoilerBackgroundColor = customThemeWrapper.getSpoilerBackgroundColor();
mSpoilerTextColor = customThemeWrapper.getSpoilerTextColor();
mFlairBackgroundColor = customThemeWrapper.getFlairBackgroundColor();
@@ -499,6 +501,9 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
((PostBaseViewHolder) holder).userTextView.setText(authorPrefixed);
}
+ ((PostBaseViewHolder) holder).userTextView.setTextColor(
+ post.isModerator() ? mModeratorColor : mUsernameColor);
+
if (mDisplaySubredditName) {
if (authorPrefixed.equals(post.getSubredditNamePrefixed())) {
if (post.getAuthorIconUrl() == null) {
@@ -1152,7 +1157,8 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
.into(((PostCompactBaseViewHolder) holder).iconGifImageView);
}
- ((PostCompactBaseViewHolder) holder).nameTextView.setTextColor(mUsernameColor);
+ ((PostCompactBaseViewHolder) holder).nameTextView.setTextColor(
+ post.isModerator() ? mModeratorColor : mUsernameColor);
if (mHideSubredditAndUserPrefix) {
((PostCompactBaseViewHolder) holder).nameTextView.setText(post.getAuthor());
} else {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
index cc888d26..463caeaf 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
@@ -180,6 +180,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
private int mPostTypeTextColor;
private int mSubredditColor;
private int mUsernameColor;
+ private int mModeratorColor;
private int mAuthorFlairTextColor;
private int mSpoilerBackgroundColor;
private int mSpoilerTextColor;
@@ -363,6 +364,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
mFlairTextColor = customThemeWrapper.getFlairTextColor();
mSubredditColor = customThemeWrapper.getSubreddit();
mUsernameColor = customThemeWrapper.getUsername();
+ mModeratorColor = customThemeWrapper.getModerator();
mUpvotedColor = customThemeWrapper.getUpvoted();
mDownvotedColor = customThemeWrapper.getDownvoted();
mVoteAndReplyUnavailableVoteButtonColor = customThemeWrapper.getVoteAndReplyUnavailableButtonColor();
@@ -575,6 +577,13 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
((PostDetailBaseViewHolder) holder).mUserTextView.setText(mPost.getAuthor());
}
+ if (mPost.isModerator()) {
+ ((PostDetailBaseViewHolder) holder).mUserTextView.setTextColor(mModeratorColor);
+ Drawable moderatorDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mModeratorColor);
+ ((PostDetailBaseViewHolder) holder).mUserTextView.setCompoundDrawablesWithIntrinsicBounds(
+ moderatorDrawable, null, null, null);
+ }
+
if (mShowElapsedTime) {
((PostDetailBaseViewHolder) holder).mPostTimeTextView.setText(
Utils.getElapsedTime(mActivity, mPost.getPostTimeMillis()));
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
index ac2df45d..2186de0b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
@@ -171,6 +171,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
private int mPostTypeTextColor;
private int mSubredditColor;
private int mUsernameColor;
+ private int mModeratorColor;
private int mSpoilerBackgroundColor;
private int mSpoilerTextColor;
private int mFlairBackgroundColor;
@@ -326,6 +327,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
mPostTypeTextColor = customThemeWrapper.getPostTypeTextColor();
mSubredditColor = customThemeWrapper.getSubreddit();
mUsernameColor = customThemeWrapper.getUsername();
+ mModeratorColor = customThemeWrapper.getModerator();
mSpoilerBackgroundColor = customThemeWrapper.getSpoilerBackgroundColor();
mSpoilerTextColor = customThemeWrapper.getSpoilerTextColor();
mFlairBackgroundColor = customThemeWrapper.getFlairBackgroundColor();
@@ -530,6 +532,9 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostBaseViewHolder) holder).userTextView.setText(authorPrefixed);
}
+ ((PostBaseViewHolder) holder).userTextView.setTextColor(
+ post.isModerator() ? mModeratorColor : mUsernameColor);
+
if (mDisplaySubredditName) {
if (authorPrefixed.equals(post.getSubredditNamePrefixed())) {
if (post.getAuthorIconUrl() == null) {
@@ -1205,7 +1210,9 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
.into(((PostCompactBaseViewHolder) holder).iconGifImageView);
}
- ((PostCompactBaseViewHolder) holder).nameTextView.setTextColor(mUsernameColor);
+ ((PostCompactBaseViewHolder) holder).nameTextView.setTextColor(
+ post.isModerator() ? mModeratorColor : mUsernameColor);
+
if (mHideSubredditAndUserPrefix) {
((PostCompactBaseViewHolder) holder).nameTextView.setText(post.getAuthor());
} else {
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 c296b8ac..67249175 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/comment/Comment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/comment/Comment.java
@@ -243,6 +243,10 @@ public class Comment implements Parcelable {
return distinguished != null && distinguished.equals("moderator");
}
+ public boolean isAdmin() {
+ return distinguished != null && distinguished.equals("admin");
+ }
+
public String getPermalink() {
return permalink;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java
index f937cfcc..8afc0e58 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java
@@ -146,6 +146,7 @@ public class ParsePost {
}
}
String authorFlair = data.isNull(JSONUtils.AUTHOR_FLAIR_TEXT_KEY) ? "" : data.getString(JSONUtils.AUTHOR_FLAIR_TEXT_KEY);
+ String distinguished = data.getString(JSONUtils.DISTINGUISHED_KEY);
long postTime = data.getLong(JSONUtils.CREATED_UTC_KEY) * 1000;
String title = data.getString(JSONUtils.TITLE_KEY);
int score = data.getInt(JSONUtils.SCORE_KEY);
@@ -234,7 +235,8 @@ public class ParsePost {
author, authorFlair, authorFlairHTMLBuilder.toString(),
postTime, title, previews,
score, voteType, nComments, upvoteRatio, flair, awardingsBuilder.toString(), nAwards, hidden,
- spoiler, nsfw, stickied, archived, locked, saved, deleted, removed, true);
+ spoiler, nsfw, stickied, archived, locked, saved, deleted, removed, true,
+ distinguished);
post.setCrosspostParentId(crosspostParent.getId());
return post;
} else {
@@ -242,7 +244,8 @@ public class ParsePost {
author, authorFlair, authorFlairHTMLBuilder.toString(),
postTime, title, previews,
score, voteType, nComments, upvoteRatio, flair, awardingsBuilder.toString(), nAwards, hidden,
- spoiler, nsfw, stickied, archived, locked, saved, deleted, removed, false);
+ spoiler, nsfw, stickied, archived, locked, saved, deleted, removed, false,
+ distinguished);
}
}
@@ -253,7 +256,8 @@ public class ParsePost {
int score, int voteType, int nComments, int upvoteRatio, String flair,
String awards, int nAwards, boolean hidden, boolean spoiler,
boolean nsfw, boolean stickied, boolean archived, boolean locked,
- boolean saved, boolean deleted, boolean removed, boolean isCrosspost) throws JSONException {
+ boolean saved, boolean deleted, boolean removed, boolean isCrosspost,
+ String distinguished) throws JSONException {
Post post;
boolean isVideo = data.getBoolean(JSONUtils.IS_VIDEO_KEY);
@@ -266,7 +270,7 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
authorFlair, authorFlairHTML, postTimeMillis, title, permalink, score, postType,
voteType, nComments, upvoteRatio, flair, awards, nAwards, hidden, spoiler, nsfw,
- stickied, archived, locked, saved, isCrosspost);
+ stickied, archived, locked, saved, isCrosspost, distinguished);
} else {
if (url.endsWith("jpg") || url.endsWith("png") || url.endsWith("jpeg")) {
//Image post
@@ -275,7 +279,7 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score,
postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, hidden,
- spoiler, nsfw, stickied, archived, locked, saved, isCrosspost);
+ spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, distinguished);
if (previews.isEmpty()) {
previews.add(new Post.Preview(url, 0, 0, "", ""));
@@ -292,7 +296,7 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair,
authorFlairHTML, postTimeMillis, title, permalink, score, postType, voteType,
nComments, upvoteRatio, flair, awards, nAwards, hidden, spoiler, nsfw, stickied,
- archived, locked, saved, isCrosspost);
+ archived, locked, saved, isCrosspost, distinguished);
post.setVideoUrl(videoUrl);
post.setVideoDownloadUrl(videoDownloadUrl);
@@ -302,7 +306,7 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score,
postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, hidden,
- spoiler, nsfw, stickied, archived, locked, saved, isCrosspost);
+ spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, distinguished);
if (data.isNull(JSONUtils.SELFTEXT_KEY)) {
post.setSelfText("");
} else {
@@ -367,7 +371,7 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair,
authorFlairHTML, postTimeMillis, title, permalink, score, postType, voteType,
nComments, upvoteRatio, flair, awards, nAwards, hidden, spoiler, nsfw, stickied,
- archived, locked, saved, isCrosspost);
+ archived, locked, saved, isCrosspost, distinguished);
post.setPreviews(previews);
post.setVideoUrl(videoUrl);
@@ -386,7 +390,7 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair,
authorFlairHTML, postTimeMillis, title, permalink, score, postType, voteType,
nComments, upvoteRatio, flair, awards, nAwards, hidden, spoiler, nsfw, stickied,
- archived, locked, saved, isCrosspost);
+ archived, locked, saved, isCrosspost, distinguished);
post.setPreviews(previews);
post.setVideoUrl(url);
post.setVideoDownloadUrl(url);
@@ -402,7 +406,7 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair,
authorFlairHTML, postTimeMillis, title, permalink, score, postType, voteType,
nComments, upvoteRatio, flair, awards, nAwards, hidden, spoiler, nsfw, stickied,
- archived, locked, saved, isCrosspost);
+ archived, locked, saved, isCrosspost, distinguished);
post.setPreviews(previews);
post.setVideoUrl(videoUrl);
post.setVideoDownloadUrl(videoDownloadUrl);
@@ -415,7 +419,8 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score,
postType, voteType, nComments, upvoteRatio, flair, awards, nAwards,
- hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost);
+ hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost,
+ distinguished);
if (previews.isEmpty()) {
previews.add(new Post.Preview(url, 0, 0, "", ""));
@@ -427,7 +432,8 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score,
postType, voteType, nComments, upvoteRatio, flair, awards, nAwards,
- hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost);
+ hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost,
+ distinguished);
post.setPreviews(previews);
post.setVideoUrl(url);
@@ -442,7 +448,8 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score,
postType, voteType, nComments, upvoteRatio, flair, awards, nAwards,
- hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost);
+ hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost,
+ distinguished);
post.setPreviews(previews);
post.setVideoUrl(url);
post.setVideoDownloadUrl(url);
@@ -454,7 +461,8 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score,
postType, voteType, nComments, upvoteRatio, flair, awards, nAwards,
- hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost);
+ hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost,
+ distinguished);
post.setPreviews(previews);
post.setVideoUrl(url);
post.setVideoDownloadUrl(url);
@@ -466,7 +474,8 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
authorFlair, authorFlairHTML, postTimeMillis, title, permalink, score,
postType, voteType, nComments, upvoteRatio, flair, awards, nAwards,
- hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost);
+ hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost,
+ distinguished);
//Need attention
post.setPreviews(previews);
@@ -477,7 +486,8 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score,
postType, voteType, nComments, upvoteRatio, flair, awards, nAwards,
- hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost);
+ hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost,
+ distinguished);
if (data.isNull(JSONUtils.SELFTEXT_KEY)) {
post.setSelfText("");
} else {
@@ -521,7 +531,7 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score,
postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, hidden,
- spoiler, nsfw, stickied, archived, locked, saved, isCrosspost);
+ spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, distinguished);
if (previews.isEmpty()) {
previews.add(new Post.Preview(url, 0, 0, "", ""));
@@ -534,7 +544,7 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score,
postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, hidden,
- spoiler, nsfw, stickied, archived, locked, saved, isCrosspost);
+ spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, distinguished);
post.setPreviews(previews);
post.setVideoUrl(url);
post.setVideoDownloadUrl(url);
@@ -545,7 +555,7 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score,
postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, hidden,
- spoiler, nsfw, stickied, archived, locked, saved, isCrosspost);
+ spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, distinguished);
//Need attention
if (data.isNull(JSONUtils.SELFTEXT_KEY)) {
post.setSelfText("");
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java
index 230921bb..7e73b0bc 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java
@@ -77,6 +77,7 @@ public class Post implements Parcelable {
private boolean isCrosspost;
private boolean isRead;
private String crosspostParentId;
+ private String distinguished;
private ArrayList<Preview> previews = new ArrayList<>();
private ArrayList<Gallery> gallery = new ArrayList<>();
@@ -85,7 +86,7 @@ public class Post implements Parcelable {
String title, String permalink, int score, int postType, int voteType, int nComments,
int upvoteRatio, String flair, String awards, int nAwards, boolean hidden, boolean spoiler,
boolean nsfw, boolean stickied, boolean archived, boolean locked, boolean saved,
- boolean isCrosspost) {
+ boolean isCrosspost, String distinguished) {
this.id = id;
this.fullName = fullName;
this.subredditName = subredditName;
@@ -113,6 +114,7 @@ public class Post implements Parcelable {
this.locked = locked;
this.saved = saved;
this.isCrosspost = isCrosspost;
+ this.distinguished = distinguished;
isRead = false;
}
@@ -121,7 +123,7 @@ public class Post implements Parcelable {
String url, String permalink, int score, int postType, int voteType, int nComments,
int upvoteRatio, String flair, String awards, int nAwards, boolean hidden, boolean spoiler,
boolean nsfw, boolean stickied, boolean archived, boolean locked, boolean saved,
- boolean isCrosspost) {
+ boolean isCrosspost, String distinguished) {
this.id = id;
this.fullName = fullName;
this.subredditName = subredditName;
@@ -150,6 +152,7 @@ public class Post implements Parcelable {
this.locked = locked;
this.saved = saved;
this.isCrosspost = isCrosspost;
+ this.distinguished = distinguished;
isRead = false;
}
@@ -198,6 +201,7 @@ public class Post implements Parcelable {
isCrosspost = in.readByte() != 0;
isRead = in.readByte() != 0;
crosspostParentId = in.readString();
+ distinguished = in.readString();
in.readTypedList(previews, Preview.CREATOR);
in.readTypedList(gallery, Gallery.CREATOR);
}
@@ -387,6 +391,14 @@ public class Post implements Parcelable {
this.flair = flair;
}
+ public boolean isModerator() {
+ return distinguished != null && distinguished.equals("moderator");
+ }
+
+ public boolean isAdmin() {
+ return distinguished != null && distinguished.equals("admin");
+ }
+
public String getAwards() {
return awards;
}
@@ -574,6 +586,7 @@ public class Post implements Parcelable {
parcel.writeByte((byte) (isCrosspost ? 1 : 0));
parcel.writeByte((byte) (isRead ? 1 : 0));
parcel.writeString(crosspostParentId);
+ parcel.writeString(distinguished);
parcel.writeTypedList(previews);
parcel.writeTypedList(gallery);
}