summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2011-10-19 21:36:08 -0700
committerWinson Chung <winsonc@google.com>2011-10-19 23:57:04 -0700
commitb8c69f3c17a40adc2d85e8e996f754c383c293dc (patch)
treee29218ccbd4ce9345c3706d5c9fe15ccff17f780 /src
parentfa4656a60b6a9e2f9b21a575c11a1d5c6e6771fc (diff)
downloadandroid_packages_apps_Trebuchet-b8c69f3c17a40adc2d85e8e996f754c383c293dc.tar.gz
android_packages_apps_Trebuchet-b8c69f3c17a40adc2d85e8e996f754c383c293dc.tar.bz2
android_packages_apps_Trebuchet-b8c69f3c17a40adc2d85e8e996f754c383c293dc.zip
Fixing issue where holographic outlines were offset when dragging from/to folders/hotseat. (Bug: 5399792)
Change-Id: Iaa39ef1293b45a1d116210ec9d7fbde17dbc99cc
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/CellLayout.java27
-rw-r--r--src/com/android/launcher2/DragController.java14
-rw-r--r--src/com/android/launcher2/DragView.java13
-rw-r--r--src/com/android/launcher2/Workspace.java27
4 files changed, 54 insertions, 27 deletions
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index ad87fa603..54fdcc53c 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -218,6 +218,7 @@ public class CellLayout extends ViewGroup {
});
mCrosshairsAnimator.getAnimator().setInterpolator(mEaseOutInterpolator);
+ mDragCell[0] = mDragCell[1] = -1;
for (int i = 0; i < mDragOutlines.length; i++) {
mDragOutlines[i] = new Point(-1, -1);
}
@@ -1171,13 +1172,13 @@ public class CellLayout extends ViewGroup {
result[1] = Math.max(0, result[1]); // Snap to top
}
- void visualizeDropLocation(
- View v, Bitmap dragOutline, int originX, int originY, int spanX, int spanY) {
+ void visualizeDropLocation(View v, Bitmap dragOutline, int originX, int originY,
+ int spanX, int spanY, Point dragOffset, Rect dragRegion) {
final int oldDragCellX = mDragCell[0];
final int oldDragCellY = mDragCell[1];
final int[] nearest = findNearestVacantArea(originX, originY, spanX, spanY, v, mDragCell);
- if (v != null) {
+ if (v != null && dragOffset == null) {
mDragCenter.set(originX + (v.getWidth() / 2), originY + (v.getHeight() / 2));
} else {
mDragCenter.set(originX, originY);
@@ -1198,7 +1199,7 @@ public class CellLayout extends ViewGroup {
int left = topLeft[0];
int top = topLeft[1];
- if (v != null) {
+ if (v != null && dragOffset == null) {
// When drawing the drag outline, it did not account for margin offsets
// added by the view's parent.
MarginLayoutParams lp = (MarginLayoutParams) v.getLayoutParams();
@@ -1213,11 +1214,19 @@ public class CellLayout extends ViewGroup {
left += ((mCellWidth * spanX) + ((spanX - 1) * mWidthGap)
- dragOutline.getWidth()) / 2;
} else {
- // Center the drag outline in the cell
- left += ((mCellWidth * spanX) + ((spanX - 1) * mWidthGap)
- - dragOutline.getWidth()) / 2;
- top += ((mCellHeight * spanY) + ((spanY - 1) * mHeightGap)
- - dragOutline.getHeight()) / 2;
+ if (dragOffset != null && dragRegion != null) {
+ // Center the drag region *horizontally* in the cell and apply a drag
+ // outline offset
+ left += dragOffset.x + ((mCellWidth * spanX) + ((spanX - 1) * mWidthGap)
+ - dragRegion.width()) / 2;
+ top += dragOffset.y;
+ } else {
+ // Center the drag outline in the cell
+ left += ((mCellWidth * spanX) + ((spanX - 1) * mWidthGap)
+ - dragOutline.getWidth()) / 2;
+ top += ((mCellHeight * spanY) + ((spanY - 1) * mHeightGap)
+ - dragOutline.getHeight()) / 2;
+ }
}
final int oldIndex = mDragOutlineCurrent;
diff --git a/src/com/android/launcher2/DragController.java b/src/com/android/launcher2/DragController.java
index 82aa30fef..ee054abcc 100644
--- a/src/com/android/launcher2/DragController.java
+++ b/src/com/android/launcher2/DragController.java
@@ -16,10 +16,9 @@
package com.android.launcher2;
-import android.appwidget.AppWidgetManager;
-import android.appwidget.AppWidgetProviderInfo;
import android.content.Context;
import android.graphics.Bitmap;
+import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Handler;
@@ -187,7 +186,7 @@ public class DragController {
int dragLayerX = loc[0];
int dragLayerY = loc[1];
- startDrag(b, dragLayerX, dragLayerY, source, dragInfo, dragAction, dragRegion);
+ startDrag(b, dragLayerX, dragLayerY, source, dragInfo, dragAction, null, dragRegion);
b.recycle();
if (dragAction == DRAG_ACTION_MOVE) {
@@ -214,7 +213,7 @@ public class DragController {
int dragLayerX = loc[0];
int dragLayerY = loc[1];
- startDrag(bmp, dragLayerX, dragLayerY, source, dragInfo, dragAction, dragRegion);
+ startDrag(bmp, dragLayerX, dragLayerY, source, dragInfo, dragAction, null, dragRegion);
if (dragAction == DRAG_ACTION_MOVE) {
v.setVisibility(View.GONE);
@@ -235,7 +234,7 @@ public class DragController {
*/
public void startDrag(Bitmap b, int dragLayerX, int dragLayerY,
DragSource source, Object dragInfo, int dragAction) {
- startDrag(b, dragLayerX, dragLayerY, source, dragInfo, dragAction, null);
+ startDrag(b, dragLayerX, dragLayerY, source, dragInfo, dragAction, null, null);
}
/**
@@ -253,7 +252,7 @@ public class DragController {
* Makes dragging feel more precise, e.g. you can clip out a transparent border
*/
public void startDrag(Bitmap b, int dragLayerX, int dragLayerY,
- DragSource source, Object dragInfo, int dragAction, Rect dragRegion) {
+ DragSource source, Object dragInfo, int dragAction, Point dragOffset, Rect dragRegion) {
if (PROFILE_DRAWING_DURING_DRAG) {
android.os.Debug.startMethodTracing("Launcher");
}
@@ -290,6 +289,9 @@ public class DragController {
final DragView dragView = mDragObject.dragView = new DragView(mLauncher, b, registrationX,
registrationY, 0, 0, b.getWidth(), b.getHeight());
+ if (dragOffset != null) {
+ dragView.setDragVisualizeOffset(new Point(dragOffset));
+ }
if (dragRegion != null) {
dragView.setDragRegion(new Rect(dragRegion));
}
diff --git a/src/com/android/launcher2/DragView.java b/src/com/android/launcher2/DragView.java
index 386cb55d3..dd94175b6 100644
--- a/src/com/android/launcher2/DragView.java
+++ b/src/com/android/launcher2/DragView.java
@@ -24,11 +24,9 @@ import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
+import android.graphics.Point;
import android.graphics.Rect;
-import android.os.IBinder;
import android.view.View;
-import android.view.WindowManager;
-import android.view.WindowManagerImpl;
import android.view.animation.DecelerateInterpolator;
import com.android.launcher.R;
@@ -39,6 +37,7 @@ public class DragView extends View {
private int mRegistrationX;
private int mRegistrationY;
+ private Point mDragVisualizeOffset = null;
private Rect mDragRegion = null;
private DragLayer mDragLayer = null;
private boolean mHasDrawn = false;
@@ -135,6 +134,14 @@ public class DragView extends View {
return mDragRegion.height();
}
+ public void setDragVisualizeOffset(Point p) {
+ mDragVisualizeOffset = p;
+ }
+
+ public Point getDragVisualizeOffset() {
+ return mDragVisualizeOffset;
+ }
+
public void setDragRegion(Rect r) {
mDragRegion = r;
}
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index d1f9617ac..e4f1fe8e0 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -17,12 +17,12 @@
package com.android.launcher2;
import android.animation.Animator;
+import android.animation.Animator.AnimatorListener;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
-import android.animation.Animator.AnimatorListener;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.app.AlertDialog;
import android.app.WallpaperManager;
@@ -40,6 +40,7 @@ import android.graphics.Camera;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
+import android.graphics.Point;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.RectF;
@@ -1784,7 +1785,7 @@ public class Workspace extends SmoothPagedView
v.getWidth() + padding, v.getHeight() + padding, Bitmap.Config.ARGB_8888);
canvas.setBitmap(b);
- drawDragView(v, canvas, padding, false);
+ drawDragView(v, canvas, padding, true);
mOutlineHelper.applyMediumExpensiveOutlineWithBlur(b, canvas, outlineColor, outlineColor);
canvas.setBitmap(null);
return b;
@@ -1866,6 +1867,8 @@ public class Workspace extends SmoothPagedView
}
public void beginDragShared(View child, DragSource source) {
+ Resources r = getResources();
+
// We need to add extra padding to the bitmap to make room for the glow effect
final int bitmapPadding = HolographicOutlineHelper.MAX_OUTER_BLUR_RADIUS;
@@ -1878,17 +1881,22 @@ public class Workspace extends SmoothPagedView
final int dragLayerX = (int) mTempXY[0] + (child.getWidth() - bmpWidth) / 2;
int dragLayerY = mTempXY[1] - bitmapPadding / 2;
+ Point dragVisualizeOffset = null;
Rect dragRect = null;
- if (child instanceof BubbleTextView) {
- int iconSize = getResources().getDimensionPixelSize(R.dimen.app_icon_size);
+ if (child instanceof BubbleTextView || child instanceof PagedViewIcon) {
+ int iconSize = r.getDimensionPixelSize(R.dimen.app_icon_size);
+ int iconPaddingTop = r.getDimensionPixelSize(R.dimen.app_icon_padding_top);
int top = child.getPaddingTop();
int left = (bmpWidth - iconSize) / 2;
int right = left + iconSize;
int bottom = top + iconSize;
dragLayerY += top;
+ // Note: The drag region is used to calculate drag layer offsets, but the
+ // dragVisualizeOffset in addition to the dragRect (the size) to position the outline.
+ dragVisualizeOffset = new Point(-bitmapPadding / 2, iconPaddingTop - bitmapPadding / 2);
dragRect = new Rect(left, top, right, bottom);
} else if (child instanceof FolderIcon) {
- int previewSize = getResources().getDimensionPixelSize(R.dimen.folder_preview_size);
+ int previewSize = r.getDimensionPixelSize(R.dimen.folder_preview_size);
dragRect = new Rect(0, 0, child.getWidth(), previewSize);
}
@@ -1899,7 +1907,7 @@ public class Workspace extends SmoothPagedView
}
mDragController.startDrag(b, dragLayerX, dragLayerY, source, child.getTag(),
- DragController.DRAG_ACTION_MOVE, dragRect);
+ DragController.DRAG_ACTION_MOVE, dragVisualizeOffset, dragRect);
b.recycle();
}
@@ -2354,13 +2362,13 @@ public class Workspace extends SmoothPagedView
showOutlines();
layout.setIsDragOccuring(true);
layout.onDragEnter();
- layout.visualizeDropLocation(null, mDragOutline, x, y, 1, 1);
+ layout.visualizeDropLocation(null, mDragOutline, x, y, 1, 1, null, null);
return true;
}
case DragEvent.ACTION_DRAG_LOCATION:
// Visualize the drop location
- layout.visualizeDropLocation(null, mDragOutline, x, y, 1, 1);
+ layout.visualizeDropLocation(null, mDragOutline, x, y, 1, 1, null, null);
return true;
case DragEvent.ACTION_DROP: {
// Try and add any shortcuts
@@ -2727,7 +2735,8 @@ public class Workspace extends SmoothPagedView
if (!mCreateUserFolderOnDrop && !isOverFolder) {
mDragTargetLayout.visualizeDropLocation(child, mDragOutline,
(int) mDragViewVisualCenter[0], (int) mDragViewVisualCenter[1],
- item.spanX, item.spanY);
+ item.spanX, item.spanY, d.dragView.getDragVisualizeOffset(),
+ d.dragView.getDragRegion());
}
}
}