Index: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappActivity.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappActivity.java |
index b4d4733d4984cb3f21ae063a447b34123ab02a84..8c05554b17ddb2efcff02e144113a064821db857 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappActivity.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappActivity.java |
@@ -233,14 +233,12 @@ public class WebappActivity extends FullScreenActivity { |
return mWebappInfo; |
} |
- protected int getBackgroundColor() { |
- return ColorUtils.getOpaqueColor(mWebappInfo.backgroundColor( |
+ private void initializeWebappData() { |
+ final int backgroundColor = ColorUtils.getOpaqueColor(mWebappInfo.backgroundColor( |
ApiCompatibilityUtils.getColor(getResources(), R.color.webapp_default_bg))); |
- } |
- private void initializeWebappData() { |
mSplashScreen = new FrameLayout(this); |
- mSplashScreen.setBackgroundColor(getBackgroundColor()); |
+ mSplashScreen.setBackgroundColor(backgroundColor); |
ViewGroup contentView = (ViewGroup) findViewById(android.R.id.content); |
contentView.addView(mSplashScreen); |
@@ -249,27 +247,39 @@ public class WebappActivity extends FullScreenActivity { |
mWebappUma.recordSplashscreenBackgroundColor(mWebappInfo.hasValidBackgroundColor() |
? WebappUma.SPLASHSCREEN_COLOR_STATUS_CUSTOM |
: WebappUma.SPLASHSCREEN_COLOR_STATUS_DEFAULT); |
+ mWebappUma.recordSplashscreenThemeColor(mWebappInfo.hasValidThemeColor() |
+ ? WebappUma.SPLASHSCREEN_COLOR_STATUS_CUSTOM |
+ : WebappUma.SPLASHSCREEN_COLOR_STATUS_DEFAULT); |
+ |
+ initializeSplashScreenWidgets(backgroundColor); |
+ } |
+ protected void initializeSplashScreenWidgets(final int backgroundColor) { |
WebappRegistry.getWebappDataStorage(this, mWebappInfo.id(), |
new WebappRegistry.FetchWebappDataStorageCallback() { |
@Override |
public void onWebappDataStorageRetrieved(WebappDataStorage storage) { |
- onDataStorageFetched(storage); |
+ if (storage == null) { |
+ onStorageIsNull(backgroundColor); |
+ return; |
+ } |
+ updateStorage(storage); |
+ |
+ // Retrieve the splash image if it exists. |
+ storage.getSplashScreenImage(new WebappDataStorage.FetchCallback<Bitmap>() { |
+ @Override |
+ public void onDataRetrieved(Bitmap splashImage) { |
+ initializeSplashScreenWidgets(backgroundColor, splashImage); |
+ } |
+ }); |
} |
} |
); |
} |
- protected void recordSplashScreenThemeColorUma() { |
- mWebappUma.recordSplashscreenThemeColor(mWebappInfo.hasValidThemeColor() |
- ? WebappUma.SPLASHSCREEN_COLOR_STATUS_CUSTOM |
- : WebappUma.SPLASHSCREEN_COLOR_STATUS_DEFAULT); |
- } |
- |
- protected void onDataStorageFetched(WebappDataStorage storage) { |
- recordSplashScreenThemeColorUma(); |
- if (storage == null) return; |
+ protected void onStorageIsNull(int backgroundColor) {} |
+ protected void updateStorage(WebappDataStorage storage) { |
// The information in the WebappDataStorage may have been purged by the |
// user clearing their history or not launching the web app recently. |
// Restore the data if necessary from the intent. |
@@ -283,21 +293,9 @@ public class WebappActivity extends FullScreenActivity { |
if (mWebappInfo.isLaunchedFromHomescreen()) { |
storage.updateLastUsedTime(); |
} |
- |
- retrieveSplashScreenImage(storage); |
- } |
- |
- protected void retrieveSplashScreenImage(WebappDataStorage storage) { |
- // Retrieve the splash image if it exists. |
- storage.getSplashScreenImage(new WebappDataStorage.FetchCallback<Bitmap>() { |
- @Override |
- public void onDataRetrieved(Bitmap splashImage) { |
- initializeSplashScreenWidgets(splashImage); |
- } |
- }); |
} |
- protected void initializeSplashScreenWidgets(Bitmap splashImage) { |
+ protected void initializeSplashScreenWidgets(int backgroundColor, Bitmap splashImage) { |
Bitmap displayIcon = splashImage == null ? mWebappInfo.icon() : splashImage; |
int minimiumSizeThreshold = getResources().getDimensionPixelSize( |
R.dimen.webapp_splash_image_size_minimum); |
@@ -346,7 +344,7 @@ public class WebappActivity extends FullScreenActivity { |
appNameView.setText(mWebappInfo.name()); |
if (splashIconView != null) splashIconView.setImageBitmap(displayIcon); |
- if (ColorUtils.shouldUseLightForegroundOnBackground(getBackgroundColor())) { |
+ if (ColorUtils.shouldUseLightForegroundOnBackground(backgroundColor)) { |
appNameView.setTextColor(ApiCompatibilityUtils.getColor(getResources(), |
R.color.webapp_splash_title_light)); |
} |