incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bcur...@apache.org
Subject [6/15] android commit: Add exit message.
Date Tue, 15 May 2012 04:38:00 GMT
Add exit message.


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/13f92b2b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/13f92b2b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/13f92b2b

Branch: refs/heads/CordovaWebView
Commit: 13f92b2b76d723729e716c7aa81214803bf1ad47
Parents: e6aa647
Author: Bryce Curtis <curtis.bryce@gmail.com>
Authored: Mon May 14 22:51:36 2012 -0500
Committer: Bryce Curtis <curtis.bryce@gmail.com>
Committed: Mon May 14 22:51:36 2012 -0500

----------------------------------------------------------------------
 framework/src/org/apache/cordova/App.java          |    2 +-
 .../org/apache/cordova/CordovaWebViewClient.java   |    3 +-
 framework/src/org/apache/cordova/DroidGap.java     |   44 ++++++++-------
 3 files changed, 26 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/13f92b2b/framework/src/org/apache/cordova/App.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/App.java b/framework/src/org/apache/cordova/App.java
index 7df0aa9..48eeb66 100755
--- a/framework/src/org/apache/cordova/App.java
+++ b/framework/src/org/apache/cordova/App.java
@@ -201,7 +201,7 @@ public class App extends Plugin {
      * Exit the Android application.
      */
     public void exitApp() {
-        this.ctx.getActivity().finish();
+        this.webView.postMessage("exit", null);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/13f92b2b/framework/src/org/apache/cordova/CordovaWebViewClient.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaWebViewClient.java b/framework/src/org/apache/cordova/CordovaWebViewClient.java
index 227e251..b118a90 100755
--- a/framework/src/org/apache/cordova/CordovaWebViewClient.java
+++ b/framework/src/org/apache/cordova/CordovaWebViewClient.java
@@ -237,6 +237,7 @@ public class CordovaWebViewClient extends WebViewClient {
     @Override
     public void onPageFinished(WebView view, String url) {
         super.onPageFinished(view, url);
+        LOG.d(TAG, "onPageFinished(" + url + ")");
 
         /**
          * Because of a timing issue we need to clear this history in onPageFinished as well
as 
@@ -286,7 +287,7 @@ public class CordovaWebViewClient extends WebViewClient {
             if (this.appView.callbackServer != null) {
                 this.appView.callbackServer.destroy();
             }
-            this.ctx.getActivity().finish();
+            appView.postMessage("exit", null);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/13f92b2b/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 842895d..bccc821 100755
--- a/framework/src/org/apache/cordova/DroidGap.java
+++ b/framework/src/org/apache/cordova/DroidGap.java
@@ -337,6 +337,7 @@ public class DroidGap extends Activity implements CordovaInterface {
             this.init();
         }
 
+        // TODO @bc - background color doesn't work
         // If backgroundColor
         this.backgroundColor = this.getIntegerProperty("backgroundColor", Color.BLACK);
         LOG.e(TAG, "Setting background color=" + this.backgroundColor);
@@ -655,6 +656,7 @@ public class DroidGap extends Activity implements CordovaInterface {
      * The final call you receive before your activity is destroyed. 
      */
     public void onDestroy() {
+        LOG.d(TAG, "onDestroy()");
         super.onDestroy();
 
         if (this.appView != null) {
@@ -749,13 +751,6 @@ public class DroidGap extends Activity implements CordovaInterface {
      * End this activity by calling finish for activity
      */
     public void endActivity() {
-        this.finish();
-    }
-
-    /**
-     * Finish for Activity has been called.
-     */
-    public void finish() {
         this.activityState = ACTIVITY_EXITING;
         super.finish();
     }
@@ -902,21 +897,25 @@ public class DroidGap extends Activity implements CordovaInterface {
         final DroidGap me = this;
         me.runOnUiThread(new Runnable() {
             public void run() {
-                AlertDialog.Builder dlg = new AlertDialog.Builder(me);
-                dlg.setMessage(message);
-                dlg.setTitle(title);
-                dlg.setCancelable(false);
-                dlg.setPositiveButton(button,
-                        new AlertDialog.OnClickListener() {
-                            public void onClick(DialogInterface dialog, int which) {
-                                dialog.dismiss();
-                                if (exit) {
-                                    me.endActivity();
+                try {
+                    AlertDialog.Builder dlg = new AlertDialog.Builder(me);
+                    dlg.setMessage(message);
+                    dlg.setTitle(title);
+                    dlg.setCancelable(false);
+                    dlg.setPositiveButton(button,
+                            new AlertDialog.OnClickListener() {
+                                public void onClick(DialogInterface dialog, int which) {
+                                    dialog.dismiss();
+                                    if (exit) {
+                                        me.endActivity();
+                                    }
                                 }
-                            }
-                        });
-                dlg.create();
-                dlg.show();
+                            });
+                    dlg.create();
+                    dlg.show();
+                } catch (Exception e) {
+                    finish();
+                }
             }
         });
     }
@@ -1077,6 +1076,9 @@ public class DroidGap extends Activity implements CordovaInterface {
                 e.printStackTrace();
             }
         }
+        else if ("exit".equals(id)) {
+            this.endActivity();
+        }
     }
 
 }


Mime
View raw message