Skip to content
Browse files

Merge "Improving pie control's user interaction" into cm-10.1

  • Loading branch information...
2 parents 289362e + e025153 commit d53e351568c6be9e2aeae5551f6ffcb402b84b6a @DvTonder DvTonder committed with Gerrit Code Review Apr 7, 2013
View
22 packages/SystemUI/src/com/android/systemui/statusbar/pie/PieItem.java
@@ -68,12 +68,17 @@
}
private PieOnClickListener mOnClickListener = null;
- public PieItem(Context context, PieLayout parent, int width, Object tag, View view) {
+ /**
+ * The item is selected / has the focus from the gesture.
+ */
+ public final static int SELECTED = 0x100;
+
+ public PieItem(Context context, PieLayout parent, int flags, int width, Object tag, View view) {
mView = view;
mPieLayout = parent;
this.tag = tag;
this.width = width;
- flags = PieDrawable.VISIBLE | PieDrawable.DISPLAY_ALL;
+ this.flags = flags | PieDrawable.VISIBLE | PieDrawable.DISPLAY_ALL;
final Resources res = context.getResources();
@@ -108,9 +113,9 @@ public void show(boolean show) {
public void setSelected(boolean selected) {
mPieLayout.postInvalidate();
if (selected) {
- flags |= PieLayout.PieDrawable.SELECTED;
+ flags |= SELECTED;
} else {
- flags &= ~PieLayout.PieDrawable.SELECTED;
+ flags &= ~SELECTED;
}
}
@@ -158,9 +163,9 @@ public void prepare(Position position, float scale) {
@Override
public void draw(Canvas canvas, Position position) {
- canvas.drawPath(mPath, (flags & PieDrawable.SELECTED) != 0
+ canvas.drawPath(mPath, (flags & SELECTED) != 0
? mSelectedPaint : mBackgroundPaint);
- canvas.drawPath(mPath, (flags & PieDrawable.SELECTED) != 0
+ canvas.drawPath(mPath, (flags & SELECTED) != 0
? mSelectedPaint : mOutlinePaint);
if (mView != null) {
@@ -193,6 +198,11 @@ public PieItem interact(float alpha, int radius) {
}
}
+ private boolean hit(float alpha, int radius) {
+ return (alpha > mStart) && (alpha < mStart + mSweep)
+ && (radius > mInner && radius < mOuter);
+ }
+
private Path getOutline(float scale) {
RectF outerBB = new RectF(-mOuter * scale, -mOuter * scale, mOuter * scale, mOuter * scale);
RectF innerBB = new RectF(-mInner * scale, -mInner * scale, mInner * scale, mInner * scale);
View
8 packages/SystemUI/src/com/android/systemui/statusbar/pie/PieLayout.java
@@ -136,11 +136,6 @@ public void setGeometry(float start, float sweep, int inner, int outer) {
mOuter = outer;
}
- public boolean hit(float alpha, int radius) {
- return (alpha > mStart) && (alpha < mStart + mSweep)
- && (radius > mInner) && (radius < mOuter);
- }
-
// Display on all positions
public final static int DISPLAY_ALL = Position.LEFT.FLAG
| Position.BOTTOM.FLAG
@@ -152,8 +147,6 @@ public boolean hit(float alpha, int radius) {
| Position.RIGHT.FLAG;
// The PieDrawable is visible, note that slice visibility overrides item visibility
public final static int VISIBLE = 0x10;
- // The item (?) is selected
- public final static int SELECTED = 0x20;
public int flags;
};
@@ -604,6 +597,7 @@ public void exit() {
if (mActiveItem != null) {
mActiveItem.setSelected(false);
}
+ mActiveItem = null;
mActive = false;
}
View
17 packages/SystemUI/src/com/android/systemui/statusbar/policy/PieController.java
@@ -145,6 +145,7 @@
public static float sDistance;
private float initialX = 0;
private float initialY = 0;
+ private float gracePeriod = 0;
private Tracker(Position position) {
this.position = position;
@@ -153,6 +154,14 @@ private Tracker(Position position) {
public void start(MotionEvent event) {
initialX = event.getX();
initialY = event.getY();
+ switch (position) {
+ case LEFT:
+ gracePeriod = initialX + sDistance / 3.0f;
+ break;
+ case RIGHT:
+ gracePeriod = initialX - sDistance / 3.0f;
+ break;
+ }
active = true;
}
@@ -168,6 +177,9 @@ public boolean move(MotionEvent event) {
boolean loaded = false;
switch (position) {
case LEFT:
+ if (x < gracePeriod) {
+ initialY = y;
+ }
if (initialY - y < sDistance && y - initialY < sDistance) {
if (x - initialX <= sDistance) {
return false;
@@ -192,6 +204,9 @@ public boolean move(MotionEvent event) {
}
break;
case RIGHT:
+ if (x > gracePeriod) {
+ initialY = y;
+ }
if (initialY - y < sDistance && y - initialY < sDistance) {
if (initialX - x <= sDistance) {
return false;
@@ -392,7 +407,7 @@ private PieItem constructItem(int width, ButtonInfo type, int image, int minimum
view.setMinimumHeight(minimumImageSize);
LayoutParams lp = new LayoutParams(minimumImageSize, minimumImageSize);
view.setLayoutParams(lp);
- PieItem item = new PieItem(mContext, mPieContainer, width, type, view);
+ PieItem item = new PieItem(mContext, mPieContainer, 0, width, type, view);
item.setOnClickListener(this);
return item;
}

0 comments on commit d53e351

Please sign in to comment.
Something went wrong with that request. Please try again.