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 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 {

View File

@ -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()));

View File

@ -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 {

View File

@ -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;
}

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 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("");

View File

@ -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);
}