summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/values-sw600dp/config.xml4
-rw-r--r--res/values/config.xml2
-rw-r--r--src/com/android/launcher2/CellLayout.java42
-rw-r--r--src/com/android/launcher2/DragLayer.java19
-rw-r--r--src/com/android/launcher2/DragView.java4
-rw-r--r--src/com/android/launcher2/Folder.java6
-rw-r--r--src/com/android/launcher2/Hotseat.java2
-rw-r--r--src/com/android/launcher2/Launcher.java8
-rw-r--r--src/com/android/launcher2/Workspace.java20
9 files changed, 73 insertions, 34 deletions
diff --git a/res/values-sw600dp/config.xml b/res/values-sw600dp/config.xml
index d07391eeb..bda3c329e 100644
--- a/res/values-sw600dp/config.xml
+++ b/res/values-sw600dp/config.xml
@@ -18,4 +18,8 @@
<!-- Camera distance for the overscroll effect. We use a higher value here because the
workspace screens run nearly flush to the edge of the screen-->
<integer name="config_cameraDistance">14000</integer>
+
+<!-- Hotseat -->
+ <!-- must be between 0 and 100 -->
+ <integer name="hotseat_item_scale_percentage">90</integer>
</resources>
diff --git a/res/values/config.xml b/res/values/config.xml
index 381ef1b25..8717f6a47 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -82,4 +82,6 @@
<bool name="hotseat_transpose_layout_with_orientation">true</bool>
<integer name="hotseat_cell_count">5</integer>
<integer name="hotseat_all_apps_index">2</integer>
+ <!-- must be between 0 and 100 -->
+ <integer name="hotseat_item_scale_percentage">100</integer>
</resources>
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index fe69e9fd0..c158f413a 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -138,6 +138,7 @@ public class CellLayout extends ViewGroup {
private ShortcutAndWidgetContainer mShortcutsAndWidgets;
private boolean mIsHotseat = false;
+ private float mHotseatScale = 1f;
public static final int MODE_DRAG_OVER = 0;
public static final int MODE_ON_DROP = 1;
@@ -200,6 +201,7 @@ public class CellLayout extends ViewGroup {
setAlwaysDrawnWithCacheEnabled(false);
final Resources res = getResources();
+ mHotseatScale = (res.getInteger(R.integer.hotseat_item_scale_percentage) / 100f);
mNormalBackground = res.getDrawable(R.drawable.homescreen_blue_normal_holo);
mActiveGlowBackground = res.getDrawable(R.drawable.homescreen_blue_strong_holo);
@@ -317,6 +319,10 @@ public class CellLayout extends ViewGroup {
mShortcutsAndWidgets.buildLayer();
}
+ public float getChildrenScale() {
+ return mIsHotseat ? mHotseatScale : 1.0f;
+ }
+
public void setGridSize(int x, int y) {
mCountX = x;
mCountY = y;
@@ -387,6 +393,25 @@ public class CellLayout extends ViewGroup {
}
}
+ public void scaleRect(Rect r, float scale) {
+ if (scale != 1.0f) {
+ r.left = (int) (r.left * scale + 0.5f);
+ r.top = (int) (r.top * scale + 0.5f);
+ r.right = (int) (r.right * scale + 0.5f);
+ r.bottom = (int) (r.bottom * scale + 0.5f);
+ }
+ }
+
+ Rect temp = new Rect();
+ void scaleRectAboutCenter(Rect in, Rect out, float scale) {
+ int cx = in.centerX();
+ int cy = in.centerY();
+ out.set(in);
+ out.offset(-cx, -cy);
+ scaleRect(out, scale);
+ out.offset(cx, cy);
+ }
+
@Override
protected void onDraw(Canvas canvas) {
// When we're large, we are either drawn in a "hover" state (ie when dragging an item to
@@ -414,9 +439,10 @@ public class CellLayout extends ViewGroup {
final float alpha = mDragOutlineAlphas[i];
if (alpha > 0) {
final Rect r = mDragOutlines[i];
+ scaleRectAboutCenter(r, temp, getChildrenScale());
final Bitmap b = (Bitmap) mDragOutlineAnims[i].getTag();
paint.setAlpha((int)(alpha + .5f));
- canvas.drawBitmap(b, null, r, paint);
+ canvas.drawBitmap(b, null, temp, paint);
}
}
@@ -591,6 +617,9 @@ public class CellLayout extends ViewGroup {
}
}
+ child.setScaleX(getChildrenScale());
+ child.setScaleY(getChildrenScale());
+
// Generate an id for each view, this assumes we have at most 256x256 cells
// per workspace screen
if (lp.cellX >= 0 && lp.cellX <= mCountX - 1 && lp.cellY >= 0 && lp.cellY <= mCountY - 1) {
@@ -2072,11 +2101,8 @@ public class CellLayout extends ViewGroup {
}
initDeltaX = child.getTranslationX();
initDeltaY = child.getTranslationY();
- finalScale = 1.0f - 4.0f / child.getWidth();
+ finalScale = getChildrenScale() - 4.0f / child.getWidth();
initScale = child.getScaleX();
-
- child.setPivotY(child.getMeasuredHeight() * 0.5f);
- child.setPivotX(child.getMeasuredWidth() * 0.5f);
this.child = child;
}
@@ -2117,7 +2143,7 @@ public class CellLayout extends ViewGroup {
// We make sure to end only after a full period
initDeltaX = 0;
initDeltaY = 0;
- initScale = 1.0f;
+ initScale = getChildrenScale();
}
});
mShakeAnimators.put(child, this);
@@ -2138,8 +2164,8 @@ public class CellLayout extends ViewGroup {
AnimatorSet s = LauncherAnimUtils.createAnimatorSet();
a = s;
s.playTogether(
- LauncherAnimUtils.ofFloat(child, "scaleX", 1f),
- LauncherAnimUtils.ofFloat(child, "scaleY", 1f),
+ LauncherAnimUtils.ofFloat(child, "scaleX", getChildrenScale()),
+ LauncherAnimUtils.ofFloat(child, "scaleY", getChildrenScale()),
LauncherAnimUtils.ofFloat(child, "translationX", 0f),
LauncherAnimUtils.ofFloat(child, "translationY", 0f)
);
diff --git a/src/com/android/launcher2/DragLayer.java b/src/com/android/launcher2/DragLayer.java
index 0bcd64c41..a2f2bcd6c 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 {
diff --git a/src/com/android/launcher2/DragView.java b/src/com/android/launcher2/DragView.java
index 389421d52..e6b15b8ee 100644
--- a/src/com/android/launcher2/DragView.java
+++ b/src/com/android/launcher2/DragView.java
@@ -75,6 +75,10 @@ public class DragView extends View {
final float scaleDps = res.getDimensionPixelSize(R.dimen.dragViewScale);
final float scale = (width + scaleDps) / width;
+ // Set the initial scale to avoid any jumps
+ setScaleX(initialScale);
+ setScaleY(initialScale);
+
// Animate the view into the correct position
mAnim = LauncherAnimUtils.ofFloat(0.0f, 1.0f);
mAnim.setDuration(150);
diff --git a/src/com/android/launcher2/Folder.java b/src/com/android/launcher2/Folder.java
index 8aa6e2f62..5feac2f4b 100644
--- a/src/com/android/launcher2/Folder.java
+++ b/src/com/android/launcher2/Folder.java
@@ -805,10 +805,10 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
+ mFolderNameHeight;
DragLayer parent = (DragLayer) mLauncher.findViewById(R.id.drag_layer);
- parent.getDescendantRectRelativeToSelf(mFolderIcon, mTempRect);
+ float scale = parent.getDescendantRectRelativeToSelf(mFolderIcon, mTempRect);
- int centerX = mTempRect.centerX();
- int centerY = mTempRect.centerY();
+ int centerX = (int) (mTempRect.left + mTempRect.width() * scale / 2);
+ int centerY = (int) (mTempRect.top + mTempRect.height() * scale / 2);
int centeredLeft = centerX - width / 2;
int centeredTop = centerY - height / 2;
diff --git a/src/com/android/launcher2/Hotseat.java b/src/com/android/launcher2/Hotseat.java
index 38feaa4fd..c122695eb 100644
--- a/src/com/android/launcher2/Hotseat.java
+++ b/src/com/android/launcher2/Hotseat.java
@@ -38,7 +38,7 @@ public class Hotseat extends FrameLayout {
private int mCellCountX;
private int mCellCountY;
private int mAllAppsButtonRank;
-
+
private boolean mTransposeLayoutWithOrientation;
private boolean mIsLandscape;
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index ad50bbfd8..d82753126 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -2129,12 +2129,14 @@ public final class Launcher extends Activity
lp = new DragLayer.LayoutParams(width, height);
}
- mDragLayer.getViewRectRelativeToSelf(fi, mRectForFolderAnimation);
+ // The layout from which the folder is being opened may be scaled, adjust the starting
+ // view size by this scale factor.
+ float scale = mDragLayer.getDescendantRectRelativeToSelf(fi, mRectForFolderAnimation);
lp.customPosition = true;
lp.x = mRectForFolderAnimation.left;
lp.y = mRectForFolderAnimation.top;
- lp.width = width;
- lp.height = height;
+ lp.width = (int) (scale * width);
+ lp.height = (int) (scale * height);
mFolderIconCanvas.drawColor(0, PorterDuff.Mode.CLEAR);
fi.draw(mFolderIconCanvas);
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index d1d47f5f6..504f9dcfe 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -1892,11 +1892,11 @@ public class Workspace extends SmoothPagedView
final int bmpWidth = b.getWidth();
final int bmpHeight = b.getHeight();
- mLauncher.getDragLayer().getLocationInDragLayer(child, mTempXY);
+ float scale = mLauncher.getDragLayer().getLocationInDragLayer(child, mTempXY);
int dragLayerX =
- Math.round(mTempXY[0] - (bmpWidth - child.getScaleX() * child.getWidth()) / 2);
+ Math.round(mTempXY[0] - (bmpWidth - scale * child.getWidth()) / 2);
int dragLayerY =
- Math.round(mTempXY[1] - (bmpHeight - child.getScaleY() * bmpHeight) / 2
+ Math.round(mTempXY[1] - (bmpHeight - scale * bmpHeight) / 2
- DRAG_BITMAP_PADDING / 2);
Point dragVisualizeOffset = null;
@@ -1926,7 +1926,7 @@ public class Workspace extends SmoothPagedView
}
mDragController.startDrag(b, dragLayerX, dragLayerY, source, child.getTag(),
- DragController.DRAG_ACTION_MOVE, dragVisualizeOffset, dragRect, child.getScaleX());
+ DragController.DRAG_ACTION_MOVE, dragVisualizeOffset, dragRect, scale);
b.recycle();
// Show the scrolling indicator when you pick up an item
@@ -1966,7 +1966,7 @@ public class Workspace extends SmoothPagedView
// We want the point to be mapped to the dragTarget.
if (mLauncher.isHotseatLayout(dropTargetLayout)) {
- mapPointFromSelfToSibling(mLauncher.getHotseat(), mDragViewVisualCenter);
+ mapPointFromSelfToHotseatLayout(mLauncher.getHotseat(), mDragViewVisualCenter);
} else {
mapPointFromSelfToChild(dropTargetLayout, mDragViewVisualCenter, null);
}
@@ -2577,18 +2577,12 @@ public class Workspace extends SmoothPagedView
cachedInverseMatrix.mapPoints(xy);
}
- /*
- * Maps a point from the Workspace's coordinate system to another sibling view's. (Workspace
- * covers the full screen)
- */
- void mapPointFromSelfToSibling(View v, float[] xy) {
- xy[0] = xy[0] - v.getLeft();
- xy[1] = xy[1] - v.getTop();
- }
void mapPointFromSelfToHotseatLayout(Hotseat hotseat, float[] xy) {
+ hotseat.getLayout().getMatrix().invert(mTempInverseMatrix);
xy[0] = xy[0] - hotseat.getLeft() - hotseat.getLayout().getLeft();
xy[1] = xy[1] - hotseat.getTop() - hotseat.getLayout().getTop();
+ mTempInverseMatrix.mapPoints(xy);
}
/*