Reverting: "Animating the drag view scale up and down when dragging items."
Change-Id: I133ff2631834a4b97e1e4750fb7c07793ddeba69
diff --git a/src/com/android/launcher2/DragView.java b/src/com/android/launcher2/DragView.java
index 7be70a2..a3063b6 100644
--- a/src/com/android/launcher2/DragView.java
+++ b/src/com/android/launcher2/DragView.java
@@ -32,8 +32,6 @@
import com.android.launcher.R;
public class DragView extends View {
- private static float sDragAlpha = 0.8f;
-
private Bitmap mBitmap;
private Paint mPaint;
private int mRegistrationX;
@@ -67,13 +65,20 @@
mDragLayer = launcher.getDragLayer();
final Resources res = getResources();
- final float scale = res.getInteger(R.integer.config_dragViewScaleFactor) / 100f;
- final float offsetX = res.getDimensionPixelSize(R.dimen.dragViewOffsetX);
- final float offsetY = res.getDimensionPixelSize(R.dimen.dragViewOffsetY);
+ final int dragScale = res.getInteger(R.integer.config_dragViewExtraPixels);
+
+ Matrix scale = new Matrix();
+ final float scaleFactor = (width + dragScale) / width;
+ if (scaleFactor != 1.0f) {
+ scale.setScale(scaleFactor, scaleFactor);
+ }
+
+ final int offsetX = res.getDimensionPixelSize(R.dimen.dragViewOffsetX);
+ final int offsetY = res.getDimensionPixelSize(R.dimen.dragViewOffsetY);
// Animate the view into the correct position
mAnim = ValueAnimator.ofFloat(0.0f, 1.0f);
- mAnim.setDuration(150);
+ mAnim.setDuration(110);
mAnim.setInterpolator(new DecelerateInterpolator(2.5f));
mAnim.addUpdateListener(new AnimatorUpdateListener() {
@Override
@@ -85,9 +90,6 @@
mOffsetX += deltaX;
mOffsetY += deltaY;
- setScaleX(1f + (value * (scale - 1f)));
- setScaleY(1f + (value * (scale - 1f)));
- setAlpha(sDragAlpha * value + (1f - value));
if (getParent() == null) {
animation.cancel();
@@ -95,14 +97,12 @@
DragLayer.LayoutParams lp = mLayoutParams;
lp.x += deltaX;
lp.y += deltaY;
- lp.width = mBitmap.getWidth();
- lp.height = mBitmap.getHeight();
mDragLayer.requestLayout();
}
}
});
- mBitmap = Bitmap.createBitmap(bitmap, left, top, width, height);
+ mBitmap = Bitmap.createBitmap(bitmap, left, top, width, height, scale, true);
setDragRegion(new Rect(0, 0, width, height));
// The point in our scaled bitmap that the touch events are located
@@ -208,18 +208,6 @@
mAnim.start();
}
- public void cancelAnimation() {
- if (mAnim != null && mAnim.isRunning()) {
- mAnim.cancel();
- }
- }
-
- public void resetLayoutParams() {
- DragLayer.LayoutParams lp = mLayoutParams;
- lp.x = lp.y = 0;
- mOffsetX = mOffsetY = 0;
- }
-
/**
* Move the window containing this view.
*
@@ -234,9 +222,7 @@
}
void remove() {
- if (getParent() != null) {
- mDragLayer.removeView(DragView.this);
- }
+ mDragLayer.removeView(DragView.this);
}
int[] getPosition(int[] result) {