From c48c5dafdcfae8029423f92aaa8cf07a70460d7a Mon Sep 17 00:00:00 2001 From: MorenoTropical <154519856+morenotropical@users.noreply.github.com> Date: Tue, 10 Dec 2024 18:05:22 -0300 Subject: [PATCH] warn if user action is not set in new reviewer --- AnkiDroid/src/main/assets/scripts/ankidroid.js | 2 ++ .../com/ichi2/anki/previewer/CardViewerFragment.kt | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/AnkiDroid/src/main/assets/scripts/ankidroid.js b/AnkiDroid/src/main/assets/scripts/ankidroid.js index 5cf49c6085ae..a2dd0210bdbd 100644 --- a/AnkiDroid/src/main/assets/scripts/ankidroid.js +++ b/AnkiDroid/src/main/assets/scripts/ankidroid.js @@ -6,6 +6,8 @@ globalThis.ankidroid.userAction = function (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/previewer/CardViewerFragment.kt b/AnkiDroid/src/main/java/com/ichi2/anki/previewer/CardViewerFragment.kt index c9810cc5110d..878cf2541e0e 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/previewer/CardViewerFragment.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/previewer/CardViewerFragment.kt @@ -42,8 +42,10 @@ import com.ichi2.anki.dialogs.TtsVoicesDialogFragment import com.ichi2.anki.localizedErrorMessage import com.ichi2.anki.snackbar.showSnackbar import com.ichi2.anki.utils.ext.packageManager +import com.ichi2.anki.utils.openUrl import com.ichi2.compat.CompatHelper.Companion.resolveActivityCompat import com.ichi2.themes.Themes +import com.ichi2.utils.show import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import timber.log.Timber @@ -162,6 +164,17 @@ abstract class CardViewerFragment( "tts-voices" -> TtsVoicesDialogFragment().show(childFragmentManager, null) "android-app" -> handleIntentUrl(url, Intent.URI_ANDROID_APP_SCHEME) "intent" -> handleIntentUrl(url, Intent.URI_INTENT_SCHEME) + "missing-user-action" -> { + val actionNumber = url.toString().substringAfter(":") + val message = getString(R.string.missing_user_action_dialog_message, actionNumber) + AlertDialog.Builder(requireContext()).show { + setMessage(message) + setPositiveButton(R.string.dialog_ok) { _, _ -> } + setNeutralButton(R.string.help) { _, _ -> + openUrl(R.string.link_user_actions_help) + } + } + } else -> { try { openUrl(url)