Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(658)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappActivity.java

Issue 1414873004: Web app splash screen: add even moar tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@splashscreen-uma
Patch Set: rebase Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappActivityTestBase.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6e05c9b9637671073d9aa9adb3190f1de75f1d9f..52352dc018e0471bc54a9f9af2384a7796ce3698 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
@@ -196,7 +196,8 @@ public class WebappActivity extends FullScreenActivity {
ApiCompatibilityUtils.getColor(getResources(), R.color.webapp_default_bg));
ViewGroup contentView = (ViewGroup) findViewById(android.R.id.content);
- mSplashScreen = createSplashScreen(contentView);
+ mSplashScreen = (ViewGroup) LayoutInflater.from(this).inflate(
+ R.layout.webapp_splash_screen, contentView, false);
mSplashScreen.setBackgroundColor(backgroundColor);
contentView.addView(mSplashScreen);
@@ -212,7 +213,32 @@ public class WebappActivity extends FullScreenActivity {
.getSplashScreenImage(new WebappDataStorage.FetchCallback<Bitmap>() {
@Override
public void onDataRetrieved(Bitmap splashIcon) {
- setSplashScreenIconAndText(mSplashScreen, splashIcon, backgroundColor);
+ Bitmap displayIcon = splashIcon == null ? mWebappInfo.icon() : splashIcon;
+ if (displayIcon == null || displayIcon.getWidth() < getResources()
+ .getDimensionPixelSize(R.dimen.webapp_splash_image_min_size)) {
+ mWebappUma.recordSplashscreenIconType(
+ WebappUma.SPLASHSCREEN_ICON_TYPE_NONE);
+ return;
+ }
+
+ mWebappUma.recordSplashscreenIconType(splashIcon != null
+ ? WebappUma.SPLASHSCREEN_ICON_TYPE_CUSTOM
+ : WebappUma.SPLASHSCREEN_ICON_TYPE_FALLBACK);
+ mWebappUma.recordSplashscreenIconSize(
+ Math.round((float) displayIcon.getWidth()
+ / getResources().getDisplayMetrics().density));
+
+ TextView appNameView = (TextView) mSplashScreen.findViewById(
+ R.id.webapp_splash_screen_name);
+ ImageView splashIconView = (ImageView) mSplashScreen.findViewById(
+ R.id.webapp_splash_screen_icon);
+ appNameView.setText(mWebappInfo.name());
+ splashIconView.setImageBitmap(displayIcon);
+
+ if (ColorUtils.shoudUseLightForegroundOnBackground(backgroundColor)) {
+ appNameView.setTextColor(ApiCompatibilityUtils.getColor(getResources(),
+ R.color.webapp_splash_title_light));
+ }
}
});
}
@@ -374,42 +400,6 @@ public class WebappActivity extends FullScreenActivity {
return mDirectoryManager.getWebappDirectory(this, getId());
}
- @VisibleForTesting
- ViewGroup createSplashScreen(ViewGroup parentView) {
- return (ViewGroup) LayoutInflater.from(this)
- .inflate(R.layout.webapp_splash_screen, parentView, false);
- }
-
- @VisibleForTesting
- void setSplashScreenIconAndText(View splashScreen, Bitmap splashIcon, int backgroundColor) {
- if (splashScreen == null) return;
-
- Bitmap displayIcon = splashIcon == null ? mWebappInfo.icon() : splashIcon;
- if (displayIcon == null || displayIcon.getWidth() < getResources()
- .getDimensionPixelSize(R.dimen.webapp_splash_image_min_size)) {
- mWebappUma.recordSplashscreenIconType(WebappUma.SPLASHSCREEN_ICON_TYPE_NONE);
- return;
- }
-
- mWebappUma.recordSplashscreenIconType(splashIcon != null
- ? WebappUma.SPLASHSCREEN_ICON_TYPE_CUSTOM
- : WebappUma.SPLASHSCREEN_ICON_TYPE_FALLBACK);
- mWebappUma.recordSplashscreenIconSize(Math.round(
- (float) displayIcon.getWidth() / getResources().getDisplayMetrics().density));
-
- TextView appNameView = (TextView) splashScreen.findViewById(
- R.id.webapp_splash_screen_name);
- ImageView splashIconView = (ImageView) splashScreen.findViewById(
- R.id.webapp_splash_screen_icon);
- appNameView.setText(mWebappInfo.name());
- splashIconView.setImageBitmap(displayIcon);
-
- if (ColorUtils.shoudUseLightForegroundOnBackground(backgroundColor)) {
- appNameView.setTextColor(ApiCompatibilityUtils.getColor(getResources(),
- R.color.webapp_splash_title_light));
- }
- }
-
private void hideSplashScreen(final int reason) {
if (mSplashScreen == null) return;
@@ -429,11 +419,16 @@ public class WebappActivity extends FullScreenActivity {
}
@VisibleForTesting
- boolean isSplashScreenVisibleForTest() {
+ boolean isSplashScreenVisibleForTests() {
return mSplashScreen != null;
}
@VisibleForTesting
+ ViewGroup getSplashScreenForTests() {
+ return mSplashScreen;
+ }
+
+ @VisibleForTesting
WebappUrlBar getUrlBarForTests() {
return mUrlBar;
}
« no previous file with comments | « no previous file | chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappActivityTestBase.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698