am 678b4c20: Merge change 25013 into eclair
Merge commit '678b4c20cb92ac2b86f13e52ea86d70301358680' into eclair-plus-aosp * commit '678b4c20cb92ac2b86f13e52ea86d70301358680': Various fixed for back key handling.
This commit is contained in:
@@ -34,6 +34,7 @@ import android.graphics.Canvas;
|
|||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
@@ -1752,8 +1753,16 @@ public class Activity extends ContextThemeWrapper
|
|||||||
*
|
*
|
||||||
* <p>If the focused view didn't want this event, this method is called.
|
* <p>If the focused view didn't want this event, this method is called.
|
||||||
*
|
*
|
||||||
* <p>The default implementation sets up state to call
|
* <p>The default implementation takes care of {@link KeyEvent#KEYCODE_BACK}
|
||||||
* {@link #onKeyLongPress}, and does other default key handling
|
* by calling {@link #onBackPressed()}, though the behavior varies based
|
||||||
|
* on the application compatibility mode: for
|
||||||
|
* {@link android.os.Build.VERSION_CODES#ECLAIR} or later applications,
|
||||||
|
* it will set up the dispatch to call {@link #onKeyUp} where the action
|
||||||
|
* will be performed; for earlier applications, it will perform the
|
||||||
|
* action immediately in on-down, as those versions of the platform
|
||||||
|
* behaved.
|
||||||
|
*
|
||||||
|
* <p>Other additional default key handling may be performed
|
||||||
* if configured with {@link #setDefaultKeyMode}.
|
* if configured with {@link #setDefaultKeyMode}.
|
||||||
*
|
*
|
||||||
* @return Return <code>true</code> to prevent this event from being propagated
|
* @return Return <code>true</code> to prevent this event from being propagated
|
||||||
@@ -1764,7 +1773,12 @@ public class Activity extends ContextThemeWrapper
|
|||||||
*/
|
*/
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||||
event.startTracking();
|
if (getApplicationInfo().targetSdkVersion
|
||||||
|
>= Build.VERSION_CODES.ECLAIR) {
|
||||||
|
event.startTracking();
|
||||||
|
} else {
|
||||||
|
onBackPressed();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1841,10 +1855,13 @@ public class Activity extends ContextThemeWrapper
|
|||||||
* @see KeyEvent
|
* @see KeyEvent
|
||||||
*/
|
*/
|
||||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK && event.isTracking()
|
if (getApplicationInfo().targetSdkVersion
|
||||||
&& !event.isCanceled()) {
|
>= Build.VERSION_CODES.ECLAIR) {
|
||||||
onBackPressed();
|
if (keyCode == KeyEvent.KEYCODE_BACK && event.isTracking()
|
||||||
return true;
|
&& !event.isCanceled()) {
|
||||||
|
onBackPressed();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -2016,11 +2033,14 @@ public class Activity extends ContextThemeWrapper
|
|||||||
*/
|
*/
|
||||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||||
onUserInteraction();
|
onUserInteraction();
|
||||||
if (getWindow().superDispatchKeyEvent(event)) {
|
Window win = getWindow();
|
||||||
|
if (win.superDispatchKeyEvent(event)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return event.dispatch(this, mDecor != null
|
View decor = mDecor;
|
||||||
? mDecor.getKeyDispatcherState() : null, this);
|
if (decor == null) decor = win.getDecorView();
|
||||||
|
return event.dispatch(this, decor != null
|
||||||
|
? decor.getKeyDispatcherState() : null, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ import android.util.Log;
|
|||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewConfiguration;
|
import android.view.ViewConfiguration;
|
||||||
@@ -1684,7 +1683,6 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
|
|||||||
public static class SearchAutoComplete extends AutoCompleteTextView {
|
public static class SearchAutoComplete extends AutoCompleteTextView {
|
||||||
|
|
||||||
private int mThreshold;
|
private int mThreshold;
|
||||||
private int mLastKeyDown;
|
|
||||||
private SearchDialog mSearchDialog;
|
private SearchDialog mSearchDialog;
|
||||||
|
|
||||||
public SearchAutoComplete(Context context) {
|
public SearchAutoComplete(Context context) {
|
||||||
@@ -1765,26 +1763,26 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
|
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
|
||||||
mLastKeyDown = keyCode;
|
|
||||||
if (mSearchDialog.mSearchable == null) {
|
if (mSearchDialog.mSearchable == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||||
if (event.getAction() == KeyEvent.ACTION_DOWN
|
if (event.getAction() == KeyEvent.ACTION_DOWN
|
||||||
&& event.getRepeatCount() == 0) {
|
&& event.getRepeatCount() == 0) {
|
||||||
// We releae the back key, might we want to do
|
// We release the back key, might we want to do
|
||||||
// something before the IME?
|
// something before the IME?
|
||||||
if (mSearchDialog.backToPreviousComponent(false)) {
|
if (mSearchDialog.backToPreviousComponent(false)) {
|
||||||
|
getKeyDispatcherState().startTracking(event, this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (isInputMethodNotNeeded() ||
|
if (isInputMethodNotNeeded() ||
|
||||||
(isEmpty() && getDropDownChildCount() >= getAdapterCount())) {
|
(isEmpty() && getDropDownChildCount() >= getAdapterCount())) {
|
||||||
|
getKeyDispatcherState().startTracking(event, this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
mLastKeyDown = 0;
|
|
||||||
return false; // will dismiss soft keyboard if necessary
|
return false; // will dismiss soft keyboard if necessary
|
||||||
} else if (event.getAction() == KeyEvent.ACTION_UP
|
} else if (event.getAction() == KeyEvent.ACTION_UP
|
||||||
&& mLastKeyDown == keyCode && !event.isCanceled()) {
|
&& event.isTracking() && !event.isCanceled()) {
|
||||||
if (mSearchDialog.backToPreviousComponent(true)) {
|
if (mSearchDialog.backToPreviousComponent(true)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1815,8 +1813,10 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
|
|||||||
|
|
||||||
protected boolean handleBackKey(int keyCode, KeyEvent event) {
|
protected boolean handleBackKey(int keyCode, KeyEvent event) {
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
if (event.getAction() == KeyEvent.ACTION_DOWN
|
||||||
|
&& event.getRepeatCount() == 0) {
|
||||||
// Consume the event, to get an up at which point we execute.
|
// Consume the event, to get an up at which point we execute.
|
||||||
|
event.startTracking();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (event.getAction() == KeyEvent.ACTION_UP && event.isTracking()
|
if (event.getAction() == KeyEvent.ACTION_UP && event.isTracking()
|
||||||
|
|||||||
@@ -143,6 +143,9 @@ public class Build {
|
|||||||
* Service.onStartCommand} function will return the new
|
* Service.onStartCommand} function will return the new
|
||||||
* {@link android.app.Service#START_STICKY} behavior instead of the
|
* {@link android.app.Service#START_STICKY} behavior instead of the
|
||||||
* old compatibility {@link android.app.Service#START_STICKY_COMPATIBILITY}.
|
* old compatibility {@link android.app.Service#START_STICKY_COMPATIBILITY}.
|
||||||
|
* <li> The {@link android.app.Activity} class will now execute back
|
||||||
|
* key presses on the key up instead of key down, to be able to detect
|
||||||
|
* canceled presses from virtual keys.
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
public static final int ECLAIR = CUR_DEVELOPMENT;
|
public static final int ECLAIR = CUR_DEVELOPMENT;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package android.view;
|
|||||||
|
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
import android.util.Log;
|
||||||
import android.util.SparseIntArray;
|
import android.util.SparseIntArray;
|
||||||
import android.view.KeyCharacterMap;
|
import android.view.KeyCharacterMap;
|
||||||
import android.view.KeyCharacterMap.KeyData;
|
import android.view.KeyCharacterMap.KeyData;
|
||||||
@@ -319,6 +320,9 @@ public class KeyEvent implements Parcelable {
|
|||||||
return KeyCharacterMap.getDeadChar(accent, c);
|
return KeyCharacterMap.getDeadChar(accent, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static final boolean DEBUG = false;
|
||||||
|
static final String TAG = "KeyEvent";
|
||||||
|
|
||||||
private int mMetaState;
|
private int mMetaState;
|
||||||
private int mAction;
|
private int mAction;
|
||||||
private int mKeyCode;
|
private int mKeyCode;
|
||||||
@@ -1028,13 +1032,17 @@ public class KeyEvent implements Parcelable {
|
|||||||
switch (mAction) {
|
switch (mAction) {
|
||||||
case ACTION_DOWN: {
|
case ACTION_DOWN: {
|
||||||
mFlags &= ~FLAG_START_TRACKING;
|
mFlags &= ~FLAG_START_TRACKING;
|
||||||
|
if (DEBUG) Log.v(TAG, "Key down to " + target + " in " + state
|
||||||
|
+ ": " + this);
|
||||||
boolean res = receiver.onKeyDown(mKeyCode, this);
|
boolean res = receiver.onKeyDown(mKeyCode, this);
|
||||||
if (state != null) {
|
if (state != null) {
|
||||||
if (res && mRepeatCount == 0 && (mFlags&FLAG_START_TRACKING) != 0) {
|
if (res && mRepeatCount == 0 && (mFlags&FLAG_START_TRACKING) != 0) {
|
||||||
|
if (DEBUG) Log.v(TAG, " Start tracking!");
|
||||||
state.startTracking(this, target);
|
state.startTracking(this, target);
|
||||||
} else if (isLongPress() && state.isTracking(this)) {
|
} else if (isLongPress() && state.isTracking(this)) {
|
||||||
try {
|
try {
|
||||||
if (receiver.onKeyLongPress(mKeyCode, this)) {
|
if (receiver.onKeyLongPress(mKeyCode, this)) {
|
||||||
|
if (DEBUG) Log.v(TAG, " Clear from long press!");
|
||||||
state.performedLongPress(this);
|
state.performedLongPress(this);
|
||||||
res = true;
|
res = true;
|
||||||
}
|
}
|
||||||
@@ -1045,6 +1053,8 @@ public class KeyEvent implements Parcelable {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
case ACTION_UP:
|
case ACTION_UP:
|
||||||
|
if (DEBUG) Log.v(TAG, "Key up to " + target + " in " + state
|
||||||
|
+ ": " + this);
|
||||||
if (state != null) {
|
if (state != null) {
|
||||||
state.handleUpEvent(this);
|
state.handleUpEvent(this);
|
||||||
}
|
}
|
||||||
@@ -1085,6 +1095,7 @@ public class KeyEvent implements Parcelable {
|
|||||||
* Reset back to initial state.
|
* Reset back to initial state.
|
||||||
*/
|
*/
|
||||||
public void reset() {
|
public void reset() {
|
||||||
|
if (DEBUG) Log.v(TAG, "Reset: " + this);
|
||||||
mDownKeyCode = 0;
|
mDownKeyCode = 0;
|
||||||
mDownTarget = null;
|
mDownTarget = null;
|
||||||
mActiveLongPresses.clear();
|
mActiveLongPresses.clear();
|
||||||
@@ -1095,6 +1106,7 @@ public class KeyEvent implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
public void reset(Object target) {
|
public void reset(Object target) {
|
||||||
if (mDownTarget == target) {
|
if (mDownTarget == target) {
|
||||||
|
if (DEBUG) Log.v(TAG, "Reset in " + target + ": " + this);
|
||||||
mDownKeyCode = 0;
|
mDownKeyCode = 0;
|
||||||
mDownTarget = null;
|
mDownTarget = null;
|
||||||
}
|
}
|
||||||
@@ -1115,6 +1127,7 @@ public class KeyEvent implements Parcelable {
|
|||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Can only start tracking on a down event");
|
"Can only start tracking on a down event");
|
||||||
}
|
}
|
||||||
|
if (DEBUG) Log.v(TAG, "Start trackingt in " + target + ": " + this);
|
||||||
mDownKeyCode = event.getKeyCode();
|
mDownKeyCode = event.getKeyCode();
|
||||||
mDownTarget = target;
|
mDownTarget = target;
|
||||||
}
|
}
|
||||||
@@ -1145,12 +1158,15 @@ public class KeyEvent implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
public void handleUpEvent(KeyEvent event) {
|
public void handleUpEvent(KeyEvent event) {
|
||||||
final int keyCode = event.getKeyCode();
|
final int keyCode = event.getKeyCode();
|
||||||
|
if (DEBUG) Log.v(TAG, "Handle key up " + event + ": " + this);
|
||||||
int index = mActiveLongPresses.indexOfKey(keyCode);
|
int index = mActiveLongPresses.indexOfKey(keyCode);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
|
if (DEBUG) Log.v(TAG, " Index: " + index);
|
||||||
event.mFlags |= FLAG_CANCELED | FLAG_CANCELED_LONG_PRESS;
|
event.mFlags |= FLAG_CANCELED | FLAG_CANCELED_LONG_PRESS;
|
||||||
mActiveLongPresses.removeAt(index);
|
mActiveLongPresses.removeAt(index);
|
||||||
}
|
}
|
||||||
if (mDownKeyCode == keyCode) {
|
if (mDownKeyCode == keyCode) {
|
||||||
|
if (DEBUG) Log.v(TAG, " Tracking!");
|
||||||
event.mFlags |= FLAG_TRACKING;
|
event.mFlags |= FLAG_TRACKING;
|
||||||
mDownKeyCode = 0;
|
mDownKeyCode = 0;
|
||||||
mDownTarget = null;
|
mDownTarget = null;
|
||||||
|
|||||||
@@ -2946,7 +2946,9 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
|||||||
break;
|
break;
|
||||||
case KeyEvent.KEYCODE_BACK:
|
case KeyEvent.KEYCODE_BACK:
|
||||||
if (mFiltered && mPopup != null && mPopup.isShowing()) {
|
if (mFiltered && mPopup != null && mPopup.isShowing()) {
|
||||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
if (event.getAction() == KeyEvent.ACTION_DOWN
|
||||||
|
&& event.getRepeatCount() == 0) {
|
||||||
|
getKeyDispatcherState().startTracking(event, this);
|
||||||
handled = true;
|
handled = true;
|
||||||
} else if (event.getAction() == KeyEvent.ACTION_UP
|
} else if (event.getAction() == KeyEvent.ACTION_UP
|
||||||
&& event.isTracking() && !event.isCanceled()) {
|
&& event.isTracking() && !event.isCanceled()) {
|
||||||
|
|||||||
@@ -132,8 +132,6 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
|
|||||||
|
|
||||||
private AutoCompleteTextView.PassThroughClickListener mPassThroughClickListener;
|
private AutoCompleteTextView.PassThroughClickListener mPassThroughClickListener;
|
||||||
|
|
||||||
private int mDownKeyCode;
|
|
||||||
|
|
||||||
public AutoCompleteTextView(Context context) {
|
public AutoCompleteTextView(Context context) {
|
||||||
this(context, null);
|
this(context, null);
|
||||||
}
|
}
|
||||||
@@ -605,19 +603,18 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
|
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
|
||||||
if (event.getAction() == KeyEvent.ACTION_DOWN
|
if (keyCode == KeyEvent.KEYCODE_BACK && isPopupShowing()
|
||||||
&& event.getRepeatCount() == 0) {
|
&& !mDropDownAlwaysVisible) {
|
||||||
mDownKeyCode = keyCode;
|
|
||||||
}
|
|
||||||
if (isPopupShowing()) {
|
|
||||||
// special case for the back key, we do not even try to send it
|
// special case for the back key, we do not even try to send it
|
||||||
// to the drop down list but instead, consume it immediately
|
// to the drop down list but instead, consume it immediately
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK && !mDropDownAlwaysVisible) {
|
if (event.getAction() == KeyEvent.ACTION_DOWN
|
||||||
if (event.getAction() == KeyEvent.ACTION_UP
|
&& event.getRepeatCount() == 0) {
|
||||||
&& mDownKeyCode == keyCode && !event.isCanceled()) {
|
getKeyDispatcherState().startTracking(event, this);
|
||||||
dismissDropDown();
|
return true;
|
||||||
return true;
|
} else if (event.getAction() == KeyEvent.ACTION_UP
|
||||||
}
|
&& event.isTracking() && !event.isCanceled()) {
|
||||||
|
dismissDropDown();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.onKeyPreIme(keyCode, event);
|
return super.onKeyPreIme(keyCode, event);
|
||||||
@@ -1026,7 +1023,6 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
|
|||||||
@Override
|
@Override
|
||||||
public void onWindowFocusChanged(boolean hasWindowFocus) {
|
public void onWindowFocusChanged(boolean hasWindowFocus) {
|
||||||
super.onWindowFocusChanged(hasWindowFocus);
|
super.onWindowFocusChanged(hasWindowFocus);
|
||||||
mDownKeyCode = 0;
|
|
||||||
performValidation();
|
performValidation();
|
||||||
if (!hasWindowFocus && !mDropDownAlwaysVisible) {
|
if (!hasWindowFocus && !mDropDownAlwaysVisible) {
|
||||||
dismissDropDown();
|
dismissDropDown();
|
||||||
@@ -1036,7 +1032,6 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
|
|||||||
@Override
|
@Override
|
||||||
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
|
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
|
||||||
super.onFocusChanged(focused, direction, previouslyFocusedRect);
|
super.onFocusChanged(focused, direction, previouslyFocusedRect);
|
||||||
mDownKeyCode = 0;
|
|
||||||
performValidation();
|
performValidation();
|
||||||
if (!focused && !mDropDownAlwaysVisible) {
|
if (!focused && !mDropDownAlwaysVisible) {
|
||||||
dismissDropDown();
|
dismissDropDown();
|
||||||
|
|||||||
@@ -1323,8 +1323,16 @@ public class PopupWindow {
|
|||||||
@Override
|
@Override
|
||||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||||
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
||||||
dismiss();
|
if (event.getAction() == KeyEvent.ACTION_DOWN
|
||||||
return true;
|
&& event.getRepeatCount() == 0) {
|
||||||
|
getKeyDispatcherState().startTracking(event, this);
|
||||||
|
return true;
|
||||||
|
} else if (event.getAction() == KeyEvent.ACTION_UP
|
||||||
|
&& event.isTracking() && !event.isCanceled()) {
|
||||||
|
dismiss();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.dispatchKeyEvent(event);
|
||||||
} else {
|
} else {
|
||||||
return super.dispatchKeyEvent(event);
|
return super.dispatchKeyEvent(event);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -476,7 +476,21 @@ public class ZoomButtonsController implements View.OnTouchListener {
|
|||||||
if (isInterestingKey(keyCode)) {
|
if (isInterestingKey(keyCode)) {
|
||||||
|
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||||
setVisible(false);
|
if (event.getAction() == KeyEvent.ACTION_DOWN
|
||||||
|
&& event.getRepeatCount() == 0) {
|
||||||
|
if (mOwnerView != null) {
|
||||||
|
KeyEvent.DispatcherState ds = mOwnerView.getKeyDispatcherState();
|
||||||
|
if (ds != null) {
|
||||||
|
ds.startTracking(event, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else if (event.getAction() == KeyEvent.ACTION_UP
|
||||||
|
&& event.isTracking() && !event.isCanceled()) {
|
||||||
|
setVisible(false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
dismissControlsDelayed(ZOOM_CONTROLS_TIMEOUT);
|
dismissControlsDelayed(ZOOM_CONTROLS_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import android.content.DialogInterface;
|
|||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.ListAdapter;
|
import android.widget.ListAdapter;
|
||||||
|
|
||||||
@@ -86,18 +87,26 @@ public class MenuDialogHelper implements DialogInterface.OnKeyListener, DialogIn
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
|
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
|
||||||
/*
|
if (keyCode == KeyEvent.KEYCODE_MENU || keyCode == KeyEvent.KEYCODE_BACK) {
|
||||||
* Close menu on key down (more responsive, and there's no way to cancel
|
if (event.getAction() == KeyEvent.ACTION_DOWN
|
||||||
* a key press so no point having it on key up. Note: This is also
|
&& event.getRepeatCount() == 0) {
|
||||||
* needed because when a top-level menu item that shows a submenu is
|
Window win = mDialog.getWindow();
|
||||||
* invoked by chording, this onKey method will be called with the menu
|
if (win != null) {
|
||||||
* up event.
|
View decor = win.getDecorView();
|
||||||
*/
|
if (decor != null) {
|
||||||
if (event.getAction() == KeyEvent.ACTION_DOWN && (keyCode == KeyEvent.KEYCODE_MENU)
|
KeyEvent.DispatcherState ds = decor.getKeyDispatcherState();
|
||||||
|| (keyCode == KeyEvent.KEYCODE_BACK)) {
|
if (ds != null) {
|
||||||
mMenu.close(true);
|
ds.startTracking(event, this);
|
||||||
dialog.dismiss();
|
return true;
|
||||||
return true;
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (event.getAction() == KeyEvent.ACTION_UP
|
||||||
|
&& event.isTracking() && !event.isCanceled()) {
|
||||||
|
mMenu.close(true);
|
||||||
|
dialog.dismiss();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Menu shortcut matching
|
// Menu shortcut matching
|
||||||
|
|||||||
Reference in New Issue
Block a user