You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
(1) Each KeyCode can have only one correspondence method. Even if there are "Multi-Keycodes"
Wrong:
@KeyDownpublicbooleanbackPressed() {}
// ERROR: Same keycode used in this activity@KeyDown(KeyEvent.KEYCODE_BACK)
publicbooleanonBackPressed(KeyEventevent) {}
// ERROR: Also apply for Multi-Keycodes@KeyDown({KeyEvent.KEYCODE_BACK, KeyEvent.KEYCODE_MENU})
publicbooleanonKeyPressed(intkeyCode) {}
(2) OnKeyLongPress can only used on Android 2.0+. OnKeyShortcut on Android 3.0+.
We'll report an error at compile time. Also, we need to specify in the Wiki
(3) At the moment, we don't support Fragment, because it does not support onKeyXX methods which write more complex.
If I have more free time, I will consider write it in future releases (4.0+, maybe).
i think this is because of the posibility to return a boolean if the key has been handled. what to do if a method wants to return true or false here? when there would be an ensured calling order that might be something that the developer could workaround, but due to the current nature of random order i think this limitation is valid.
Actually KeyEvent.Callback is implemented in lot of classes, not just in Activity. I think we should allow them in everywhere where they can be called and validate against whether it is implemented in the current class or not.
It is not implemented in Fragments, but it would be definitely useful. You can call getActivity().onKeyXXX there instead of onKeyXXXif (getActvity() != null).
@WonderCsabo
I'm sorry about that. I really do not have time to do it recently. Because there are some unforeseen circumstances I need to deal with.
I do this feature is expected to be completed after the Spring Festival (the end of February) .
If you want this feature anxiously, you can let someone else do it.
Activity
jiongxuan commentedon Nov 20, 2014
(1) OnKeyDown
Generate:
(2) OnKeyUp/OnKeyLongPress/OnKeyShortcut are very similar to OnKeyDown
(3) OnKeyMultiple
Generate:
(4) Multi-Keycodes
Generate:
jiongxuan commentedon Nov 20, 2014
Limitation:
(1) Each
KeyCodecan have only one correspondence method. Even if there are "Multi-Keycodes"Wrong:
You should do it manually:
(2)
OnKeyLongPresscan only used on Android 2.0+.OnKeyShortcuton Android 3.0+.We'll report an error at compile time. Also, we need to specify in the Wiki
(3) At the moment, we don't support
Fragment, because it does not supportonKeyXXmethods which write more complex.If I have more free time, I will consider write it in future releases (4.0+, maybe).
@WonderCsabo @yDelouis @dodgex
Any great idea? :)
yDelouis commentedon Nov 20, 2014
Looks good to me.
jiongxuan commentedon Nov 20, 2014
My English is not good, in order to avoid such problems such as English grammar, I still want to you to write down the Wiki and Cookbook part. :)
I take charge of to help you write the code, etc.
WonderCsabo commentedon Nov 20, 2014
I have several comments:
On Nov 20, 2014 9:39 AM, "Jiongxuan Zhang" notifications@github.com wrote:
dodgex commentedon Nov 20, 2014
i think this is because of the posibility to
returna boolean if the key has been handled. what to do if a method wants to return true or false here? when there would be an ensured calling order that might be something that the developer could workaround, but due to the current nature of random order i think this limitation is valid.jiongxuan commentedon Nov 20, 2014
I Edit it for a while
Okay
For ex.
If we consider to run
onBackPressed1first, Is there no need to performonBackPressed2?There are ruled out the "random call" situation
Fragmentdoes not haveonKeyXXmethods, we must:onKeyXXmethods which is own writtenActivity(you know i mean)There was too mixed up for me, in fact :)
Sure.
WonderCsabo commentedon Nov 20, 2014
Actually
KeyEvent.Callbackis implemented in lot of classes, not just inActivity. I think we should allow them in everywhere where they can be called and validate against whether it is implemented in the current class or not.It is not implemented in
Fragments, but it would be definitely useful. You can callgetActivity().onKeyXXXthere instead ofonKeyXXXif (getActvity() != null).WonderCsabo commentedon Dec 23, 2014
@jiongxuan any news on this?
jiongxuan commentedon Dec 26, 2014
@WonderCsabo
I'm sorry about that. I really do not have time to do it recently. Because there are some unforeseen circumstances I need to deal with.
I do this feature is expected to be completed after the Spring Festival (the end of February) .
If you want this feature anxiously, you can let someone else do it.
Thank you for understanding. :)
WonderCsabo commentedon Sep 12, 2015
Finally implemented.