summaryrefslogtreecommitdiff
path: root/core/java/android/view/KeyEvent.java
diff options
context:
space:
mode:
authorMichael Wright <michaelwr@google.com>2014-03-29 00:56:00 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-03-29 00:56:00 +0000
commitd020fd33d147c88a9cda4976d2fa559e55b4ab03 (patch)
treef1efcf211ac61ea9deab18c423185faa1216ec6c /core/java/android/view/KeyEvent.java
parent594c73fc57c99a0bceaa84ccd7524e5038a17ad8 (diff)
parent1b10869f39978a864cfcc4efc73aefc312d8ed79 (diff)
Merge changes Ib18c99b9,I9f42eeb9 into klp-modular-dev
* changes: Generate and respect ACTION_CANCEL for joystick fallbacks. DO NOT MERGE Adds API for determining confirm and cancel keys.
Diffstat (limited to 'core/java/android/view/KeyEvent.java')
-rw-r--r--core/java/android/view/KeyEvent.java27
1 files changed, 23 insertions, 4 deletions
diff --git a/core/java/android/view/KeyEvent.java b/core/java/android/view/KeyEvent.java
index 6a6c1271a823..437ccfb29176 100644
--- a/core/java/android/view/KeyEvent.java
+++ b/core/java/android/view/KeyEvent.java
@@ -1847,13 +1847,32 @@ public class KeyEvent extends InputEvent implements Parcelable {
}
}
- /** Whether key will, by default, trigger a click on the focused view.
- * @hide
+ /**
+ * Returns true if the key event should be treated as a confirming action.
+ * @return True for a confirmation key, such as {@link #KEYCODE_DPAD_CENTER},
+ * {@link #KEYCODE_ENTER}, or {@link #KEYCODE_BUTTON_A}.
*/
- public static final boolean isConfirmKey(int keyCode) {
- switch (keyCode) {
+ public final boolean isConfirmKey() {
+ switch (mKeyCode) {
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_ENTER:
+ case KeyEvent.KEYCODE_BUTTON_A:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ /**
+ * Returns true if the key event should be treated as a cancelling action.
+ * @return True for a cancellation key, such as {@link #KEYCODE_ESCAPE},
+ * {@link #KEYCODE_BACK}, or {@link #KEYCODE_BUTTON_B}.
+ */
+ public final boolean isCancelKey() {
+ switch (mKeyCode) {
+ case KeyEvent.KEYCODE_BUTTON_B:
+ case KeyEvent.KEYCODE_ESCAPE:
+ case KeyEvent.KEYCODE_BACK:
return true;
default:
return false;