Chromium Code Reviews| 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 263f0445093984137030ed7e605dee887798280c..aa38cd215de322c5188409d748e577181a0f4103 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 |
| @@ -12,7 +12,12 @@ import android.os.AsyncTask; |
| import android.os.Bundle; |
| import android.text.TextUtils; |
| import android.util.Log; |
| +import android.view.Gravity; |
| import android.view.View; |
| +import android.view.ViewGroup; |
| +import android.widget.FrameLayout; |
| +import android.widget.ImageView; |
| +import android.widget.TextView; |
| import org.chromium.base.ActivityState; |
| import org.chromium.base.ApiCompatibilityUtils; |
| @@ -50,6 +55,7 @@ public class WebappActivity extends FullScreenActivity { |
| private WebContentsObserver mWebContentsObserver; |
| + private ViewGroup mSplashScreen; |
| private WebappUrlBar mUrlBar; |
| private boolean mIsInitialized; |
| @@ -94,7 +100,6 @@ public class WebappActivity extends FullScreenActivity { |
| mWebContentsObserver = createWebContentsObserver(); |
| getActivityTab().addObserver(createTabObserver()); |
| updateTaskDescription(); |
| - removeWindowBackground(); |
|
David Trainor- moved to gerrit
2015/07/24 20:39:19
Does not clearing this cause overdraw issues?
newt (away)
2015/07/24 21:06:05
+1. Since the window background isn't needed anymo
Lalit Maganti
2015/07/30 10:15:33
Yes it does indeed cause overdraw. I will attempt
|
| } |
| @Override |
| @@ -154,7 +159,49 @@ public class WebappActivity extends FullScreenActivity { |
| @Override |
| public void postInflationStartup() { |
| + if (mWebappInfo.icon() != null) { |
| + // Create the splash screen |
|
gone
2015/07/24 17:57:31
all of these comments should have periods:
http://
|
| + mSplashScreen = new FrameLayout(this); |
| + mSplashScreen.setBackgroundResource(getBackgroundDrawableResource()); |
| + |
| + // Create the view to hold the icon |
|
newt (away)
2015/07/24 21:20:57
It would be much more readable to define this layo
Lalit Maganti
2015/07/30 10:15:33
Agreed. Since this is a WIP CL I threw everything
|
| + ImageView iconView = new ImageView(this); |
| + iconView.setImageBitmap(mWebappInfo.icon()); |
| + iconView.setScaleType(ImageView.ScaleType.FIT_XY); |
| + |
| + // Set the layout parameters for the icon |
| + int imageSize = (int) getResources().getDimension(R.dimen |
| + .webapp_icon_size); |
| + FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(imageSize, imageSize); |
| + lp.gravity = Gravity.CENTER; |
| + |
| + // Add the icon to the splash |
| + mSplashScreen.addView(iconView, lp); |
| + |
| + // Create the text for the app name |
| + TextView appNameView = new TextView(this); |
| + appNameView.setText(mWebappInfo.name()); |
| + appNameView.setTextAppearance(this, R.style.WebAppSplashScreenTextAppearanceTitle); |
| + |
| + // Get the bottom margin |
| + int bottom = (int) getResources().getDimension(R.dimen |
| + .webapp_splash_title_bottom_margin); |
| + |
| + // Add the app name to the splash screen |
| + FrameLayout.LayoutParams nameLp = new FrameLayout.LayoutParams( |
| + ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); |
| + nameLp.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL; |
| + nameLp.bottomMargin = bottom; |
| + mSplashScreen.addView(appNameView, nameLp); |
| + |
| + // Add the splash screen itself |
| + ViewGroup contentView = (ViewGroup) findViewById(android.R.id.content); |
| + contentView.addView(mSplashScreen, new ViewGroup.LayoutParams( |
| + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); |
| + } |
| + |
| super.postInflationStartup(); |
| + |
| WebappControlContainer controlContainer = |
| (WebappControlContainer) findViewById(R.id.control_container); |
| mUrlBar = (WebappUrlBar) controlContainer.findViewById(R.id.webapp_url_bar); |
| @@ -214,6 +261,18 @@ public class WebappActivity extends FullScreenActivity { |
| public void didDetachInterstitialPage() { |
| updateUrlBar(); |
| } |
| + |
| + @Override |
| + public void didFirstVisuallyNonEmptyPaint() { |
| + mSplashScreen.animate() |
| + .alpha(0f) |
| + .withEndAction(new Runnable() { |
| + @Override |
| + public void run() { |
| + mSplashScreen.setVisibility(View.GONE); |
|
newt (away)
2015/07/24 19:24:50
Remove the view from the view hierarchy and set mS
Lalit Maganti
2015/07/30 10:15:33
Huh I never thought of that - thanks for pointing
|
| + } |
| + }); |
| + } |
| }; |
| } |
| @@ -320,6 +379,11 @@ public class WebappActivity extends FullScreenActivity { |
| return false; |
| } |
| + @Override |
| + protected int getBackgroundDrawableResource() { |
| + return R.color.webapp_splash_default_bg; |
| + } |
| + |
| /** |
| * Launches the URL in its own WebappActivity. |
| * @param context Context to use for launching the webapp. |