-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: don't show warning on numpad #17495
Conversation
@SanjaySargam our PR template has an Approach section typically, where you would describe the why behind the change, that can help in review. I see the change and I can read the code and puzzle it out, but it is much quicker if you use the Approach section to say something like: "realized that the existing code makes XYZ assumption which isn't always true / mixes two ideas, split it into separate checks to more correctly NNN the AAA" or something |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it looks like you have done a refactor but I don't see any change in functionality
Did you reproduce this?
Can you show a video reproducing it before and not-reproducing it after?
If I'm reading the code correctly (I may not be - it is hard to review things when there is a refactor and a functional change mixed in the same commit) then I don't see anything that would/should affect behavior here
Yeah I dunno, can't make much sense of it with the refactor mixed in 🤷 . I just re-read it, still can't, and with no further explanation 🤷 |
Tbh, I still don't know why we don't use Android's default shortcut, which is
The user may have system shortcuts that AnkiDroid can't recognize for doing other things, so warning every time a unknown shortcut is used isn't sane IMO. And this is the 3rd? 4th? PR about shortcuts and still haven't got it right |
88caaa6
to
56aa7f4
Compare
@BrayanDSO I already tried this: if (event.isMetaPressed && keyCode == KeyEvent.KEYCODE_SLASH) {
showKeyboardShortcutsDialog()
return true
} but it's not working. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment was marked as outdated.
This comment was marked as outdated.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
For reference, I would solve this as: Index: AnkiDroid/src/main/java/com/ichi2/anki/android/input/Shortcut.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/android/input/Shortcut.kt b/AnkiDroid/src/main/java/com/ichi2/anki/android/input/Shortcut.kt
--- a/AnkiDroid/src/main/java/com/ichi2/anki/android/input/Shortcut.kt (revision 2c2fe1b46e8912eaadbb329d814de824f0ea5b4b)
+++ b/AnkiDroid/src/main/java/com/ichi2/anki/android/input/Shortcut.kt (date 1732899886387)
@@ -80,8 +80,12 @@
companion object {
@CheckResult
- fun isUnmappedShortcut(event: KeyEvent, keyCode: Int): Boolean =
- (event.isCtrlPressed || event.isAltPressed || event.isMetaPressed) && (keyCode in KeyEvent.KEYCODE_A..KeyEvent.KEYCODE_Z) || (keyCode in KeyEvent.KEYCODE_NUMPAD_0..KeyEvent.KEYCODE_NUMPAD_9)
+ fun isUnmappedShortcut(event: KeyEvent, keyCode: Int): Boolean {
+ val modifierPressed = (event.isCtrlPressed || event.isAltPressed || event.isMetaPressed)
+ if (!modifierPressed) return false
+ return (keyCode in KeyEvent.KEYCODE_A..KeyEvent.KEYCODE_Z) ||
+ (keyCode in KeyEvent.KEYCODE_NUMPAD_0..KeyEvent.KEYCODE_NUMPAD_9)
+ }
}
} |
This comment has been minimized.
This comment has been minimized.
companion object {
@CheckResult
fun isUnmappedShortcut(event: KeyEvent, keyCode: Int): Boolean =
(event.isCtrlPressed || event.isAltPressed || event.isMetaPressed) && ((keyCode in KeyEvent.KEYCODE_A..KeyEvent.KEYCODE_Z) || (keyCode in KeyEvent.KEYCODE_NUMPAD_0..KeyEvent.KEYCODE_NUMPAD_9))
} I changed like this. And it works/fixed problem. Can we go with this ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll leave this to Reviewer 2
It fixes the bug, I'd rather the code were a little more clear but I won't insist on it
AnkiDroid/src/main/java/com/ichi2/anki/android/input/Shortcut.kt
Outdated
Show resolved
Hide resolved
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've done the rebase, let's get this in
Now I can see the parentheses moving at least - they're not jumbled in with other changes, and it has test support
This comment was marked as resolved.
This comment was marked as resolved.
065414f
to
52fe4b8
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
feaf4b9
to
979a9c9
Compare
CI fixed in: 333ef64
|
Grouped the numeric key check with the modifier key check to ensure the condition is true only when both a modifier key and a numeric key are pressed
Purpose / Description
"Press Alt+K to show keyboard shortcuts" pops up on Numpad 1
Approach
Previously the code was incorrectly handled which it only checks isNumKey pressed then condition getting true which is not expected. I group isNumKey condition with isModifierKey it will be true when both modifier and num key pressed.
Fixes
How Has This Been Tested?
Chromebook
Checklist
Please, go through these checks before submitting the PR.