Skip to content

Commit

Permalink
feat(new reviewer): show hint action
Browse files Browse the repository at this point in the history
  • Loading branch information
BrayanDSO committed Feb 8, 2025
1 parent f2127e4 commit 22bf1b0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
16 changes: 16 additions & 0 deletions AnkiDroid/src/main/assets/scripts/ankidroid.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,19 @@ globalThis.ankidroid.userAction = function (number) {
alert(e);
}
};

globalThis.ankidroid.showHint = function () {
var hints = document.querySelectorAll("a.hint");
for (var i = 0; i < hints.length; i++) {
if (hints[i].style.display != "none") {
hints[i].click();
break;
}
}
};

globalThis.ankidroid.showAllHints = function () {
document.querySelectorAll("a.hint").forEach(el => {
el.click();
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ enum class ViewerAction(
FLIP_OR_ANSWER_EASE2,
FLIP_OR_ANSWER_EASE3,
FLIP_OR_ANSWER_EASE4,
SHOW_HINT,
SHOW_ALL_HINTS,
;

override val preferenceKey: String get() = "binding_$name"
Expand All @@ -119,6 +121,8 @@ enum class ViewerAction(
SUSPEND_NOTE -> listOf(unicode('!'))
SUSPEND_CARD -> listOf(unicode('@'))
TOGGLE_AUTO_ADVANCE -> listOf(keycode(KeyEvent.KEYCODE_A, shift()))
SHOW_HINT -> listOf(keycode(KeyEvent.KEYCODE_H))
SHOW_ALL_HINTS -> listOf(keycode(KeyEvent.KEYCODE_G))
FLIP_OR_ANSWER_EASE1 ->
listOf(
keycode(KeyEvent.KEYCODE_BUTTON_Y),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,8 @@ class ReviewerViewModel(
ViewerAction.FLIP_OR_ANSWER_EASE2 -> flipOrAnswer(Ease.HARD)
ViewerAction.FLIP_OR_ANSWER_EASE3 -> flipOrAnswer(Ease.GOOD)
ViewerAction.FLIP_OR_ANSWER_EASE4 -> flipOrAnswer(Ease.EASY)
ViewerAction.SHOW_HINT -> eval.emit("ankidroid.showHint()")
ViewerAction.SHOW_ALL_HINTS -> eval.emit("ankidroid.showAllHints()")
ViewerAction.USER_ACTION_1 -> userAction(1)
ViewerAction.USER_ACTION_2 -> userAction(2)
ViewerAction.USER_ACTION_3 -> userAction(3)
Expand Down

0 comments on commit 22bf1b0

Please sign in to comment.