Commit 10d564ab authored by Calder Kitagawa's avatar Calder Kitagawa Committed by Commit Bot

[WebAPK] Proposed splash_icon resource rearrangement

Rearrange the WebAPK resources such that a higher density
app_icon_<density>.png can be used as the splash_icon.xml and add
app_icon.xml to not break anything as a result of moving and renaming
the app_icon.png files.

Also adds a splashId to the AndroidManifest.xml for use in Chrome such
that the WebAPK can update the splash screen image rather than using
the primaryIcon for the splash screen.

Modifies Chrome code to support decoding XML aliases to images.

TBR=dominickn@chromium.org

Bug: 819755
Change-Id: Id42c2e898a5996dfba46ad6608cc1d3103300521
Reviewed-on: https://chromium-review.googlesource.com/1128256
Commit-Queue: Calder Kitagawa <ckitagawa@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Reviewed-by: default avatarPeter Kotwicz <pkotwicz@chromium.org>
Reviewed-by: default avatarXi Han <hanxi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576471}
parent 9f11bd98
......@@ -9,10 +9,11 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.text.TextUtils;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.ContextUtils;
import org.chromium.base.Log;
import org.chromium.blink_public.platform.WebDisplayMode;
......@@ -139,10 +140,10 @@ public class WebApkInfo extends WebappInfo {
Map<String, String> iconUrlToMurmur2HashMap = getIconUrlAndIconMurmur2HashMap(bundle);
int primaryIconId = IntentUtils.safeGetInt(bundle, WebApkMetaDataKeys.ICON_ID, 0);
Bitmap primaryIcon = decodeImageResource(res, primaryIconId);
Bitmap primaryIcon = decodeBitmapFromDrawable(res, primaryIconId);
int badgeIconId = IntentUtils.safeGetInt(bundle, WebApkMetaDataKeys.BADGE_ICON_ID, 0);
Bitmap badgeIcon = decodeImageResource(res, badgeIconId);
Bitmap badgeIcon = decodeBitmapFromDrawable(res, badgeIconId);
return create(WebApkConstants.WEBAPK_ID_PREFIX + webApkPackageName, url, scope,
new Icon(primaryIcon), new Icon(badgeIcon), name, shortName, displayMode,
......@@ -276,10 +277,19 @@ public class WebApkInfo extends WebappInfo {
}
/**
* Decodes bitmap from WebAPK's resources.
* Decodes bitmap drawable from WebAPK's resources. This should also be used for XML aliases.
*/
private static Bitmap decodeImageResource(Resources webApkResources, int resourceId) {
return BitmapFactory.decodeResource(webApkResources, resourceId);
private static Bitmap decodeBitmapFromDrawable(Resources webApkResources, int resourceId) {
if (resourceId == 0) {
return null;
}
try {
BitmapDrawable bitmapDrawable =
(BitmapDrawable) ApiCompatibilityUtils.getDrawable(webApkResources, resourceId);
return bitmapDrawable != null ? bitmapDrawable.getBitmap() : null;
} catch (Resources.NotFoundException e) {
return null;
}
}
/**
......
......@@ -65,7 +65,8 @@
<meta-data android:name="org.chromium.webapk.shell_apk.orientation" android:value="{{{orientation}}}" />
<meta-data android:name="org.chromium.webapk.shell_apk.themeColor" android:value="{{{theme_color}}}" />
<meta-data android:name="org.chromium.webapk.shell_apk.backgroundColor" android:value="{{{background_color}}}" />
<meta-data android:name="org.chromium.webapk.shell_apk.iconId" android:resource="{{{splash_screen_icon}}}" />
<meta-data android:name="org.chromium.webapk.shell_apk.iconId" android:resource="@mipmap/app_icon" />
<meta-data android:name="org.chromium.webapk.shell_apk.splashId" android:resource="@drawable/splash_icon" />
{{! Hashes of icons should be taken of the icons as they are available on the web. The icon
bytes should not be transformed (e.g. decoded / encoded) prior to taking the hash.
......
......@@ -12,7 +12,6 @@
"orientation": "portrait",
"theme_color": "2147483648L",
"background_color": "2147483648L",
"splash_screen_icon": "@mipmap/app_icon",
"icon_urls_and_icon_murmur2_hashes": "http://www.pwa.rocks/icon1.png 0 http://www.pwa.rocks/icon2.png 0",
"web_manifest_url": "https://pwa.rocks/pwa.webmanifest",
"version_code": "1",
......
......@@ -12,7 +12,6 @@
"orientation": "portrait",
"theme_color": "2147483648L",
"background_color": "2147483648L",
"splash_screen_icon": "@mipmap/app_icon",
"icon_urls_and_icon_murmur2_hashes": "http://www.pwa.rocks/icon1.png 0 http://www.pwa.rocks/icon2.png 0",
"web_manifest_url": "https://pwa.rocks/pwa.webmanifest",
"version_code": "1",
......
......@@ -12,7 +12,6 @@
"orientation": "portrait",
"theme_color": "2147483648L",
"background_color": "2147483648L",
"splash_screen_icon": "@mipmap/app_icon",
"icon_urls_and_icon_murmur2_hashes": "http://www.pwa.rocks/icon1.png 0 http://www.pwa.rocks/icon2.png 0",
"web_manifest_url": "https://pwa.rocks/pwa.webmanifest",
"version_code": "1",
......
......@@ -12,7 +12,6 @@
"orientation": "portrait",
"theme_color": "2147483648L",
"background_color": "2147483648L",
"splash_screen_icon": "@mipmap/app_icon",
"icon_urls_and_icon_murmur2_hashes": "https://maps.gstatic.com/mapfiles/maps_lite/pwa/icons/maps_pwa_icon_v0920_48x48.png 0 https://maps.gstatic.com/mapfiles/maps_lite/pwa/icons/maps_pwa_icon_v0920_72x72 0",
"web_manifest_url": "https://maps.gstatic.com/tactile/worker/ml.json",
"version_code": "1",
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@mipmap/app_icon_xxhdpi"/>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@mipmap/app_icon_xhdpi"/>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@mipmap/app_icon_xxxhdpi"/>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@mipmap/app_icon_xxxhdpi"/>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@mipmap/app_icon_xxxhdpi"/>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@mipmap/app_icon_hdpi"/>
......@@ -4,4 +4,4 @@
found in the LICENSE file. -->
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@mipmap/app_icon"/>
\ No newline at end of file
android:src="@mipmap/app_icon_hdpi"/>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@mipmap/app_icon_mdpi"/>
......@@ -4,4 +4,4 @@
found in the LICENSE file. -->
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@mipmap/app_icon"/>
\ No newline at end of file
android:src="@mipmap/app_icon_mdpi"/>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@mipmap/app_icon_xhdpi"/>
......@@ -4,4 +4,4 @@
found in the LICENSE file. -->
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@mipmap/app_icon"/>
\ No newline at end of file
android:src="@mipmap/app_icon_xhdpi"/>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@mipmap/app_icon_xxhdpi"/>
......@@ -4,4 +4,4 @@
found in the LICENSE file. -->
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@mipmap/app_icon"/>
\ No newline at end of file
android:src="@mipmap/app_icon_xxhdpi"/>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@mipmap/app_icon_xxxhdpi"/>
......@@ -4,4 +4,4 @@
found in the LICENSE file. -->
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@mipmap/app_icon"/>
\ No newline at end of file
android:src="@mipmap/app_icon_xxxhdpi"/>
......@@ -6,7 +6,7 @@
# (including AndroidManifest.xml) is updated. This version should be incremented
# prior to uploading a new ShellAPK to the WebAPK Minting Server.
# Does not affect Chrome.apk
template_shell_apk_version = 46
template_shell_apk_version = 47
# The ShellAPK version expected by Chrome. Chrome will try to update the WebAPK
# if the WebAPK's ShellAPK version is less than |expected_shell_apk_version|.
......
......@@ -13,7 +13,6 @@
"orientation": "portrait",
"theme_color": "2147483648L",
"background_color": "2147483648L",
"splash_screen_icon": "@mipmap/app_icon",
"icon_urls_and_icon_murmur2_hashes": "http://www.pwa.rocks/icon1.png 0 http://www.pwa.rocks/icon2.png 0",
"web_manifest_url": "https://pwa.rocks/pwa.webmanifest",
"version_code": "1",
......
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