Proper Admin/Moderator indication

This commit adds proper indicators if a post or comment is made by a moderator or an admin. If a user is both an admin and a moderator, both indicators will be shown.

Closes #267
This commit is contained in:
Balazs Toldi 2024-07-30 09:32:16 +02:00
parent 4ccb1a38bf
commit 6457a4db2f
10 changed files with 180 additions and 44 deletions

View File

@ -0,0 +1,78 @@
package eu.toldi.infinityforlemmy;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import androidx.annotation.Nullable;
public class DualBadgeDrawable extends Drawable {
private Drawable leftBadge;
private Drawable rightBadge;
public DualBadgeDrawable(Drawable leftBadge, Drawable rightBadge) {
this.leftBadge = leftBadge;
this.rightBadge = rightBadge;
}
@Override
public void draw(Canvas canvas) {
if (leftBadge == null || rightBadge == null) {
return;
}
int width = getBounds().width();
int height = getBounds().height();
// Draw the left badge on the left half of the canvas
Rect leftRect = new Rect(0, 0, width / 2, height);
leftBadge.setBounds(leftRect);
leftBadge.draw(canvas);
// Draw the right badge on the right half of the canvas
Rect rightRect = new Rect(width / 2, 0, width, height);
rightBadge.setBounds(rightRect);
rightBadge.draw(canvas);
}
@Override
public void setAlpha(int alpha) {
if (leftBadge != null) {
leftBadge.setAlpha(alpha);
}
if (rightBadge != null) {
rightBadge.setAlpha(alpha);
}
}
@Override
public void setColorFilter(@Nullable ColorFilter colorFilter) {
if (leftBadge != null) {
leftBadge.setColorFilter(colorFilter);
}
if (rightBadge != null) {
rightBadge.setColorFilter(colorFilter);
}
}
@Override
public int getOpacity() {
return leftBadge != null ? leftBadge.getOpacity() : rightBadge.getOpacity();
}
@Override
public int getIntrinsicWidth() {
int leftWidth = leftBadge != null ? leftBadge.getIntrinsicWidth() : 0;
int rightWidth = rightBadge != null ? rightBadge.getIntrinsicWidth() : 0;
return leftWidth + rightWidth;
}
@Override
public int getIntrinsicHeight() {
int leftHeight = leftBadge != null ? leftBadge.getIntrinsicHeight() : 0;
int rightHeight = rightBadge != null ? rightBadge.getIntrinsicHeight() : 0;
return Math.max(leftHeight, rightHeight);
}
}

View File

@ -43,6 +43,7 @@ import java.util.regex.Pattern;
import butterknife.BindView;
import butterknife.ButterKnife;
import eu.toldi.infinityforlemmy.DualBadgeDrawable;
import eu.toldi.infinityforlemmy.R;
import eu.toldi.infinityforlemmy.RetrofitHolder;
import eu.toldi.infinityforlemmy.SaveComment;
@ -155,6 +156,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
private int mUsernameColor;
private int mSubmitterColor;
private int mModeratorColor;
private int mAdminColor;
private int mCurrentUserColor;
private int mAuthorFlairTextColor;
private int mUpvotedColor;
@ -271,6 +273,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
mCommentBackgroundColor = customThemeWrapper.getCommentBackgroundColor();
mSubmitterColor = customThemeWrapper.getSubmitter();
mModeratorColor = customThemeWrapper.getModerator();
mAdminColor = customThemeWrapper.getAdmin();
mCurrentUserColor = customThemeWrapper.getCurrentUser();
mAuthorFlairTextColor = customThemeWrapper.getAuthorFlairTextColor();
mUsernameColor = customThemeWrapper.getUsername();
@ -392,11 +395,23 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
Drawable submitterDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_mic_14dp, mSubmitterColor);
((CommentBaseViewHolder) holder).authorTextView.setCompoundDrawablesWithIntrinsicBounds(
submitterDrawable, null, null, null);
} else if (comment.isModerator() && comment.isAdmin()) {
((CommentBaseViewHolder) holder).authorTextView.setTextColor(mModeratorColor);
Drawable moderatorDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mModeratorColor);
Drawable adminDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mAdminColor);
Drawable dualDrawable = new DualBadgeDrawable(adminDrawable, moderatorDrawable);
((CommentBaseViewHolder) holder).authorTextView.setCompoundDrawablesWithIntrinsicBounds(
dualDrawable, null, null, null);
} else if (comment.isModerator()) {
((CommentBaseViewHolder) holder).authorTextView.setTextColor(mModeratorColor);
Drawable moderatorDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mModeratorColor);
((CommentBaseViewHolder) holder).authorTextView.setCompoundDrawablesWithIntrinsicBounds(
moderatorDrawable, null, null, null);
} else if (comment.isAdmin()) {
((CommentBaseViewHolder) holder).authorTextView.setTextColor(mAdminColor);
Drawable adminDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mAdminColor);
((CommentBaseViewHolder) holder).authorTextView.setCompoundDrawablesWithIntrinsicBounds(
adminDrawable, null, null, null);
} else if (comment.getAuthorQualifiedName().equals(mAccountQualifiedName)) {
((CommentBaseViewHolder) holder).authorTextView.setTextColor(mCurrentUserColor);
Drawable currentUserDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_current_user_14dp, mCurrentUserColor);

