diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostOptionsBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostOptionsBottomSheetFragment.java index f24f38b2..64bb6bdb 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostOptionsBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostOptionsBottomSheetFragment.java @@ -268,7 +268,16 @@ public class PostOptionsBottomSheetFragment extends LandscapeExpandedRoundedBott intent.putExtra(ReportActivity.EXTRA_SUBREDDIT_NAME, mPost.getSubredditName()); intent.putExtra(ReportActivity.EXTRA_THING_FULLNAME, mPost.getFullName()); startActivity(intent); + + dismiss(); }); + + if (mPost.isCanModPost()) { + binding.modTextViewPostOptionsBottomSheetFragment.setVisibility(View.VISIBLE); + binding.modTextViewPostOptionsBottomSheetFragment.setOnClickListener(view -> { + dismiss(); + }); + } } } 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 113b6267..69d3616c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java @@ -183,6 +183,7 @@ public class ParsePost { boolean saved = data.getBoolean(JSONUtils.SAVED_KEY); boolean deleted = !data.isNull(JSONUtils.REMOVED_BY_CATEGORY_KEY) && data.getString(JSONUtils.REMOVED_BY_CATEGORY_KEY).equals("deleted"); boolean removed = !data.isNull(JSONUtils.REMOVED_BY_CATEGORY_KEY) && data.getString(JSONUtils.REMOVED_BY_CATEGORY_KEY).equals("moderator"); + boolean canModPost = data.getBoolean(JSONUtils.CAN_MOD_POST_KEY); StringBuilder postFlairHTMLBuilder = new StringBuilder(); String flair = ""; if (data.has(JSONUtils.LINK_FLAIR_RICHTEXT_KEY)) { @@ -241,7 +242,7 @@ public class ParsePost { author, authorFlair, authorFlairHTMLBuilder.toString(), postTime, title, previews, mediaMetadataMap, score, voteType, nComments, upvoteRatio, flair, hidden, - spoiler, nsfw, stickied, archived, locked, saved, deleted, removed, true, + spoiler, nsfw, stickied, archived, locked, saved, deleted, removed, true, canModPost, distinguished, suggestedSort); post.setCrosspostParentId(crosspostParent.getId()); return post; @@ -250,7 +251,7 @@ public class ParsePost { author, authorFlair, authorFlairHTMLBuilder.toString(), postTime, title, previews, mediaMetadataMap, score, voteType, nComments, upvoteRatio, flair, hidden, - spoiler, nsfw, stickied, archived, locked, saved, deleted, removed, false, + spoiler, nsfw, stickied, archived, locked, saved, deleted, removed, false, canModPost, distinguished, suggestedSort); } } @@ -262,7 +263,7 @@ public class ParsePost { int score, int voteType, int nComments, int upvoteRatio, String flair, boolean hidden, boolean spoiler, boolean nsfw, boolean stickied, boolean archived, boolean locked, boolean saved, - boolean deleted, boolean removed, boolean isCrosspost, + boolean deleted, boolean removed, boolean isCrosspost, boolean canModPost, String distinguished, String suggestedSort) throws JSONException { Post post; @@ -278,7 +279,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, permalink, score, postType, voteType, nComments, upvoteRatio, flair, hidden, spoiler, nsfw, - stickied, archived, locked, saved, isCrosspost, distinguished, suggestedSort); + stickied, archived, locked, saved, isCrosspost, canModPost, distinguished, suggestedSort); } else { if (path.endsWith(".jpg") || path.endsWith(".png") || path.endsWith(".jpeg")) { //Image post @@ -287,7 +288,8 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, postType, voteType, nComments, upvoteRatio, flair, hidden, - spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, distinguished, suggestedSort); + spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, canModPost, distinguished, + suggestedSort); if (previews.isEmpty()) { if ("i.redgifs.com".equals(uri.getAuthority())) { @@ -315,7 +317,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, permalink, score, postType, voteType, nComments, upvoteRatio, flair, hidden, spoiler, nsfw, stickied, - archived, locked, saved, isCrosspost, distinguished, suggestedSort); + archived, locked, saved, isCrosspost, canModPost, distinguished, suggestedSort); post.setVideoUrl(videoUrl); post.setVideoDownloadUrl(videoDownloadUrl); @@ -325,7 +327,8 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, postType, voteType, nComments, upvoteRatio, flair, hidden, - spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, distinguished, suggestedSort); + spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, canModPost, + distinguished, suggestedSort); if (data.isNull(JSONUtils.SELFTEXT_KEY)) { post.setSelfText(""); } else { @@ -384,7 +387,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, permalink, score, postType, voteType, nComments, upvoteRatio, flair, hidden, spoiler, nsfw, stickied, - archived, locked, saved, isCrosspost, distinguished, suggestedSort); + archived, locked, saved, isCrosspost, canModPost, distinguished, suggestedSort); post.setPreviews(previews); post.setVideoUrl(videoUrl); @@ -402,7 +405,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, permalink, score, postType, voteType, nComments, upvoteRatio, flair, hidden, spoiler, nsfw, stickied, - archived, locked, saved, isCrosspost, distinguished, suggestedSort); + archived, locked, saved, isCrosspost, canModPost, distinguished, suggestedSort); post.setPreviews(previews); post.setVideoUrl(url); post.setVideoDownloadUrl(url); @@ -418,7 +421,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, permalink, score, postType, voteType, nComments, upvoteRatio, flair, hidden, spoiler, nsfw, stickied, - archived, locked, saved, isCrosspost, distinguished, suggestedSort); + archived, locked, saved, isCrosspost, canModPost, distinguished, suggestedSort); post.setPreviews(previews); post.setVideoUrl(videoUrl); post.setVideoDownloadUrl(videoDownloadUrl); @@ -433,7 +436,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, postType, voteType, nComments, upvoteRatio, flair, - hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, + hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, canModPost, distinguished, suggestedSort); if (previews.isEmpty()) { @@ -453,7 +456,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, postType, voteType, nComments, upvoteRatio, flair, - hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, + hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, canModPost, distinguished, suggestedSort); post.setPreviews(previews); @@ -479,7 +482,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, postType, voteType, nComments, upvoteRatio, flair, - hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, + hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, canModPost, distinguished, suggestedSort); post.setPreviews(previews); post.setVideoUrl(url); @@ -492,7 +495,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, postType, voteType, nComments, upvoteRatio, flair, - hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, + hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, canModPost, distinguished, suggestedSort); post.setPreviews(previews); post.setVideoUrl(url); @@ -505,7 +508,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, permalink, score, postType, voteType, nComments, upvoteRatio, flair, - hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, + hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, canModPost, distinguished, suggestedSort); //Need attention @@ -517,7 +520,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, postType, voteType, nComments, upvoteRatio, flair, - hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, + hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, canModPost, distinguished, suggestedSort); if (data.isNull(JSONUtils.SELFTEXT_KEY)) { post.setSelfText(""); @@ -556,7 +559,8 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, postType, voteType, nComments, upvoteRatio, flair, hidden, - spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, distinguished, suggestedSort); + spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, canModPost, + distinguished, suggestedSort); if (previews.isEmpty()) { if ("i.redgifs.com".equals(uri.getAuthority())) { @@ -576,7 +580,8 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, postType, voteType, nComments, upvoteRatio, flair, hidden, - spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, distinguished, suggestedSort); + spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, canModPost, + distinguished, suggestedSort); post.setPreviews(previews); post.setVideoUrl(url); post.setVideoDownloadUrl(url); @@ -587,7 +592,8 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, postType, voteType, nComments, upvoteRatio, flair, hidden, - spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, distinguished, suggestedSort); + spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, canModPost, + distinguished, suggestedSort); //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 c6490942..6780e628 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java @@ -76,6 +76,7 @@ public class Post implements Parcelable { @Nullable private Map mediaMetadataMap; private ArrayList gallery = new ArrayList<>(); + private boolean canModPost; //Text and video posts public Post(String id, String fullName, String subredditName, String subredditNamePrefixed, @@ -83,7 +84,7 @@ public class Post implements Parcelable { String title, String permalink, int score, int postType, int voteType, int nComments, int upvoteRatio, String flair, boolean hidden, boolean spoiler, boolean nsfw, boolean stickied, boolean archived, boolean locked, boolean saved, - boolean isCrosspost, String distinguished, String suggestedSort) { + boolean isCrosspost, boolean canModPost, String distinguished, String suggestedSort) { this.id = id; this.fullName = fullName; this.subredditName = subredditName; @@ -109,6 +110,7 @@ public class Post implements Parcelable { this.locked = locked; this.saved = saved; this.isCrosspost = isCrosspost; + this.canModPost = canModPost; this.distinguished = distinguished; this.suggestedSort = suggestedSort; isRead = false; @@ -119,7 +121,7 @@ public class Post implements Parcelable { String url, String permalink, int score, int postType, int voteType, int nComments, int upvoteRatio, String flair, boolean hidden, boolean spoiler, boolean nsfw, boolean stickied, boolean archived, boolean locked, boolean saved, - boolean isCrosspost, String distinguished, String suggestedSort) { + boolean isCrosspost, boolean canModPost, String distinguished, String suggestedSort) { this.id = id; this.fullName = fullName; this.subredditName = subredditName; @@ -146,6 +148,7 @@ public class Post implements Parcelable { this.locked = locked; this.saved = saved; this.isCrosspost = isCrosspost; + this.canModPost = canModPost; this.distinguished = distinguished; this.suggestedSort = suggestedSort; isRead = false; @@ -192,6 +195,7 @@ public class Post implements Parcelable { locked = in.readByte() != 0; saved = in.readByte() != 0; isCrosspost = in.readByte() != 0; + canModPost = in.readByte() != 0; isRead = in.readByte() != 0; crosspostParentId = in.readString(); distinguished = in.readString(); @@ -523,6 +527,7 @@ public class Post implements Parcelable { dest.writeByte((byte) (locked ? 1 : 0)); dest.writeByte((byte) (saved ? 1 : 0)); dest.writeByte((byte) (isCrosspost ? 1 : 0)); + dest.writeByte((byte) (canModPost ? 1 : 0)); dest.writeByte((byte) (isRead ? 1 : 0)); dest.writeString(crosspostParentId); dest.writeString(distinguished); @@ -557,6 +562,10 @@ public class Post implements Parcelable { return isCrosspost; } + public boolean isCanModPost() { + return canModPost; + } + public void markAsRead() { isRead = true; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/JSONUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/JSONUtils.java index 6a2730a3..38c322ad 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/JSONUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/JSONUtils.java @@ -200,6 +200,7 @@ public class JSONUtils { public static final String PROFILE_IMG_KEY = "profile_img"; public static final String AUTHOR_FULLNAME_KEY = "author_fullname"; public static final String IS_MOD_KEY = "is_mod"; + public static final String CAN_MOD_POST_KEY = "can_mod_post"; @Nullable public static Map parseMediaMetadata(JSONObject data) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/MaterialYouUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/MaterialYouUtils.java index fbc529cc..dce45d1a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/MaterialYouUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/MaterialYouUtils.java @@ -96,7 +96,7 @@ public class MaterialYouUtils { lightTheme.colorAccent = context.getColor(android.R.color.system_accent3_300); lightTheme.colorPrimaryLightTheme = lightTheme.colorPrimary; lightTheme.backgroundColor = context.getColor(android.R.color.system_neutral1_50); - lightTheme.cardViewBackgroundColor = context.getColor(android.R.color.system_neutral2_10); + lightTheme.cardViewBackgroundColor = context.getColor(android.R.color.system_accent3_10); lightTheme.filledCardViewBackgroundColor = lightTheme.cardViewBackgroundColor; lightTheme.commentBackgroundColor = context.getColor(android.R.color.system_neutral2_10); lightTheme.awardedCommentBackgroundColor = context.getColor(android.R.color.system_neutral2_10); diff --git a/app/src/main/res/drawable/ic_mod_24dp.xml b/app/src/main/res/drawable/ic_mod_24dp.xml new file mode 100644 index 00000000..20963870 --- /dev/null +++ b/app/src/main/res/drawable/ic_mod_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/fragment_post_options_bottom_sheet.xml b/app/src/main/res/layout/fragment_post_options_bottom_sheet.xml index 390606ff..68236b2b 100644 --- a/app/src/main/res/layout/fragment_post_options_bottom_sheet.xml +++ b/app/src/main/res/layout/fragment_post_options_bottom_sheet.xml @@ -172,6 +172,27 @@ android:textSize="?attr/font_default" app:drawableTint="?attr/primaryTextColor" /> + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fbdf0009..bca1cb90 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1546,4 +1546,6 @@ Long Press on Media Show Post Options Preview in Fullscreen + + Moderation