summaryrefslogtreecommitdiff
path: root/src/com/android/launcher2/DragLayer.java
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2012-08-16 17:55:58 -0700
committerAdam Cohen <adamcohen@google.com>2012-08-20 21:49:43 -0700
commit307fe23f125cbbd5512ad8d4660025f2ab68f30b (patch)
tree0bb74d508939237e628e96fade69d3b5ccf3c07b /src/com/android/launcher2/DragLayer.java
parent5c768e2fac95f8b8b2d6b5c523d7e1cdc968e395 (diff)
downloadLauncher2-307fe23f125cbbd5512ad8d4660025f2ab68f30b.tar.gz
Adding the ability to scale the hotseat or items in the hotseat
--> A bunch of stuff breaks when scaling the hotseat. More specifically, drag and drop animations between hotseat and workspace, scaling on pick up, folder animations, determination of item placement. This CL fixes these issues so that the hotseat or hotseat items are ready to be scaled. --> For now, using 90% scale factor for 7-inch+ UIs Change-Id: Iac098409347e76139e4d726a071397b56ac684d2
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 0bcd64c4..a2f2bcd6 100644
--- a/src/com/android/launcher2/DragLayer.java
+++ b/src/com/android/launcher2/DragLayer.java
@@ -274,10 +274,10 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang
return scale;
}
- public void getLocationInDragLayer(View child, int[] loc) {
+ public float getLocationInDragLayer(View child, int[] loc) {
loc[0] = 0;
loc[1] = 0;
- getDescendantCoordRelativeToSelf(child, loc);
+ return getDescendantCoordRelativeToSelf(child, loc);
}
/**
@@ -286,7 +286,9 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang
*
* @param descendant The descendant to which the passed coordinate is relative.
* @param coord The coordinate that we want mapped.
- * @return The factor by which this descendant is scaled relative to this DragLayer.
+ * @return The factor by which this descendant is scaled relative to this DragLayer. Caution
+ * this scale factor is assumed to be equal in X and Y, and so if at any point this
+ * assumption fails, we will need to return a pair of scale factors.
*/
public float getDescendantCoordRelativeToSelf(View descendant, int[] coord) {
float scale = 1.0f;
@@ -451,12 +453,16 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang
getViewRectRelativeToSelf(dragView, r);
int coord[] = new int[2];
- coord[0] = lp.x;
- coord[1] = lp.y;
+ float childScale = child.getScaleX();
+ coord[0] = lp.x + (int) (child.getMeasuredWidth() * (1 - childScale) / 2);
+ coord[1] = lp.y + (int) (child.getMeasuredHeight() * (1 - childScale) / 2);
// 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);
+ // We need to account for the scale of the child itself, as the above only accounts for
+ // for the scale in parents.
+ scale *= childScale;
int toX = coord[0];
int toY = coord[1];
if (child instanceof TextView) {
@@ -470,7 +476,8 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang
toX -= (dragView.getMeasuredWidth() - Math.round(scale * child.getMeasuredWidth())) / 2;
} else if (child instanceof FolderIcon) {
// Account for holographic blur padding on the drag view
- toY -= Workspace.DRAG_BITMAP_PADDING / 2;
+ toY -= scale * Workspace.DRAG_BITMAP_PADDING / 2;
+ toY -= (1 - scale) * dragView.getMeasuredHeight() / 2;
// Center in the x coordinate about the target's drawable
toX -= (dragView.getMeasuredWidth() - Math.round(scale * child.getMeasuredWidth())) / 2;
} else {