Skip to content

Commit

Permalink
add missing user action message
Browse files Browse the repository at this point in the history
  • Loading branch information
MorenoTropical authored and david-allison committed Oct 12, 2024
1 parent 1049265 commit fad9be5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions AnkiDroid/src/main/assets/scripts/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 13 additions & 0 deletions AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions AnkiDroid/src/main/res/values/02-strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -423,4 +423,5 @@ opening the system text to speech settings fails">
<string name="edit_browser_appearance" comment="Description of the shortcut that edits the browser appearance of card template">Edit browser appearance</string>

<string name="show_shortcuts_message">Press Alt+K to show keyboard shortcuts</string>
<string name="missing_user_action_dialog_message" comment="%s is the user action number">User action %s is not set in this notetype. Please configure it</string>
</resources>

0 comments on commit fad9be5

Please sign in to comment.