Merge branch 'master' into honeycomb-release
diff --git a/CleanSpec.mk b/CleanSpec.mk
index b84e1b6..444dbd8 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -44,6 +44,8 @@
#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/Launcher2_intermediates)
+
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
-# ************************************************
+# ************************************************
\ No newline at end of file
diff --git a/proguard.flags b/proguard.flags
index 82411eb..22a7ddc 100644
--- a/proguard.flags
+++ b/proguard.flags
@@ -11,6 +11,23 @@
-keep class com.android.launcher2.CellLayout {
public float getBackgroundAlpha();
public void setBackgroundAlpha(float);
+ public float getDimmableProgress();
+ public void setDimmableProgress(float);
+}
+
+-keep class com.android.launcher2.DimmableBubbleTextView {
+ public float getDimmableProgress();
+ public void setDimmableProgress(float);
+}
+
+-keep class com.android.launcher2.DimmableAppWidgetHostView {
+ public float getDimmableProgress();
+ public void setDimmableProgress(float);
+}
+
+-keep class com.android.launcher2.Workspace {
+ public float getBackgroundAlpha();
+ public void setBackgroundAlpha(float);
}
-keep class com.android.launcher2.AllApps3D$Defines {
@@ -19,4 +36,4 @@
-keep class com.android.launcher2.ClippedImageView {
*;
-}
+}
\ No newline at end of file
diff --git a/res/drawable-xlarge/home_screen_bg.9.png b/res/drawable-xlarge/home_screen_bg.9.png
deleted file mode 100644
index d939d5c..0000000
--- a/res/drawable-xlarge/home_screen_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable/gardening_crosshairs.png b/res/drawable/gardening_crosshairs.png
new file mode 100644
index 0000000..cbaee78
--- /dev/null
+++ b/res/drawable/gardening_crosshairs.png
Binary files differ
diff --git a/res/values-xlarge/config.xml b/res/values-xlarge/config.xml
index 9b1bc0d..f6f6646 100644
--- a/res/values-xlarge/config.xml
+++ b/res/values-xlarge/config.xml
@@ -26,4 +26,16 @@
animations between all apps, customize, & the workspace. -->
<integer name="config_toolbarButtonFadeInTime">350</integer>
<integer name="config_toolbarButtonFadeOutTime">350</integer>
+
+ <integer name="config_crosshairsFadeInTime">600</integer>
+
+ <!-- When dragging items on the workspace, how much bigger (in pixels) the dragged view
+ should be, as compared to the original view. If 0, it will not be scaled at all.
+ Should be an even number, for pixel alignment. -->
+ <integer name="config_dragViewExtraPixels">0</integer>
+
+ <!-- When dragging items on the workspace, the number of pixels by which the position of
+ the drag view should be offset from the position of the original view. -->
+ <integer name="config_dragViewOffsetX">0</integer>
+ <integer name="config_dragViewOffsetY">12</integer>
</resources>
diff --git a/res/values/config.xml b/res/values/config.xml
index 7811882..db967ea 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -4,4 +4,15 @@
<integer name="config_allAppsBatchLoadDelay">0</integer>
<integer name="config_allAppsBatchSize">0</integer>
<bool name="config_hardwareAccelerated">false</bool>
+
+ <!-- When dragging an item on the workspace, how much bigger (in pixels) the dragged view
+ should be, as compared to the original view. If 0, it will not be scaled at all.
+ Should be an even number, for pixel alignment. -->
+ <integer name="config_dragViewExtraPixels">40</integer>
+
+ <!-- When dragging items on the workspace, the number of pixels by which the position of
+ the drag view should be offset from the position of the original view.
+ Setting to 1/2 of config_dragViewExtraPixels keeps it centered on its old position. -->
+ <integer name="config_dragViewOffsetX">20</integer>
+ <integer name="config_dragViewOffsetY">20</integer>
</resources>
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 0caaf2e..84b26f2 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -18,15 +18,20 @@
import com.android.launcher.R;
+import android.animation.ValueAnimator;
+import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.app.WallpaperManager;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Canvas;
+import android.graphics.Point;
+import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
+import android.util.Log;
import android.view.ContextMenu;
import android.view.MotionEvent;
import android.view.View;
@@ -37,7 +42,7 @@
import java.util.Arrays;
-public class CellLayout extends ViewGroup implements Dimmable {
+public class CellLayout extends ViewGroup {
static final String TAG = "CellLayout";
private int mCellWidth;
@@ -58,9 +63,11 @@
private final RectF mRectF = new RectF();
private final CellInfo mCellInfo = new CellInfo();
- // This is a temporary variable to prevent having to allocate a new object just to
- // return an (x, y) value from helper functions. Do NOT use it to maintain other state.
+ // These are temporary variables to prevent having to allocate a new object just to
+ // return an (x, y) value from helper functions. Do NOT use them to maintain other state.
private final int[] mTmpCellXY = new int[2];
+ private final int[] mTmpPoint = new int[2];
+ private final PointF mTmpPointF = new PointF();
boolean[][] mOccupied;
@@ -68,25 +75,21 @@
private float mBackgroundAlpha;
private final Rect mBackgroundLayoutRect = new Rect();
-
private Drawable mBackground;
- private Drawable mBackgroundMini;
- private Drawable mBackgroundMiniHover;
+ private Drawable mBackgroundHover;
// If we're actively dragging something over this screen and it's small,
// mHover is true
private boolean mHover = false;
private final RectF mDragRect = new RectF();
+ private final Point mDragCenter = new Point();
- // When dragging, used to indicate a vacant drop location
- private Drawable mVacantDrawable;
-
- // When dragging, used to indicate an occupied drop location
- private Drawable mOccupiedDrawable;
-
- // Updated to point to mVacantDrawable or mOccupiedDrawable, as appropriate
private Drawable mDragRectDrawable;
+ private Drawable mCrosshairsDrawable = null;
+ private ValueAnimator mCrosshairsAnimator = null;
+ private float mCrosshairsVisibility = 0.0f;
+
// When a drag operation is in progress, holds the nearest cell to the touch point
private final int[] mDragCell = new int[2];
@@ -106,17 +109,6 @@
// A ViewGroup usually does not draw, but CellLayout needs to draw a rectangle to show
// the user where a dragged item will land when dropped.
setWillNotDraw(false);
- mVacantDrawable = getResources().getDrawable(R.drawable.rounded_rect_green);
- mOccupiedDrawable = getResources().getDrawable(R.drawable.rounded_rect_red);
-
- if (LauncherApplication.isScreenXLarge()) {
- mBackgroundMini = getResources().getDrawable(R.drawable.mini_home_screen_bg);
- mBackgroundMini.setFilterBitmap(true);
- mBackground = getResources().getDrawable(R.drawable.home_screen_bg);
- mBackground.setFilterBitmap(true);
- mBackgroundMiniHover = getResources().getDrawable(R.drawable.mini_home_screen_bg_hover);
- mBackgroundMiniHover.setFilterBitmap(true);
- }
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CellLayout, defStyle, 0);
@@ -140,7 +132,29 @@
setAlwaysDrawnWithCacheEnabled(false);
- mWallpaperManager = WallpaperManager.getInstance(getContext());
+ mWallpaperManager = WallpaperManager.getInstance(context);
+
+ if (LauncherApplication.isScreenXLarge()) {
+ final Resources res = getResources();
+
+ mBackground = res.getDrawable(R.drawable.mini_home_screen_bg);
+ mBackground.setFilterBitmap(true);
+ mBackgroundHover = res.getDrawable(R.drawable.mini_home_screen_bg_hover);
+ mBackgroundHover.setFilterBitmap(true);
+
+ mDragRectDrawable = res.getDrawable(R.drawable.rounded_rect_green);
+ mCrosshairsDrawable = res.getDrawable(R.drawable.gardening_crosshairs);
+
+ // Set up the animation for fading the crosshairs in and out
+ int animDuration = res.getInteger(R.integer.config_crosshairsFadeInTime);
+ mCrosshairsAnimator = new ValueAnimator<Float>(animDuration);
+ mCrosshairsAnimator.addUpdateListener(new AnimatorUpdateListener() {
+ public void onAnimationUpdate(ValueAnimator animation) {
+ mCrosshairsVisibility = ((Float) animation.getAnimatedValue()).floatValue();
+ CellLayout.this.invalidate();
+ }
+ });
+ }
}
public void setHover(boolean value) {
@@ -150,17 +164,19 @@
mHover = value;
}
+ private void animateCrosshairsTo(float value) {
+ final ValueAnimator anim = mCrosshairsAnimator;
+ long fullDuration = getResources().getInteger(R.integer.config_crosshairsFadeInTime);
+ anim.setDuration(fullDuration - anim.getCurrentPlayTime());
+ anim.setValues(mCrosshairsVisibility, value);
+ anim.cancel();
+ anim.start();
+ }
+
@Override
public void dispatchDraw(Canvas canvas) {
if (mBackgroundAlpha > 0.0f) {
- Drawable bg;
- if (mHover && getScaleX() < 0.5f) {
- bg = mBackgroundMiniHover;
- } else if (getScaleX() < 0.5f) {
- bg = mBackgroundMini;
- } else {
- bg = mBackground;
- }
+ final Drawable bg = mHover ? mBackgroundHover : mBackground;
bg.setAlpha((int) (mBackgroundAlpha * 255));
bg.draw(canvas);
}
@@ -169,29 +185,47 @@
@Override
protected void onDraw(Canvas canvas) {
- if (!mDragRect.isEmpty()) {
- mDragRectDrawable.setBounds(
- (int)mDragRect.left,
- (int)mDragRect.top,
- (int)mDragRect.right,
- (int)mDragRect.bottom);
- mDragRectDrawable.draw(canvas);
- }
- super.onDraw(canvas);
- }
+ if (mCrosshairsVisibility > 0.0f) {
+ final int countX = mCountX;
+ final int countY = mCountY;
- public void setDimmableProgress(float progress) {
- for (int i = 0; i < getChildCount(); i++) {
- Dimmable d = (Dimmable) getChildAt(i);
- d.setDimmableProgress(progress);
- }
- }
+ if (!mDragRect.isEmpty()) {
+ mDragRectDrawable.setBounds(
+ (int)mDragRect.left,
+ (int)mDragRect.top,
+ (int)mDragRect.right,
+ (int)mDragRect.bottom);
+ mDragRectDrawable.setAlpha((int) (mCrosshairsVisibility * 255));
+ mDragRectDrawable.draw(canvas);
+ }
- public float getDimmableProgress() {
- if (getChildCount() > 0) {
- return ((Dimmable) getChildAt(0)).getDimmableProgress();
+ final float MAX_ALPHA = 0.4f;
+ final int MAX_VISIBLE_DISTANCE = 600;
+ final float DISTANCE_MULTIPLIER = 0.002f;
+
+ final Drawable d = mCrosshairsDrawable;
+ final int width = d.getIntrinsicWidth();
+ final int height = d.getIntrinsicHeight();
+
+ int x = getLeftPadding() - (mWidthGap / 2) - (width / 2);
+ for (int col = 0; col <= countX; col++) {
+ int y = getTopPadding() - (mHeightGap / 2) - (height / 2);
+ for (int row = 0; row <= countY; row++) {
+ mTmpPointF.set(x - mDragCenter.x, y - mDragCenter.y);
+ float dist = mTmpPointF.length();
+ // Crosshairs further from the drag point are more faint
+ float alpha = Math.min(MAX_ALPHA,
+ DISTANCE_MULTIPLIER * (MAX_VISIBLE_DISTANCE - dist));
+ if (alpha > 0.0f) {
+ d.setBounds(x, y, x + width, y + height);
+ d.setAlpha((int) (alpha * 255 * mCrosshairsVisibility));
+ d.draw(canvas);
+ }
+ y += mCellHeight + mHeightGap;
+ }
+ x += mCellWidth + mWidthGap;
+ }
}
- return 0.0f;
}
@Override
@@ -218,7 +252,6 @@
return mCountY;
}
- // Takes canonical layout parameters
public boolean addViewToCellLayout(View child, int index, int childId, LayoutParams params) {
final LayoutParams lp = params;
@@ -548,11 +581,8 @@
if (mBackground != null) {
mBackground.setBounds(mBackgroundLayoutRect);
}
- if (mBackgroundMiniHover != null) {
- mBackgroundMiniHover.setBounds(mBackgroundLayoutRect);
- }
- if (mBackgroundMini != null) {
- mBackgroundMini.setBounds(mBackgroundLayoutRect);
+ if (mBackgroundHover != null) {
+ mBackgroundHover.setBounds(mBackgroundLayoutRect);
}
}
@@ -680,34 +710,24 @@
result[1] = Math.max(0, result[1]); // Snap to top
}
- void visualizeDropLocation(
- View view, int originX, int originY, int spanX, int spanY, View draggedItem) {
- final int[] originCell = mDragCell;
- final int[] cellXY = mTmpCellXY;
- estimateDropCell(originX, originY, spanX, spanY, cellXY);
+ void visualizeDropLocation(View view, int originX, int originY, int spanX, int spanY) {
+ final int[] nearest = findNearestVacantArea(originX, originY, spanX, spanY, view, mDragCell);
+ mDragCenter.set(originX + (view.getWidth() / 2), originY + (view.getHeight() / 2));
- // Only recalculate the bounding rect when necessary
- if (!Arrays.equals(cellXY, originCell)) {
- originCell[0] = cellXY[0];
- originCell[1] = cellXY[1];
-
+ if (nearest != null) {
// Find the top left corner of the rect the object will occupy
- final int[] topLeft = mTmpCellXY;
- cellToPoint(originCell[0], originCell[1], topLeft);
+ final int[] topLeft = mTmpPoint;
+ cellToPoint(nearest[0], nearest[1], topLeft);
+
+ // Need to copy these, because the next call to cellToPoint will overwrite them
final int left = topLeft[0];
final int top = topLeft[1];
// Now find the bottom right
- final int[] bottomRight = mTmpCellXY;
- cellToPoint(originCell[0] + spanX - 1, originCell[1] + spanY - 1, bottomRight);
+ final int[] bottomRight = mTmpPoint;
+ cellToPoint(nearest[0] + spanX - 1, nearest[1] + spanY - 1, bottomRight);
bottomRight[0] += mCellWidth;
bottomRight[1] += mCellHeight;
-
- boolean vacant =
- isVacantIgnoring(originCell[0], originCell[1], spanX, spanY, draggedItem);
- mDragRectDrawable = vacant ? mVacantDrawable : mOccupiedDrawable;
-
- // mDragRect will be rendered in onDraw()
mDragRect.set(left, top, bottomRight[0], bottomRight[1]);
invalidate();
}
@@ -721,14 +741,14 @@
* @param pixelY The Y location at which you want to search for a vacant area.
* @param spanX Horizontal span of the object.
* @param spanY Vertical span of the object.
- * @param vacantCells Pre-computed set of vacant cells to search.
- * @param recycle Previously returned value to possibly recycle.
+ * @param result Array in which to place the result, or null (in which case a new array will
+ * be allocated)
* @return The X, Y cell of a vacant area that can contain this object,
* nearest the requested location.
*/
int[] findNearestVacantArea(
- int pixelX, int pixelY, int spanX, int spanY, int[] recycle) {
- return findNearestVacantArea(pixelX, pixelY, spanX, spanY, null, recycle);
+ int pixelX, int pixelY, int spanX, int spanY, int[] result) {
+ return findNearestVacantArea(pixelX, pixelY, spanX, spanY, null, result);
}
/**
@@ -739,27 +759,30 @@
* @param pixelY The Y location at which you want to search for a vacant area.
* @param spanX Horizontal span of the object.
* @param spanY Vertical span of the object.
- * @param vacantCells Pre-computed set of vacant cells to search.
- * @param recycle Previously returned value to possibly recycle.
* @param ignoreView Considers space occupied by this view as unoccupied
+ * @param result Previously returned value to possibly recycle.
* @return The X, Y cell of a vacant area that can contain this object,
* nearest the requested location.
*/
int[] findNearestVacantArea(
- int pixelX, int pixelY, int spanX, int spanY, View ignoreView, int[] recycle) {
+ int pixelX, int pixelY, int spanX, int spanY, View ignoreView, int[] result) {
if (ignoreView != null) {
markCellsAsUnoccupiedForView(ignoreView);
}
// Keep track of best-scoring drop area
- final int[] bestXY = recycle != null ? recycle : new int[2];
+ final int[] bestXY = result != null ? result : new int[2];
double bestDistance = Double.MAX_VALUE;
- for (int x = 0; x < mCountX - (spanX - 1); x++) {
+ final int countX = mCountX;
+ final int countY = mCountY;
+ final boolean[][] occupied = mOccupied;
+
+ for (int x = 0; x < countX - (spanX - 1); x++) {
inner:
- for (int y = 0; y < mCountY - (spanY - 1); y++) {
+ for (int y = 0; y < countY - (spanY - 1); y++) {
for (int i = 0; i < spanX; i++) {
for (int j = 0; j < spanY; j++) {
- if (mOccupied[x + i][y + j]) {
+ if (occupied[x + i][y + j]) {
// small optimization: we can skip to below the row we just found
// an occupied cell
y += j;
@@ -919,12 +942,18 @@
mDragCell[1] = -1;
setHover(false);
- mDragRect.setEmpty();
invalidate();
+
+ // Fade out the drag indicators
+ if (mCrosshairsAnimator != null) {
+ animateCrosshairsTo(0.0f);
+ }
}
/**
* Mark a child as having been dropped.
+ * At the beginning of the drag operation, the child may have been on another
+ * screen, but it is reparented before this method is called.
*
* @param child The child that is being dropped
*/
@@ -933,7 +962,6 @@
LayoutParams lp = (LayoutParams) child.getLayoutParams();
lp.isDragging = false;
lp.dropped = true;
- mDragRect.setEmpty();
child.requestLayout();
}
onDragExit();
@@ -954,7 +982,19 @@
void onDragChild(View child) {
LayoutParams lp = (LayoutParams) child.getLayoutParams();
lp.isDragging = true;
+ }
+
+ /**
+ * A drag event has begun over this layout.
+ * It may have begun over this layout (in which case onDragChild is called first),
+ * or it may have begun on another layout.
+ */
+ void onDragEnter(View dragView) {
mDragRect.setEmpty();
+ // Fade in the drag indicators
+ if (mCrosshairsAnimator != null) {
+ animateCrosshairsTo(1.0f);
+ }
}
/**
diff --git a/src/com/android/launcher2/Dimmable.java b/src/com/android/launcher2/Dimmable.java
deleted file mode 100644
index df43b3c..0000000
--- a/src/com/android/launcher2/Dimmable.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package com.android.launcher2;
-
-public interface Dimmable {
- public void setDimmableProgress(float progress);
- public float getDimmableProgress();
-}
diff --git a/src/com/android/launcher2/DimmableAppWidgetHostView.java b/src/com/android/launcher2/DimmableAppWidgetHostView.java
index 1f512a3..7a1d4f9 100644
--- a/src/com/android/launcher2/DimmableAppWidgetHostView.java
+++ b/src/com/android/launcher2/DimmableAppWidgetHostView.java
@@ -21,21 +21,52 @@
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
+import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.view.View;
-public class DimmableAppWidgetHostView extends LauncherAppWidgetHostView implements Dimmable {
+public class DimmableAppWidgetHostView extends LauncherAppWidgetHostView {
public DimmableAppWidgetHostView(Context context) {
super(context);
mPaint.setFilterBitmap(true);
}
private final Paint mPaint = new Paint();
+ private int mAlpha;
+ private int mDimmedAlpha;
private Bitmap mDimmedView;
private Canvas mDimmedViewCanvas;
private boolean isDimmedViewUpdatePass;
- private float mDimmableProgress;
+
+ private static float cubic(float r) {
+ return (float) (Math.pow(r-1, 3) + 1);
+ }
+
+ /**
+ * Returns the interpolated holographic highlight alpha for the effect we want when scrolling
+ * pages.
+ */
+ public static float highlightAlphaInterpolator(float r) {
+ final float pivot = 0.3f;
+ if (r < pivot) {
+ return Math.max(0.5f, 0.65f*cubic(r/pivot));
+ } else {
+ return Math.min(1.0f, 0.65f*cubic(1 - (r-pivot)/(1-pivot)));
+ }
+ }
+
+ /**
+ * Returns the interpolated view alpha for the effect we want when scrolling pages.
+ */
+ public static float viewAlphaInterpolator(float r) {
+ final float pivot = 0.6f;
+ if (r < pivot) {
+ return r/pivot;
+ } else {
+ return 1.0f;
+ }
+ }
private void setChildAlpha(float alpha) {
if (getChildCount() > 0) {
@@ -52,18 +83,20 @@
setChildAlpha(getAlpha());
}
- //@Override
+ @Override
public boolean onSetAlpha(int alpha) {
super.onSetAlpha(alpha);
return true;
}
- public void setDimmableProgress(float progress) {
- mDimmableProgress = progress;
- }
-
- public float getDimmableProgress() {
- return mDimmableProgress;
+ @Override
+ public void setAlpha(float alpha) {
+ final float viewAlpha = viewAlphaInterpolator(alpha);
+ final float dimmedAlpha = highlightAlphaInterpolator(alpha);
+ mAlpha = (int) (viewAlpha * 255);
+ mDimmedAlpha = (int) (dimmedAlpha * 255);
+ super.setAlpha(viewAlpha);
+ setChildAlpha(viewAlpha);
}
private void updateDimmedView() {
@@ -80,14 +113,13 @@
int dimmedColor = getContext().getResources().getColor(R.color.dimmed_view_color);
mDimmedViewCanvas.drawColor(dimmedColor, PorterDuff.Mode.SRC_IN);
isDimmedViewUpdatePass = false;
- invalidate();
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
- if (mDimmedView == null && mDimmableProgress > 0.0f) {
+ if (mDimmedView == null && mDimmedAlpha > 0.0f) {
updateDimmedView();
}
}
@@ -102,9 +134,9 @@
canvas.restore();
setAlpha(alpha);
} else {
- if (mDimmedView != null && mDimmableProgress > 0) {
+ if (mDimmedView != null && mDimmedAlpha > 0) {
// draw the dimmed version of this widget
- mPaint.setAlpha((int) (mDimmableProgress * 255));
+ mPaint.setAlpha(mDimmedAlpha);
canvas.drawBitmap(mDimmedView, 0, 0, mPaint);
}
@@ -112,4 +144,4 @@
super.dispatchDraw(canvas);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/com/android/launcher2/DimmableBubbleTextView.java b/src/com/android/launcher2/DimmableBubbleTextView.java
index cb3b8ef..66cc97a 100644
--- a/src/com/android/launcher2/DimmableBubbleTextView.java
+++ b/src/com/android/launcher2/DimmableBubbleTextView.java
@@ -21,17 +21,18 @@
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
+import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.util.AttributeSet;
-public class DimmableBubbleTextView extends BubbleTextView implements Dimmable {
+public class DimmableBubbleTextView extends BubbleTextView {
private Paint mDimmedPaint = new Paint();
private int mAlpha;
+ private int mDimmedAlpha;
private Bitmap mDimmedView;
private Canvas mDimmedViewCanvas;
private boolean isDimmedViewUpdatePass;
- private float mDimmableProgress;
public DimmableBubbleTextView(Context context) {
super(context);
@@ -48,12 +49,48 @@
mDimmedPaint.setFilterBitmap(true);
}
- public void setDimmableProgress(float progress) {
- mDimmableProgress = progress;
+ private static float cubic(float r) {
+ return (float) (Math.pow(r-1, 3) + 1);
}
- public float getDimmableProgress() {
- return mDimmableProgress;
+ /**
+ * Returns the interpolated holographic highlight alpha for the effect we want when scrolling
+ * pages.
+ */
+ public static float highlightAlphaInterpolator(float r) {
+ final float pivot = 0.3f;
+ if (r < pivot) {
+ return Math.max(0.5f, 0.65f*cubic(r/pivot));
+ } else {
+ return Math.min(1.0f, 0.65f*cubic(1 - (r-pivot)/(1-pivot)));
+ }
+ }
+
+ /**
+ * Returns the interpolated view alpha for the effect we want when scrolling pages.
+ */
+ public static float viewAlphaInterpolator(float r) {
+ final float pivot = 0.6f;
+ if (r < pivot) {
+ return r/pivot;
+ } else {
+ return 1.0f;
+ }
+ }
+
+ @Override
+ public boolean onSetAlpha(int alpha) {
+ super.onSetAlpha(alpha);
+ return true;
+ }
+
+ @Override
+ public void setAlpha(float alpha) {
+ final float viewAlpha = viewAlphaInterpolator(alpha);
+ final float dimmedAlpha = highlightAlphaInterpolator(alpha);
+ mAlpha = (int) (viewAlpha * 255);
+ mDimmedAlpha = (int) (dimmedAlpha * 255);
+ super.setAlpha(viewAlpha);
}
@Override
@@ -87,11 +124,13 @@
super.setAlpha(alpha);
canvas.restore();
} else {
- super.onDraw(canvas);
+ if (mAlpha > 0) {
+ super.onDraw(canvas);
+ }
}
- if (mDimmedView != null && mDimmableProgress > 0) {
- mDimmedPaint.setAlpha((int) (mDimmableProgress * 255));
+ if (mDimmedView != null && mDimmedAlpha > 0) {
+ mDimmedPaint.setAlpha(mDimmedAlpha);
canvas.drawBitmap(mDimmedView, mScrollX, mScrollY, mDimmedPaint);
}
}
diff --git a/src/com/android/launcher2/DragController.java b/src/com/android/launcher2/DragController.java
index 87b3473..185f704 100644
--- a/src/com/android/launcher2/DragController.java
+++ b/src/com/android/launcher2/DragController.java
@@ -18,7 +18,6 @@
import android.content.Context;
import android.graphics.Bitmap;
-import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Handler;
@@ -311,6 +310,8 @@
}
dragView.show(mWindowToken, (int)mMotionDownX, (int)mMotionDownY);
+
+ handleMoveEvent((int) mMotionDownX, (int) mMotionDownY);
}
/**
@@ -437,12 +438,68 @@
return mMoveTarget != null && mMoveTarget.dispatchUnhandledMove(focused, direction);
}
+ private void handleMoveEvent(int x, int y) {
+ mDragView.move(x, y);
+
+ // Drop on someone?
+ final int[] coordinates = mCoordinatesTemp;
+ DropTarget dropTarget = findDropTarget(x, y, coordinates);
+ if (dropTarget != null) {
+ DropTarget delegate = dropTarget.getDropTargetDelegate(
+ mDragSource, coordinates[0], coordinates[1],
+ (int) mTouchOffsetX, (int) mTouchOffsetY, mDragView, mDragInfo);
+ if (delegate != null) {
+ dropTarget = delegate;
+ }
+
+ if (mLastDropTarget != dropTarget) {
+ if (mLastDropTarget != null) {
+ mLastDropTarget.onDragExit(mDragSource, coordinates[0], coordinates[1],
+ (int) mTouchOffsetX, (int) mTouchOffsetY, mDragView, mDragInfo);
+ }
+ dropTarget.onDragEnter(mDragSource, coordinates[0], coordinates[1],
+ (int) mTouchOffsetX, (int) mTouchOffsetY, mDragView, mDragInfo);
+ }
+ dropTarget.onDragOver(mDragSource, coordinates[0], coordinates[1],
+ (int) mTouchOffsetX, (int) mTouchOffsetY, mDragView, mDragInfo);
+ } else {
+ if (mLastDropTarget != null) {
+ mLastDropTarget.onDragExit(mDragSource, coordinates[0], coordinates[1],
+ (int) mTouchOffsetX, (int) mTouchOffsetY, mDragView, mDragInfo);
+ }
+ }
+ mLastDropTarget = dropTarget;
+
+ // Scroll, maybe, but not if we're in the delete region.
+ boolean inDeleteRegion = false;
+ if (mDeleteRegion != null) {
+ inDeleteRegion = mDeleteRegion.contains(x, y);
+ }
+ if (!inDeleteRegion && x < SCROLL_ZONE) {
+ if (mScrollState == SCROLL_OUTSIDE_ZONE) {
+ mScrollState = SCROLL_WAITING_IN_ZONE;
+ mScrollRunnable.setDirection(SCROLL_LEFT);
+ mHandler.postDelayed(mScrollRunnable, SCROLL_DELAY);
+ }
+ } else if (!inDeleteRegion && x > mScrollView.getWidth() - SCROLL_ZONE) {
+ if (mScrollState == SCROLL_OUTSIDE_ZONE) {
+ mScrollState = SCROLL_WAITING_IN_ZONE;
+ mScrollRunnable.setDirection(SCROLL_RIGHT);
+ mHandler.postDelayed(mScrollRunnable, SCROLL_DELAY);
+ }
+ } else {
+ if (mScrollState == SCROLL_WAITING_IN_ZONE) {
+ mScrollState = SCROLL_OUTSIDE_ZONE;
+ mScrollRunnable.setDirection(SCROLL_RIGHT);
+ mHandler.removeCallbacks(mScrollRunnable);
+ }
+ }
+ }
+
/**
* Call this from a drag source view.
*/
public boolean onTouchEvent(MotionEvent ev) {
- View scrollView = mScrollView;
-
if (!mDragging) {
return false;
}
@@ -457,74 +514,15 @@
mMotionDownX = screenX;
mMotionDownY = screenY;
- if ((screenX < SCROLL_ZONE) || (screenX > scrollView.getWidth() - SCROLL_ZONE)) {
+ if ((screenX < SCROLL_ZONE) || (screenX > mScrollView.getWidth() - SCROLL_ZONE)) {
mScrollState = SCROLL_WAITING_IN_ZONE;
mHandler.postDelayed(mScrollRunnable, SCROLL_DELAY);
} else {
mScrollState = SCROLL_OUTSIDE_ZONE;
}
-
break;
case MotionEvent.ACTION_MOVE:
- // Update the drag view. Don't use the clamped pos here so the dragging looks
- // like it goes off screen a little, intead of bumping up against the edge.
- mDragView.move((int)ev.getRawX(), (int)ev.getRawY());
-
- // Drop on someone?
- final int[] coordinates = mCoordinatesTemp;
- DropTarget dropTarget = findDropTarget(screenX, screenY, coordinates);
- if (dropTarget != null) {
- DropTarget delegate = dropTarget.getDropTargetDelegate(
- mDragSource, coordinates[0], coordinates[1],
- (int) mTouchOffsetX, (int) mTouchOffsetY, mDragView, mDragInfo);
- if (delegate != null) {
- dropTarget = delegate;
- }
-
- if (mLastDropTarget == dropTarget) {
- dropTarget.onDragOver(mDragSource, coordinates[0], coordinates[1],
- (int) mTouchOffsetX, (int) mTouchOffsetY, mDragView, mDragInfo);
- } else {
- if (mLastDropTarget != null) {
- mLastDropTarget.onDragExit(mDragSource, coordinates[0], coordinates[1],
- (int) mTouchOffsetX, (int) mTouchOffsetY, mDragView, mDragInfo);
- }
- dropTarget.onDragEnter(mDragSource, coordinates[0], coordinates[1],
- (int) mTouchOffsetX, (int) mTouchOffsetY, mDragView, mDragInfo);
- }
- } else {
- if (mLastDropTarget != null) {
- mLastDropTarget.onDragExit(mDragSource, coordinates[0], coordinates[1],
- (int) mTouchOffsetX, (int) mTouchOffsetY, mDragView, mDragInfo);
- }
- }
- mLastDropTarget = dropTarget;
-
- // Scroll, maybe, but not if we're in the delete region.
- boolean inDeleteRegion = false;
- if (mDeleteRegion != null) {
- inDeleteRegion = mDeleteRegion.contains(screenX, screenY);
- }
- if (!inDeleteRegion && screenX < SCROLL_ZONE) {
- if (mScrollState == SCROLL_OUTSIDE_ZONE) {
- mScrollState = SCROLL_WAITING_IN_ZONE;
- mScrollRunnable.setDirection(SCROLL_LEFT);
- mHandler.postDelayed(mScrollRunnable, SCROLL_DELAY);
- }
- } else if (!inDeleteRegion && screenX > scrollView.getWidth() - SCROLL_ZONE) {
- if (mScrollState == SCROLL_OUTSIDE_ZONE) {
- mScrollState = SCROLL_WAITING_IN_ZONE;
- mScrollRunnable.setDirection(SCROLL_RIGHT);
- mHandler.postDelayed(mScrollRunnable, SCROLL_DELAY);
- }
- } else {
- if (mScrollState == SCROLL_WAITING_IN_ZONE) {
- mScrollState = SCROLL_OUTSIDE_ZONE;
- mScrollRunnable.setDirection(SCROLL_RIGHT);
- mHandler.removeCallbacks(mScrollRunnable);
- }
- }
-
+ handleMoveEvent(screenX, screenY);
break;
case MotionEvent.ACTION_UP:
mHandler.removeCallbacks(mScrollRunnable);
diff --git a/src/com/android/launcher2/DragView.java b/src/com/android/launcher2/DragView.java
index d14f5f7..ca0e7b4 100644
--- a/src/com/android/launcher2/DragView.java
+++ b/src/com/android/launcher2/DragView.java
@@ -17,7 +17,10 @@
package com.android.launcher2;
+import com.android.launcher.R;
+
import android.content.Context;
+import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
@@ -31,9 +34,6 @@
import android.view.WindowManagerImpl;
public class DragView extends View implements TweenCallback {
- // Number of pixels to add to the dragged item for scaling. Should be even for pixel alignment.
- private static final int DRAG_SCALE = 40;
-
private Bitmap mBitmap;
private Paint mPaint;
private int mRegistrationX;
@@ -66,21 +66,24 @@
int left, int top, int width, int height) {
super(context);
+ final Resources res = getResources();
+ final int dragScale = res.getInteger(R.integer.config_dragViewExtraPixels);
+
mWindowManager = WindowManagerImpl.getDefault();
mTween = new SymmetricalLinearTween(false, 110 /*ms duration*/, this);
Matrix scale = new Matrix();
float scaleFactor = width;
- scaleFactor = mScale = (scaleFactor + DRAG_SCALE) / scaleFactor;
+ scaleFactor = mScale = (scaleFactor + dragScale) / scaleFactor;
scale.setScale(scaleFactor, scaleFactor);
mBitmap = Bitmap.createBitmap(bitmap, left, top, width, height, scale, true);
setDragRegion(0, 0, width, height);
// The point in our scaled bitmap that the touch events are located
- mRegistrationX = registrationX + (DRAG_SCALE / 2);
- mRegistrationY = registrationY + (DRAG_SCALE / 2);
+ mRegistrationX = registrationX + res.getInteger(R.integer.config_dragViewOffsetX);
+ mRegistrationY = registrationY + res.getInteger(R.integer.config_dragViewOffsetY);
}
public void setDragRegion(int left, int top, int width, int height) {
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 4e47acb..5aec48e 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -78,7 +78,6 @@
protected final static int TOUCH_STATE_SCROLLING = 1;
protected final static int TOUCH_STATE_PREV_PAGE = 2;
protected final static int TOUCH_STATE_NEXT_PAGE = 3;
- protected final static float ALPHA_QUANTIZE_LEVEL = 0.01f;
protected int mTouchState = TOUCH_STATE_REST;
@@ -368,6 +367,7 @@
if (mDirtyPageAlpha || (mTouchState == TOUCH_STATE_SCROLLING) || !mScroller.isFinished()) {
int halfScreenSize = getMeasuredWidth() / 2;
int screenCenter = mScrollX + halfScreenSize;
+
final int childCount = getChildCount();
for (int i = 0; i < childCount; ++i) {
View layout = (View) getChildAt(i);
@@ -391,12 +391,6 @@
dimAlpha = Math.max(0.0f, Math.min(1.0f, (dimAlpha * dimAlpha)));
float alpha = 1.0f - dimAlpha;
- if (alpha < ALPHA_QUANTIZE_LEVEL) {
- alpha = 0.0f;
- } else if (alpha > 1.0f - ALPHA_QUANTIZE_LEVEL) {
- alpha = 1.0f;
- }
-
if (Float.compare(alpha, layout.getAlpha()) != 0) {
layout.setAlpha(alpha);
}
@@ -406,16 +400,10 @@
}
}
- protected void screenScrolled(int screenCenter) {
- }
-
@Override
protected void dispatchDraw(Canvas canvas) {
updateAdjacentPagesAlpha();
- int halfScreenSize = getMeasuredWidth() / 2;
- int screenCenter = mScrollX + halfScreenSize;
- screenScrolled(screenCenter);
// Find out which screens are visible; as an optimization we only call draw on them
// As an optimization, this code assumes that all pages have the same width as the 0th
// page.
diff --git a/src/com/android/launcher2/SmoothPagedView.java b/src/com/android/launcher2/SmoothPagedView.java
index 56037ff..5f80f25 100644
--- a/src/com/android/launcher2/SmoothPagedView.java
+++ b/src/com/android/launcher2/SmoothPagedView.java
@@ -26,15 +26,11 @@
private static final float SMOOTHING_SPEED = 0.75f;
private static final float SMOOTHING_CONSTANT = (float) (0.016 / Math.log(SMOOTHING_SPEED));
- private float mBaseLineFlingVelocity;
- private float mFlingVelocityInfluence;
- static final int OVERSHOOT_MODE = 0;
- static final int QUINTIC_MODE = 1;
+ private static final float BASELINE_FLING_VELOCITY = 2500.f;
+ private static final float FLING_VELOCITY_INFLUENCE = 0.4f;
- int mScrollMode;
-
- private Interpolator mScrollInterpolator;
+ private WorkspaceOvershootInterpolator mScrollInterpolator;
private static class WorkspaceOvershootInterpolator implements Interpolator {
private static final float DEFAULT_TENSION = 1.3f;
@@ -60,16 +56,6 @@
}
}
- private static class QuinticInterpolator implements Interpolator {
- public QuinticInterpolator() {
- }
-
- public float getInterpolation(float t) {
- t -= 1.0f;
- return t*t*t*t*t + 1;
- }
- }
-
/**
* Used to inflate the Workspace from XML.
*
@@ -97,27 +83,14 @@
mDeferScrollUpdate = true;
}
- protected int getScrollMode() {
- return OVERSHOOT_MODE;
- }
-
/**
* Initializes various states for this workspace.
*/
@Override
protected void init() {
super.init();
-
- mScrollMode = getScrollMode();
- if (mScrollMode == QUINTIC_MODE) {
- mBaseLineFlingVelocity = 700.0f;
- mFlingVelocityInfluence = 0.8f;
- mScrollInterpolator = new QuinticInterpolator();
- } else { // QUINTIC_MODE
- mBaseLineFlingVelocity = 2500.0f;
- mFlingVelocityInfluence = 0.4f;
- mScrollInterpolator = new WorkspaceOvershootInterpolator();
- }
+ mScrollInterpolator = new WorkspaceOvershootInterpolator();
+ // overwrite the previous mScroller
mScroller = new Scroller(getContext(), mScrollInterpolator);
}
@@ -139,32 +112,25 @@
final int screenDelta = Math.max(1, Math.abs(whichPage - mCurrentPage));
final int newX = getChildOffset(whichPage) - getRelativeChildOffset(whichPage);
final int delta = newX - mScrollX;
- int duration;
- if (mScrollMode == OVERSHOOT_MODE) {
- duration = (screenDelta + 1) * 100;
- } else { // QUINTIC_MODE
- duration = Math.round(Math.abs(delta) * 0.6f);
- }
+ int duration = (screenDelta + 1) * 100;
if (!mScroller.isFinished()) {
mScroller.abortAnimation();
}
- if (mScrollMode == OVERSHOOT_MODE) {
- if (settle) {
- ((WorkspaceOvershootInterpolator) mScrollInterpolator).setDistance(screenDelta);
- } else {
- ((WorkspaceOvershootInterpolator) mScrollInterpolator).disableSettle();
- }
+ if (settle) {
+ mScrollInterpolator.setDistance(screenDelta);
+ } else {
+ mScrollInterpolator.disableSettle();
}
velocity = Math.abs(velocity);
if (velocity > 0) {
- duration += (duration / (velocity / mBaseLineFlingVelocity)) * mFlingVelocityInfluence;
+ duration += (duration / (velocity / BASELINE_FLING_VELOCITY))
+ * FLING_VELOCITY_INFLUENCE;
} else {
duration += 100;
}
-
snapToPage(whichPage, delta, duration);
}
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 160283b..4d820cf 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -19,10 +19,10 @@
import com.android.launcher.R;
import android.animation.Animator;
+import android.animation.Animator.AnimatorListener;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
-import android.animation.Animator.AnimatorListener;
import android.app.WallpaperManager;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProviderInfo;
@@ -33,9 +33,7 @@
import android.content.pm.ProviderInfo;
import android.content.res.Resources;
import android.content.res.TypedArray;
-import android.graphics.Camera;
import android.graphics.Canvas;
-import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
@@ -46,7 +44,6 @@
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
-import android.view.ViewGroup;
import android.widget.TextView;
import java.util.ArrayList;
@@ -66,8 +63,8 @@
// customization mode
private static final float SHRINK_FACTOR = 0.16f;
- // Y rotation to apply to the workspace screens
- private static final float WORKSPACE_ROTATION = 12.5f;
+ // The maximum Y rotation to apply to the mini home screens
+ private static final float MINI_PAGE_MAX_ROTATION = 25.0f;
// These are extra scale factors to apply to the mini home screens
// so as to achieve the desired transform
@@ -75,18 +72,6 @@
private static final float EXTRA_SCALE_FACTOR_1 = 1.0f;
private static final float EXTRA_SCALE_FACTOR_2 = 1.08f;
- private static final int BACKGROUND_FADE_OUT_DELAY = 300;
- private static final int BACKGROUND_FADE_OUT_DURATION = 300;
- private static final int BACKGROUND_FADE_IN_DURATION = 100;
-
- static final int SCROLL_RIGHT = 0;
- static final int SCROLL_LEFT = 1;
-
- // These animators are used to fade the
- private ObjectAnimator<Float> mBackgroundFadeIn;
- private ObjectAnimator<Float> mBackgroundFadeOut;
- private float mBackgroundAlpha = 0;
-
private enum ShrinkPosition { SHRINK_TO_TOP, SHRINK_TO_MIDDLE, SHRINK_TO_BOTTOM };
private final WallpaperManager mWallpaperManager;
@@ -195,15 +180,6 @@
}
@Override
- protected int getScrollMode() {
- if (LauncherApplication.isScreenXLarge()) {
- return SmoothPagedView.QUINTIC_MODE;
- } else {
- return SmoothPagedView.OVERSHOOT_MODE;
- }
- }
-
- @Override
public void addView(View child, int index, LayoutParams params) {
if (!(child instanceof CellLayout)) {
throw new IllegalArgumentException("A Workspace can only have CellLayout children.");
@@ -406,14 +382,12 @@
enableChildrenCache(mCurrentPage - 1, mCurrentPage + 1);
}
}
- showOutlines();
}
protected void pageEndMoving() {
if (!LauncherApplication.isScreenXLarge()) {
clearChildrenCache();
}
- hideOutlines();
}
@Override
@@ -450,99 +424,6 @@
}
}
- private float getScaleXForRotation(float degrees) {
- return (float) (1.0f / Math.cos(Math.PI * degrees / 180.0f));
- }
-
- public void showOutlines() {
- if (mBackgroundFadeOut != null) mBackgroundFadeOut.cancel();
- if (mBackgroundFadeIn != null) mBackgroundFadeIn.cancel();
- mBackgroundFadeIn = new ObjectAnimator<Float>(BACKGROUND_FADE_IN_DURATION, this,
- new PropertyValuesHolder<Float>("backgroundAlpha", 1.0f));
- mBackgroundFadeIn.start();
- }
-
- public void hideOutlines() {
- if (mBackgroundFadeIn != null) mBackgroundFadeIn.cancel();
- if (mBackgroundFadeOut != null) mBackgroundFadeOut.cancel();
- mBackgroundFadeOut = new ObjectAnimator<Float>(BACKGROUND_FADE_OUT_DURATION, this,
- new PropertyValuesHolder<Float>("backgroundAlpha", 0.0f));
- mBackgroundFadeOut.setStartDelay(BACKGROUND_FADE_OUT_DELAY);
- mBackgroundFadeOut.start();
- }
-
- public void setBackgroundAlpha(float alpha) {
- mBackgroundAlpha = alpha;
- for (int i = 0; i < getChildCount(); i++) {
- CellLayout cl = (CellLayout) getChildAt(i);
- cl.setBackgroundAlpha(alpha);
- }
- }
-
- public float getBackgroundAlpha() {
- return mBackgroundAlpha;
- }
-
- @Override
- protected void screenScrolled(int screenCenter) {
- View cur = getChildAt(mCurrentPage);
- View toRight = getChildAt(mCurrentPage + 1);
- View toLeft = getChildAt(mCurrentPage - 1);
-
- for (int i = 0; i < mCurrentPage - 1; i++) {
- View v = getChildAt(i);
- if (v != null) {
- v.setRotationY(WORKSPACE_ROTATION);
- v.setScaleX(getScaleXForRotation(WORKSPACE_ROTATION));
- }
- }
- for (int i = mCurrentPage + 1; i < getChildCount(); i++) {
- View v = getChildAt(i);
- if (v != null) {
- v.setRotationY(-WORKSPACE_ROTATION);
- v.setScaleX(getScaleXForRotation(-WORKSPACE_ROTATION));
- }
- }
-
- int pageWidth = cur.getMeasuredWidth();
- int delta = screenCenter - (mCurrentPage * pageWidth + pageWidth / 2 +
- getRelativeChildOffset(0));
-
- float scrollProgress = Math.abs(delta/(pageWidth*1.0f));
- int scrollDirection = delta > 0 ? SCROLL_LEFT : SCROLL_RIGHT;
-
- float rotation;
-
- if (scrollDirection == SCROLL_RIGHT) {
- rotation = -scrollProgress * WORKSPACE_ROTATION;
- cur.setRotationY(rotation);
- cur.setScaleX(getScaleXForRotation(rotation));
- if (toLeft != null) {
- rotation = WORKSPACE_ROTATION * (1 - scrollProgress);
- toLeft.setRotationY(rotation);
- toLeft.setScaleX(getScaleXForRotation(rotation));
- }
- if (toRight != null) {
- toRight.setRotationY(-WORKSPACE_ROTATION);
- toRight.setScaleX(getScaleXForRotation(WORKSPACE_ROTATION));
- }
- } else {
- rotation = scrollProgress * WORKSPACE_ROTATION;
- cur.setRotationY(rotation);
- cur.setScaleX(getScaleXForRotation(rotation));
-
- if (toRight != null) {
- rotation = -WORKSPACE_ROTATION * (1 - scrollProgress);
- toRight.setRotationY(rotation);
- toRight.setScaleX(getScaleXForRotation(rotation));
- }
- if (toLeft != null) {
- toLeft.setRotationY(WORKSPACE_ROTATION);
- toLeft.setScaleX(getScaleXForRotation(WORKSPACE_ROTATION));
- }
- }
- }
-
protected void onAttachedToWindow() {
super.onAttachedToWindow();
computeScroll();
@@ -743,7 +624,7 @@
for (int i = 0; i < screenCount; i++) {
CellLayout cl = (CellLayout) getChildAt(i);
- float rotation = (-i + 2) * WORKSPACE_ROTATION;
+ float rotation = (-i + 2) * MINI_PAGE_MAX_ROTATION / 2.0f;
float rotationScaleX = (float) (1.0f / Math.cos(Math.PI * rotation / 180.0f));
float rotationScaleY = getYScaleForScreen(i);
@@ -755,16 +636,14 @@
new PropertyValuesHolder<Float>("scaleX", SHRINK_FACTOR * rotationScaleX),
new PropertyValuesHolder<Float>("scaleY", SHRINK_FACTOR * rotationScaleY),
new PropertyValuesHolder<Float>("backgroundAlpha", 1.0f),
- new PropertyValuesHolder<Float>("dimmableProgress", 1.0f),
new PropertyValuesHolder<Float>("alpha", 0.0f),
new PropertyValuesHolder<Float>("rotationY", rotation)).start();
} else {
cl.setX((int)newX);
cl.setY((int)newY);
- cl.setScaleX(SHRINK_FACTOR * rotationScaleX);
- cl.setScaleY(SHRINK_FACTOR * rotationScaleY);
+ cl.setScaleX(SHRINK_FACTOR);
+ cl.setScaleY(SHRINK_FACTOR);
cl.setBackgroundAlpha(1.0f);
- cl.setDimmableProgress(1.0f);
cl.setAlpha(0.0f);
cl.setRotationY(rotation);
}
@@ -817,14 +696,6 @@
for (int i = 0; i < screenCount; i++) {
final CellLayout cl = (CellLayout)getChildAt(i);
float finalAlphaValue = (i == mCurrentPage) ? 1.0f : 0.0f;
- float rotation = 0.0f;
-
- if (i < mCurrentPage) {
- rotation = WORKSPACE_ROTATION;
- } else if (i > mCurrentPage) {
- rotation = -WORKSPACE_ROTATION;
- }
-
if (animated) {
s.playTogether(
new ObjectAnimator<Float>(duration, cl, "translationX", 0.0f),
@@ -833,17 +704,15 @@
new ObjectAnimator<Float>(duration, cl, "scaleY", 1.0f),
new ObjectAnimator<Float>(duration, cl, "backgroundAlpha", 0.0f),
new ObjectAnimator<Float>(duration, cl, "alpha", finalAlphaValue),
- new ObjectAnimator<Float>(duration, cl, "dimmableProgress", 0.0f),
- new ObjectAnimator<Float>(duration, cl, "rotationY", rotation));
+ new ObjectAnimator<Float>(duration, cl, "rotationY", 0.0f));
} else {
cl.setTranslationX(0.0f);
cl.setTranslationY(0.0f);
cl.setScaleX(1.0f);
cl.setScaleY(1.0f);
cl.setBackgroundAlpha(0.0f);
- cl.setDimmableProgress(0.0f);
- cl.setAlpha(finalAlphaValue);
- cl.setRotationY(rotation);
+ cl.setAlpha(1.0f);
+ cl.setRotationY(0.0f);
}
}
s.addListener(mUnshrinkAnimationListener);
@@ -866,6 +735,7 @@
current.onDragChild(child);
mDragController.startDrag(child, this, child.getTag(), DragController.DRAG_ACTION_MOVE);
+ current.onDragEnter(child);
invalidate();
}
@@ -939,6 +809,7 @@
public void onDragEnter(DragSource source, int x, int y, int xOffset,
int yOffset, DragView dragView, Object dragInfo) {
+ getCurrentDropLayout().onDragEnter(dragView);
}
public DropTarget getDropTargetDelegate(DragSource source, int x, int y, int xOffset, int yOffset,
@@ -982,7 +853,6 @@
return null;
}
-
private void mapPointGlobalToLocal(View v, float[] xy) {
xy[0] = xy[0] + mScrollX - v.getLeft();
xy[1] = xy[1] + mScrollY - v.getTop();
@@ -1113,6 +983,7 @@
if (currentLayout != mDragTargetLayout) {
if (mDragTargetLayout != null) {
mDragTargetLayout.onDragExit();
+ currentLayout.onDragEnter(dragView);
}
mDragTargetLayout = currentLayout;
}
@@ -1125,7 +996,7 @@
int localOriginX = originX - (mDragTargetLayout.getLeft() - mScrollX);
int localOriginY = originY - (mDragTargetLayout.getTop() - mScrollY);
mDragTargetLayout.visualizeDropLocation(
- child, localOriginX, localOriginY, item.spanX, item.spanY, child);
+ child, localOriginX, localOriginY, item.spanX, item.spanY);
}
}