You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by da...@apache.org on 2016/01/26 12:21:02 UTC

cordova-plugin-splashscreen git commit: CB-9516 Android SplashScreen - Spinner Does Not Display

Repository: cordova-plugin-splashscreen
Updated Branches:
  refs/heads/master 5b3c2c8b1 -> 799b0a173


CB-9516 Android SplashScreen - Spinner Does Not Display

Removes spinnerStop call from onMessage("spinner", "stop") as it is called when webview is shown and we are hiding spinner manually along with the splashscreen dialog.
Changed the spinner to be noncancellable.
Changed the ProgressDialog to custom only-spinner mode (on transparent background, without title/message and dimming).
Removed unused spinnerStart action handler.
Updated the docs.


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/commit/799b0a17
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/tree/799b0a17
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/diff/799b0a17

Branch: refs/heads/master
Commit: 799b0a1737e44418b2139ed619fae90ffcbf1804
Parents: 5b3c2c8
Author: daserge <v-...@microsoft.com>
Authored: Fri Jan 15 14:09:37 2016 +0300
Committer: daserge <v-...@microsoft.com>
Committed: Fri Jan 22 14:21:34 2016 +0300

----------------------------------------------------------------------
 README.md                     |  4 +-
 src/android/SplashScreen.java | 91 +++++++++++++++++---------------------
 2 files changed, 41 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/blob/799b0a17/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 9e6a435..f3c0b93 100644
--- a/README.md
+++ b/README.md
@@ -91,7 +91,7 @@ You can use the following preferences in your `config.xml`:
     </platform>
 
 
-### Android and iOS Quirks
+### Android and iOS Quirks
 
 - `FadeSplashScreen` (boolean, defaults to `true`): Set to `false` to
   prevent the splash screen from fading in and out when its display
@@ -123,8 +123,6 @@ window.setTimeout(function () {
 }, splashDuration - fadeDuration);
 ```
 
-### iOS Quirks
-
 - `ShowSplashScreenSpinner` (boolean, defaults to `true`): Set to `false`
   to hide the splash-screen spinner.
 

http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/blob/799b0a17/src/android/SplashScreen.java
----------------------------------------------------------------------
diff --git a/src/android/SplashScreen.java b/src/android/SplashScreen.java
index 833ebc2..68a4ce0 100644
--- a/src/android/SplashScreen.java
+++ b/src/android/SplashScreen.java
@@ -25,8 +25,10 @@ import android.content.Context;
 import android.content.DialogInterface;
 import android.content.res.Configuration;
 import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
 import android.os.Handler;
 import android.view.Display;
+import android.view.Gravity;
 import android.view.View;
 import android.view.ViewGroup.LayoutParams;
 import android.view.WindowManager;
@@ -35,6 +37,8 @@ import android.view.animation.AlphaAnimation;
 import android.view.animation.DecelerateInterpolator;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
+import android.widget.ProgressBar;
+import android.widget.RelativeLayout;
 
 import org.apache.cordova.CallbackContext;
 import org.apache.cordova.CordovaPlugin;
@@ -96,7 +100,6 @@ public class SplashScreen extends CordovaPlugin {
 
         if (firstShow) {
             boolean autoHide = preferences.getBoolean("AutoHideSplashScreen", true);
-            loadSpinner();
             showSplashScreen(autoHide);
         }
 
@@ -159,16 +162,6 @@ public class SplashScreen extends CordovaPlugin {
                     webView.postMessage("splashscreen", "show");
                 }
             });
-        } else if (action.equals("spinnerStart")) {
-            if (!HAS_BUILT_IN_SPLASH_SCREEN) {
-                final String title = args.getString(0);
-                final String message = args.getString(1);
-                cordova.getActivity().runOnUiThread(new Runnable() {
-                    public void run() {
-                        spinnerStart(title, message);
-                    }
-                });
-            }
         } else {
             return false;
         }
@@ -190,11 +183,10 @@ public class SplashScreen extends CordovaPlugin {
             }
         } else if ("spinner".equals(id)) {
             if ("stop".equals(data.toString())) {
-                this.spinnerStop();
                 getView().setVisibility(View.VISIBLE);
             }
         } else if ("onReceivedError".equals(id)) {
-            spinnerStop();
+            this.spinnerStop();
         }
         return null;
     }
@@ -230,6 +222,7 @@ public class SplashScreen extends CordovaPlugin {
                         fadeOut.setAnimationListener(new Animation.AnimationListener() {
                             @Override
                             public void onAnimationStart(Animation animation) {
+                                spinnerStop();
                             }
 
                             @Override
@@ -246,6 +239,7 @@ public class SplashScreen extends CordovaPlugin {
                             }
                         });
                     } else {
+                        spinnerStop();
                         splashDialog.dismiss();
                         splashDialog = null;
                         splashImageView = null;
@@ -315,6 +309,10 @@ public class SplashScreen extends CordovaPlugin {
                 splashDialog.setCancelable(false);
                 splashDialog.show();
 
+                if (preferences.getBoolean("ShowSplashScreenSpinner", true)) {
+                    spinnerStart();
+                }
+
                 // Set Runnable to remove splash screen just in case
                 if (hideAfterDelay) {
                     final Handler handler = new Handler();
@@ -330,47 +328,38 @@ public class SplashScreen extends CordovaPlugin {
         });
     }
 
-    /*
-     * Load the spinner
-     */
-    private void loadSpinner() {
-        // If loadingDialog property, then show the App loading dialog for first page of app
-        String loading = null;
-        if (webView.canGoBack()) {
-            loading = preferences.getString("LoadingDialog", null);
-        }
-        else {
-            loading = preferences.getString("LoadingPageDialog", null);
-        }
-        if (loading != null) {
-            String title = "";
-            String message = "Loading Application...";
-
-            if (loading.length() > 0) {
-                int comma = loading.indexOf(',');
-                if (comma > 0) {
-                    title = loading.substring(0, comma);
-                    message = loading.substring(comma + 1);
-                }
-                else {
-                    title = "";
-                    message = loading;
-                }
-            }
-            spinnerStart(title, message);
-        }
-    }
-
-    private void spinnerStart(final String title, final String message) {
+    // Show only spinner in the center of the screen
+    private void spinnerStart() {
         cordova.getActivity().runOnUiThread(new Runnable() {
             public void run() {
                 spinnerStop();
-                spinnerDialog = ProgressDialog.show(webView.getContext(), title, message, true, true,
-                        new DialogInterface.OnCancelListener() {
-                            public void onCancel(DialogInterface dialog) {
-                                spinnerDialog = null;
-                            }
-                        });
+
+                spinnerDialog = new ProgressDialog(webView.getContext());
+                spinnerDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
+                    public void onCancel(DialogInterface dialog) {
+                        spinnerDialog = null;
+                    }
+                });
+
+                spinnerDialog.setCancelable(false);
+                spinnerDialog.setIndeterminate(true);
+
+                RelativeLayout centeredLayout = new RelativeLayout(cordova.getActivity());
+                centeredLayout.setGravity(Gravity.CENTER);
+                centeredLayout.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
+
+                ProgressBar progressBar = new ProgressBar(webView.getContext());
+                RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
+                layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
+                progressBar.setLayoutParams(layoutParams);
+
+                centeredLayout.addView(progressBar);
+
+                spinnerDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
+                spinnerDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
+
+                spinnerDialog.show();
+                spinnerDialog.setContentView(centeredLayout);
             }
         });
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org