summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-05-29 13:56:39 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-05-29 13:56:39 -0700
commit0a91b0be8f0eedc52f5b1f68d3bf6f64f13d7228 (patch)
tree61283bf12a129a2635861a389c1692e3fbe6741d
parent4f67310f196e9b159e001bbe9bee5a9353ba0152 (diff)
parent7a8c437723a50b171d0cd97cb17886b28dffce92 (diff)
downloadframeworks_base-0a91b0be8f0eedc52f5b1f68d3bf6f64f13d7228.zip
frameworks_base-0a91b0be8f0eedc52f5b1f68d3bf6f64f13d7228.tar.gz
frameworks_base-0a91b0be8f0eedc52f5b1f68d3bf6f64f13d7228.tar.bz2
am 7a8c4377: Merge change 2737 into donut
Merge commit '7a8c437723a50b171d0cd97cb17886b28dffce92' * commit '7a8c437723a50b171d0cd97cb17886b28dffce92': Fixes #1878499.
-rwxr-xr-xcore/java/android/gesture/GestureOverlayView.java100
-rw-r--r--core/java/android/gesture/GestureStroke.java2
-rw-r--r--core/res/res/values/styles.xml2
3 files changed, 57 insertions, 47 deletions
diff --git a/core/java/android/gesture/GestureOverlayView.java b/core/java/android/gesture/GestureOverlayView.java
index c21cc55..cc58f1d 100755
--- a/core/java/android/gesture/GestureOverlayView.java
+++ b/core/java/android/gesture/GestureOverlayView.java
@@ -75,7 +75,7 @@ public class GestureOverlayView extends FrameLayout {
private int mInvalidateExtraBorder = 10;
private int mGestureStrokeType = GESTURE_STROKE_TYPE_SINGLE;
- private float mGestureStrokeLengthThreshold = 30.0f;
+ private float mGestureStrokeLengthThreshold = 50.0f;
private float mGestureStrokeSquarenessTreshold = 0.275f;
private float mGestureStrokeAngleThreshold = 40.0f;
@@ -554,39 +554,39 @@ public class GestureOverlayView extends FrameLayout {
mX = x;
mY = y;
- }
- mStrokeBuffer.add(new GesturePoint(x, y, event.getEventTime()));
+ mStrokeBuffer.add(new GesturePoint(x, y, event.getEventTime()));
- if (mHandleGestureActions && !mIsGesturing) {
- mTotalLength += (float) Math.sqrt(dx * dx + dy * dy);
+ if (mHandleGestureActions && !mIsGesturing) {
+ mTotalLength += (float) Math.sqrt(dx * dx + dy * dy);
- if (mTotalLength > mGestureStrokeLengthThreshold) {
- final OrientedBoundingBox box =
- GestureUtilities.computeOrientedBoundingBox(mStrokeBuffer);
+ if (mTotalLength > mGestureStrokeLengthThreshold) {
+ final OrientedBoundingBox box =
+ GestureUtilities.computeOrientedBoundingBox(mStrokeBuffer);
- float angle = Math.abs(box.orientation);
- if (angle > 90) {
- angle = 180 - angle;
- }
+ float angle = Math.abs(box.orientation);
+ if (angle > 90) {
+ angle = 180 - angle;
+ }
- if (box.squareness > mGestureStrokeSquarenessTreshold ||
- (mOrientation == ORIENTATION_VERTICAL ?
- angle < mGestureStrokeAngleThreshold :
- angle > mGestureStrokeAngleThreshold)) {
+ if (box.squareness > mGestureStrokeSquarenessTreshold ||
+ (mOrientation == ORIENTATION_VERTICAL ?
+ angle < mGestureStrokeAngleThreshold :
+ angle > mGestureStrokeAngleThreshold)) {
- mIsGesturing = true;
- setCurrentColor(mCertainGestureColor);
+ mIsGesturing = true;
+ setCurrentColor(mCertainGestureColor);
+ }
}
}
- }
- // pass the event to handlers
- final ArrayList<OnGestureListener> listeners = mOnGestureListeners;
- final int count = listeners.size();
- for (int i = 0; i < count; i++) {
- listeners.get(i).onGesture(this, event);
- }
+ // pass the event to handlers
+ final ArrayList<OnGestureListener> listeners = mOnGestureListeners;
+ final int count = listeners.size();
+ for (int i = 0; i < count; i++) {
+ listeners.get(i).onGesture(this, event);
+ }
+ }
return areaToRefresh;
}
@@ -594,35 +594,45 @@ public class GestureOverlayView extends FrameLayout {
private void touchUp(MotionEvent event, boolean cancel) {
mIsListeningForGestures = false;
- // add the stroke to the current gesture
- mCurrentGesture.addStroke(new GestureStroke(mStrokeBuffer));
- mStrokeBuffer.clear();
+ // A gesture wasn't started or was cancelled
+ if (mCurrentGesture != null) {
+ // add the stroke to the current gesture
+ mCurrentGesture.addStroke(new GestureStroke(mStrokeBuffer));
+
+ if (!cancel) {
+ // pass the event to handlers
+ final ArrayList<OnGestureListener> listeners = mOnGestureListeners;
+ int count = listeners.size();
+ for (int i = 0; i < count; i++) {
+ listeners.get(i).onGestureEnded(this, event);
+ }
- if (!cancel) {
- // pass the event to handlers
- final ArrayList<OnGestureListener> listeners = mOnGestureListeners;
- int count = listeners.size();
- for (int i = 0; i < count; i++) {
- listeners.get(i).onGestureEnded(this, event);
- }
+ if (mHandleGestureActions) {
+ clear(mFadeEnabled, mIsGesturing);
+ }
+ } else {
+ cancelGesture(event);
- if (mHandleGestureActions) {
- clear(mFadeEnabled, mIsGesturing);
}
} else {
- // pass the event to handlers
- final ArrayList<OnGestureListener> listeners = mOnGestureListeners;
- final int count = listeners.size();
- for (int i = 0; i < count; i++) {
- listeners.get(i).onGestureCancelled(this, event);
- }
-
- clear(false);
+ cancelGesture(event);
}
+ mStrokeBuffer.clear();
mIsGesturing = false;
}
+ private void cancelGesture(MotionEvent event) {
+ // pass the event to handlers
+ final ArrayList<OnGestureListener> listeners = mOnGestureListeners;
+ final int count = listeners.size();
+ for (int i = 0; i < count; i++) {
+ listeners.get(i).onGestureCancelled(this, event);
+ }
+
+ clear(false);
+ }
+
private void fireOnGesturePerformed() {
final ArrayList<OnGesturePerformedListener> actionListeners =
mOnGesturePerformedListeners;
diff --git a/core/java/android/gesture/GestureStroke.java b/core/java/android/gesture/GestureStroke.java
index 90faaed..598eb85 100644
--- a/core/java/android/gesture/GestureStroke.java
+++ b/core/java/android/gesture/GestureStroke.java
@@ -30,7 +30,7 @@ import java.util.ArrayList;
* A gesture stroke started on a touch down and ended on a touch up.
*/
public class GestureStroke {
- static final float TOUCH_TOLERANCE = 3;
+ static final float TOUCH_TOLERANCE = 8;
public final RectF boundingBox;
diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml
index 490abde..72402d0 100644
--- a/core/res/res/values/styles.xml
+++ b/core/res/res/values/styles.xml
@@ -177,7 +177,7 @@
<item name="android:uncertainGestureColor">#48ffff00</item>
<item name="android:fadeOffset">420</item>
<item name="android:fadeDuration">150</item>
- <item name="android:gestureStrokeLengthThreshold">30.0</item>
+ <item name="android:gestureStrokeLengthThreshold">50.0</item>
<item name="android:gestureStrokeSquarenessThreshold">0.275</item>
<item name="android:gestureStrokeAngleThreshold">40.0</item>
<item name="android:eventsInterceptionEnabled">true</item>