From 9a3b17e1bc3c3bd4bc1c5b3c1f93e11d9429d24c Mon Sep 17 00:00:00 2001 From: cheb0chik Date: Fri, 6 Nov 2026 18:57:00 +0300 Subject: [PATCH] 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 --- AndroidManifest.xml | 4 +- src/lihonstore/app/ItemPage.java | 63 ++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 7d4a24b..f2c0e33 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="2" + android:versionName="0.2"> diff --git a/src/lihonstore/app/ItemPage.java b/src/lihonstore/app/ItemPage.java index 862aed7..3724a0b 100644 --- a/src/lihonstore/app/ItemPage.java +++ b/src/lihonstore/app/ItemPage.java @@ -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() { + @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();