Loading api/current.txt +1 −1 Original line number Diff line number Diff line Loading @@ -13828,7 +13828,7 @@ package android.graphics.drawable { public class AdaptiveIconDrawable extends android.graphics.drawable.Drawable implements android.graphics.drawable.Drawable.Callback { method public void draw(android.graphics.Canvas); method public android.graphics.drawable.Drawable getBackground(); method public static float getExtraInsetPercentage(); method public static float getExtraInsetFraction(); method public android.graphics.drawable.Drawable getForeground(); method public android.graphics.Path getIconMask(); method public int getOpacity(); api/system-current.txt +1 −1 Original line number Diff line number Diff line Loading @@ -14595,7 +14595,7 @@ package android.graphics.drawable { public class AdaptiveIconDrawable extends android.graphics.drawable.Drawable implements android.graphics.drawable.Drawable.Callback { method public void draw(android.graphics.Canvas); method public android.graphics.drawable.Drawable getBackground(); method public static float getExtraInsetPercentage(); method public static float getExtraInsetFraction(); method public android.graphics.drawable.Drawable getForeground(); method public android.graphics.Path getIconMask(); method public int getOpacity(); api/test-current.txt +1 −1 Original line number Diff line number Diff line Loading @@ -13879,7 +13879,7 @@ package android.graphics.drawable { public class AdaptiveIconDrawable extends android.graphics.drawable.Drawable implements android.graphics.drawable.Drawable.Callback { method public void draw(android.graphics.Canvas); method public android.graphics.drawable.Drawable getBackground(); method public static float getExtraInsetPercentage(); method public static float getExtraInsetFraction(); method public android.graphics.drawable.Drawable getForeground(); method public android.graphics.Path getIconMask(); method public int getOpacity(); core/java/android/util/LauncherIcons.java +1 −5 Original line number Diff line number Diff line Loading @@ -20,11 +20,8 @@ import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.PaintFlagsDrawFilter; import android.graphics.Path; import android.graphics.RectF; import android.graphics.drawable.AdaptiveIconDrawable; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; Loading @@ -49,7 +46,7 @@ public final class LauncherIcons { public LauncherIcons(Context context) { mRes = context.getResources(); DisplayMetrics metrics = mRes.getDisplayMetrics(); mShadowInset = (int) metrics.density / DisplayMetrics.DENSITY_DEFAULT; mShadowInset = (int)(2 * metrics.density); mCanvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.DITHER_FLAG, Paint.FILTER_BITMAP_FLAG)); mIconSize = (int) mRes.getDimensionPixelSize(android.R.dimen.app_icon_size); Loading Loading @@ -91,7 +88,6 @@ public final class LauncherIcons { return mShadowBitmap; } int shadowSize = mIconSize - mShadowInset; mShadowBitmap = Bitmap.createBitmap(mIconSize, mIconSize, Bitmap.Config.ALPHA_8); mCanvas.setBitmap(mShadowBitmap); Loading core/tests/coretests/src/android/graphics/drawable/AdaptiveIconDrawableTest.java +71 −2 Original line number Diff line number Diff line Loading @@ -2,18 +2,22 @@ package android.graphics.drawable; import static org.junit.Assert.assertTrue; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Outline; import android.graphics.Paint; import android.graphics.Path; import android.graphics.Path.Direction; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.Region; import android.test.AndroidTestCase; import android.util.Log; import android.util.PathParser; import java.io.File; import java.io.FileOutputStream; import java.util.Arrays; Loading @@ -35,7 +39,7 @@ public class AdaptiveIconDrawableTest extends AndroidTestCase { * Nothing is drawn. */ @Test public void testDrawWithoutSetBounds() throws Exception { public void testDraw_withoutBounds() throws Exception { mBackgroundDrawable = new ColorDrawable(Color.BLUE); mForegroundDrawable = new ColorDrawable(Color.RED); mIconDrawable = new AdaptiveIconDrawable(mBackgroundDrawable, mForegroundDrawable); Loading @@ -59,7 +63,7 @@ public class AdaptiveIconDrawableTest extends AndroidTestCase { * When setBound is called, translate accordingly. */ @Test public void testDrawSetBounds() throws Exception { public void testDraw_withBounds() throws Exception { int dpi = 4 ; int top = 18 * dpi; int left = 18 * dpi; Loading Loading @@ -102,6 +106,71 @@ public class AdaptiveIconDrawableTest extends AndroidTestCase { } } /** * When setBound isn't called before getIconMask method is called. * default device config mask is returned. */ @Test public void testGetIconMask_withoutBounds() throws Exception { mIconDrawable = new AdaptiveIconDrawable(mBackgroundDrawable, mForegroundDrawable); Path pathFromDrawable = mIconDrawable.getIconMask(); Path pathFromDeviceConfig = PathParser.createPathFromPathData( Resources.getSystem().getString(com.android.internal.R.string.config_icon_mask)); RectF boundFromDrawable = new RectF(); pathFromDrawable.computeBounds(boundFromDrawable, true); RectF boundFromDeviceConfig = new RectF(); pathFromDeviceConfig.computeBounds(boundFromDeviceConfig, true); double delta = 0.01; assertEquals("left", boundFromDrawable.left, boundFromDeviceConfig.left, delta); assertEquals("top", boundFromDrawable.top, boundFromDeviceConfig.top, delta); assertEquals("right", boundFromDrawable.right, boundFromDeviceConfig.right, delta); assertEquals("bottom", boundFromDrawable.bottom, boundFromDeviceConfig.bottom, delta); assertTrue("path from device config is convex.", pathFromDeviceConfig.isConvex()); assertTrue("path from drawable is convex.", pathFromDrawable.isConvex()); } @Test public void testGetIconMaskAfterSetBounds() throws Exception { int dpi = 4; int top = 18 * dpi; int left = 18 * dpi; int right = 90 * dpi; int bottom = 90 * dpi; mIconDrawable = new AdaptiveIconDrawable(mBackgroundDrawable, mForegroundDrawable); mIconDrawable.setBounds(left, top, right, bottom); RectF maskBounds = new RectF(); mIconDrawable.getIconMask().computeBounds(maskBounds, true); double delta = 0.01; assertEquals("left", left, maskBounds.left, delta); assertEquals("top", top, maskBounds.top, delta); assertEquals("right", right, maskBounds.right, delta); assertEquals("bottom", bottom, maskBounds.bottom, delta); assertTrue(mIconDrawable.getIconMask().isConvex()); } @Test public void testGetOutline_withBounds() throws Exception { int dpi = 4; int top = 18 * dpi; int left = 18 * dpi; int right = 90 * dpi; int bottom = 90 * dpi; mIconDrawable = new AdaptiveIconDrawable(mBackgroundDrawable, mForegroundDrawable); mIconDrawable.setBounds(left, top, right, bottom); Outline outline = new Outline(); mIconDrawable.getOutline(outline); assertTrue("outline path should be convex", outline.mPath.isConvex()); } // // Utils // Loading Loading
api/current.txt +1 −1 Original line number Diff line number Diff line Loading @@ -13828,7 +13828,7 @@ package android.graphics.drawable { public class AdaptiveIconDrawable extends android.graphics.drawable.Drawable implements android.graphics.drawable.Drawable.Callback { method public void draw(android.graphics.Canvas); method public android.graphics.drawable.Drawable getBackground(); method public static float getExtraInsetPercentage(); method public static float getExtraInsetFraction(); method public android.graphics.drawable.Drawable getForeground(); method public android.graphics.Path getIconMask(); method public int getOpacity();
api/system-current.txt +1 −1 Original line number Diff line number Diff line Loading @@ -14595,7 +14595,7 @@ package android.graphics.drawable { public class AdaptiveIconDrawable extends android.graphics.drawable.Drawable implements android.graphics.drawable.Drawable.Callback { method public void draw(android.graphics.Canvas); method public android.graphics.drawable.Drawable getBackground(); method public static float getExtraInsetPercentage(); method public static float getExtraInsetFraction(); method public android.graphics.drawable.Drawable getForeground(); method public android.graphics.Path getIconMask(); method public int getOpacity();
api/test-current.txt +1 −1 Original line number Diff line number Diff line Loading @@ -13879,7 +13879,7 @@ package android.graphics.drawable { public class AdaptiveIconDrawable extends android.graphics.drawable.Drawable implements android.graphics.drawable.Drawable.Callback { method public void draw(android.graphics.Canvas); method public android.graphics.drawable.Drawable getBackground(); method public static float getExtraInsetPercentage(); method public static float getExtraInsetFraction(); method public android.graphics.drawable.Drawable getForeground(); method public android.graphics.Path getIconMask(); method public int getOpacity();
core/java/android/util/LauncherIcons.java +1 −5 Original line number Diff line number Diff line Loading @@ -20,11 +20,8 @@ import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.PaintFlagsDrawFilter; import android.graphics.Path; import android.graphics.RectF; import android.graphics.drawable.AdaptiveIconDrawable; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; Loading @@ -49,7 +46,7 @@ public final class LauncherIcons { public LauncherIcons(Context context) { mRes = context.getResources(); DisplayMetrics metrics = mRes.getDisplayMetrics(); mShadowInset = (int) metrics.density / DisplayMetrics.DENSITY_DEFAULT; mShadowInset = (int)(2 * metrics.density); mCanvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.DITHER_FLAG, Paint.FILTER_BITMAP_FLAG)); mIconSize = (int) mRes.getDimensionPixelSize(android.R.dimen.app_icon_size); Loading Loading @@ -91,7 +88,6 @@ public final class LauncherIcons { return mShadowBitmap; } int shadowSize = mIconSize - mShadowInset; mShadowBitmap = Bitmap.createBitmap(mIconSize, mIconSize, Bitmap.Config.ALPHA_8); mCanvas.setBitmap(mShadowBitmap); Loading
core/tests/coretests/src/android/graphics/drawable/AdaptiveIconDrawableTest.java +71 −2 Original line number Diff line number Diff line Loading @@ -2,18 +2,22 @@ package android.graphics.drawable; import static org.junit.Assert.assertTrue; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Outline; import android.graphics.Paint; import android.graphics.Path; import android.graphics.Path.Direction; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.Region; import android.test.AndroidTestCase; import android.util.Log; import android.util.PathParser; import java.io.File; import java.io.FileOutputStream; import java.util.Arrays; Loading @@ -35,7 +39,7 @@ public class AdaptiveIconDrawableTest extends AndroidTestCase { * Nothing is drawn. */ @Test public void testDrawWithoutSetBounds() throws Exception { public void testDraw_withoutBounds() throws Exception { mBackgroundDrawable = new ColorDrawable(Color.BLUE); mForegroundDrawable = new ColorDrawable(Color.RED); mIconDrawable = new AdaptiveIconDrawable(mBackgroundDrawable, mForegroundDrawable); Loading @@ -59,7 +63,7 @@ public class AdaptiveIconDrawableTest extends AndroidTestCase { * When setBound is called, translate accordingly. */ @Test public void testDrawSetBounds() throws Exception { public void testDraw_withBounds() throws Exception { int dpi = 4 ; int top = 18 * dpi; int left = 18 * dpi; Loading Loading @@ -102,6 +106,71 @@ public class AdaptiveIconDrawableTest extends AndroidTestCase { } } /** * When setBound isn't called before getIconMask method is called. * default device config mask is returned. */ @Test public void testGetIconMask_withoutBounds() throws Exception { mIconDrawable = new AdaptiveIconDrawable(mBackgroundDrawable, mForegroundDrawable); Path pathFromDrawable = mIconDrawable.getIconMask(); Path pathFromDeviceConfig = PathParser.createPathFromPathData( Resources.getSystem().getString(com.android.internal.R.string.config_icon_mask)); RectF boundFromDrawable = new RectF(); pathFromDrawable.computeBounds(boundFromDrawable, true); RectF boundFromDeviceConfig = new RectF(); pathFromDeviceConfig.computeBounds(boundFromDeviceConfig, true); double delta = 0.01; assertEquals("left", boundFromDrawable.left, boundFromDeviceConfig.left, delta); assertEquals("top", boundFromDrawable.top, boundFromDeviceConfig.top, delta); assertEquals("right", boundFromDrawable.right, boundFromDeviceConfig.right, delta); assertEquals("bottom", boundFromDrawable.bottom, boundFromDeviceConfig.bottom, delta); assertTrue("path from device config is convex.", pathFromDeviceConfig.isConvex()); assertTrue("path from drawable is convex.", pathFromDrawable.isConvex()); } @Test public void testGetIconMaskAfterSetBounds() throws Exception { int dpi = 4; int top = 18 * dpi; int left = 18 * dpi; int right = 90 * dpi; int bottom = 90 * dpi; mIconDrawable = new AdaptiveIconDrawable(mBackgroundDrawable, mForegroundDrawable); mIconDrawable.setBounds(left, top, right, bottom); RectF maskBounds = new RectF(); mIconDrawable.getIconMask().computeBounds(maskBounds, true); double delta = 0.01; assertEquals("left", left, maskBounds.left, delta); assertEquals("top", top, maskBounds.top, delta); assertEquals("right", right, maskBounds.right, delta); assertEquals("bottom", bottom, maskBounds.bottom, delta); assertTrue(mIconDrawable.getIconMask().isConvex()); } @Test public void testGetOutline_withBounds() throws Exception { int dpi = 4; int top = 18 * dpi; int left = 18 * dpi; int right = 90 * dpi; int bottom = 90 * dpi; mIconDrawable = new AdaptiveIconDrawable(mBackgroundDrawable, mForegroundDrawable); mIconDrawable.setBounds(left, top, right, bottom); Outline outline = new Outline(); mIconDrawable.getOutline(outline); assertTrue("outline path should be convex", outline.mPath.isConvex()); } // // Utils // Loading