diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerFragment.kt b/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerFragment.kt index 2b3cb0fe07bd..ca89ea0b008c 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerFragment.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerFragment.kt @@ -228,7 +228,28 @@ class PreviewerFragment : } override fun dispatchKeyEvent(event: KeyEvent): Boolean { - if (event.action != KeyEvent.ACTION_DOWN) return false + if (event.action == KeyEvent.ACTION_UP) return false + + if (event.isCtrlPressed) { + when (event.keyCode) { + KeyEvent.KEYCODE_1 -> viewModel.toggleFlag(Flag.RED) + KeyEvent.KEYCODE_2 -> viewModel.toggleFlag(Flag.ORANGE) + KeyEvent.KEYCODE_3 -> viewModel.toggleFlag(Flag.GREEN) + KeyEvent.KEYCODE_4 -> viewModel.toggleFlag(Flag.BLUE) + KeyEvent.KEYCODE_5 -> viewModel.toggleFlag(Flag.PINK) + KeyEvent.KEYCODE_6 -> viewModel.toggleFlag(Flag.TURQUOISE) + KeyEvent.KEYCODE_7 -> viewModel.toggleFlag(Flag.PURPLE) + else -> return false + } + return true + } + + when (event.unicodeChar.toChar()) { + '*' -> { + viewModel.toggleMark() + return true + } + } when (event.keyCode) { KeyEvent.KEYCODE_DPAD_LEFT -> { diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerViewModel.kt b/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerViewModel.kt index 932c96cba7f9..fc02a21a69c1 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerViewModel.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerViewModel.kt @@ -129,6 +129,14 @@ class PreviewerViewModel(previewerIdsFile: PreviewerIdsFile, firstIndex: Int, ca } } + fun toggleFlag(flag: Flag) { + if (flagCode.value == flag.code) { + setFlag(Flag.NONE) + } else { + setFlag(flag) + } + } + /** * Shows the current card's answer * or the next question if the answer is already being shown