From e68b1f48ba7a3394c1949e6679940c79e34bd07c Mon Sep 17 00:00:00 2001 From: Brad Lassey Date: Mon, 27 Dec 2010 10:33:37 -0500 Subject: [PATCH] bug 619626 - implement faster splash screen for android r=mwu a=blocking-fennec --- embedding/android/GeckoApp.java | 6 ---- embedding/android/GeckoAppShell.java | 5 +-- embedding/android/GeckoSurfaceView.java | 32 ++++++++++++++++++- embedding/android/Makefile.in | 10 ++++-- .../android/locales/en-US/android_strings.dtd | 2 +- embedding/android/resources/values/colors.xml | 6 ++++ 6 files changed, 47 insertions(+), 14 deletions(-) create mode 100644 embedding/android/resources/values/colors.xml diff --git a/embedding/android/GeckoApp.java b/embedding/android/GeckoApp.java index 4768d67e4b13..17d0009b4987 100644 --- a/embedding/android/GeckoApp.java +++ b/embedding/android/GeckoApp.java @@ -69,7 +69,6 @@ abstract public class GeckoApp public static GeckoSurfaceView surfaceView; public static GeckoApp mAppContext; public static boolean mFullscreen = false; - ProgressDialog mProgressDialog; enum LaunchState {PreLaunch, Launching, WaitButton, Launched, GeckoRunning, GeckoExiting}; @@ -135,11 +134,6 @@ abstract public class GeckoApp return false; } - mProgressDialog = - ProgressDialog.show(GeckoApp.this, "", - getString(R.string.splash_screen_label), - true); - // and then fire us up if (i == null) i = getIntent(); diff --git a/embedding/android/GeckoAppShell.java b/embedding/android/GeckoAppShell.java index 8e279cca3eaa..e3e2b7382de3 100644 --- a/embedding/android/GeckoAppShell.java +++ b/embedding/android/GeckoAppShell.java @@ -635,10 +635,7 @@ class GeckoAppShell } public static void hideProgressDialog() { - if (GeckoApp.mAppContext.mProgressDialog != null) { - GeckoApp.mAppContext.mProgressDialog.dismiss(); - GeckoApp.mAppContext.mProgressDialog = null; - } + GeckoApp.surfaceView.mShowingSplashScreen = false; } public static void setKeepScreenOn(final boolean on) { diff --git a/embedding/android/GeckoSurfaceView.java b/embedding/android/GeckoSurfaceView.java index 3bfb8ce3cd88..5b64b3520fcc 100644 --- a/embedding/android/GeckoSurfaceView.java +++ b/embedding/android/GeckoSurfaceView.java @@ -56,6 +56,8 @@ import android.graphics.*; import android.widget.*; import android.hardware.*; import android.location.*; +import android.graphics.drawable.*; +import android.content.res.*; import android.util.*; @@ -95,11 +97,37 @@ class GeckoSurfaceView super.finalize(); } + void drawSplashScreen(SurfaceHolder holder, int width, int height) { + Canvas c = holder.lockCanvas(); + if (c == null) { + Log.i("GeckoSurfaceView", "canvas is null"); + return; + } + Resources res = getResources(); + c.drawColor(res.getColor(R.color.splash_background)); + Drawable drawable = res.getDrawable(R.drawable.splash); + int w = drawable.getIntrinsicWidth(); + int h = drawable.getIntrinsicHeight(); + int x = (width - w)/2; + int y = (height - h)/2; + drawable.setBounds(x, y, x + w, y + h); + drawable.draw(c); + Paint p = new Paint(); + p.setTextAlign(Paint.Align.CENTER); + p.setTextSize(32f); + p.setAntiAlias(true); + p.setColor(res.getColor(R.color.splash_font)); + c.drawText(res.getString(R.string.splash_screen_label), width/2, y + h + 32, p); + holder.unlockCanvasAndPost(c); + } + /* * Called on main thread */ public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { + if (mShowingSplashScreen) + drawSplashScreen(holder, width, height); mSurfaceLock.lock(); try { @@ -132,7 +160,7 @@ class GeckoSurfaceView GeckoAppShell.scheduleRedraw(); if (!doSyncDraw) { - if (mDrawMode == DRAW_GLES_2) + if (mDrawMode == DRAW_GLES_2 || mShowingSplashScreen) return; Canvas c = holder.lockCanvas(); c.drawARGB(255, 255, 255, 255); @@ -503,6 +531,8 @@ class GeckoSurfaceView // True if gecko requests a buffer int mDrawMode; + static boolean mShowingSplashScreen = true; + // let's not change stuff around while we're in the middle of // starting drawing, ending drawing, or changing surface // characteristics diff --git a/embedding/android/Makefile.in b/embedding/android/Makefile.in index d926f630184e..e15a7dd1c015 100644 --- a/embedding/android/Makefile.in +++ b/embedding/android/Makefile.in @@ -102,6 +102,8 @@ RES_LAYOUT = \ res/layout/notification_progress_text.xml \ $(NULL) +RES_VALUES = res/values/colors.xml + JAVA_CLASSPATH = $(ANDROID_SDK)/android.jar DEFAULT_BRANDPATH = $(DEPTH)/$(MOZ_BRANDING_DIRECTORY)/locales/en-US/brand.dtd @@ -157,10 +159,14 @@ $(RES_LAYOUT): $(subst res/,$(srcdir)/resources/,$(RES_LAYOUT)) $(NSINSTALL) -D res/layout $(NSINSTALL) $(srcdir)/resources/layout/* res/layout/ -R.java: $(MOZ_APP_ICON) $(RES_LAYOUT) $(RES_DRAWABLE) res/drawable/icon.png res/drawable-hdpi/icon.png res/values/strings.xml AndroidManifest.xml +$(RES_VALUES): $(subst res/,$(srcdir)/resources/,$(RES_VALUES)) + $(NSINSTALL) -D res/values + $(NSINSTALL) $(srcdir)/resources/values/* res/values/ + +R.java: $(MOZ_APP_ICON) $(RES_LAYOUT) $(RES_DRAWABLE) $(RES_VALUES) res/drawable/icon.png res/drawable-hdpi/icon.png res/values/strings.xml AndroidManifest.xml $(AAPT) package -f -M AndroidManifest.xml -I $(ANDROID_SDK)/android.jar -S res -J . --custom-package org.mozilla.gecko -gecko.ap_: AndroidManifest.xml res/drawable/icon.png res/drawable-hdpi/icon.png $(RES_LAYOUT) $(RES_DRAWABLE) res/values/strings.xml FORCE +gecko.ap_: AndroidManifest.xml res/drawable/icon.png res/drawable-hdpi/icon.png $(RES_LAYOUT) $(RES_DRAWABLE) $(RES_VALUES) res/values/strings.xml FORCE $(AAPT) package -f -M AndroidManifest.xml -I $(ANDROID_SDK)/android.jar -S res -F $@ res/values/strings.xml: $(DEFAULT_BRANDPATH) $(DEFAULT_STRINGSPATH) diff --git a/embedding/android/locales/en-US/android_strings.dtd b/embedding/android/locales/en-US/android_strings.dtd index 03f752904094..010bc802dcda 100644 --- a/embedding/android/locales/en-US/android_strings.dtd +++ b/embedding/android/locales/en-US/android_strings.dtd @@ -1,4 +1,4 @@ - + diff --git a/embedding/android/resources/values/colors.xml b/embedding/android/resources/values/colors.xml new file mode 100644 index 000000000000..5c61d6b82ea3 --- /dev/null +++ b/embedding/android/resources/values/colors.xml @@ -0,0 +1,6 @@ + + + #3a3a3a + #ffffff + +