Commit 71e69b41 authored by Henry Jian's avatar Henry Jian Committed by Commit Bot

Change ideal WebAPK's ideal adaptive icon size

Previously, the ideal size for WebAPK's adaptive icon is set to be
108dp. It neglects the fact that a total of 30% padding is needed
to bridge the gap in safe zone percentage between the web spec
(https://www.w3.org/TR/appmanifest/#icon-masks) and the Android spec
(https://developer.android.com/guide/practices/ui_guidelines/icon_design_adaptive).

This CL changes it to the right value, 83dp.

Bug: 977173
Change-Id: I99411d10751e410a87ae3946bfe5175fe295057d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1869372
Commit-Queue: Henry Jian <hzjian@google.com>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Reviewed-by: default avatarPeter Kotwicz <pkotwicz@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707564}
parent dc30575c
......@@ -254,7 +254,16 @@
There are two possible layouts for splash screens, which is chosen based on whether an
icon was auto-generated by Chrome and whether the icon is bigger than a threshold. -->
<dimen name="webapp_home_screen_icon_size">48dp</dimen>
<dimen name="webapk_adaptive_icon_size">108dp</dimen>
<!-- The Android Spec
(https://developer.android.com/guide/practices/ui_guidelines/icon_design_adaptive)
states that the adaptive icon should be 108dp. It also states that the safe zone should
be a circle with diameter being ~61% (66dp/108dp) of width.
The Web Spec (https://www.w3.org/TR/appmanifest/#icon-masks), however, states that the
safe zone should be a circle with diameter being 80% of width.
To bridge the difference in safe zone size percentage, we have to add a 15% padding on
each size of orignal image. As a result, the ideal adaptive icon size for WebAPK is
83dp -->
<dimen name="webapk_adaptive_icon_size">83dp</dimen>
<dimen name="webapk_badge_icon_size">24dp</dimen>
......
......@@ -44,20 +44,18 @@ const int kMinimumPrimaryIconSizeInPx = 144;
// This constant is the smallest possible adaptive launcher icon size for any
// device density.
// The adaptive icon size guide states that an adaptive launcher icon should be
// 108dp.
// (https://developer.android.com/guide/practices/ui_guidelines/icon_design_adaptive)
// For a manifest to be valid, we do NOT need an maskable icon to be
// 108dp for the device's screen density. Instead, we only need the maskable
// icon be larger than (or equal to) 108dp in the smallest screen density (that
// is the mdpi screen density). For mdpi devices, 1dp is 1px. Therefore, we have
// 108px here.
// The ideal icon size is 83dp (see documentation for
// R.dimen.webapk_adaptive_icon_size for discussion of maskable icon size). For
// a manifest to be valid, we do NOT need an maskable icon to be 83dp for the
// device's screen density. Instead, we only need the maskable icon be larger
// than (or equal to) 83dp in the smallest screen density (that is the mdpi
// screen density). For mdpi devices, 1dp is 1px. Therefore, we have 83px here.
// Requiring the minimum icon size (in pixel) independent of the device's screen
// density is because we use mipmap-anydpi-v26 to specify adaptive launcher
// icon, and it will make the icon adaptive as long as there is one usable
// maskable icon (if that icon is of wrong size, it'll be automatically
// resized).
const int kMinimumPrimaryAdaptiveLauncherIconSizeInPx = 108;
const int kMinimumPrimaryAdaptiveLauncherIconSizeInPx = 83;
#if !defined(OS_ANDROID)
const int kMinimumBadgeIconSizeInPx = 72;
......
......@@ -219,7 +219,7 @@ TEST_F(InstallableManagerUnitTest, ManifestRequiresMinimalSize) {
blink::Manifest::ImageResource maskable_icon;
maskable_icon.type = base::ASCIIToUTF16("image/png");
maskable_icon.sizes.push_back(gfx::Size(107, 107));
maskable_icon.sizes.push_back(gfx::Size(82, 82));
maskable_icon.purpose.push_back(IconPurpose::MASKABLE);
manifest.icons.push_back(maskable_icon);
EXPECT_FALSE(IsManifestValid(manifest, true, true));
......@@ -227,14 +227,14 @@ TEST_F(InstallableManagerUnitTest, ManifestRequiresMinimalSize) {
// When preferring maskable icons, the maskable icon is smaller than required.
manifest.icons[0].sizes[0] = gfx::Size(144, 144);
manifest.icons[1].sizes[0] = gfx::Size(107, 107);
manifest.icons[1].sizes[0] = gfx::Size(82, 82);
EXPECT_TRUE(IsManifestValid(manifest, true, true));
EXPECT_EQ(NO_ERROR_DETECTED, GetErrorCode());
// When preferring maskable icons, the maskable icon satisfies the size
// requirement though the non maskable one doesn't
manifest.icons[0].sizes[0] = gfx::Size(1, 1);
manifest.icons[1].sizes[0] = gfx::Size(108, 108);
manifest.icons[1].sizes[0] = gfx::Size(83, 83);
EXPECT_TRUE(IsManifestValid(manifest, true, true));
EXPECT_EQ(NO_ERROR_DETECTED, GetErrorCode());
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment