diff options
| author | Dianne Hackborn <hackbod@google.com> | 2009-10-14 18:21:28 -0700 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2009-10-14 18:21:28 -0700 |
| commit | 862eadb62221429b9e2bb86dd6b7c9c61110e95b (patch) | |
| tree | 5b7f368875595f4a2971e076f7e8d90f656f517d /apps/Development/src/com/android/development | |
| parent | 82bb67e55593074cc83123fe703e99c816463586 (diff) | |
| parent | a8baf9bcc8d9776e9aba35207af17723f7226027 (diff) | |
| download | android_development-862eadb62221429b9e2bb86dd6b7c9c61110e95b.tar.gz android_development-862eadb62221429b9e2bb86dd6b7c9c61110e95b.tar.bz2 android_development-862eadb62221429b9e2bb86dd6b7c9c61110e95b.zip | |
am a8baf9bc: Merge change Ie7eb359a into eclair
Merge commit 'a8baf9bcc8d9776e9aba35207af17723f7226027' into eclair-mr2
* commit 'a8baf9bcc8d9776e9aba35207af17723f7226027':
Tweaks to Pointer Location.
Diffstat (limited to 'apps/Development/src/com/android/development')
| -rw-r--r-- | apps/Development/src/com/android/development/PointerLocation.java | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/apps/Development/src/com/android/development/PointerLocation.java b/apps/Development/src/com/android/development/PointerLocation.java index 9935b7e63..38b4af2dc 100644 --- a/apps/Development/src/com/android/development/PointerLocation.java +++ b/apps/Development/src/com/android/development/PointerLocation.java @@ -24,6 +24,7 @@ import android.graphics.Paint.FontMetricsInt; import android.os.Bundle; import android.util.Log; import android.view.MotionEvent; +import android.view.ViewConfiguration; import android.view.WindowManager; import android.view.VelocityTracker; import android.view.View; @@ -59,6 +60,7 @@ public class PointerLocation extends Activity { } public class MyView extends View { + private final ViewConfiguration mVC; private final Paint mTextPaint; private final Paint mTextBackgroundPaint; private final Paint mTextLevelPaint; @@ -75,6 +77,7 @@ public class PointerLocation extends Activity { public MyView(Context c) { super(c); + mVC = ViewConfiguration.get(c); mTextPaint = new Paint(); mTextPaint.setAntiAlias(true); mTextPaint.setTextSize(10 @@ -132,11 +135,24 @@ public class PointerLocation extends Activity { canvas.drawText("P: " + mCurNumPointers + " / " + mMaxNumPointers, 1, base, mTextPaint); - canvas.drawRect(itemW, 0, (itemW * 2) - 1, bottom, mTextBackgroundPaint); - canvas.drawText("X: " + ps.mCurX, 1 + itemW, base, mTextPaint); - - canvas.drawRect(itemW * 2, 0, (itemW * 3) - 1, bottom, mTextBackgroundPaint); - canvas.drawText("Y: " + ps.mCurY, 1 + itemW * 2, base, mTextPaint); + final int N = ps.mXs.size(); + if ((mCurDown && ps.mCurDown) || N == 0) { + canvas.drawRect(itemW, 0, (itemW * 2) - 1, bottom, mTextBackgroundPaint); + canvas.drawText("X: " + ps.mCurX, 1 + itemW, base, mTextPaint); + canvas.drawRect(itemW * 2, 0, (itemW * 3) - 1, bottom, mTextBackgroundPaint); + canvas.drawText("Y: " + ps.mCurY, 1 + itemW * 2, base, mTextPaint); + } else { + float dx = ps.mXs.get(N-1) - ps.mXs.get(0); + float dy = ps.mYs.get(N-1) - ps.mYs.get(0); + canvas.drawRect(itemW, 0, (itemW * 2) - 1, bottom, + Math.abs(dx) < mVC.getScaledTouchSlop() + ? mTextBackgroundPaint : mTextLevelPaint); + canvas.drawText("dX: " + String.format("%.1f", dx), 1 + itemW, base, mTextPaint); + canvas.drawRect(itemW * 2, 0, (itemW * 3) - 1, bottom, + Math.abs(dy) < mVC.getScaledTouchSlop() + ? mTextBackgroundPaint : mTextLevelPaint); + canvas.drawText("dY: " + String.format("%.1f", dy), 1 + itemW * 2, base, mTextPaint); + } canvas.drawRect(itemW * 3, 0, (itemW * 4) - 1, bottom, mTextBackgroundPaint); int velocity = ps.mVelocity == null ? 0 : (int) (ps.mVelocity.getXVelocity() * 1000); @@ -237,6 +253,7 @@ public class PointerLocation extends Activity { } mPointers.get(0).mCurDown = true; mMaxNumPointers = 0; + Log.i("Pointer", "Pointer 1: DOWN"); } if ((action&MotionEvent.ACTION_MASK) == MotionEvent.ACTION_POINTER_DOWN) { @@ -251,6 +268,7 @@ public class PointerLocation extends Activity { final PointerState ps = mPointers.get(id); ps.mVelocity = VelocityTracker.obtain(); ps.mCurDown = true; + Log.i("Pointer", "Pointer " + (id+1) + ": DOWN"); } final int NI = event.getPointerCount(); @@ -268,9 +286,18 @@ public class PointerLocation extends Activity { ps.mVelocity.computeCurrentVelocity(1); final int N = event.getHistorySize(); for (int j=0; j<N; j++) { + Log.i("Pointer", "Pointer " + (i+1) + ": (" + + event.getHistoricalX(i, j) + + ", " + event.getHistoricalY(i, j) + ")" + + " Prs=" + event.getHistoricalPressure(i, j) + + " Size=" + event.getHistoricalSize(i, j)); ps.mXs.add(event.getHistoricalX(i, j)); ps.mYs.add(event.getHistoricalY(i, j)); } + Log.i("Pointer", "Pointer " + (i+1) + ": (" + + event.getX(i) + ", " + event.getY(i) + ")" + + " Prs=" + event.getPressure(i) + + " Size=" + event.getSize(i)); ps.mXs.add(event.getX(i)); ps.mYs.add(event.getY(i)); ps.mCurX = (int)event.getX(i); @@ -289,6 +316,17 @@ public class PointerLocation extends Activity { ps.mXs.add(Float.NaN); ps.mYs.add(Float.NaN); ps.mCurDown = false; + Log.i("Pointer", "Pointer " + (id+1) + ": UP"); + } + + if (action == MotionEvent.ACTION_UP) { + for (int i=0; i<NI; i++) { + final PointerState ps = mPointers.get(event.getPointerId(i)); + if (ps.mCurDown) { + ps.mCurDown = false; + Log.i("Pointer", "Pointer " + (i+1) + ": UP"); + } + } } //if (mCurDown) { |
