bug 619626 - implement faster splash screen for android r=mwu a=blocking-fennec

This commit is contained in:
Brad Lassey 2010-12-27 10:33:37 -05:00
Родитель ff7f0d4bfe
Коммит e68b1f48ba
6 изменённых файлов: 47 добавлений и 14 удалений

Просмотреть файл

@ -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();

Просмотреть файл

@ -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) {

Просмотреть файл

@ -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

Просмотреть файл

@ -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)

Просмотреть файл

@ -1,4 +1,4 @@
<!ENTITY splash_screen_label "&brandShortName; is loading">
<!ENTITY splash_screen_label "loading">
<!ENTITY incompatable_cpu_error "This device does not meet the minimum system requirements for &brandShortName;.">
<!ENTITY no_space_to_start_error "There is not enough space available for &brandShortName; to start.">
<!ENTITY error_loading_file "An error occurred when trying to load files required to run &brandShortName;">

Просмотреть файл

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="splash_background">#3a3a3a</color>
<color name="splash_font">#ffffff</color>
</resources>