am 9b64ef13: Merge change 25647 into eclair
Merge commit '9b64ef133c1eb24c8d00aa7e46ec86c544af5fe2' into eclair-plus-aosp * commit '9b64ef133c1eb24c8d00aa7e46ec86c544af5fe2': Some tweaks to the rotary lock widget.
This commit is contained in:
@@ -105,6 +105,11 @@ public class RotarySelector extends View {
|
|||||||
*/
|
*/
|
||||||
private static final int EDGE_PADDING_DIP = 9;
|
private static final int EDGE_PADDING_DIP = 9;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How far from the edge of the screen the user must drag to trigger the event.
|
||||||
|
*/
|
||||||
|
private static final int EDGE_TRIGGER_DIP = 65;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dimensions of arc in background drawable.
|
* Dimensions of arc in background drawable.
|
||||||
*/
|
*/
|
||||||
@@ -113,12 +118,12 @@ public class RotarySelector extends View {
|
|||||||
private static final int ANIMATION_DURATION_MILLIS = 300;
|
private static final int ANIMATION_DURATION_MILLIS = 300;
|
||||||
|
|
||||||
private static final boolean DRAW_CENTER_DIMPLE = false;
|
private static final boolean DRAW_CENTER_DIMPLE = false;
|
||||||
|
private int mEdgeTriggerThresh;
|
||||||
|
|
||||||
public RotarySelector(Context context) {
|
public RotarySelector(Context context) {
|
||||||
this(context, null);
|
this(context, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor used when this widget is created from a layout file.
|
* Constructor used when this widget is created from a layout file.
|
||||||
*/
|
*/
|
||||||
@@ -148,6 +153,8 @@ public class RotarySelector extends View {
|
|||||||
mArrowLongRight.setBounds(0, 0, arrowW, arrowH);
|
mArrowLongRight.setBounds(0, 0, arrowW, arrowH);
|
||||||
|
|
||||||
mInterpolator = new AccelerateInterpolator();
|
mInterpolator = new AccelerateInterpolator();
|
||||||
|
|
||||||
|
mEdgeTriggerThresh = (int) (mDensity * EDGE_TRIGGER_DIP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -252,7 +259,6 @@ public class RotarySelector extends View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Background:
|
// Background:
|
||||||
final int backgroundW = mBackground.getIntrinsicWidth();
|
final int backgroundW = mBackground.getIntrinsicWidth();
|
||||||
final int backgroundH = mBackground.getIntrinsicHeight();
|
final int backgroundH = mBackground.getIntrinsicHeight();
|
||||||
@@ -268,7 +274,7 @@ public class RotarySelector extends View {
|
|||||||
Drawable currentArrow;
|
Drawable currentArrow;
|
||||||
switch (mGrabbedState) {
|
switch (mGrabbedState) {
|
||||||
case NOTHING_GRABBED:
|
case NOTHING_GRABBED:
|
||||||
currentArrow = mArrowShortLeftAndRight;
|
currentArrow = null; //mArrowShortLeftAndRight;
|
||||||
break;
|
break;
|
||||||
case LEFT_HANDLE_GRABBED:
|
case LEFT_HANDLE_GRABBED:
|
||||||
currentArrow = mArrowLongLeft;
|
currentArrow = mArrowLongLeft;
|
||||||
@@ -279,7 +285,7 @@ public class RotarySelector extends View {
|
|||||||
default:
|
default:
|
||||||
throw new IllegalStateException("invalid mGrabbedState: " + mGrabbedState);
|
throw new IllegalStateException("invalid mGrabbedState: " + mGrabbedState);
|
||||||
}
|
}
|
||||||
currentArrow.draw(canvas);
|
if (currentArrow != null) currentArrow.draw(canvas);
|
||||||
|
|
||||||
// debug: draw circle that should match the outer arc (good sanity check)
|
// debug: draw circle that should match the outer arc (good sanity check)
|
||||||
// mPaint.setColor(Color.RED);
|
// mPaint.setColor(Color.RED);
|
||||||
@@ -300,7 +306,9 @@ public class RotarySelector extends View {
|
|||||||
xOffset);
|
xOffset);
|
||||||
|
|
||||||
drawCentered(mDimple, canvas, xOffset, drawableY + bgTop);
|
drawCentered(mDimple, canvas, xOffset, drawableY + bgTop);
|
||||||
drawCentered(mLeftHandleIcon, canvas, xOffset, drawableY + bgTop);
|
if (mGrabbedState != RIGHT_HANDLE_GRABBED) {
|
||||||
|
drawCentered(mLeftHandleIcon, canvas, xOffset, drawableY + bgTop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DRAW_CENTER_DIMPLE) {
|
if (DRAW_CENTER_DIMPLE) {
|
||||||
@@ -323,7 +331,9 @@ public class RotarySelector extends View {
|
|||||||
xOffset);
|
xOffset);
|
||||||
|
|
||||||
drawCentered(mDimple, canvas, xOffset, drawableY + bgTop);
|
drawCentered(mDimple, canvas, xOffset, drawableY + bgTop);
|
||||||
drawCentered(mRightHandleIcon, canvas, xOffset, drawableY + bgTop);
|
if (mGrabbedState != LEFT_HANDLE_GRABBED) {
|
||||||
|
drawCentered(mRightHandleIcon, canvas, xOffset, drawableY + bgTop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mAnimating) invalidate();
|
if (mAnimating) invalidate();
|
||||||
@@ -407,14 +417,14 @@ public class RotarySelector extends View {
|
|||||||
if (mGrabbedState == LEFT_HANDLE_GRABBED) {
|
if (mGrabbedState == LEFT_HANDLE_GRABBED) {
|
||||||
mTouchDragOffset = eventX - mLeftHandleX;
|
mTouchDragOffset = eventX - mLeftHandleX;
|
||||||
invalidate();
|
invalidate();
|
||||||
if (eventX >= mRightHandleX - EDGE_PADDING_DIP && !mTriggered) {
|
if (eventX >= getRight() - mEdgeTriggerThresh && !mTriggered) {
|
||||||
mTriggered = true;
|
mTriggered = true;
|
||||||
mFrozen = dispatchTriggerEvent(OnDialTriggerListener.LEFT_HANDLE);
|
mFrozen = dispatchTriggerEvent(OnDialTriggerListener.LEFT_HANDLE);
|
||||||
}
|
}
|
||||||
} else if (mGrabbedState == RIGHT_HANDLE_GRABBED) {
|
} else if (mGrabbedState == RIGHT_HANDLE_GRABBED) {
|
||||||
mTouchDragOffset = eventX - mRightHandleX;
|
mTouchDragOffset = eventX - mRightHandleX;
|
||||||
invalidate();
|
invalidate();
|
||||||
if (eventX <= mLeftHandleX + EDGE_PADDING_DIP && !mTriggered) {
|
if (eventX <= mEdgeTriggerThresh && !mTriggered) {
|
||||||
mTriggered = true;
|
mTriggered = true;
|
||||||
mFrozen = dispatchTriggerEvent(OnDialTriggerListener.RIGHT_HANDLE);
|
mFrozen = dispatchTriggerEvent(OnDialTriggerListener.RIGHT_HANDLE);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user