Merge change 25959 into eclair
* changes: Add better transition to rotary lock widget when triggering: spin around instead of snap back.
This commit is contained in:
@@ -69,12 +69,6 @@ public class RotarySelector extends View {
|
|||||||
private int mAnimatingDelta;
|
private int mAnimatingDelta;
|
||||||
private AccelerateInterpolator mInterpolator;
|
private AccelerateInterpolator mInterpolator;
|
||||||
|
|
||||||
/**
|
|
||||||
* True after triggering an action if the user of {@link OnDialTriggerListener} wants to
|
|
||||||
* freeze the UI (until they transition to another screen).
|
|
||||||
*/
|
|
||||||
private boolean mFrozen = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the user is currently dragging something.
|
* If the user is currently dragging something.
|
||||||
*/
|
*/
|
||||||
@@ -119,6 +113,9 @@ public class RotarySelector extends View {
|
|||||||
|
|
||||||
private static final boolean DRAW_CENTER_DIMPLE = false;
|
private static final boolean DRAW_CENTER_DIMPLE = false;
|
||||||
private int mEdgeTriggerThresh;
|
private int mEdgeTriggerThresh;
|
||||||
|
private int mDimpleWidth;
|
||||||
|
private int mBackgroundWidth;
|
||||||
|
private int mBackgroundHeight;
|
||||||
|
|
||||||
public RotarySelector(Context context) {
|
public RotarySelector(Context context) {
|
||||||
this(context, null);
|
this(context, null);
|
||||||
@@ -155,6 +152,11 @@ public class RotarySelector extends View {
|
|||||||
mInterpolator = new AccelerateInterpolator();
|
mInterpolator = new AccelerateInterpolator();
|
||||||
|
|
||||||
mEdgeTriggerThresh = (int) (mDensity * EDGE_TRIGGER_DIP);
|
mEdgeTriggerThresh = (int) (mDensity * EDGE_TRIGGER_DIP);
|
||||||
|
|
||||||
|
mDimpleWidth = mDimple.getIntrinsicWidth();
|
||||||
|
|
||||||
|
mBackgroundWidth = mBackground.getIntrinsicWidth();
|
||||||
|
mBackgroundHeight = mBackground.getIntrinsicHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -214,7 +216,7 @@ public class RotarySelector extends View {
|
|||||||
final int width = MeasureSpec.getSize(widthMeasureSpec); // screen width
|
final int width = MeasureSpec.getSize(widthMeasureSpec); // screen width
|
||||||
|
|
||||||
final int arrowH = mArrowShortLeftAndRight.getIntrinsicHeight();
|
final int arrowH = mArrowShortLeftAndRight.getIntrinsicHeight();
|
||||||
final int backgroundH = mBackground.getIntrinsicHeight();
|
final int backgroundH = mBackgroundHeight;
|
||||||
|
|
||||||
// by making the height less than arrow + bg, arrow and bg will be scrunched together,
|
// by making the height less than arrow + bg, arrow and bg will be scrunched together,
|
||||||
// overlaying somewhat (though on transparent portions of the drawable).
|
// overlaying somewhat (though on transparent portions of the drawable).
|
||||||
@@ -228,9 +230,9 @@ public class RotarySelector extends View {
|
|||||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||||
super.onSizeChanged(w, h, oldw, oldh);
|
super.onSizeChanged(w, h, oldw, oldh);
|
||||||
|
|
||||||
mLeftHandleX = (int) (EDGE_PADDING_DIP * mDensity) + mDimple.getIntrinsicWidth() / 2;
|
mLeftHandleX = (int) (EDGE_PADDING_DIP * mDensity) + mDimpleWidth / 2;
|
||||||
mRightHandleX =
|
mRightHandleX =
|
||||||
getWidth() - (int) (EDGE_PADDING_DIP * mDensity) - mDimple.getIntrinsicWidth() / 2;
|
getWidth() - (int) (EDGE_PADDING_DIP * mDensity) - mDimpleWidth / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// private Paint mPaint = new Paint();
|
// private Paint mPaint = new Paint();
|
||||||
@@ -239,15 +241,14 @@ public class RotarySelector extends View {
|
|||||||
protected void onDraw(Canvas canvas) {
|
protected void onDraw(Canvas canvas) {
|
||||||
super.onDraw(canvas);
|
super.onDraw(canvas);
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
log(String.format("onDraw: mAnimating=%s, mTouchDragOffset=%d, mGrabbedState=%d," +
|
log(String.format("onDraw: mAnimating=%s, mTouchDragOffset=%d, mGrabbedState=%d",
|
||||||
"mFrozen=%s",
|
mAnimating, mTouchDragOffset, mGrabbedState));
|
||||||
mAnimating, mTouchDragOffset, mGrabbedState, mFrozen));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final int height = getHeight();
|
final int height = getHeight();
|
||||||
|
|
||||||
// update animating state before we draw anything
|
// update animating state before we draw anything
|
||||||
if (mAnimating && !mFrozen) {
|
if (mAnimating) {
|
||||||
long millisLeft = mAnimationEndTime - currentAnimationTimeMillis();
|
long millisLeft = mAnimationEndTime - currentAnimationTimeMillis();
|
||||||
if (DBG) log("millisleft for animating: " + millisLeft);
|
if (DBG) log("millisleft for animating: " + millisLeft);
|
||||||
if (millisLeft <= 0) {
|
if (millisLeft <= 0) {
|
||||||
@@ -260,8 +261,8 @@ public class RotarySelector extends View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Background:
|
// Background:
|
||||||
final int backgroundW = mBackground.getIntrinsicWidth();
|
final int backgroundW = mBackgroundWidth;
|
||||||
final int backgroundH = mBackground.getIntrinsicHeight();
|
final int backgroundH = mBackgroundHeight;
|
||||||
final int backgroundY = height - backgroundH;
|
final int backgroundY = height - backgroundH;
|
||||||
if (DBG) log("- Background INTRINSIC: " + backgroundW + " x " + backgroundH);
|
if (DBG) log("- Background INTRINSIC: " + backgroundW + " x " + backgroundH);
|
||||||
mBackground.setBounds(0, backgroundY,
|
mBackground.setBounds(0, backgroundY,
|
||||||
@@ -383,12 +384,12 @@ public class RotarySelector extends View {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent event) {
|
public boolean onTouchEvent(MotionEvent event) {
|
||||||
if (mAnimating || mFrozen) {
|
if (mAnimating) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int eventX = (int) event.getX();
|
final int eventX = (int) event.getX();
|
||||||
final int hitWindow = mDimple.getIntrinsicWidth();
|
final int hitWindow = mDimpleWidth;
|
||||||
|
|
||||||
final int action = event.getAction();
|
final int action = event.getAction();
|
||||||
switch (action) {
|
switch (action) {
|
||||||
@@ -419,14 +420,29 @@ public class RotarySelector extends View {
|
|||||||
invalidate();
|
invalidate();
|
||||||
if (eventX >= getRight() - mEdgeTriggerThresh && !mTriggered) {
|
if (eventX >= getRight() - mEdgeTriggerThresh && !mTriggered) {
|
||||||
mTriggered = true;
|
mTriggered = true;
|
||||||
mFrozen = dispatchTriggerEvent(OnDialTriggerListener.LEFT_HANDLE);
|
dispatchTriggerEvent(OnDialTriggerListener.LEFT_HANDLE);
|
||||||
|
// set up "spin around animation"
|
||||||
|
mAnimating = true;
|
||||||
|
mAnimationEndTime = currentAnimationTimeMillis() + ANIMATION_DURATION_MILLIS;
|
||||||
|
mAnimatingDelta = -mBackgroundWidth;
|
||||||
|
mTouchDragOffset = 0;
|
||||||
|
mGrabbedState = NOTHING_GRABBED;
|
||||||
|
invalidate();
|
||||||
|
|
||||||
}
|
}
|
||||||
} else if (mGrabbedState == RIGHT_HANDLE_GRABBED) {
|
} else if (mGrabbedState == RIGHT_HANDLE_GRABBED) {
|
||||||
mTouchDragOffset = eventX - mRightHandleX;
|
mTouchDragOffset = eventX - mRightHandleX;
|
||||||
invalidate();
|
invalidate();
|
||||||
if (eventX <= mEdgeTriggerThresh && !mTriggered) {
|
if (eventX <= mEdgeTriggerThresh && !mTriggered) {
|
||||||
mTriggered = true;
|
mTriggered = true;
|
||||||
mFrozen = dispatchTriggerEvent(OnDialTriggerListener.RIGHT_HANDLE);
|
dispatchTriggerEvent(OnDialTriggerListener.RIGHT_HANDLE);
|
||||||
|
// set up "spin around animation"
|
||||||
|
mAnimating = true;
|
||||||
|
mAnimationEndTime = currentAnimationTimeMillis() + ANIMATION_DURATION_MILLIS;
|
||||||
|
mAnimatingDelta = mBackgroundWidth;
|
||||||
|
mTouchDragOffset = 0;
|
||||||
|
mGrabbedState = NOTHING_GRABBED;
|
||||||
|
invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -435,11 +451,13 @@ public class RotarySelector extends View {
|
|||||||
// handle animating back to start if they didn't trigger
|
// handle animating back to start if they didn't trigger
|
||||||
if (mGrabbedState == LEFT_HANDLE_GRABBED
|
if (mGrabbedState == LEFT_HANDLE_GRABBED
|
||||||
&& Math.abs(eventX - mLeftHandleX) > 5) {
|
&& Math.abs(eventX - mLeftHandleX) > 5) {
|
||||||
|
// set up "snap back" animation
|
||||||
mAnimating = true;
|
mAnimating = true;
|
||||||
mAnimationEndTime = currentAnimationTimeMillis() + ANIMATION_DURATION_MILLIS;
|
mAnimationEndTime = currentAnimationTimeMillis() + ANIMATION_DURATION_MILLIS;
|
||||||
mAnimatingDelta = eventX - mLeftHandleX;
|
mAnimatingDelta = eventX - mLeftHandleX;
|
||||||
} else if (mGrabbedState == RIGHT_HANDLE_GRABBED
|
} else if (mGrabbedState == RIGHT_HANDLE_GRABBED
|
||||||
&& Math.abs(eventX - mRightHandleX) > 5) {
|
&& Math.abs(eventX - mRightHandleX) > 5) {
|
||||||
|
// set up "snap back" animation
|
||||||
mAnimating = true;
|
mAnimating = true;
|
||||||
mAnimationEndTime = currentAnimationTimeMillis() + ANIMATION_DURATION_MILLIS;
|
mAnimationEndTime = currentAnimationTimeMillis() + ANIMATION_DURATION_MILLIS;
|
||||||
mAnimatingDelta = eventX - mRightHandleX;
|
mAnimatingDelta = eventX - mRightHandleX;
|
||||||
@@ -504,12 +522,11 @@ public class RotarySelector extends View {
|
|||||||
/**
|
/**
|
||||||
* Dispatches a trigger event to our listener.
|
* Dispatches a trigger event to our listener.
|
||||||
*/
|
*/
|
||||||
private boolean dispatchTriggerEvent(int whichHandle) {
|
private void dispatchTriggerEvent(int whichHandle) {
|
||||||
vibrate(VIBRATE_LONG);
|
vibrate(VIBRATE_LONG);
|
||||||
if (mOnDialTriggerListener != null) {
|
if (mOnDialTriggerListener != null) {
|
||||||
return mOnDialTriggerListener.onDialTrigger(this, whichHandle);
|
mOnDialTriggerListener.onDialTrigger(this, whichHandle);
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -529,23 +546,14 @@ public class RotarySelector extends View {
|
|||||||
*/
|
*/
|
||||||
public static final int RIGHT_HANDLE = 2;
|
public static final int RIGHT_HANDLE = 2;
|
||||||
|
|
||||||
/**
|
|
||||||
* @hide
|
|
||||||
* The center handle is currently unused.
|
|
||||||
*/
|
|
||||||
public static final int CENTER_HANDLE = 3;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the dial is triggered.
|
* Called when the dial is triggered.
|
||||||
*
|
*
|
||||||
* @param v The view that was triggered
|
* @param v The view that was triggered
|
||||||
* @param whichHandle Which "dial handle" the user grabbed,
|
* @param whichHandle Which "dial handle" the user grabbed,
|
||||||
* either {@link #LEFT_HANDLE}, {@link #RIGHT_HANDLE}, or
|
* either {@link #LEFT_HANDLE}, {@link #RIGHT_HANDLE}.
|
||||||
* {@link #CENTER_HANDLE}.
|
|
||||||
* @return Whether the widget should freeze (e.g when the action goes to another screen,
|
|
||||||
* you want the UI to stay put until the transition occurs).
|
|
||||||
*/
|
*/
|
||||||
boolean onDialTrigger(View v, int whichHandle);
|
void onDialTrigger(View v, int whichHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
BIN
core/res/res/drawable-hdpi/ic_lock_ringer_off.png
Normal file
BIN
core/res/res/drawable-hdpi/ic_lock_ringer_off.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
BIN
core/res/res/drawable-hdpi/ic_lock_ringer_on.png
Normal file
BIN
core/res/res/drawable-hdpi/ic_lock_ringer_on.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
BIN
core/res/res/drawable-mdpi/ic_lock_ringer_off.png
Normal file
BIN
core/res/res/drawable-mdpi/ic_lock_ringer_off.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 906 B |
BIN
core/res/res/drawable-mdpi/ic_lock_ringer_on.png
Normal file
BIN
core/res/res/drawable-mdpi/ic_lock_ringer_on.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 977 B |
@@ -83,6 +83,7 @@
|
|||||||
android:layout_marginTop="6dip"
|
android:layout_marginTop="6dip"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
android:drawablePadding="4dip"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@@ -94,6 +95,7 @@
|
|||||||
android:layout_marginTop="6dip"
|
android:layout_marginTop="6dip"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
android:drawablePadding="4dip"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@@ -108,15 +110,15 @@
|
|||||||
android:layout_marginTop="12dip"
|
android:layout_marginTop="12dip"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- By having the rotary selector hang below "screen locked" text, we get a layout more
|
<!-- By having the rotary selector hang from the top, we get a layout more
|
||||||
robust for different screen sizes. On wvga, the widget should be flush with the bottom.-->
|
robust for different screen sizes. On hvga, the widget should be flush with the bottom.-->
|
||||||
<com.android.internal.widget.RotarySelector
|
<com.android.internal.widget.RotarySelector
|
||||||
android:id="@+id/rotary"
|
android:id="@+id/rotary"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/screenLocked"
|
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:layout_marginTop="24dip"
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_marginTop="286dip"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- emergency call button shown when sim is missing or PUKd -->
|
<!-- emergency call button shown when sim is missing or PUKd -->
|
||||||
|
|||||||
Reference in New Issue
Block a user