From ddca3ee3e86fbaa05c1528bd72afd955f0fb4ee6 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Thu, 23 Jul 2009 19:01:31 -0700 Subject: Add support for power keys, improve behavior of virtual keys. The platform now knows how to deal with a platform key, which at this point is "just like end call, but don't end a call." Also improve the handling of virtual keys, to allow for canceling when sliding off into the display and providing haptic feedback. Finally fixes a bug where the raw x and y in motion event were not always set which caused the status bar to not work. --- core/java/android/view/KeyEvent.java | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'core/java/android/view/KeyEvent.java') diff --git a/core/java/android/view/KeyEvent.java b/core/java/android/view/KeyEvent.java index 6349288b7e4b..f9b16fc9f1a5 100644 --- a/core/java/android/view/KeyEvent.java +++ b/core/java/android/view/KeyEvent.java @@ -257,6 +257,25 @@ public class KeyEvent implements Parcelable { */ public static final int FLAG_EDITOR_ACTION = 0x10; + /** + * When associated with up key events, this indicates that the key press + * has been canceled. Typically this is used with virtual touch screen + * keys, where the user can slide from the virtual key area on to the + * display: in that case, the application will receive a canceled up + * event and should not perform the action normally associated with the + * key. Note that for this to work, the application can not perform an + * action for a key until it receives an up or the long press timeout has + * expired. + */ + public static final int FLAG_CANCELED = 0x20; + + /** + * This key event was generated by a virtual (on-screen) hard key area. + * Typically this is an area of the touchscreen, outside of the regular + * display, dedicated to "hardware" buttons. + */ + public static final int FLAG_VIRTUAL_HARD_KEY = 0x40; + /** * Returns the maximum keycode. */ @@ -693,6 +712,14 @@ public class KeyEvent implements Parcelable { return mAction; } + /** + * For {@link #ACTION_UP} events, indicates that the event has been + * canceled as per {@link #FLAG_CANCELED}. + */ + public final boolean isCanceled() { + return (mFlags&FLAG_CANCELED) != 0; + } + /** * Retrieve the key code of the key event. This is the physical key that * was pressed, not the Unicode character. -- cgit v1.2.3