diff options
author | Jeff Brown <jeffbrown@google.com> | 2011-03-09 18:29:22 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-03-09 18:29:22 -0800 |
commit | e2296212194a74438d80f77bc3d68d88b1f2be09 (patch) | |
tree | f5a3b6847833db5d667425e67a188d50296287db /core/java | |
parent | f49c3ae2da7b6343088200bdafdf6e9906258bf4 (diff) | |
parent | 06a0c9f5ee1f1c51607446f29ffb9697fa95e549 (diff) | |
download | frameworks_base-e2296212194a74438d80f77bc3d68d88b1f2be09.zip frameworks_base-e2296212194a74438d80f77bc3d68d88b1f2be09.tar.gz frameworks_base-e2296212194a74438d80f77bc3d68d88b1f2be09.tar.bz2 |
am 06a0c9f5: Merge "Make PointerLocationView also log generic motions and some keys. (DO NOT MERGE)" into honeycomb-mr1
* commit '06a0c9f5ee1f1c51607446f29ffb9697fa95e549':
Make PointerLocationView also log generic motions and some keys. (DO NOT MERGE)
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/com/android/internal/widget/PointerLocationView.java | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/core/java/com/android/internal/widget/PointerLocationView.java b/core/java/com/android/internal/widget/PointerLocationView.java index 5ac903d..076a1cb 100644 --- a/core/java/com/android/internal/widget/PointerLocationView.java +++ b/core/java/com/android/internal/widget/PointerLocationView.java @@ -23,6 +23,7 @@ import android.graphics.RectF; import android.graphics.Paint.FontMetricsInt; import android.util.Log; import android.view.InputDevice; +import android.view.KeyEvent; import android.view.MotionEvent; import android.view.VelocityTracker; import android.view.View; @@ -97,7 +98,8 @@ public class PointerLocationView extends View { public PointerLocationView(Context c) { super(c); - setFocusable(true); + setFocusableInTouchMode(true); + mVC = ViewConfiguration.get(c); mTextPaint = new Paint(); mTextPaint.setAntiAlias(true); @@ -505,22 +507,69 @@ public class PointerLocationView extends View { @Override public boolean onTouchEvent(MotionEvent event) { addPointerEvent(event); + + if (event.getAction() == MotionEvent.ACTION_DOWN && !isFocused()) { + requestFocus(); + } return true; } @Override public boolean onGenericMotionEvent(MotionEvent event) { - if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { + final int source = event.getSource(); + if ((source & InputDevice.SOURCE_CLASS_POINTER) != 0) { addPointerEvent(event); + } else if ((source & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) { + Log.i(TAG, "Joystick: " + event); + } else if ((source & InputDevice.SOURCE_CLASS_POSITION) != 0) { + Log.i(TAG, "Position: " + event); + } else { + Log.i(TAG, "Generic: " + event); + } + return true; + } + + @Override + public boolean onKeyDown(int keyCode, KeyEvent event) { + if (shouldLogKey(keyCode)) { + final int repeatCount = event.getRepeatCount(); + if (repeatCount == 0) { + Log.i(TAG, "Key Down: " + event); + } else { + Log.i(TAG, "Key Repeat #" + repeatCount + ": " + event); + } return true; } - return super.onGenericMotionEvent(event); + return super.onKeyDown(keyCode, event); + } + + @Override + public boolean onKeyUp(int keyCode, KeyEvent event) { + if (shouldLogKey(keyCode)) { + Log.i(TAG, "Key Up: " + event); + return true; + } + return super.onKeyUp(keyCode, event); + } + + private static boolean shouldLogKey(int keyCode) { + switch (keyCode) { + case KeyEvent.KEYCODE_DPAD_UP: + case KeyEvent.KEYCODE_DPAD_DOWN: + case KeyEvent.KEYCODE_DPAD_LEFT: + case KeyEvent.KEYCODE_DPAD_RIGHT: + case KeyEvent.KEYCODE_DPAD_CENTER: + return true; + default: + return KeyEvent.isGamepadButton(keyCode) + || KeyEvent.isModifierKey(keyCode); + } } @Override public boolean onTrackballEvent(MotionEvent event) { Log.i(TAG, "Trackball: " + event); - return super.onTrackballEvent(event); + return true; } // HACK |