LihonT Store 0.2
A rejected work gets a detailed report on request: a PDF with the reason in Russian, the AI model and the time of the check, red squares on what triggered it and the contact for an appeal. Saved to Downloads from the item page. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="lihonstore.app"
|
||||
android:versionCode="1"
|
||||
android:versionName="0.1">
|
||||
android:versionCode="2"
|
||||
android:versionName="0.2">
|
||||
|
||||
<uses-sdk android:minSdkVersion="31" android:targetSdkVersion="34"/>
|
||||
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
package lihonstore.app;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.provider.MediaStore;
|
||||
import android.util.Base64;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
@@ -68,6 +73,13 @@ final class ItemPage {
|
||||
action.setOnClickListener(v -> toggle());
|
||||
}
|
||||
Account account = host.account();
|
||||
if (account != null && account.uid.equals(item.authorUid) && "rejected".equals(item.status)) {
|
||||
TextView detail = theme.button(host, "Подробный отчёт (PDF)", false);
|
||||
detail.setOnClickListener(v -> report(detail));
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(-1, -2);
|
||||
params.topMargin = theme.dp(4);
|
||||
page.addView(detail, params);
|
||||
}
|
||||
if (account != null && account.uid.equals(item.authorUid) && item.listed && "approved".equals(item.status)) {
|
||||
TextView off = theme.button(host, "Снять с публикации", false);
|
||||
off.setOnClickListener(v -> unpublish());
|
||||
@@ -115,6 +127,57 @@ final class ItemPage {
|
||||
action.postDelayed(() -> action.setEnabled(true), 3000L);
|
||||
}
|
||||
|
||||
/** Asks for the detailed rejection report, saves it to Downloads and opens it. */
|
||||
private void report(final TextView button) {
|
||||
button.setEnabled(false);
|
||||
host.toast("Готовим отчёт, это до полуминуты");
|
||||
host.proven(() -> Work.run(() -> {
|
||||
JSONObject request = host.body();
|
||||
try {
|
||||
request.put("id", item.id);
|
||||
} catch (org.json.JSONException impossible) {
|
||||
throw new IllegalStateException(impossible);
|
||||
}
|
||||
return Api.post("report", request);
|
||||
}, new Work.Done<JSONObject>() {
|
||||
@Override public void ok(JSONObject reply) {
|
||||
button.setEnabled(true);
|
||||
save(Base64.decode(reply.optString("pdf", ""), Base64.DEFAULT));
|
||||
}
|
||||
|
||||
@Override public void failed(String message) {
|
||||
button.setEnabled(true);
|
||||
host.toast(message);
|
||||
}
|
||||
}));
|
||||
button.postDelayed(() -> button.setEnabled(true), 40000L);
|
||||
}
|
||||
|
||||
private void save(byte[] pdf) {
|
||||
if (pdf.length == 0) {
|
||||
host.toast("Отчёт пустой");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(MediaStore.Downloads.DISPLAY_NAME, "LihonT-отчёт-" + item.id.substring(0, 8) + ".pdf");
|
||||
values.put(MediaStore.Downloads.MIME_TYPE, "application/pdf");
|
||||
Uri uri = host.getContentResolver().insert(MediaStore.Downloads.EXTERNAL_CONTENT_URI, values);
|
||||
if (uri == null) throw new java.io.IOException("no uri");
|
||||
try (java.io.OutputStream out = host.getContentResolver().openOutputStream(uri)) {
|
||||
out.write(pdf);
|
||||
}
|
||||
host.toast("Отчёт сохранён в «Загрузки»");
|
||||
try {
|
||||
host.startActivity(new Intent(Intent.ACTION_VIEW).setDataAndType(uri, "application/pdf").addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION));
|
||||
} catch (android.content.ActivityNotFoundException noViewer) {
|
||||
// the file is in Downloads anyway
|
||||
}
|
||||
} catch (java.io.IOException | RuntimeException failed) {
|
||||
host.toast("Не удалось сохранить отчёт");
|
||||
}
|
||||
}
|
||||
|
||||
private void unpublish() {
|
||||
Work.run(() -> {
|
||||
JSONObject request = host.body();
|
||||
|
||||
Reference in New Issue
Block a user