You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ma...@apache.org on 2012/06/20 02:22:50 UTC
[3/3] android commit: CB-883: SplashScreen without show() method,
only hide()
CB-883: SplashScreen without show() method, only hide()
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/5c778330
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/5c778330
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/5c778330
Branch: refs/heads/master
Commit: 5c7783305a6f195a184c077bc17fdbd603366f00
Parents: 6c594b6
Author: macdonst <si...@gmail.com>
Authored: Tue Jun 19 20:21:13 2012 -0400
Committer: macdonst <si...@gmail.com>
Committed: Tue Jun 19 20:21:13 2012 -0400
----------------------------------------------------------------------
framework/src/org/apache/cordova/DroidGap.java | 72 ++++++++-------
framework/src/org/apache/cordova/SplashScreen.java | 3 +-
2 files changed, 41 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/5c778330/framework/src/org/apache/cordova/DroidGap.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/DroidGap.java b/framework/src/org/apache/cordova/DroidGap.java
index d4c142d..a5e2a7d 100755
--- a/framework/src/org/apache/cordova/DroidGap.java
+++ b/framework/src/org/apache/cordova/DroidGap.java
@@ -260,7 +260,7 @@ public class DroidGap extends Activity implements CordovaInterface {
{
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
}
-
+
if(this.getBooleanProperty("setFullscreen", false))
{
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
@@ -866,7 +866,7 @@ public class DroidGap extends Activity implements CordovaInterface {
}
/**
- * Launch an activity for which you would like a result when it finished. When this activity exits,
+ * Launch an activity for which you would like a result when it finished. When this activity exits,
* your onActivityResult() method will be called.
*
* @param command The command object
@@ -1088,40 +1088,46 @@ public class DroidGap extends Activity implements CordovaInterface {
* Shows the splash screen over the full Activity
*/
@SuppressWarnings("deprecation")
- protected void showSplashScreen(int time) {
-
- // Get reference to display
- Display display = getWindowManager().getDefaultDisplay();
+ protected void showSplashScreen(final int time) {
+ final DroidGap that = this;
- // Create the layout for the dialog
- LinearLayout root = new LinearLayout(this);
- root.setMinimumHeight(display.getHeight());
- root.setMinimumWidth(display.getWidth());
- root.setOrientation(LinearLayout.VERTICAL);
- root.setBackgroundColor(this.getIntegerProperty("backgroundColor", Color.BLACK));
- root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
- ViewGroup.LayoutParams.FILL_PARENT, 0.0F));
- root.setBackgroundResource(this.splashscreen);
-
- // Create and show the dialog
- splashDialog = new Dialog(this, android.R.style.Theme_Translucent_NoTitleBar);
- // check to see if the splash screen should be full screen
- if ((getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN)
- == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
- splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- }
- splashDialog.setContentView(root);
- splashDialog.setCancelable(false);
- splashDialog.show();
-
- // Set Runnable to remove splash screen just in case
- final Handler handler = new Handler();
- handler.postDelayed(new Runnable() {
+ Runnable runnable = new Runnable() {
public void run() {
- removeSplashScreen();
+ // Get reference to display
+ Display display = getWindowManager().getDefaultDisplay();
+
+ // Create the layout for the dialog
+ LinearLayout root = new LinearLayout(that.getActivity());
+ root.setMinimumHeight(display.getHeight());
+ root.setMinimumWidth(display.getWidth());
+ root.setOrientation(LinearLayout.VERTICAL);
+ root.setBackgroundColor(that.getIntegerProperty("backgroundColor", Color.BLACK));
+ root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
+ ViewGroup.LayoutParams.FILL_PARENT, 0.0F));
+ root.setBackgroundResource(that.splashscreen);
+
+ // Create and show the dialog
+ splashDialog = new Dialog(that, android.R.style.Theme_Translucent_NoTitleBar);
+ // check to see if the splash screen should be full screen
+ if ((getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN)
+ == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
+ splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ }
+ splashDialog.setContentView(root);
+ splashDialog.setCancelable(false);
+ splashDialog.show();
+
+ // Set Runnable to remove splash screen just in case
+ final Handler handler = new Handler();
+ handler.postDelayed(new Runnable() {
+ public void run() {
+ removeSplashScreen();
+ }
+ }, time);
}
- }, time);
+ };
+ this.runOnUiThread(runnable);
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/5c778330/framework/src/org/apache/cordova/SplashScreen.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/SplashScreen.java b/framework/src/org/apache/cordova/SplashScreen.java
index 9fca9b2..93ab628 100644
--- a/framework/src/org/apache/cordova/SplashScreen.java
+++ b/framework/src/org/apache/cordova/SplashScreen.java
@@ -31,8 +31,9 @@ public class SplashScreen extends Plugin {
String result = "";
if (action.equals("hide")) {
- //((DroidGap)this.ctx).removeSplashScreen();
this.webView.postMessage("splashscreen", "hide");
+ } else if (action.equals("show")){
+ this.webView.postMessage("splashscreen", "show");
}
else {
status = PluginResult.Status.INVALID_ACTION;