summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/DragLayer.java
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2012-03-02 17:14:58 -0800
committerWinson Chung <winsonc@google.com>2012-03-08 13:37:46 -0800
commiteecf02da58adef5486bf0c9ff7127ea891f457a4 (patch)
treeaa96fab5fb3528fdd838b4547922b8577112df7f /src/com/android/launcher2/DragLayer.java
parent633f1aad55aea7afbefd8409ccfd1f693b27870b (diff)
downloadandroid_packages_apps_Trebuchet-eecf02da58adef5486bf0c9ff7127ea891f457a4.tar.gz
android_packages_apps_Trebuchet-eecf02da58adef5486bf0c9ff7127ea891f457a4.tar.bz2
android_packages_apps_Trebuchet-eecf02da58adef5486bf0c9ff7127ea891f457a4.zip
Fixing some issues/regressions related to scaled icons.
- Fixes issue with folder icons being clipped in landscape in sw720dp (Bug: 6118397) - Fixes issue with divider being in wrong orientation in sw720dp - Fixes issue with scaled icons not being drawn with filtering - Fixes issue with side pages showing under the hotseat when in landscape in phone UI - Animates the drag view on pick up and drop Change-Id: Iad26427ec63fcbc9bdb3b29a4645689ba445d5c8
Diffstat (limited to 'src/com/android/launcher2/DragLayer.java')
-rw-r--r--src/com/android/launcher2/DragLayer.java19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/com/android/launcher2/DragLayer.java b/src/com/android/launcher2/DragLayer.java
index a3b389d24..ce5c8c517 100644
--- a/src/com/android/launcher2/DragLayer.java
+++ b/src/com/android/launcher2/DragLayer.java
@@ -433,8 +433,10 @@ public class DragLayer extends FrameLayout {
public void animateViewIntoPosition(DragView dragView, final View child, int duration,
final Runnable onFinishAnimationRunnable, View anchorView) {
- ((CellLayoutChildren) child.getParent()).measureChild(child);
+ CellLayoutChildren parentChildren = (CellLayoutChildren) child.getParent();
+ CellLayout parent = (CellLayout) (CellLayout) parentChildren.getParent();
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams();
+ parentChildren.measureChild(child);
Rect r = new Rect();
getViewRectRelativeToSelf(dragView, r);
@@ -442,20 +444,25 @@ public class DragLayer extends FrameLayout {
int coord[] = new int[2];
coord[0] = lp.x;
coord[1] = lp.y;
+
// Since the child hasn't necessarily been laid out, we force the lp to be updated with
// the correct coordinates (above) and use these to determine the final location
float scale = getDescendantCoordRelativeToSelf((View) child.getParent(), coord);
int toX = coord[0];
int toY = coord[1];
if (child instanceof TextView) {
+ float childrenScale = parent.getChildrenScale();
TextView tv = (TextView) child;
- Drawable d = tv.getCompoundDrawables()[1];
- // Center in the y coordinate about the target's drawable
- toY += Math.round(scale * tv.getPaddingTop());
- toY -= (dragView.getHeight() - (int) Math.round(scale * d.getIntrinsicHeight())) / 2;
- // Center in the x coordinate about the target's drawable
+ // The child may be scaled (always about the center of the view) so to account for it,
+ // we have to offset the position by the scaled size. Once we do that, we can center
+ // the drag view about the scaled child view.
+ toY += Math.round(((1f - childrenScale) * child.getMeasuredHeight()) / 2 +
+ scale * childrenScale * tv.getPaddingTop());
+ toY -= dragView.getMeasuredHeight() * (1 - scale * childrenScale) / 2;
toX -= (dragView.getMeasuredWidth() - Math.round(scale * child.getMeasuredWidth())) / 2;
+
+ scale *= childrenScale;
} else if (child instanceof FolderIcon) {
// Account for holographic blur padding on the drag view
toY -= Workspace.DRAG_BITMAP_PADDING / 2;