New option in PostOptionsBottomSheetFragment: Moderation.

This commit is contained in:
Docile-Alligator
2025-07-09 16:39:36 -04:00
parent d3d3556fda
commit a698f32fd6
8 changed files with 79 additions and 22 deletions

View File

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

View File

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

View File

@ -76,6 +76,7 @@ public class Post implements Parcelable {
@Nullable
private Map<String, MediaMetadata> mediaMetadataMap;
private ArrayList<Gallery> 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;
}

View File

@ -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<String, MediaMetadata> parseMediaMetadata(JSONObject data) {

View File

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

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:pathData="M480,876q-7,0 -13,-1t-12,-3q-135,-45 -215,-166.5T160,444v-189q0,-25 14.5,-45t37.5,-29l240,-90q14,-5 28,-5t28,5l240,90q23,9 37.5,29t14.5,45v189q0,140 -80,261.5T505,872q-6,2 -12,3t-13,1ZM480,796q104,-33 172,-132t68,-220v-189l-240,-90 -240,90v189q0,121 68,220t172,132ZM480,480Z"
android:fillColor="#000000"/>
</vector>

View File

@ -172,6 +172,27 @@
android:textSize="?attr/font_default"
app:drawableTint="?attr/primaryTextColor" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/mod_text_view_post_options_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:drawableStart="@drawable/ic_mod_24dp"
android:drawablePadding="48dp"
android:focusable="true"
android:fontFamily="?attr/font_family"
android:paddingStart="32dp"
android:paddingTop="16dp"
android:paddingEnd="32dp"
android:paddingBottom="16dp"
android:text="@string/moderation"
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
android:visibility="gone"
app:drawableTint="?attr/primaryTextColor" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>

View File

@ -1546,4 +1546,6 @@
<string name="long_press_post_media">Long Press on Media</string>
<string name="show_post_options">Show Post Options</string>
<string name="preview_in_fullscreen">Preview in Fullscreen</string>
<string name="moderation">Moderation</string>
</resources>