From 60ef384ac0d993f35582d8af6f437c702e87a556 Mon Sep 17 00:00:00 2001 From: MorenoTropical <154519856+morenotropical@users.noreply.github.com> Date: Fri, 11 Oct 2024 15:08:55 -0300 Subject: [PATCH] add missing user action message --- AnkiDroid/src/main/assets/scripts/card.js | 2 ++ .../java/com/ichi2/anki/AbstractFlashcardViewer.kt | 13 +++++++++++++ AnkiDroid/src/main/res/values/02-strings.xml | 1 + 3 files changed, 16 insertions(+) diff --git a/AnkiDroid/src/main/assets/scripts/card.js b/AnkiDroid/src/main/assets/scripts/card.js index 05dfa7b0f1d9..694a9aae4d81 100644 --- a/AnkiDroid/src/main/assets/scripts/card.js +++ b/AnkiDroid/src/main/assets/scripts/card.js @@ -253,6 +253,8 @@ function userAction(number) { let userJs = globalThis[`userJs${number}`]; if (userJs != null) { userJs(); + } else { + window.location.href = `missing-user-action:${number}`; } } catch (e) { alert(e); diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.kt b/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.kt index 663c0b8f1e9b..023326932312 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.kt @@ -2341,6 +2341,19 @@ abstract class AbstractFlashcardViewer : } return true } + if (url.startsWith("missing-user-action:")) { + val actionNumber = url.substringAfter(":") + val message = getString(R.string.missing_user_action_dialog_message, actionNumber) + AlertDialog.Builder(this@AbstractFlashcardViewer).show { + setTitle(R.string.vague_error) + setMessage(message) + setPositiveButton(R.string.dialog_ok) { _, _ -> } + setNeutralButton(R.string.help) { _, _ -> + openUrl(R.string.link_user_actions_help) + } + } + return true + } if (url.startsWith("videoended:")) { // note: 'q:0' is provided cardMediaPlayer.onVideoFinished() diff --git a/AnkiDroid/src/main/res/values/02-strings.xml b/AnkiDroid/src/main/res/values/02-strings.xml index f38a9e4c5052..038ec4b38f46 100644 --- a/AnkiDroid/src/main/res/values/02-strings.xml +++ b/AnkiDroid/src/main/res/values/02-strings.xml @@ -423,4 +423,5 @@ opening the system text to speech settings fails"> Edit browser appearance Press Alt+K to show keyboard shortcuts + User action %s is not set in this notetype. Please configure it