Skip to content

Commit 952d01a

Browse files
committed
feat(preferences): shortcut for 'Display screen shortcuts'
'Show keyboard shortcuts' was unintuitive: app shortcuts only showed Ctrl+Z This makes the 'Access list of system / apps shortcuts' more prominent by including it in the 'Current app' tab It may be buggy on custom Android systems which change this default shortcut, but should work for the vast majority of systems Fixes 18488
1 parent 15cadc2 commit 952d01a

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

AnkiDroid/src/main/java/com/ichi2/anki/AnkiActivity.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,11 @@ open class AnkiActivity :
704704
ShortcutGroup(
705705
listOf(
706706
shortcut("Ctrl+Z", R.string.undo),
707+
// For 'Controls': to help user discover shortcuts in all screens
708+
// BUG: There is no way to access system shortcuts, so this may not be correct
709+
// This is copied from AOSP, which will be correct in most cases
710+
// https://cs.android.com/android/_/android/platform/frameworks/base/+/1cdfff555f4a21f71ccc978290e2e212e2f8b168:packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/source/SystemShortcutsSource.kt;l=162-166;bpv=1;bpt=0;drc=697cd49fb770afa8480d4c187b30553645b5879c
711+
shortcut("Meta+/", R.string.shortcut_label_show_shortcuts_for_app),
707712
),
708713
R.string.pref_cat_general,
709714
).toShortcutGroup(this)

AnkiDroid/src/main/java/com/ichi2/anki/android/input/Shortcut.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,15 @@ data class Shortcut(
5151
/**
5252
* Maps a modifier string to its corresponding KeyEvent meta flag.
5353
*
54-
* @param modifier The modifier string (e.g., "Ctrl", "Alt", "Shift").
54+
* @param modifier The modifier string (e.g., "Ctrl", "Alt", "Shift", "Meta").
5555
* @return The corresponding KeyEvent meta flag.
5656
*/
5757
private fun getModifier(modifier: String): Int =
5858
when (modifier) {
5959
"Ctrl" -> KeyEvent.META_CTRL_ON
6060
"Alt" -> KeyEvent.META_ALT_ON
6161
"Shift" -> KeyEvent.META_SHIFT_ON
62+
"Meta" -> KeyEvent.META_META_ON
6263

6364
else -> 0
6465
}

AnkiDroid/src/main/res/values/02-strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,5 +407,7 @@ opening the system text to speech settings fails">Failed to open text to speech
407407
<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>
408408

409409
<string name="directory_inaccessible_info">Learn more about how to restore access here %s or go to settings to update collection folder.</string>
410+
411+
<string name="shortcut_label_show_shortcuts_for_app">Display screen shortcuts</string>
410412
</resources>
411413

0 commit comments

Comments
 (0)