Merge change I86daa3fb into eclair
* changes:
Live wallpaper improvements.
diff --git a/res/drawable-hdpi/home_button.png b/res/drawable-hdpi/home_button.png
new file mode 100644
index 0000000..3124a7f
--- /dev/null
+++ b/res/drawable-hdpi/home_button.png
Binary files differ
diff --git a/res/raw/rollo.c b/res/raw/rollo.c
index 0844c97..8d09127 100644
--- a/res/raw/rollo.c
+++ b/res/raw/rollo.c
@@ -92,6 +92,10 @@
//g_Zoom += (maxf(fabsf(g_PosVelocity), 3) - 3) / 2.f;
}
+void touchUp() {
+ g_LastTouchDown = 0;
+}
+
void setZoomTarget() {
g_ZoomTarget = state->zoomTarget;
//debugF("zoom target", g_ZoomTarget);
@@ -320,8 +324,10 @@
// Set clear value to dim the background based on the zoom position.
if (g_Zoom < 0.001f) {
pfClearColor(0.0f, 0.0f, 0.0f, 0.0f);
- // Nothing else to do if fully zoomed out.
- g_PosPage = roundf(g_PosPage);
+ // When we're zoomed out and not tracking motion events, reset the pos to 0.
+ if (!g_LastTouchDown) {
+ g_PosPage = 0;
+ }
return 1; // 0;
} else if (g_Zoom < 0.8f) {
pfClearColor(0.0f, 0.0f, 0.0f, g_Zoom);
@@ -329,8 +335,6 @@
pfClearColor(0.0f, 0.0f, 0.0f, 0.80f);
}
-
-
// icons & labels
int iconCount = state->iconCount;
g_PageCount = count_pages(iconCount);
diff --git a/src/com/android/launcher2/AllAppsView.java b/src/com/android/launcher2/AllAppsView.java
index ae44677..17d9a78 100644
--- a/src/com/android/launcher2/AllAppsView.java
+++ b/src/com/android/launcher2/AllAppsView.java
@@ -87,6 +87,7 @@
private int mMotionDownRawY;
private int mScrollHandleTop;
private long mTouchTime;
+ private boolean mZoomSwipeInProgress;
static class Defines {
private static float farSize(float sizeAt0) {
@@ -236,16 +237,17 @@
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
+ if (!mZoomSwipeInProgress) {
+ mRollo.mState.newPositionX = ev.getRawX() / Defines.SCREEN_WIDTH_PX;
+ mRollo.mState.newTouchDown = 0;
- mRollo.mState.newPositionX = ev.getRawX() / Defines.SCREEN_WIDTH_PX;
- mRollo.mState.newTouchDown = 0;
-
- mVelocity.computeCurrentVelocity(1000 /* px/sec */,
- mConfig.getScaledMaximumFlingVelocity());
- mRollo.mState.flingVelocityX = mVelocity.getXVelocity() / Defines.SCREEN_WIDTH_PX;
- mRollo.clearSelectedIcon();
- mRollo.mState.save();
- mRollo.mInvokeFling.execute();
+ mVelocity.computeCurrentVelocity(1000 /* px/sec */,
+ mConfig.getScaledMaximumFlingVelocity());
+ mRollo.mState.flingVelocityX = mVelocity.getXVelocity() / Defines.SCREEN_WIDTH_PX;
+ mRollo.clearSelectedIcon();
+ mRollo.mState.save();
+ mRollo.mInvokeFling.execute();
+ }
mLastMotionX = -10000;
mVelocity.recycle();
mVelocity = null;
@@ -297,6 +299,15 @@
public void onDropCompleted(View target, boolean success) {
}
+ public void setZoomSwipeInProgress(boolean swiping, boolean touchStillDown) {
+ mZoomSwipeInProgress = swiping;
+ if (!touchStillDown) {
+ mRollo.mState.newTouchDown = 0;
+ mRollo.mState.save();
+ mRollo.mInvokeTouchUp.execute();
+ }
+ }
+
public void setZoomTarget(float amount) {
zoom(amount, true);
}
@@ -403,6 +414,7 @@
private Script.Invokable mInvokeFling;
private Script.Invokable mInvokeSetZoomTarget;
private Script.Invokable mInvokeSetZoom;
+ private Script.Invokable mInvokeTouchUp;
private Sampler mSampler;
private Sampler mSamplerText;
@@ -631,6 +643,7 @@
mInvokeFling = sb.addInvokable("fling");
mInvokeSetZoomTarget = sb.addInvokable("setZoomTarget");
mInvokeSetZoom = sb.addInvokable("setZoom");
+ mInvokeTouchUp = sb.addInvokable("touchUp");
mScript = sb.create();
mScript.setClearColor(0.0f, 0.0f, 0.0f, 0.0f);
diff --git a/src/com/android/launcher2/SwipeController.java b/src/com/android/launcher2/SwipeController.java
index 7617fe0..a900fca 100644
--- a/src/com/android/launcher2/SwipeController.java
+++ b/src/com/android/launcher2/SwipeController.java
@@ -125,6 +125,7 @@
mTracking = false;
mDownX = screenX;
mDownY = screenY;
+ mAllAppsView.setZoomSwipeInProgress(true, true);
break;
case MotionEvent.ACTION_MOVE:
@@ -132,6 +133,7 @@
if (Math.abs(deltaX) > mSlop) {
mCanceled = true;
mTracking = false;
+ mAllAppsView.setZoomSwipeInProgress(false, true);
}
if (Math.abs(deltaY) > mSlop) {
mTracking = true;
@@ -146,6 +148,7 @@
case MotionEvent.ACTION_UP:
if (mTracking && !mCanceled) {
fling(screenY);
+ mAllAppsView.setZoomSwipeInProgress(false, false);
}
mVelocityTracker.recycle();
mVelocityTracker = null;
diff --git a/src/com/android/launcher2/Utilities.java b/src/com/android/launcher2/Utilities.java
index dbb5ac6..a7eabe3 100644
--- a/src/com/android/launcher2/Utilities.java
+++ b/src/com/android/launcher2/Utilities.java
@@ -56,7 +56,7 @@
private static final Paint sEmptyPaint = new Paint();
private static final Rect sBounds = new Rect();
private static final Rect sOldBounds = new Rect();
- private static Canvas sCanvas = new Canvas();
+ private static final Canvas sCanvas = new Canvas();
static {
sCanvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.DITHER_FLAG,
@@ -104,7 +104,6 @@
int width = sIconWidth;
int height = sIconHeight;
- float scale = 1.0f;
if (icon instanceof PaintDrawable) {
PaintDrawable painter = (PaintDrawable) icon;
painter.setIntrinsicWidth(width);
@@ -120,8 +119,8 @@
int iconWidth = icon.getIntrinsicWidth();
int iconHeight = icon.getIntrinsicHeight();
- if (iconWidth > 0 && iconWidth > 0) {
- if (width < iconWidth || height < iconHeight || scale != 1.0f) {
+ if (iconWidth > 0 && iconHeight > 0) {
+ if (width < iconWidth || height < iconHeight) {
final float ratio = (float) iconWidth / iconHeight;
if (iconWidth > iconHeight) {
@@ -182,7 +181,6 @@
int width = sIconWidth;
int height = sIconHeight;
- float scale = 1.0f;
if (icon instanceof PaintDrawable) {
PaintDrawable painter = (PaintDrawable) icon;
painter.setIntrinsicWidth(width);
@@ -200,7 +198,7 @@
if (sourceWidth > 0 && sourceWidth > 0) {
// There are intrinsic sizes.
- if (width < sourceWidth || height < sourceHeight || scale != 1.0f) {
+ if (width < sourceWidth || height < sourceHeight) {
// It's too big, scale it down.
final float ratio = (float) sourceWidth / sourceHeight;
if (sourceWidth > sourceHeight) {
@@ -211,7 +209,7 @@
} else if (sourceWidth < width && sourceHeight < height) {
// It's small, use the size they gave us.
width = sourceWidth;
- height = sourceWidth;
+ height = sourceHeight;
}
}
@@ -295,27 +293,40 @@
final int bitmapWidth = bitmap.getWidth();
final int bitmapHeight = bitmap.getHeight();
- if (width > 0 && height > 0 && (width < bitmapWidth || height < bitmapHeight)) {
- final float ratio = (float) bitmapWidth / bitmapHeight;
-
- if (bitmapWidth > bitmapHeight) {
- height = (int) (width / ratio);
- } else if (bitmapHeight > bitmapWidth) {
- width = (int) (height * ratio);
+ if (width > 0 && height > 0) {
+ if (width < bitmapWidth || height < bitmapHeight) {
+ final float ratio = (float) bitmapWidth / bitmapHeight;
+
+ if (bitmapWidth > bitmapHeight) {
+ height = (int) (width / ratio);
+ } else if (bitmapHeight > bitmapWidth) {
+ width = (int) (height * ratio);
+ }
+
+ final Bitmap.Config c = (width == sIconWidth && height == sIconHeight) ?
+ bitmap.getConfig() : Bitmap.Config.ARGB_8888;
+ final Bitmap thumb = Bitmap.createBitmap(sIconWidth, sIconHeight, c);
+ final Canvas canvas = sCanvas;
+ final Paint paint = sPaint;
+ canvas.setBitmap(thumb);
+ paint.setDither(false);
+ paint.setFilterBitmap(true);
+ sBounds.set((sIconWidth - width) / 2, (sIconHeight - height) / 2, width, height);
+ sOldBounds.set(0, 0, bitmapWidth, bitmapHeight);
+ canvas.drawBitmap(bitmap, sOldBounds, sBounds, paint);
+ return thumb;
+ } else if (bitmapWidth < width || bitmapHeight < height) {
+ final Bitmap.Config c = Bitmap.Config.ARGB_8888;
+ final Bitmap thumb = Bitmap.createBitmap(sIconWidth, sIconHeight, c);
+ final Canvas canvas = sCanvas;
+ final Paint paint = sPaint;
+ canvas.setBitmap(thumb);
+ paint.setDither(false);
+ paint.setFilterBitmap(true);
+ canvas.drawBitmap(bitmap, (sIconWidth - bitmapWidth) / 2,
+ (sIconHeight - bitmapHeight) / 2, paint);
+ return thumb;
}
-
- final Bitmap.Config c = (width == sIconWidth && height == sIconHeight) ?
- bitmap.getConfig() : Bitmap.Config.ARGB_8888;
- final Bitmap thumb = Bitmap.createBitmap(sIconWidth, sIconHeight, c);
- final Canvas canvas = sCanvas;
- final Paint paint = sPaint;
- canvas.setBitmap(thumb);
- paint.setDither(false);
- paint.setFilterBitmap(true);
- sBounds.set((sIconWidth - width) / 2, (sIconHeight - height) / 2, width, height);
- sOldBounds.set(0, 0, bitmapWidth, bitmapHeight);
- canvas.drawBitmap(bitmap, sOldBounds, sBounds, paint);
- return thumb;
}
return bitmap;
@@ -337,10 +348,8 @@
static class BubbleText {
private static final int MAX_LINES = 2;
private TextPaint mTextPaint;
- private Paint mRectPaint;
private float mBubblePadding;
- private float mCornerRadius;
private RectF mBubbleRect = new RectF();
private float mTextWidth;
@@ -367,10 +376,9 @@
bubbleRect.top = 0;
bubbleRect.right = (int)(bubbleWidth+0.5f);
- mCornerRadius = BubbleTextView.CORNER_RADIUS * scale;
mTextWidth = bubbleWidth - mBubblePadding - mBubblePadding;
- Paint rectPaint = mRectPaint = new Paint();
+ Paint rectPaint = new Paint();
rectPaint.setColor(0xff000000);
rectPaint.setAntiAlias(true);