summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/Utilities.java
diff options
context:
space:
mode:
authorJon Miranda <jonmiranda@google.com>2016-12-07 12:10:44 -0800
committerJon Miranda <jonmiranda@google.com>2016-12-14 16:30:20 -0800
commite96798e885e3ac97b6de0a1c598eb09cf62349af (patch)
treeac56f7cd1feb645abeaffbe3382a883527cf01c6 /src/com/android/launcher3/Utilities.java
parent8f03c86b3ac0ee4e80b62e9b85a06c2a31748acf (diff)
downloadandroid_packages_apps_Trebuchet-e96798e885e3ac97b6de0a1c598eb09cf62349af.tar.gz
android_packages_apps_Trebuchet-e96798e885e3ac97b6de0a1c598eb09cf62349af.tar.bz2
android_packages_apps_Trebuchet-e96798e885e3ac97b6de0a1c598eb09cf62349af.zip
Smooth animation when dropping a widget in multi-window mode.
Factored in app widget scaling in methods related to estimating widget size and positions. ie. Dropping a widget that needs to be resized to fit in the workspace. Bug: 32176631 Change-Id: I106fe12041565a090047f146a07d4bc80a074b4a
Diffstat (limited to 'src/com/android/launcher3/Utilities.java')
-rw-r--r--src/com/android/launcher3/Utilities.java23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 197aaf752..ce6d5a40f 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -249,19 +249,18 @@ public final class Utilities {
return delta;
}
- 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 shrinkRectAboutCenter(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);
+ r.left += deltaX;
+ r.right -= deltaX;
+
+ int deltaY = (int) (r.height() * (scaleY - scale) * 0.5f);
+ r.top += deltaY;
+ r.bottom -= deltaY;
}
+ return scale;
}
public static void startActivityForResultSafely(