summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/util
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-07-20 19:15:09 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-07-20 19:15:09 +0000
commit1f418d236122910df26f0893ba8e239989a5ee6c (patch)
treeadbdfd474717ff1a8daba87b4f547dc37734a665 /src/com/android/launcher3/util
parentcb6287aedcae9b100663b1c31766aa1d293a7011 (diff)
parent4a464794f202c6e913ff0ea442d248e86bebbd12 (diff)
downloadandroid_packages_apps_Trebuchet-1f418d236122910df26f0893ba8e239989a5ee6c.tar.gz
android_packages_apps_Trebuchet-1f418d236122910df26f0893ba8e239989a5ee6c.tar.bz2
android_packages_apps_Trebuchet-1f418d236122910df26f0893ba8e239989a5ee6c.zip
Merge "Adding support for dynamically adding shadows to the icon" into ub-launcher3-calgary
Diffstat (limited to 'src/com/android/launcher3/util')
-rw-r--r--src/com/android/launcher3/util/IconNormalizer.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/com/android/launcher3/util/IconNormalizer.java b/src/com/android/launcher3/util/IconNormalizer.java
index 4087d7bcf..040a1b51a 100644
--- a/src/com/android/launcher3/util/IconNormalizer.java
+++ b/src/com/android/launcher3/util/IconNormalizer.java
@@ -19,6 +19,7 @@ package com.android.launcher3.util;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
+import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import com.android.launcher3.LauncherAppState;
@@ -74,8 +75,10 @@ public class IconNormalizer {
*
* This closeness is used to determine the ratio of hull area to the full icon size.
* Refer {@link #MAX_CIRCLE_AREA_FACTOR} and {@link #MAX_SQUARE_AREA_FACTOR}
+ *
+ * @param outBounds optional rect to receive the fraction distance from each edge.
*/
- public synchronized float getScale(Drawable d) {
+ public synchronized float getScale(Drawable d, RectF outBounds) {
int width = d.getIntrinsicWidth();
int height = d.getIntrinsicHeight();
if (width <= 0 || height <= 0) {
@@ -168,6 +171,14 @@ public class IconNormalizer {
scaleRequired = MAX_SQUARE_AREA_FACTOR + LINEAR_SCALE_SLOPE * (1 - hullByRect);
}
+ if (outBounds != null) {
+ outBounds.left = ((float) leftX) / width;
+ outBounds.right = 1 - ((float) rightX) / width;
+
+ outBounds.top = ((float) topY) / height;
+ outBounds.bottom = 1 - ((float) bottomY) / height;
+ }
+
float areaScale = area / (width * height);
// Use sqrt of the final ratio as the images is scaled across both width and height.
float scale = areaScale > scaleRequired ? (float) Math.sqrt(scaleRequired / areaScale) : 1;