Loading core/res/res/values-television/config.xml +4 −0 Original line number Diff line number Diff line Loading @@ -73,4 +73,8 @@ <!-- Android TV does not have a Recents UI by default. --> <bool name="config_hasRecents">false</bool> <!-- Rectangle with rounded corners shape mask to be used for {@link AdaptiveIconDrawable} banners. --> <string name="config_banner_mask" translatable="false">"M0 10C0 4.47716 2.5184 0 5.625 0H94.375C97.4816 0 100 4.47715 100 10V90C100 95.5229 97.4816 100 94.375 100H5.625C2.5184 100 0 95.5229 0 90V10Z"</string> </resources> core/res/res/values/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -4837,6 +4837,9 @@ <!-- Specifies the path that is used by AdaptiveIconDrawable class to crop launcher icons. --> <string name="config_icon_mask" translatable="false">"M50,0L92,0C96.42,0 100,4.58 100 8L100,92C100, 96.42 96.42 100 92 100L8 100C4.58, 100 0 96.42 0 92L0 8 C 0 4.42 4.42 0 8 0L50 0Z"</string> <!-- Specifies the path that is used by AdaptiveIconDrawable class to crop launcher banners. --> <string name="config_banner_mask" translatable="false">@string/config_icon_mask</string> <!-- The component name, flattened to a string, for the default accessibility service to be enabled by the accessibility shortcut. This service must be trusted, as it can be activated Loading core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -3796,6 +3796,7 @@ <java-symbol type="raw" name="fallback_categories" /> <java-symbol type="string" name="config_icon_mask" /> <java-symbol type="string" name="config_banner_mask" /> <java-symbol type="string" name="config_batterymeterPerimeterPath" /> <java-symbol type="string" name="config_batterymeterErrorPerimeterPath" /> <java-symbol type="string" name="config_batterymeterFillMask" /> Loading graphics/java/android/graphics/drawable/AdaptiveIconDrawable.java +19 −2 Original line number Diff line number Diff line Loading @@ -105,11 +105,20 @@ public class AdaptiveIconDrawable extends Drawable implements Drawable.Callback private static final float EXTRA_INSET_PERCENTAGE = 1 / 4f; private static final float DEFAULT_VIEW_PORT_SCALE = 1f / (1 + 2 * EXTRA_INSET_PERCENTAGE); // Aspect ratio over which the icon should be considered a banner. Halfway between square icon // and 16:9 banner to account for slight variations in aspect ratios. private static final float BANNER_THRESHOLD_ASPECT_RATIO = 1.38f; /** * Clip path defined in R.string.config_icon_mask. */ private static Path sMask; /** * Clip path defined in R.string.config_banner_mask; */ private static Path sMaskBanner; /** * Scaled mask based on the view bounds. */ Loading Loading @@ -165,6 +174,7 @@ public class AdaptiveIconDrawable extends Drawable implements Drawable.Callback // TODO: either make sMask update only when config_icon_mask changes OR // get rid of it all-together in layoutlib sMask = PathParser.createPathFromPathData(r.getString(R.string.config_icon_mask)); sMaskBanner = PathParser.createPathFromPathData(r.getString(R.string.config_banner_mask)); mMask = new Path(sMask); mMaskScaleOnly = new Path(mMask); mMaskMatrix = new Matrix(); Loading Loading @@ -362,12 +372,19 @@ public class AdaptiveIconDrawable extends Drawable implements Drawable.Callback } private void updateMaskBoundsInternal(Rect b) { Path mask; if (b.width() / (float) b.height() > BANNER_THRESHOLD_ASPECT_RATIO) { mask = sMaskBanner; } else { mask = sMask; } // reset everything that depends on the view bounds mMaskMatrix.setScale(b.width() / MASK_SIZE, b.height() / MASK_SIZE); sMask.transform(mMaskMatrix, mMaskScaleOnly); mask.transform(mMaskMatrix, mMaskScaleOnly); mMaskMatrix.postTranslate(b.left, b.top); sMask.transform(mMaskMatrix, mMask); mask.transform(mMaskMatrix, mMask); if (mLayersBitmap == null || mLayersBitmap.getWidth() != b.width() || mLayersBitmap.getHeight() != b.height()) { Loading Loading
core/res/res/values-television/config.xml +4 −0 Original line number Diff line number Diff line Loading @@ -73,4 +73,8 @@ <!-- Android TV does not have a Recents UI by default. --> <bool name="config_hasRecents">false</bool> <!-- Rectangle with rounded corners shape mask to be used for {@link AdaptiveIconDrawable} banners. --> <string name="config_banner_mask" translatable="false">"M0 10C0 4.47716 2.5184 0 5.625 0H94.375C97.4816 0 100 4.47715 100 10V90C100 95.5229 97.4816 100 94.375 100H5.625C2.5184 100 0 95.5229 0 90V10Z"</string> </resources>
core/res/res/values/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -4837,6 +4837,9 @@ <!-- Specifies the path that is used by AdaptiveIconDrawable class to crop launcher icons. --> <string name="config_icon_mask" translatable="false">"M50,0L92,0C96.42,0 100,4.58 100 8L100,92C100, 96.42 96.42 100 92 100L8 100C4.58, 100 0 96.42 0 92L0 8 C 0 4.42 4.42 0 8 0L50 0Z"</string> <!-- Specifies the path that is used by AdaptiveIconDrawable class to crop launcher banners. --> <string name="config_banner_mask" translatable="false">@string/config_icon_mask</string> <!-- The component name, flattened to a string, for the default accessibility service to be enabled by the accessibility shortcut. This service must be trusted, as it can be activated Loading
core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -3796,6 +3796,7 @@ <java-symbol type="raw" name="fallback_categories" /> <java-symbol type="string" name="config_icon_mask" /> <java-symbol type="string" name="config_banner_mask" /> <java-symbol type="string" name="config_batterymeterPerimeterPath" /> <java-symbol type="string" name="config_batterymeterErrorPerimeterPath" /> <java-symbol type="string" name="config_batterymeterFillMask" /> Loading
graphics/java/android/graphics/drawable/AdaptiveIconDrawable.java +19 −2 Original line number Diff line number Diff line Loading @@ -105,11 +105,20 @@ public class AdaptiveIconDrawable extends Drawable implements Drawable.Callback private static final float EXTRA_INSET_PERCENTAGE = 1 / 4f; private static final float DEFAULT_VIEW_PORT_SCALE = 1f / (1 + 2 * EXTRA_INSET_PERCENTAGE); // Aspect ratio over which the icon should be considered a banner. Halfway between square icon // and 16:9 banner to account for slight variations in aspect ratios. private static final float BANNER_THRESHOLD_ASPECT_RATIO = 1.38f; /** * Clip path defined in R.string.config_icon_mask. */ private static Path sMask; /** * Clip path defined in R.string.config_banner_mask; */ private static Path sMaskBanner; /** * Scaled mask based on the view bounds. */ Loading Loading @@ -165,6 +174,7 @@ public class AdaptiveIconDrawable extends Drawable implements Drawable.Callback // TODO: either make sMask update only when config_icon_mask changes OR // get rid of it all-together in layoutlib sMask = PathParser.createPathFromPathData(r.getString(R.string.config_icon_mask)); sMaskBanner = PathParser.createPathFromPathData(r.getString(R.string.config_banner_mask)); mMask = new Path(sMask); mMaskScaleOnly = new Path(mMask); mMaskMatrix = new Matrix(); Loading Loading @@ -362,12 +372,19 @@ public class AdaptiveIconDrawable extends Drawable implements Drawable.Callback } private void updateMaskBoundsInternal(Rect b) { Path mask; if (b.width() / (float) b.height() > BANNER_THRESHOLD_ASPECT_RATIO) { mask = sMaskBanner; } else { mask = sMask; } // reset everything that depends on the view bounds mMaskMatrix.setScale(b.width() / MASK_SIZE, b.height() / MASK_SIZE); sMask.transform(mMaskMatrix, mMaskScaleOnly); mask.transform(mMaskMatrix, mMaskScaleOnly); mMaskMatrix.postTranslate(b.left, b.top); sMask.transform(mMaskMatrix, mMask); mask.transform(mMaskMatrix, mMask); if (mLayersBitmap == null || mLayersBitmap.getWidth() != b.width() || mLayersBitmap.getHeight() != b.height()) { Loading