You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bo...@apache.org on 2012/04/18 02:50:26 UTC

[1/2] android commit: Fixed back button behaviour. WIN

Updated Branches:
  refs/heads/master c341cf0d4 -> 180696bae


Fixed back button behaviour.  WIN


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

Branch: refs/heads/master
Commit: 180696baec28d6e6b67e8bb23a5302f21bce6b79
Parents: 76820eb
Author: Joe Bowser <bo...@apache.org>
Authored: Tue Apr 17 17:50:07 2012 -0700
Committer: Joe Bowser <bo...@apache.org>
Committed: Tue Apr 17 17:50:07 2012 -0700

----------------------------------------------------------------------
 framework/src/org/apache/cordova/DroidGap.java |   33 ++++++++++--------
 1 files changed, 18 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/180696ba/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 c48bf50..decd10d 100755
--- a/framework/src/org/apache/cordova/DroidGap.java
+++ b/framework/src/org/apache/cordova/DroidGap.java
@@ -1071,8 +1071,25 @@ public class DroidGap extends Activity implements CordovaInterface {
         this.finish();
     }
     
+    
+   /** 
+    * Called when the back key is pressed
+    * 
+    * (non-Javadoc)
+    * @see android.app.Activity#onBackPressed()
+    */
+   @Override
+   public void onBackPressed()
+   {
+     // If back key is bound, then send event to JavaScript
+     if (!(this.bound || this.backHistory())) {
+         this.activityState = ACTIVITY_EXITING;
+         super.onBackPressed();
+     }
+   }
+    
     /**
-     * Called when a key is pressed.
+     * Called when a key is de-pressed. (Key UP)
      * 
      * @param keyCode
      * @param event
@@ -1092,20 +1109,6 @@ public class DroidGap extends Activity implements CordovaInterface {
                 return true;
             }
 
-            // If not bound
-            else {
-
-                // Go to previous page in webview if it is possible to go back
-                if (this.backHistory()) {
-                    return true;
-                }
-
-                // If not, then invoke behavior of super class
-                else {
-                    this.activityState = ACTIVITY_EXITING;
-                    return super.onKeyUp(keyCode, event);
-                }
-            }
         }
 
         // If menu key