From 36e774c37033eef36e0286147ee3ff8c668efb14 Mon Sep 17 00:00:00 2001 From: Contributor <> Date: Fri, 3 Apr 2026 08:43:01 -0700 Subject: [PATCH 1/2] update report message form field per astral --- .../src/main/java/com/ferg/awfulapp/constants/Constants.java | 1 - Awful.apk/src/main/java/com/ferg/awfulapp/task/ReportRequest.kt | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Awful.apk/src/main/java/com/ferg/awfulapp/constants/Constants.java b/Awful.apk/src/main/java/com/ferg/awfulapp/constants/Constants.java index 1678b15b8..f4a919394 100644 --- a/Awful.apk/src/main/java/com/ferg/awfulapp/constants/Constants.java +++ b/Awful.apk/src/main/java/com/ferg/awfulapp/constants/Constants.java @@ -88,7 +88,6 @@ public class Constants { public static final String PARAM_VOTE = "vote"; public static final String PARAM_POST_ID = "postid"; public static final String PARAM_USERLIST = "userlist"; - public static final String PARAM_COMMENTS = "comments"; public static final String PARAM_FORMKEY = "formkey"; public static final String PARAM_FORM_COOKIE = "form_cookie"; public static final String PARAM_ATTACHMENT = "attachment"; diff --git a/Awful.apk/src/main/java/com/ferg/awfulapp/task/ReportRequest.kt b/Awful.apk/src/main/java/com/ferg/awfulapp/task/ReportRequest.kt index c1d616ff0..4b5ce95e7 100644 --- a/Awful.apk/src/main/java/com/ferg/awfulapp/task/ReportRequest.kt +++ b/Awful.apk/src/main/java/com/ferg/awfulapp/task/ReportRequest.kt @@ -18,7 +18,7 @@ class ReportRequest(context: Context, private val postId: Int, private val comme init { with(parameters) { - add(PARAM_COMMENTS, comments) + add(PARAM_MESSAGE, comments) add(PARAM_POST_ID, postId.toString()) add(PARAM_ACTION, "submit") } From 9eb941b47771941a8e070ae91a0d4633c6f7b1a9 Mon Sep 17 00:00:00 2001 From: Contributor <> Date: Fri, 3 Apr 2026 09:45:39 -0700 Subject: [PATCH 2/2] prevent double report error toasts and add astral's new report screen warnings to our popup --- .../ferg/awfulapp/ThreadDisplayFragment.java | 31 +++++++++++++++---- .../ferg/awfulapp/task/ReportCheckRequest.kt | 27 +++++++++++++--- Awful.apk/src/main/res/values/colors.xml | 2 ++ 3 files changed, 50 insertions(+), 10 deletions(-) diff --git a/Awful.apk/src/main/java/com/ferg/awfulapp/ThreadDisplayFragment.java b/Awful.apk/src/main/java/com/ferg/awfulapp/ThreadDisplayFragment.java index 6fb083bec..7d2c55f22 100644 --- a/Awful.apk/src/main/java/com/ferg/awfulapp/ThreadDisplayFragment.java +++ b/Awful.apk/src/main/java/com/ferg/awfulapp/ThreadDisplayFragment.java @@ -46,8 +46,11 @@ import android.os.Bundle; import android.os.Environment; import android.os.Handler; +import android.text.SpannableString; +import android.text.SpannableStringBuilder; import android.text.TextUtils; import android.text.format.Formatter; +import android.text.style.ForegroundColorSpan; import android.view.InflateException; import android.view.LayoutInflater; import android.view.Menu; @@ -84,6 +87,7 @@ import com.ferg.awfulapp.task.RedirectTask; import com.ferg.awfulapp.task.RefreshUserProfileRequest; import com.ferg.awfulapp.task.ReportCheckRequest; +import com.ferg.awfulapp.task.ReportCheckResult; import com.ferg.awfulapp.task.ReportRequest; import com.ferg.awfulapp.task.SinglePostRequest; import com.ferg.awfulapp.task.ThreadLockUnlockRequest; @@ -770,14 +774,14 @@ public void toggleUserPosts(int aPostId, int aUserId, String aUsername){ */ public void reportUser(int postId){ queueRequest(new ReportCheckRequest(getActivity(), postId) - .build(ThreadDisplayFragment.this, new AwfulRequest.AwfulResultCallback() { + .build(ThreadDisplayFragment.this, new AwfulRequest.AwfulResultCallback() { @Override - public void success(Boolean alreadyReported) { - if (alreadyReported) { + public void success(ReportCheckResult result) { + if (result.getAlreadyReported()) { getAlertView().setTitle("This post has already been reported recently") .setIcon(R.drawable.ic_mood).show(); } else { - showReportDialog(postId); + showReportDialog(postId, result.getWarning() != null ? result.getWarning() : ""); } } @@ -789,12 +793,27 @@ public void failure(VolleyError error) { })); } - private void showReportDialog(int postId) { + private void showReportDialog(int postId, String warning) { final EditText reportReason = new EditText(this.getActivity()); + String body = "Did this post break the forum rules? If so, please report it by clicking below. If you would like to add any comments explaining why you submitted this post, please do so here:"; + CharSequence message; + if (warning.isEmpty()) { + message = body; + } else { + int warningColor = getResources().getColor(R.color.popup_warning_text); + SpannableString warningSpan = new SpannableString(warning); + warningSpan.setSpan(new ForegroundColorSpan(warningColor), 0, warning.length(), 0); + SpannableStringBuilder sb = new SpannableStringBuilder(); + sb.append(warningSpan); + sb.append("\n\n"); + sb.append(body); + message = sb; + } + new AlertDialog.Builder(this.getActivity()) .setTitle("Report inappropriate post") - .setMessage("Did this post break the forum rules? If so, please report it by clicking below. If you would like to add any comments explaining why you submitted this post, please do so here:") + .setMessage(message) .setView(reportReason) .setPositiveButton("Report", (dialog, whichButton) -> { String reason = reportReason.getText().toString(); diff --git a/Awful.apk/src/main/java/com/ferg/awfulapp/task/ReportCheckRequest.kt b/Awful.apk/src/main/java/com/ferg/awfulapp/task/ReportCheckRequest.kt index 94a31f7b7..0009c925a 100644 --- a/Awful.apk/src/main/java/com/ferg/awfulapp/task/ReportCheckRequest.kt +++ b/Awful.apk/src/main/java/com/ferg/awfulapp/task/ReportCheckRequest.kt @@ -2,20 +2,39 @@ package com.ferg.awfulapp.task import android.content.Context import com.ferg.awfulapp.constants.Constants.* +import com.ferg.awfulapp.util.AwfulError import org.jsoup.nodes.Document /** - * A request that checks whether a post has already been reported recently. + * Checks whether a post has already been reported, and if it hasn't it grabs the warning + * text above the report editor (e.g. the post is more than two weeks old). + * + * Overrides [handleCriticalError] since the already-reported page triggers the base + * class's standarderror detection. */ class ReportCheckRequest(context: Context, postId: Int) - : AwfulRequest(context, FUNCTION_REPORT) { + : AwfulRequest(context, FUNCTION_REPORT) { init { parameters.add(PARAM_POST_ID, postId.toString()) } - override fun handleResponse(doc: Document): Boolean { + override fun handleCriticalError(error: AwfulError, doc: Document): Boolean = true + + override fun handleResponse(doc: Document): ReportCheckResult { val body = doc.body() - return body != null && body.hasClass("standarderror") + if (body.hasClass("standarderror")) { + return ReportCheckResult(alreadyReported = true) + } + val warning = body.select("span.warningsmalltext") + ?.mapNotNull { it.text().takeIf(String::isNotBlank) } + ?.joinToString("\n") + ?.takeIf(String::isNotEmpty) + return ReportCheckResult(alreadyReported = false, warning = warning) } } + +data class ReportCheckResult( + val alreadyReported: Boolean, + val warning: String? = null +) diff --git a/Awful.apk/src/main/res/values/colors.xml b/Awful.apk/src/main/res/values/colors.xml index 76dcc83f1..ae5779bd0 100644 --- a/Awful.apk/src/main/res/values/colors.xml +++ b/Awful.apk/src/main/res/values/colors.xml @@ -57,6 +57,8 @@ #1A2800 #1E0E00 + #FF0000 +