diff --git a/AnkiDroid/src/main/assets/scripts/card.js b/AnkiDroid/src/main/assets/scripts/card.js index f102e7d03e36..269db891ed4c 100644 --- a/AnkiDroid/src/main/assets/scripts/card.js +++ b/AnkiDroid/src/main/assets/scripts/card.js @@ -134,6 +134,12 @@ function ankiToggleFlag(flag) { } } +// Show toast using js +function ankiShowToast(message) { + var msg = encodeURI(message); + window.location.href = "signal:anki_show_toast:" + msg; +} + /* Tell the app the text in the input box when it loses focus */ function taBlur(itag) { //#5944 - percent wasn't encoded, but Mandarin was. diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.java b/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.java index 97a84ead5499..95a1396f3290 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.java +++ b/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.java @@ -3181,6 +3181,14 @@ private boolean filterUrl(String url) { } } + // Show toast using JS + if (url.startsWith("signal:anki_show_toast:")) { + String msg = url.replaceFirst("signal:anki_show_toast:", ""); + String msgDecode = decodeUrl(msg); + UIUtils.showThemedToast(AbstractFlashcardViewer.this, msgDecode, true); + return true; + } + int signalOrdinal = WebViewSignalParserUtils.getSignalFromUrl(url); switch (signalOrdinal) { case WebViewSignalParserUtils.SIGNAL_UNHANDLED: