Show moderator author/user colors in more places, such as post lists and history. Show moderator badging in post details as well as color. (#1288)

This commit is contained in:
cmp 2022-12-23 16:25:14 -06:00 committed by GitHub
parent a21eccca0d
commit 5786ac028d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 72 additions and 23 deletions

View File

@ -164,6 +164,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
private int mPostTypeTextColor; private int mPostTypeTextColor;
private int mSubredditColor; private int mSubredditColor;
private int mUsernameColor; private int mUsernameColor;
private int mModeratorColor;
private int mSpoilerBackgroundColor; private int mSpoilerBackgroundColor;
private int mSpoilerTextColor; private int mSpoilerTextColor;
private int mFlairBackgroundColor; private int mFlairBackgroundColor;
@ -306,6 +307,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
mPostTypeTextColor = customThemeWrapper.getPostTypeTextColor(); mPostTypeTextColor = customThemeWrapper.getPostTypeTextColor();
mSubredditColor = customThemeWrapper.getSubreddit(); mSubredditColor = customThemeWrapper.getSubreddit();
mUsernameColor = customThemeWrapper.getUsername(); mUsernameColor = customThemeWrapper.getUsername();
mModeratorColor = customThemeWrapper.getModerator();
mSpoilerBackgroundColor = customThemeWrapper.getSpoilerBackgroundColor(); mSpoilerBackgroundColor = customThemeWrapper.getSpoilerBackgroundColor();
mSpoilerTextColor = customThemeWrapper.getSpoilerTextColor(); mSpoilerTextColor = customThemeWrapper.getSpoilerTextColor();
mFlairBackgroundColor = customThemeWrapper.getFlairBackgroundColor(); mFlairBackgroundColor = customThemeWrapper.getFlairBackgroundColor();
@ -499,6 +501,9 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
((PostBaseViewHolder) holder).userTextView.setText(authorPrefixed); ((PostBaseViewHolder) holder).userTextView.setText(authorPrefixed);
} }
((PostBaseViewHolder) holder).userTextView.setTextColor(
post.isModerator() ? mModeratorColor : mUsernameColor);
if (mDisplaySubredditName) { if (mDisplaySubredditName) {
if (authorPrefixed.equals(post.getSubredditNamePrefixed())) { if (authorPrefixed.equals(post.getSubredditNamePrefixed())) {
if (post.getAuthorIconUrl() == null) { if (post.getAuthorIconUrl() == null) {
@ -1152,7 +1157,8 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
.into(((PostCompactBaseViewHolder) holder).iconGifImageView); .into(((PostCompactBaseViewHolder) holder).iconGifImageView);
} }
((PostCompactBaseViewHolder) holder).nameTextView.setTextColor(mUsernameColor); ((PostCompactBaseViewHolder) holder).nameTextView.setTextColor(
post.isModerator() ? mModeratorColor : mUsernameColor);
if (mHideSubredditAndUserPrefix) { if (mHideSubredditAndUserPrefix) {
((PostCompactBaseViewHolder) holder).nameTextView.setText(post.getAuthor()); ((PostCompactBaseViewHolder) holder).nameTextView.setText(post.getAuthor());
} else { } else {

View File

@ -180,6 +180,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
private int mPostTypeTextColor; private int mPostTypeTextColor;
private int mSubredditColor; private int mSubredditColor;
private int mUsernameColor; private int mUsernameColor;
private int mModeratorColor;
private int mAuthorFlairTextColor; private int mAuthorFlairTextColor;
private int mSpoilerBackgroundColor; private int mSpoilerBackgroundColor;
private int mSpoilerTextColor; private int mSpoilerTextColor;
@ -363,6 +364,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
mFlairTextColor = customThemeWrapper.getFlairTextColor(); mFlairTextColor = customThemeWrapper.getFlairTextColor();
mSubredditColor = customThemeWrapper.getSubreddit(); mSubredditColor = customThemeWrapper.getSubreddit();
mUsernameColor = customThemeWrapper.getUsername(); mUsernameColor = customThemeWrapper.getUsername();
mModeratorColor = customThemeWrapper.getModerator();
mUpvotedColor = customThemeWrapper.getUpvoted(); mUpvotedColor = customThemeWrapper.getUpvoted();
mDownvotedColor = customThemeWrapper.getDownvoted(); mDownvotedColor = customThemeWrapper.getDownvoted();
mVoteAndReplyUnavailableVoteButtonColor = customThemeWrapper.getVoteAndReplyUnavailableButtonColor(); mVoteAndReplyUnavailableVoteButtonColor = customThemeWrapper.getVoteAndReplyUnavailableButtonColor();
@ -575,6 +577,13 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
((PostDetailBaseViewHolder) holder).mUserTextView.setText(mPost.getAuthor()); ((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) { if (mShowElapsedTime) {
((PostDetailBaseViewHolder) holder).mPostTimeTextView.setText( ((PostDetailBaseViewHolder) holder).mPostTimeTextView.setText(
Utils.getElapsedTime(mActivity, mPost.getPostTimeMillis())); Utils.getElapsedTime(mActivity, mPost.getPostTimeMillis()));

View File

@ -171,6 +171,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
private int mPostTypeTextColor; private int mPostTypeTextColor;
private int mSubredditColor; private int mSubredditColor;
private int mUsernameColor; private int mUsernameColor;
private int mModeratorColor;
private int mSpoilerBackgroundColor; private int mSpoilerBackgroundColor;
private int mSpoilerTextColor; private int mSpoilerTextColor;
private int mFlairBackgroundColor; private int mFlairBackgroundColor;
@ -326,6 +327,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
mPostTypeTextColor = customThemeWrapper.getPostTypeTextColor(); mPostTypeTextColor = customThemeWrapper.getPostTypeTextColor();
mSubredditColor = customThemeWrapper.getSubreddit(); mSubredditColor = customThemeWrapper.getSubreddit();
mUsernameColor = customThemeWrapper.getUsername(); mUsernameColor = customThemeWrapper.getUsername();
mModeratorColor = customThemeWrapper.getModerator();
mSpoilerBackgroundColor = customThemeWrapper.getSpoilerBackgroundColor(); mSpoilerBackgroundColor = customThemeWrapper.getSpoilerBackgroundColor();
mSpoilerTextColor = customThemeWrapper.getSpoilerTextColor(); mSpoilerTextColor = customThemeWrapper.getSpoilerTextColor();
mFlairBackgroundColor = customThemeWrapper.getFlairBackgroundColor(); mFlairBackgroundColor = customThemeWrapper.getFlairBackgroundColor();
@ -530,6 +532,9 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostBaseViewHolder) holder).userTextView.setText(authorPrefixed); ((PostBaseViewHolder) holder).userTextView.setText(authorPrefixed);
} }
((PostBaseViewHolder) holder).userTextView.setTextColor(
post.isModerator() ? mModeratorColor : mUsernameColor);
if (mDisplaySubredditName) { if (mDisplaySubredditName) {
if (authorPrefixed.equals(post.getSubredditNamePrefixed())) { if (authorPrefixed.equals(post.getSubredditNamePrefixed())) {
if (post.getAuthorIconUrl() == null) { if (post.getAuthorIconUrl() == null) {
@ -1205,7 +1210,9 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
.into(((PostCompactBaseViewHolder) holder).iconGifImageView); .into(((PostCompactBaseViewHolder) holder).iconGifImageView);
} }
((PostCompactBaseViewHolder) holder).nameTextView.setTextColor(mUsernameColor); ((PostCompactBaseViewHolder) holder).nameTextView.setTextColor(
post.isModerator() ? mModeratorColor : mUsernameColor);
if (mHideSubredditAndUserPrefix) { if (mHideSubredditAndUserPrefix) {
((PostCompactBaseViewHolder) holder).nameTextView.setText(post.getAuthor()); ((PostCompactBaseViewHolder) holder).nameTextView.setText(post.getAuthor());
} else { } else {

View File

@ -243,6 +243,10 @@ public class Comment implements Parcelable {
return distinguished != null && distinguished.equals("moderator"); return distinguished != null && distinguished.equals("moderator");
} }
public boolean isAdmin() {
return distinguished != null && distinguished.equals("admin");
}
public String getPermalink() { public String getPermalink() {
return permalink; return permalink;
} }

View File

@ -146,6 +146,7 @@ public class ParsePost {
} }
} }
String authorFlair = data.isNull(JSONUtils.AUTHOR_FLAIR_TEXT_KEY) ? "" : data.getString(JSONUtils.AUTHOR_FLAIR_TEXT_KEY); 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; long postTime = data.getLong(JSONUtils.CREATED_UTC_KEY) * 1000;
String title = data.getString(JSONUtils.TITLE_KEY); String title = data.getString(JSONUtils.TITLE_KEY);
int score = data.getInt(JSONUtils.SCORE_KEY); int score = data.getInt(JSONUtils.SCORE_KEY);
@ -234,7 +235,8 @@ public class ParsePost {
author, authorFlair, authorFlairHTMLBuilder.toString(), author, authorFlair, authorFlairHTMLBuilder.toString(),
postTime, title, previews, postTime, title, previews,
score, voteType, nComments, upvoteRatio, flair, awardingsBuilder.toString(), nAwards, hidden, 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()); post.setCrosspostParentId(crosspostParent.getId());
return post; return post;
} else { } else {
@ -242,7 +244,8 @@ public class ParsePost {
author, authorFlair, authorFlairHTMLBuilder.toString(), author, authorFlair, authorFlairHTMLBuilder.toString(),
postTime, title, previews, postTime, title, previews,
score, voteType, nComments, upvoteRatio, flair, awardingsBuilder.toString(), nAwards, hidden, 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, int score, int voteType, int nComments, int upvoteRatio, String flair,
String awards, int nAwards, boolean hidden, boolean spoiler, String awards, int nAwards, boolean hidden, boolean spoiler,
boolean nsfw, boolean stickied, boolean archived, boolean locked, 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; Post post;
boolean isVideo = data.getBoolean(JSONUtils.IS_VIDEO_KEY); boolean isVideo = data.getBoolean(JSONUtils.IS_VIDEO_KEY);
@ -266,7 +270,7 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
authorFlair, authorFlairHTML, postTimeMillis, title, permalink, score, postType, authorFlair, authorFlairHTML, postTimeMillis, title, permalink, score, postType,
voteType, nComments, upvoteRatio, flair, awards, nAwards, hidden, spoiler, nsfw, voteType, nComments, upvoteRatio, flair, awards, nAwards, hidden, spoiler, nsfw,
stickied, archived, locked, saved, isCrosspost); stickied, archived, locked, saved, isCrosspost, distinguished);
} else { } else {
if (url.endsWith("jpg") || url.endsWith("png") || url.endsWith("jpeg")) { if (url.endsWith("jpg") || url.endsWith("png") || url.endsWith("jpeg")) {
//Image post //Image post
@ -275,7 +279,7 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score,
postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, hidden, 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()) { if (previews.isEmpty()) {
previews.add(new Post.Preview(url, 0, 0, "", "")); previews.add(new Post.Preview(url, 0, 0, "", ""));
@ -292,7 +296,7 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair,
authorFlairHTML, postTimeMillis, title, permalink, score, postType, voteType, authorFlairHTML, postTimeMillis, title, permalink, score, postType, voteType,
nComments, upvoteRatio, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, nComments, upvoteRatio, flair, awards, nAwards, hidden, spoiler, nsfw, stickied,
archived, locked, saved, isCrosspost); archived, locked, saved, isCrosspost, distinguished);
post.setVideoUrl(videoUrl); post.setVideoUrl(videoUrl);
post.setVideoDownloadUrl(videoDownloadUrl); post.setVideoDownloadUrl(videoDownloadUrl);
@ -302,7 +306,7 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score,
postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, hidden, 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)) { if (data.isNull(JSONUtils.SELFTEXT_KEY)) {
post.setSelfText(""); post.setSelfText("");
} else { } else {
@ -367,7 +371,7 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair,
authorFlairHTML, postTimeMillis, title, permalink, score, postType, voteType, authorFlairHTML, postTimeMillis, title, permalink, score, postType, voteType,
nComments, upvoteRatio, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, nComments, upvoteRatio, flair, awards, nAwards, hidden, spoiler, nsfw, stickied,
archived, locked, saved, isCrosspost); archived, locked, saved, isCrosspost, distinguished);
post.setPreviews(previews); post.setPreviews(previews);
post.setVideoUrl(videoUrl); post.setVideoUrl(videoUrl);
@ -386,7 +390,7 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair,
authorFlairHTML, postTimeMillis, title, permalink, score, postType, voteType, authorFlairHTML, postTimeMillis, title, permalink, score, postType, voteType,
nComments, upvoteRatio, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, nComments, upvoteRatio, flair, awards, nAwards, hidden, spoiler, nsfw, stickied,
archived, locked, saved, isCrosspost); archived, locked, saved, isCrosspost, distinguished);
post.setPreviews(previews); post.setPreviews(previews);
post.setVideoUrl(url); post.setVideoUrl(url);
post.setVideoDownloadUrl(url); post.setVideoDownloadUrl(url);
@ -402,7 +406,7 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair,
authorFlairHTML, postTimeMillis, title, permalink, score, postType, voteType, authorFlairHTML, postTimeMillis, title, permalink, score, postType, voteType,
nComments, upvoteRatio, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, nComments, upvoteRatio, flair, awards, nAwards, hidden, spoiler, nsfw, stickied,
archived, locked, saved, isCrosspost); archived, locked, saved, isCrosspost, distinguished);
post.setPreviews(previews); post.setPreviews(previews);
post.setVideoUrl(videoUrl); post.setVideoUrl(videoUrl);
post.setVideoDownloadUrl(videoDownloadUrl); post.setVideoDownloadUrl(videoDownloadUrl);
@ -415,7 +419,8 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score,
postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, 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()) { if (previews.isEmpty()) {
previews.add(new Post.Preview(url, 0, 0, "", "")); previews.add(new Post.Preview(url, 0, 0, "", ""));
@ -427,7 +432,8 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score,
postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, 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.setPreviews(previews);
post.setVideoUrl(url); post.setVideoUrl(url);
@ -442,7 +448,8 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score,
postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, 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.setPreviews(previews);
post.setVideoUrl(url); post.setVideoUrl(url);
post.setVideoDownloadUrl(url); post.setVideoDownloadUrl(url);
@ -454,7 +461,8 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score,
postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, 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.setPreviews(previews);
post.setVideoUrl(url); post.setVideoUrl(url);
post.setVideoDownloadUrl(url); post.setVideoDownloadUrl(url);
@ -466,7 +474,8 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
authorFlair, authorFlairHTML, postTimeMillis, title, permalink, score, authorFlair, authorFlairHTML, postTimeMillis, title, permalink, score,
postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, 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 //Need attention
post.setPreviews(previews); post.setPreviews(previews);
@ -477,7 +486,8 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score,
postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, 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)) { if (data.isNull(JSONUtils.SELFTEXT_KEY)) {
post.setSelfText(""); post.setSelfText("");
} else { } else {
@ -521,7 +531,7 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score,
postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, hidden, 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()) { if (previews.isEmpty()) {
previews.add(new Post.Preview(url, 0, 0, "", "")); previews.add(new Post.Preview(url, 0, 0, "", ""));
@ -534,7 +544,7 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score,
postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, hidden, 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.setPreviews(previews);
post.setVideoUrl(url); post.setVideoUrl(url);
post.setVideoDownloadUrl(url); post.setVideoDownloadUrl(url);
@ -545,7 +555,7 @@ public class ParsePost {
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score,
postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, hidden, 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 //Need attention
if (data.isNull(JSONUtils.SELFTEXT_KEY)) { if (data.isNull(JSONUtils.SELFTEXT_KEY)) {
post.setSelfText(""); post.setSelfText("");

View File

@ -77,6 +77,7 @@ public class Post implements Parcelable {
private boolean isCrosspost; private boolean isCrosspost;
private boolean isRead; private boolean isRead;
private String crosspostParentId; private String crosspostParentId;
private String distinguished;
private ArrayList<Preview> previews = new ArrayList<>(); private ArrayList<Preview> previews = new ArrayList<>();
private ArrayList<Gallery> gallery = 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, String title, String permalink, int score, int postType, int voteType, int nComments,
int upvoteRatio, String flair, String awards, int nAwards, boolean hidden, boolean spoiler, int upvoteRatio, String flair, String awards, int nAwards, boolean hidden, boolean spoiler,
boolean nsfw, boolean stickied, boolean archived, boolean locked, boolean saved, boolean nsfw, boolean stickied, boolean archived, boolean locked, boolean saved,
boolean isCrosspost) { boolean isCrosspost, String distinguished) {
this.id = id; this.id = id;
this.fullName = fullName; this.fullName = fullName;
this.subredditName = subredditName; this.subredditName = subredditName;
@ -113,6 +114,7 @@ public class Post implements Parcelable {
this.locked = locked; this.locked = locked;
this.saved = saved; this.saved = saved;
this.isCrosspost = isCrosspost; this.isCrosspost = isCrosspost;
this.distinguished = distinguished;
isRead = false; isRead = false;
} }
@ -121,7 +123,7 @@ public class Post implements Parcelable {
String url, String permalink, int score, int postType, int voteType, int nComments, String url, String permalink, int score, int postType, int voteType, int nComments,
int upvoteRatio, String flair, String awards, int nAwards, boolean hidden, boolean spoiler, int upvoteRatio, String flair, String awards, int nAwards, boolean hidden, boolean spoiler,
boolean nsfw, boolean stickied, boolean archived, boolean locked, boolean saved, boolean nsfw, boolean stickied, boolean archived, boolean locked, boolean saved,
boolean isCrosspost) { boolean isCrosspost, String distinguished) {
this.id = id; this.id = id;
this.fullName = fullName; this.fullName = fullName;
this.subredditName = subredditName; this.subredditName = subredditName;
@ -150,6 +152,7 @@ public class Post implements Parcelable {
this.locked = locked; this.locked = locked;
this.saved = saved; this.saved = saved;
this.isCrosspost = isCrosspost; this.isCrosspost = isCrosspost;
this.distinguished = distinguished;
isRead = false; isRead = false;
} }
@ -198,6 +201,7 @@ public class Post implements Parcelable {
isCrosspost = in.readByte() != 0; isCrosspost = in.readByte() != 0;
isRead = in.readByte() != 0; isRead = in.readByte() != 0;
crosspostParentId = in.readString(); crosspostParentId = in.readString();
distinguished = in.readString();
in.readTypedList(previews, Preview.CREATOR); in.readTypedList(previews, Preview.CREATOR);
in.readTypedList(gallery, Gallery.CREATOR); in.readTypedList(gallery, Gallery.CREATOR);
} }
@ -387,6 +391,14 @@ public class Post implements Parcelable {
this.flair = flair; this.flair = flair;
} }
public boolean isModerator() {
return distinguished != null && distinguished.equals("moderator");
}
public boolean isAdmin() {
return distinguished != null && distinguished.equals("admin");
}
public String getAwards() { public String getAwards() {
return awards; return awards;
} }
@ -574,6 +586,7 @@ public class Post implements Parcelable {
parcel.writeByte((byte) (isCrosspost ? 1 : 0)); parcel.writeByte((byte) (isCrosspost ? 1 : 0));
parcel.writeByte((byte) (isRead ? 1 : 0)); parcel.writeByte((byte) (isRead ? 1 : 0));
parcel.writeString(crosspostParentId); parcel.writeString(crosspostParentId);
parcel.writeString(distinguished);
parcel.writeTypedList(previews); parcel.writeTypedList(previews);
parcel.writeTypedList(gallery); parcel.writeTypedList(gallery);
} }