View File

@ -58,6 +58,7 @@ import java.util.regex.Pattern;
import javax.inject.Provider;
import eu.toldi.infinityforlemmy.DualBadgeDrawable;
import eu.toldi.infinityforlemmy.FetchRedgifsVideoLinks;
import eu.toldi.infinityforlemmy.FetchStreamableVideo;
import eu.toldi.infinityforlemmy.R;
@ -195,6 +196,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
private int mSubredditColor;
private int mUsernameColor;
private int mModeratorColor;
private int mAdminColor;
private int mAuthorFlairTextColor;
private int mSpoilerBackgroundColor;
private int mSpoilerTextColor;
@ -380,6 +382,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
mSubredditColor = customThemeWrapper.getSubreddit();
mUsernameColor = customThemeWrapper.getUsername();
mModeratorColor = customThemeWrapper.getModerator();
mAdminColor = customThemeWrapper.getAdmin();
mUpvotedColor = customThemeWrapper.getUpvoted();
mDownvotedColor = customThemeWrapper.getDownvoted();
mVoteAndReplyUnavailableVoteButtonColor = customThemeWrapper.getVoteAndReplyUnavailableButtonColor();
@ -600,14 +603,25 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
((PostDetailBaseViewHolder) holder).mUserInstanceTextView.setText('@' + mPost.getAuthorNamePrefixed().split(Pattern.quote("@"))[1]);
((PostDetailBaseViewHolder) holder).mCommunityInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(mSubredditColor, 0.7f));
((PostDetailBaseViewHolder) holder).mUserInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(mPost.isModerator() || mPost.isAdmin() ? mModeratorColor : mUsernameColor, 0.7f));
((PostDetailBaseViewHolder) holder).mUserInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(mPost.isModerator() ? mModeratorColor : mPost.isAdmin() ? mAdminColor : mUsernameColor, 0.7f));
}
if (mPost.isModerator() || mPost.isAdmin()) {
if (mPost.isAdmin() && mPost.isModerator()) {
((PostDetailBaseViewHolder) holder).userTextView.setTextColor(mModeratorColor);
Drawable adminDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mAdminColor);
Drawable moderatorDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mModeratorColor);
Drawable dualBadge = new DualBadgeDrawable(adminDrawable, moderatorDrawable);
((PostDetailBaseViewHolder) holder).userTextView.setCompoundDrawablesWithIntrinsicBounds(
dualBadge, null, null, null);
} else if (mPost.isModerator()) {
((PostDetailBaseViewHolder) holder).userTextView.setTextColor(mModeratorColor);
Drawable moderatorDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mModeratorColor);
((PostDetailBaseViewHolder) holder).userTextView.setCompoundDrawablesWithIntrinsicBounds(
moderatorDrawable, null, null, null);
} else if (mPost.isAdmin()) {
((PostDetailBaseViewHolder) holder).userTextView.setTextColor(mAdminColor);
Drawable moderatorDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mAdminColor);
((PostDetailBaseViewHolder) holder).userTextView.setCompoundDrawablesWithIntrinsicBounds(
moderatorDrawable, null, null, null);
}
if (mShowElapsedTime) {

View File

@ -67,6 +67,7 @@ import javax.inject.Provider;
import butterknife.BindView;
import butterknife.ButterKnife;
import eu.toldi.infinityforlemmy.DualBadgeDrawable;
import eu.toldi.infinityforlemmy.FetchRedgifsVideoLinks;
import eu.toldi.infinityforlemmy.FetchStreamableVideo;
import eu.toldi.infinityforlemmy.MarkPostAsReadInterface;
@ -198,6 +199,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
private int mSubredditColor;
private int mUsernameColor;
private int mModeratorColor;
private int mAdminColor;
private int mSpoilerBackgroundColor;
private int mSpoilerTextColor;
private int mFlairBackgroundColor;
@ -365,6 +367,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
mSubredditColor = customThemeWrapper.getSubreddit();
mUsernameColor = customThemeWrapper.getUsername();
mModeratorColor = customThemeWrapper.getModerator();
mAdminColor = customThemeWrapper.getAdmin();
mSpoilerBackgroundColor = customThemeWrapper.getSpoilerBackgroundColor();
mSpoilerTextColor = customThemeWrapper.getSpoilerTextColor();
mFlairBackgroundColor = customThemeWrapper.getFlairBackgroundColor();
@ -633,12 +636,31 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostBaseViewHolder) holder).communityInstanceTextView.setText('@' + post.getSubredditNamePrefixed().split(Pattern.quote("@"))[1]);
((PostBaseViewHolder) holder).userInstanceTextView.setText('@' + post.getAuthorNamePrefixed().split(Pattern.quote("@"))[1]);
((PostBaseViewHolder) holder).communityInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(mSubredditColor, 0.7f));
((PostBaseViewHolder) holder).userInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(post.isModerator() || post.isAdmin() ? mModeratorColor : mUsernameColor, 0.7f));
((PostBaseViewHolder) holder).userInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(post.isModerator() ? mModeratorColor : post.isAdmin() ? mAdminColor : mUsernameColor, 0.7f));
}
((PostBaseViewHolder) holder).userTextView.setTextColor(
post.isModerator() || post.isAdmin() ? mModeratorColor : mUsernameColor);
if (post.isAdmin() && post.isModerator()) {
((PostBaseViewHolder) holder).userTextView.setTextColor(mModeratorColor);
Drawable adminDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mAdminColor);
Drawable moderatorDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mModeratorColor);
Drawable dualBadge = new DualBadgeDrawable(adminDrawable, moderatorDrawable);
((PostBaseViewHolder) holder).userTextView.setCompoundDrawablesWithIntrinsicBounds(
dualBadge, null, null, null);
} else if (post.isModerator()) {
((PostBaseViewHolder) holder).userTextView.setTextColor(mModeratorColor);
Drawable moderatorDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mModeratorColor);
((PostBaseViewHolder) holder).userTextView.setCompoundDrawablesWithIntrinsicBounds(
moderatorDrawable, null, null, null);
} else if (post.isAdmin()) {
((PostBaseViewHolder) holder).userTextView.setTextColor(mAdminColor);
Drawable moderatorDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mAdminColor);
((PostBaseViewHolder) holder).userTextView.setCompoundDrawablesWithIntrinsicBounds(
moderatorDrawable, null, null, null);
}
if (mDisplaySubredditName) {
if (authorPrefixed.equals(post.getSubredditNamePrefixed())) {
if (post.getAuthorIconUrl() == null) {
@ -2538,6 +2560,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
mGlide.clear(((PostBaseViewHolder) holder).iconGifImageView);
((PostBaseViewHolder) holder).titleTextView.setTextColor(mPostTitleColor);
((PostBaseViewHolder) holder).userTextView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
if (holder instanceof PostBaseVideoAutoplayViewHolder) {
((PostBaseVideoAutoplayViewHolder) holder).mediaUri = null;
if (((PostBaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall != null && !((PostBaseVideoAutoplayViewHolder) holder).fetchStreamableVideoCall.isCanceled()) {

View File

@ -44,7 +44,8 @@ public class Comment implements Parcelable {
private int upvotes;
private int voteType;
private boolean isSubmitter;
private String distinguished;
private boolean isModerator;
private boolean isAdmin;
private String permalink;
private int depth;
private int childCount;
@ -69,7 +70,7 @@ public class Comment implements Parcelable {
public Comment(int id, int postId, BasicUserInfo author, String linkAuthor,
long commentTimeMillis, String commentMarkdown, String commentRawText,
String linkId, String communityName, String communityQualifiedName, Integer parentId, int downvotes, int upvotes,
int voteType, boolean isSubmitter, String distinguished, String permalink,
int voteType, boolean isSubmitter, boolean isModerator, boolean isAdmin, String permalink,
int depth, boolean collapsed, boolean hasReply, boolean saved, boolean deleted,boolean removed, long edited, String[] path) {
this.id = id;
this.postId = postId;
@ -86,7 +87,8 @@ public class Comment implements Parcelable {
this.upvotes = upvotes;
this.voteType = voteType;
this.isSubmitter = isSubmitter;
this.distinguished = distinguished;
this.isModerator = isModerator;
this.isAdmin = isAdmin;
this.permalink = permalink;
this.depth = depth;
this.collapsed = collapsed;
@ -134,7 +136,8 @@ public class Comment implements Parcelable {
upvotes = in.readInt();
voteType = in.readInt();
isSubmitter = in.readByte() != 0;
distinguished = in.readString();
isModerator = in.readByte() != 0;
isAdmin = in.readByte() != 0;
permalink = in.readString();
depth = in.readInt();
childCount = in.readInt();
@ -258,11 +261,11 @@ public class Comment implements Parcelable {
}
public boolean isModerator() {
return distinguished != null && distinguished.equals("moderator");
return isModerator;
}
public boolean isAdmin() {
return distinguished != null && distinguished.equals("admin");
return isAdmin;
}
public String getPermalink() {
@ -447,7 +450,8 @@ public class Comment implements Parcelable {
parcel.writeInt(upvotes);
parcel.writeInt(voteType);
parcel.writeByte((byte) (isSubmitter ? 1 : 0));
parcel.writeString(distinguished);
parcel.writeByte((byte) (isModerator ? 1 : 0));
parcel.writeByte((byte) (isAdmin ? 1 : 0));
parcel.writeString(permalink);
parcel.writeInt(depth);
parcel.writeInt(childCount);
@ -506,8 +510,4 @@ public class Comment implements Parcelable {
public boolean isDeleted() {
return isDeleted;
}
public String getDistinguished() {
return distinguished;
}
}

View File

@ -345,7 +345,7 @@ public class ParseComment {
}
}
boolean isSubmitter = creatorObj.getInt("id") == postObj.getInt("creator_id");
String distinguished = isModerator ? "moderator" : (isAdmin ? "admin" : "");
String permalink = commentObj.getString("ap_id");
String[] path = commentObj.getString("path").split(Pattern.quote("."));
@ -362,7 +362,7 @@ public class ParseComment {
BasicUserInfo authorInfo = new BasicUserInfo(creatorObj.getInt("id"), author, authorQualifiedName, creatorObj.optString("avatar", ""), creatorObj.optString("display_name", author));
Comment comment = new Comment(id, postID, authorInfo, linkAuthor, commentTimeMillis,
commentMarkdown, commentRawText, linkId, communityName, communityQualifiedName, parentId,
downvotes, upvotes, voteType, isSubmitter, distinguished, permalink, depth, collapsed, hasReply, saved, deleted,removed, edited, path);
downvotes, upvotes, voteType, isSubmitter, isModerator, isAdmin, permalink, depth, collapsed, hasReply, saved, deleted, removed, edited, path);
int child_count = countsObj.getInt("child_count");
comment.setChildCount(child_count);
comment.setAuthorIconUrl(authorAvatar);

View File

@ -348,7 +348,7 @@ public class CustomThemeWrapper {
}
public int getAdmin() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.MODERATOR,
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.ADMIN,
getDefaultColor("#a5222f", "#c94f6d", "#EE5396"));
}

View File

@ -184,7 +184,7 @@ public class ParsePost {
boolean locked = post.getBoolean("locked");
boolean saved = data.getBoolean("saved");
boolean deleted = post.getBoolean("deleted");
String distinguished = (isModerator) ? "moderator" : (isAdmin) ? "admin" : "";
String suggestedSort = "";
ArrayList<Post.Preview> previews = new ArrayList<>();
if (!post.isNull("thumbnail_url")) {
@ -198,7 +198,7 @@ public class ParsePost {
return parseData(data, permalink, id, communityInfo,
authorInfo, postTimeMillis, title, previews,
downvotes, upvotes, voteType, nComments, upvoteRatio, nsfw, locked, saved, deleted,
distinguished, suggestedSort);
isModerator, isAdmin, suggestedSort);
}
@ -207,7 +207,7 @@ public class ParsePost {
int downvotes, int upvotes, int voteType, int nComments, int upvoteRatio,
boolean nsfw, boolean locked,
boolean saved, boolean deleted,
String distinguished, String suggestedSort) throws JSONException {
boolean isModerator, boolean isAdmin, String suggestedSort) throws JSONException {
Post post;
@ -226,7 +226,7 @@ public class ParsePost {
post = new Post(id, communityInfo, author,
postTimeMillis, title, permalink, downvotes, upvotes,
postType, voteType, nComments, upvoteRatio, nsfw,
locked, saved, deleted, distinguished, suggestedSort);
locked, saved, deleted, isModerator, isAdmin, suggestedSort);
String body = data.getJSONObject("post").getString("body");
post.setSelfText(body);
post.setSelfTextPlain(body);
@ -238,7 +238,7 @@ public class ParsePost {
post = new Post(id, communityInfo, author,
postTimeMillis, title, url, permalink, downvotes, upvotes,
postType, voteType, nComments, upvoteRatio, nsfw, locked, saved, deleted, distinguished, suggestedSort);
postType, voteType, nComments, upvoteRatio, nsfw, locked, saved, deleted, isModerator, isAdmin, suggestedSort);
if (previews.isEmpty()) {
previews.add(new Post.Preview(url, 0, 0, "", ""));
@ -250,7 +250,7 @@ public class ParsePost {
int postType = Post.VIDEO_TYPE;
post = new Post(id, communityInfo, author, postTimeMillis, title, permalink, downvotes, upvotes, postType, voteType,
nComments, upvoteRatio, nsfw, locked, saved, deleted, distinguished, suggestedSort);
nComments, upvoteRatio, nsfw, locked, saved, deleted, isModerator, isAdmin, suggestedSort);
Post.Preview preview = new Post.Preview(url, 0, 0, "", "");
post.setPreviews(new ArrayList<>(List.of(preview)));
post.setVideoUrl(url);
@ -260,7 +260,7 @@ public class ParsePost {
int postType = Post.NO_PREVIEW_LINK_TYPE;
post = new Post(id, communityInfo, author,
postTimeMillis, title, url, permalink, downvotes, upvotes,
postType, voteType, nComments, upvoteRatio, nsfw, locked, saved, deleted, distinguished, suggestedSort);
postType, voteType, nComments, upvoteRatio, nsfw, locked, saved, deleted, isModerator, isAdmin, suggestedSort);
if (data.isNull(JSONUtils.SELFTEXT_KEY)) {
post.setSelfText("");
} else {
@ -289,7 +289,7 @@ public class ParsePost {
post = new Post(id, communityInfo, author,
postTimeMillis, title, permalink, downvotes, upvotes,
postType, voteType, nComments, upvoteRatio, nsfw,
locked, saved, deleted, distinguished, suggestedSort);
locked, saved, deleted, isModerator, isAdmin, suggestedSort);
String body = "";
post.setSelfText(body);
post.setSelfTextPlain(body);
@ -326,7 +326,7 @@ public class ParsePost {
String videoDownloadUrl = redditVideoObject.getString(JSONUtils.FALLBACK_URL_KEY);
post = new Post(id, communityInfo, author, postTimeMillis, title, permalink, downvotes, upvotes, postType, voteType,
nComments, upvoteRatio, nsfw, locked, saved, deleted, distinguished, suggestedSort);
nComments, upvoteRatio, nsfw, locked, saved, deleted, isModerator, isAdmin, suggestedSort);
post.setPreviews(previews);
post.setVideoUrl(videoUrl);
@ -339,7 +339,7 @@ public class ParsePost {
post = new Post(id, communityInfo, author,
postTimeMillis, title, url, permalink, downvotes, upvotes,
postType, voteType, nComments, upvoteRatio, nsfw, locked, saved, deleted,
distinguished, suggestedSort);
isModerator, isAdmin, suggestedSort);
if (previews.isEmpty()) {
previews.add(new Post.Preview(url, 0, 0, "", ""));
@ -352,7 +352,7 @@ public class ParsePost {
postTimeMillis, title, url, permalink, downvotes, upvotes,
postType, voteType, nComments, upvoteRatio,
nsfw, locked, saved, deleted,
distinguished, suggestedSort);
isModerator, isAdmin, suggestedSort);
post.setPreviews(previews);
post.setVideoUrl(url);
@ -368,7 +368,7 @@ public class ParsePost {
postTimeMillis, title, url, permalink, downvotes, upvotes,
postType, voteType, nComments, upvoteRatio,
nsfw, locked, saved, deleted,
distinguished, suggestedSort);
isModerator, isAdmin, suggestedSort);
post.setPreviews(previews);
post.setVideoUrl(url);
post.setVideoDownloadUrl(url);
@ -380,7 +380,7 @@ public class ParsePost {
post = new Post(id, communityInfo, author,
postTimeMillis, title, url, permalink, downvotes, upvotes,
postType, voteType, nComments, upvoteRatio, nsfw, locked, saved, deleted,
distinguished, suggestedSort);
isModerator, isAdmin, suggestedSort);
post.setPreviews(previews);
post.setVideoUrl(url);
post.setVideoDownloadUrl(url);
@ -391,7 +391,7 @@ public class ParsePost {
post = new Post(id, communityInfo, author,
postTimeMillis, title, url, permalink, downvotes, upvotes,
postType, voteType, nComments, upvoteRatio, nsfw, locked, saved, deleted,
distinguished, suggestedSort);
isModerator, isAdmin, suggestedSort);
if (data.isNull(JSONUtils.SELFTEXT_KEY)) {
post.setSelfText("");
} else {
@ -425,7 +425,7 @@ public class ParsePost {
post = new Post(id, communityInfo, author,
postTimeMillis, title, url, permalink, downvotes, upvotes,
postType, voteType, nComments, upvoteRatio, nsfw, locked, saved, deleted, distinguished, suggestedSort);
postType, voteType, nComments, upvoteRatio, nsfw, locked, saved, deleted, isModerator, isAdmin, suggestedSort);
if (previews.isEmpty()) {
previews.add(new Post.Preview(url, 0, 0, "", ""));
@ -437,7 +437,7 @@ public class ParsePost {
post = new Post(id, communityInfo, author,
postTimeMillis, title, url, permalink, downvotes, upvotes,
postType, voteType, nComments, upvoteRatio, nsfw, locked, saved, deleted, distinguished, suggestedSort);
postType, voteType, nComments, upvoteRatio, nsfw, locked, saved, deleted, isModerator, isAdmin, suggestedSort);
post.setPreviews(previews);
post.setVideoUrl(url);
post.setVideoDownloadUrl(url);
@ -447,7 +447,7 @@ public class ParsePost {
post = new Post(id, communityInfo, author,
postTimeMillis, title, url, permalink, downvotes, upvotes,
postType, voteType, nComments, upvoteRatio, nsfw, locked, saved, deleted, distinguished, suggestedSort);
postType, voteType, nComments, upvoteRatio, nsfw, locked, saved, deleted, isModerator, isAdmin, suggestedSort);
//Need attention
if (data.isNull(JSONUtils.SELFTEXT_KEY)) {
post.setSelfText("");

View File

@ -73,8 +73,9 @@ public class Post implements Parcelable {
private boolean isRead;
private boolean deleted;
private boolean moderator;
private boolean admin;
private String crosspostParentId;
private String distinguished;
private String suggestedSort;
private ArrayList<Preview> previews = new ArrayList<>();
private ArrayList<Gallery> gallery = new ArrayList<>();
@ -84,7 +85,7 @@ public class Post implements Parcelable {
String title, String permalink, int downvotes, int upvotes, int postType, int voteType, int nComments,
int upvoteRatio,
boolean nsfw, boolean locked, boolean saved, boolean deleted,
String distinguished, String suggestedSort) {
boolean moderator, boolean admin, String suggestedSort) {
this.id = id;
this.communityInfo = communityInfo;
this.author = userInfo;
@ -104,7 +105,8 @@ public class Post implements Parcelable {
this.locked = locked;
this.saved = saved;
this.isCrosspost = isCrosspost;
this.distinguished = distinguished;
this.moderator = moderator;
this.admin = admin;
this.suggestedSort = suggestedSort;
isRead = false;
}
@ -113,7 +115,7 @@ public class Post implements Parcelable {
BasicUserInfo author, long postTimeMillis, String title,
String url, String permalink, int downvotes, int upvotes, int postType, int voteType, int nComments,
int upvoteRatio,
boolean nsfw, boolean locked, boolean saved, boolean deleted, String distinguished, String suggestedSort) {
boolean nsfw, boolean locked, boolean saved, boolean deleted, boolean moderator, boolean admin, String suggestedSort) {
this.id = id;
this.communityInfo = communityInfo;
this.author = author;
@ -134,7 +136,8 @@ public class Post implements Parcelable {
this.saved = saved;
this.deleted = deleted;
this.isCrosspost = isCrosspost;
this.distinguished = distinguished;
this.moderator = moderator;
this.admin = admin;
this.suggestedSort = suggestedSort;
isRead = false;
}
@ -174,7 +177,8 @@ public class Post implements Parcelable {
isCrosspost = in.readByte() != 0;
isRead = in.readByte() != 0;
crosspostParentId = in.readString();
distinguished = in.readString();
moderator = in.readByte() != 0;
admin = in.readByte() != 0;
suggestedSort = in.readString();
in.readTypedList(previews, Preview.CREATOR);
in.readTypedList(gallery, Gallery.CREATOR);
@ -354,11 +358,11 @@ public class Post implements Parcelable {
}
public boolean isModerator() {
return distinguished != null && distinguished.equals("moderator");
return moderator;
}
public boolean isAdmin() {
return distinguished != null && distinguished.equals("admin");
return admin;
}
public String getSuggestedSort() {
@ -538,7 +542,8 @@ public class Post implements Parcelable {
parcel.writeByte((byte) (isCrosspost ? 1 : 0));
parcel.writeByte((byte) (isRead ? 1 : 0));
parcel.writeString(crosspostParentId);
parcel.writeString(distinguished);
parcel.writeByte((byte) (moderator ? 1 : 0));
parcel.writeByte((byte) (admin ? 1 : 0));
parcel.writeString(suggestedSort);
parcel.writeTypedList(previews);
parcel.writeTypedList(gallery);

View File

@ -74,6 +74,7 @@ public class CustomThemeSharedPreferencesUtils {
public static final String AUTHOR_FLAIR_TEXT_COLOR = "authorFlairTextColor";
public static final String SUBMITTER = "submitter";
public static final String MODERATOR = "moderator";
public static final String ADMIN = "admin";
public static final String CURRENT_USER = "currentUser";
public static final String SINGLE_COMMENT_THREAD_BACKGROUND_COLOR = "singleCommentThreadBackgroundColor";
public static final String UNREAD_MESSAGE_BACKGROUND_COLOR = "unreadMessageBackgroundColor";