diff options
author | Michael Wright <michaelwr@google.com> | 2013-07-19 15:55:14 -0700 |
---|---|---|
committer | Michael Wright <michaelwr@google.com> | 2013-07-19 16:15:19 -0700 |
commit | 24d36f592224d1316165f579bb0937df0bf42f7c (patch) | |
tree | a02205d7a53867ba1299720d9973601681e1c234 /core | |
parent | 25b0c3096131e532e57f5aac48769430dca42c75 (diff) | |
download | frameworks_base-24d36f592224d1316165f579bb0937df0bf42f7c.zip frameworks_base-24d36f592224d1316165f579bb0937df0bf42f7c.tar.gz frameworks_base-24d36f592224d1316165f579bb0937df0bf42f7c.tar.bz2 |
Take advantage of KeyEvent.isConfirmKey
Change-Id: I2925c624338a5c622a7b3fef05b62099465b6389
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/widget/AbsListView.java | 5 | ||||
-rw-r--r-- | core/java/android/widget/Gallery.java | 13 | ||||
-rw-r--r-- | core/java/android/widget/ListPopupWindow.java | 17 |
3 files changed, 9 insertions, 26 deletions
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index 52433a5..ffb9c68 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -2925,9 +2925,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te @Override public boolean onKeyUp(int keyCode, KeyEvent event) { - switch (keyCode) { - case KeyEvent.KEYCODE_DPAD_CENTER: - case KeyEvent.KEYCODE_ENTER: + if (KeyEvent.isConfirmKey(keyCode)) { if (!isEnabled()) { return true; } @@ -2943,7 +2941,6 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te setPressed(false); return true; } - break; } return super.onKeyUp(keyCode, event); } diff --git a/core/java/android/widget/Gallery.java b/core/java/android/widget/Gallery.java index c4ef11c..78ba6e0 100644 --- a/core/java/android/widget/Gallery.java +++ b/core/java/android/widget/Gallery.java @@ -1228,13 +1228,9 @@ public class Gallery extends AbsSpinner implements GestureDetector.OnGestureList @Override public boolean onKeyUp(int keyCode, KeyEvent event) { - switch (keyCode) { - case KeyEvent.KEYCODE_DPAD_CENTER: - case KeyEvent.KEYCODE_ENTER: { - + if (KeyEvent.isConfirmKey(keyCode)) { if (mReceivedInvokeKeyDown) { if (mItemCount > 0) { - dispatchPress(mSelectedChild); postDelayed(new Runnable() { @Override @@ -1242,20 +1238,17 @@ public class Gallery extends AbsSpinner implements GestureDetector.OnGestureList dispatchUnpress(); } }, ViewConfiguration.getPressedStateDuration()); - + int selectedIndex = mSelectedPosition - mFirstPosition; performItemClick(getChildAt(selectedIndex), mSelectedPosition, mAdapter .getItemId(mSelectedPosition)); } } - + // Clear the flag mReceivedInvokeKeyDown = false; - return true; } - } - return super.onKeyUp(keyCode, event); } diff --git a/core/java/android/widget/ListPopupWindow.java b/core/java/android/widget/ListPopupWindow.java index 3d6b69e..414c318 100644 --- a/core/java/android/widget/ListPopupWindow.java +++ b/core/java/android/widget/ListPopupWindow.java @@ -821,8 +821,7 @@ public class ListPopupWindow { // to select one of its items if (keyCode != KeyEvent.KEYCODE_SPACE && (mDropDownList.getSelectedItemPosition() >= 0 - || (keyCode != KeyEvent.KEYCODE_ENTER - && keyCode != KeyEvent.KEYCODE_DPAD_CENTER))) { + || !KeyEvent.isConfirmKey(keyCode))) { int curIndex = mDropDownList.getSelectedItemPosition(); boolean consumed; @@ -910,16 +909,10 @@ public class ListPopupWindow { public boolean onKeyUp(int keyCode, KeyEvent event) { if (isShowing() && mDropDownList.getSelectedItemPosition() >= 0) { boolean consumed = mDropDownList.onKeyUp(keyCode, event); - if (consumed) { - switch (keyCode) { - // if the list accepts the key events and the key event - // was a click, the text view gets the selected item - // from the drop down as its content - case KeyEvent.KEYCODE_ENTER: - case KeyEvent.KEYCODE_DPAD_CENTER: - dismiss(); - break; - } + if (consumed && KeyEvent.isConfirmKey(keyCode)) { + // if the list accepts the key events and the key event was a click, the text view + // gets the selected item from the drop down as its content + dismiss(); } return consumed; } |