diff options
author | Winson Chung <winsonc@google.com> | 2013-08-12 16:19:28 -0700 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2013-08-20 10:56:05 -0700 |
commit | 5f8afe6280eae34620067696173e71943e1a30a3 (patch) | |
tree | eb0ebdf56f2ad0950894424a49de9d1e8dc832e0 /src/com/android/launcher3/Utilities.java | |
parent | 8a6870101c3d99257fc050d11bb69f50f5240622 (diff) | |
download | android_packages_apps_Trebuchet-5f8afe6280eae34620067696173e71943e1a30a3.tar.gz android_packages_apps_Trebuchet-5f8afe6280eae34620067696173e71943e1a30a3.tar.bz2 android_packages_apps_Trebuchet-5f8afe6280eae34620067696173e71943e1a30a3.zip |
Initial Changes for Dynamic Grid
Change-Id: I9e6f1e5167791cf8dc140778dfa447f86424e9bf
Diffstat (limited to 'src/com/android/launcher3/Utilities.java')
-rw-r--r-- | src/com/android/launcher3/Utilities.java | 87 |
1 files changed, 9 insertions, 78 deletions
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index cc22bb5db..0529cfb74 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -120,19 +120,12 @@ final class Utilities { int sourceWidth = icon.getIntrinsicWidth(); int sourceHeight = icon.getIntrinsicHeight(); if (sourceWidth > 0 && sourceHeight > 0) { - // There are intrinsic sizes. - if (width < sourceWidth || height < sourceHeight) { - // It's too big, scale it down. - final float ratio = (float) sourceWidth / sourceHeight; - if (sourceWidth > sourceHeight) { - height = (int) (width / ratio); - } else if (sourceHeight > sourceWidth) { - width = (int) (height * ratio); - } - } else if (sourceWidth < width && sourceHeight < height) { - // Don't scale up the icon - width = sourceWidth; - height = sourceHeight; + // Scale the icon proportionally to the icon dimensions + final float ratio = (float) sourceWidth / sourceHeight; + if (sourceWidth > sourceHeight) { + height = (int) (width / ratio); + } else if (sourceHeight > sourceWidth) { + width = (int) (height * ratio); } } @@ -169,34 +162,8 @@ final class Utilities { } } - static void drawSelectedAllAppsBitmap(Canvas dest, int destWidth, int destHeight, - boolean pressed, Bitmap src) { - synchronized (sCanvas) { // we share the statics :-( - if (sIconWidth == -1) { - // We can't have gotten to here without src being initialized, which - // comes from this file already. So just assert. - //initStatics(context); - throw new RuntimeException("Assertion failed: Utilities not initialized"); - } - - dest.drawColor(0, PorterDuff.Mode.CLEAR); - - int[] xy = new int[2]; - Bitmap mask = src.extractAlpha(sBlurPaint, xy); - - float px = (destWidth - src.getWidth()) / 2; - float py = (destHeight - src.getHeight()) / 2; - dest.drawBitmap(mask, px + xy[0], py + xy[1], - pressed ? sGlowColorPressedPaint : sGlowColorFocusedPaint); - - mask.recycle(); - } - } - /** * Returns a Bitmap representing the thumbnail of the specified Bitmap. - * The size of the thumbnail is defined by the dimension - * android.R.dimen.launcher_application_icon_size. * * @param bitmap The bitmap to get a thumbnail of. * @param context The application's context. @@ -219,24 +186,6 @@ final class Utilities { } } - static Bitmap drawDisabledBitmap(Bitmap bitmap, Context context) { - synchronized (sCanvas) { // we share the statics :-( - if (sIconWidth == -1) { - initStatics(context); - } - final Bitmap disabled = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), - Bitmap.Config.ARGB_8888); - final Canvas canvas = sCanvas; - canvas.setBitmap(disabled); - - canvas.drawBitmap(bitmap, 0.0f, 0.0f, sDisabledPaint); - - canvas.setBitmap(null); - - return disabled; - } - } - /** * Given a coordinate relative to the descendant, find the coordinate in a parent view's * coordinates. @@ -345,26 +294,8 @@ final class Utilities { sDisabledPaint.setAlpha(0x88); } - /** Only works for positive numbers. */ - static int roundToPow2(int n) { - int orig = n; - n >>= 1; - int mask = 0x8000000; - while (mask != 0 && (n & mask) == 0) { - mask >>= 1; - } - while (mask != 0) { - n |= mask; - mask >>= 1; - } - n += 1; - if (n != orig) { - n <<= 1; - } - return n; - } - - static int generateRandomId() { - return new Random(System.currentTimeMillis()).nextInt(1 << 24); + public static void setIconSize(int widthPx) { + sIconWidth = sIconHeight = widthPx; + sIconTextureWidth = sIconTextureHeight = widthPx; } } |