diff options
author | Jonathan Miranda <jonmiranda@google.com> | 2016-12-15 19:36:40 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2016-12-15 19:36:40 +0000 |
commit | 99d814e54b28efc8c8d8d6dec4bb036a380c3c3f (patch) | |
tree | f4289a63a316ac121fe3cf362386de645d123ed7 /src/com | |
parent | 6c46a6d324310bd2fc0ea223c9782ba6394512e7 (diff) | |
parent | 6f6a06ac470df4f58a6eea902b79a8813c44c8f7 (diff) | |
download | packages_apps_Trebuchet-99d814e54b28efc8c8d8d6dec4bb036a380c3c3f.tar.gz packages_apps_Trebuchet-99d814e54b28efc8c8d8d6dec4bb036a380c3c3f.tar.bz2 packages_apps_Trebuchet-99d814e54b28efc8c8d8d6dec4bb036a380c3c3f.zip |
Merge "Restore original scaleRectAboutCenter method." into ub-launcher3-master
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/launcher3/CellLayout.java | 5 | ||||
-rw-r--r-- | src/com/android/launcher3/Utilities.java | 17 | ||||
-rw-r--r-- | src/com/android/launcher3/Workspace.java | 5 |
3 files changed, 20 insertions, 7 deletions
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java index aef94c1eb..1e212bfd8 100644 --- a/src/com/android/launcher3/CellLayout.java +++ b/src/com/android/launcher3/CellLayout.java @@ -1018,8 +1018,7 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler { cellToRect(cellX, cellY, spanX, spanY, r); if (v instanceof LauncherAppWidgetHostView) { DeviceProfile profile = mLauncher.getDeviceProfile(); - Utilities.shrinkRectAboutCenter(r, profile.appWidgetScale.x, - profile.appWidgetScale.y); + Utilities.shrinkRect(r, profile.appWidgetScale.x, profile.appWidgetScale.y); } } else { // Find the top left corner of the rect the object will occupy @@ -1059,7 +1058,7 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler { r.set(left, top, left + dragOutline.getWidth(), top + dragOutline.getHeight()); } - Utilities.shrinkRectAboutCenter(r, mChildScale, mChildScale); + Utilities.scaleRectAboutCenter(r, mChildScale); mDragOutlineAnims[mDragOutlineCurrent].setTag(dragOutline); mDragOutlineAnims[mDragOutlineCurrent].animateIn(); diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index ce6d5a40f..3e44e33be 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -249,7 +249,22 @@ public final class Utilities { return delta; } - public static float shrinkRectAboutCenter(Rect r, float scaleX, float scaleY) { + public static void scaleRectAboutCenter(Rect r, float scale) { + if (scale != 1.0f) { + int cx = r.centerX(); + int cy = r.centerY(); + r.offset(-cx, -cy); + + 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); + + r.offset(cx, cy); + } + } + + public static float shrinkRect(Rect r, float scaleX, float scaleY) { float scale = Math.min(Math.min(scaleX, scaleY), 1.0f); if (scale < 1.0f) { int deltaX = (int) (r.width() * (scaleX - scale) * 0.5f); diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 3cfb3e1eb..ee21b422e 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -399,8 +399,7 @@ public class Workspace extends PagedView float scale = 1; if (isWidget) { DeviceProfile profile = mLauncher.getDeviceProfile(); - scale = Utilities.shrinkRectAboutCenter(r, profile.appWidgetScale.x, - profile.appWidgetScale.y); + scale = Utilities.shrinkRect(r, profile.appWidgetScale.x, profile.appWidgetScale.y); } size[0] = r.width(); size[1] = r.height(); @@ -3475,7 +3474,7 @@ public class Workspace extends PagedView Rect r = estimateItemPosition(layout, targetCell[0], targetCell[1], spanX, spanY); if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET) { DeviceProfile profile = mLauncher.getDeviceProfile(); - Utilities.shrinkRectAboutCenter(r, profile.appWidgetScale.x, profile.appWidgetScale.y); + Utilities.shrinkRect(r, profile.appWidgetScale.x, profile.appWidgetScale.y); } loc[0] = r.left; loc[1] = r.top; |