diff options
author | Michael Kolb <kolby@google.com> | 2010-12-15 16:22:42 -0800 |
---|---|---|
committer | Michael Kolb <kolby@google.com> | 2010-12-15 16:28:01 -0800 |
commit | bf9c4ee33fe87881793f84091274dc59c16f3881 (patch) | |
tree | f7108b871891dd7fc5de98bed0c87afdb9ad5470 /src | |
parent | 023a60e37c0f3374aed57531ab11b7f20ece232b (diff) | |
download | packages_apps_browser-bf9c4ee33fe87881793f84091274dc59c16f3881.zip packages_apps_browser-bf9c4ee33fe87881793f84091274dc59c16f3881.tar.gz packages_apps_browser-bf9c4ee33fe87881793f84091274dc59c16f3881.tar.bz2 |
Close QuickControls on long move
automatically close the pie when finger slides way beyond the menu
Change-Id: I004c885d3e29fe17747e5c171f96d901d1d14d4d
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/browser/view/PieMenu.java | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/src/com/android/browser/view/PieMenu.java b/src/com/android/browser/view/PieMenu.java index d838a34..6b06a3d 100644 --- a/src/com/android/browser/view/PieMenu.java +++ b/src/com/android/browser/view/PieMenu.java @@ -356,7 +356,13 @@ public class PieMenu extends FrameLayout { deselect(); return false; } else if (MotionEvent.ACTION_MOVE == action) { - View v = findView((int) x, (int) y); + PointF polar = getPolar(x, y); + if (polar.y > mRadius + 2 * mRadiusInc) { + show(false); + deselect(); + return false; + } + View v = findView(polar); if (mCurrentView != v) { onEnter(v); invalidate(); @@ -414,30 +420,40 @@ public class PieMenu extends FrameLayout { return ((MenuTag) v.getTag()).level; } - private View findView(int x, int y) { + private PointF getPolar(float x, float y) { + PointF res = new PointF(); // get angle and radius from x/y - float angle = (float) Math.PI / 2; + res.x = (float) Math.PI / 2; x = mCenter.x - x; if (mCenter.x < mSlop) { x = -x; } y = mCenter.y - y; - float dist = (float) Math.sqrt(x * x + y * y); + res.y = (float) Math.sqrt(x * x + y * y); if (y > 0) { - angle = (float) Math.asin(x / dist); + res.x = (float) Math.asin(x / res.y); } else if (y < 0) { - angle = (float) (Math.PI - Math.asin(x / dist )); + res.x = (float) (Math.PI - Math.asin(x / res.y )); } + return res; + } + + /** + * + * @param polar x: angle, y: dist + * @return + */ + private View findView(PointF polar) { // find the matching item: for (View parent : mStack) { List<View> subs = mMenu.get(parent); if (subs != null) { for (View item : subs) { MenuTag tag = (MenuTag) item.getTag(); - if ((tag.inner < dist) - && (tag.outer > dist) - && (tag.start < angle) - && (tag.start + tag.sweep > angle)) { + if ((tag.inner < polar.y) + && (tag.outer > polar.y) + && (tag.start < polar.x) + && (tag.start + tag.sweep > polar.x)) { return item; } } |