incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bows...@apache.org
Subject [3/10] android commit: Adding the volume button event changes
Date Mon, 11 Jun 2012 17:29:05 GMT
Adding the volume button event changes


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

Branch: refs/heads/master
Commit: 9f42772b7e88a4fd04ccda5fa4726cdfc02ee8ec
Parents: 80a5ea1 be165c6
Author: Joe Bowser <bowserj@apache.org>
Authored: Fri Jun 8 16:25:09 2012 -0700
Committer: Joe Bowser <bowserj@apache.org>
Committed: Fri Jun 8 16:25:09 2012 -0700

----------------------------------------------------------------------
 framework/assets/js/cordova.android.js         |   49 +++++++++++++++++-
 framework/src/org/apache/cordova/App.java      |   11 ++++
 framework/src/org/apache/cordova/DroidGap.java |   46 +++++++++++++++++
 3 files changed, 103 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/9f42772b/framework/assets/js/cordova.android.js
----------------------------------------------------------------------
diff --cc framework/assets/js/cordova.android.js
index 89d6ca7,2e91464..16dab29
--- a/framework/assets/js/cordova.android.js
+++ b/framework/assets/js/cordova.android.js
@@@ -1,6 -1,6 +1,6 @@@
- // commit ac0a3990438f4a89faa993316fb5614f61cf3be6
 -// commit 548f80ccff155e01a7dcbedfcc0d826253110f53
++// commit 347de1a785b7ecbe86c2189343ab2549a9297f9b
  
- // File generated at :: Tue Jun 05 2012 14:14:16 GMT-0700 (PDT)
 -// File generated at :: Sat Jun 02 2012 22:53:34 GMT+0200 (CEST)
++// File generated at :: Fri Jun 08 2012 16:17:50 GMT-0700 (PDT)
  
  /*
   Licensed to the Apache Software Foundation (ASF) under one
@@@ -1284,6 -1303,6 +1306,10 @@@ cameraExport.getPicture = function(succ
      exec(successCallback, errorCallback, "Camera", "takePicture", [quality, destinationType,
sourceType, targetWidth, targetHeight, encodingType, mediaType, allowEdit, correctOrientation,
saveToPhotoAlbum, popoverOptions]);
  };
  
++cameraExport.cleanup = function(successCallback, errorCallback) {
++    exec(successCallback, errorCallback, "Camera", "cleanup", []);
++}
++
  module.exports = cameraExport;
  });
  
@@@ -2591,6 -2590,6 +2617,8 @@@ var DirectoryEntry = require('cordova/p
  var FileSystem = function(name, root) {
      this.name = name || null;
      if (root) {
++        console.log('root.name ' + name);
++        console.log('root.root ' + root);
          this.root = new DirectoryEntry(root.name, root.fullPath);
      }
  };

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/9f42772b/framework/src/org/apache/cordova/App.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/App.java
index 86b7c69,ea698f9..293cd13
--- a/framework/src/org/apache/cordova/App.java
+++ b/framework/src/org/apache/cordova/App.java
@@@ -189,8 -184,19 +189,19 @@@ public class App extends Plugin 
      }
  
      /**
+      * Override the default behavior of the Android volume buttons.
+      * If overridden, when the volume button is pressed, the "volume[up|down]button" JavaScript
event will be fired.
+      *
+      * @param button        volumeup, volumedown
+      * @param override      T=override, F=cancel override
+      */
+     public void overrideButton(String button, boolean override) {
+         LOG.i("DroidGap", "WARNING: Volume Button Default Behaviour will be overridden.
 The volume event will be fired!");
+         ((DroidGap)this.ctx).bindButton(button, override);
+     }
+     /**
       * Return whether the Android back button is overridden by the user.
 -     * 
 +     *
       * @return boolean
       */
      public boolean isBackbuttonOverridden() {

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/9f42772b/framework/src/org/apache/cordova/DroidGap.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/DroidGap.java
index 7c452e7,9b6ce13..18032f8
--- a/framework/src/org/apache/cordova/DroidGap.java
+++ b/framework/src/org/apache/cordova/DroidGap.java
@@@ -181,25 -213,39 +181,29 @@@ public class DroidGap extends Activity 
      // when another application (activity) is started.
      protected boolean keepRunning = true;
  
 -    // preferences read from cordova.xml
 -    protected PreferenceSet preferences;
++    private boolean volumeupBound;
++
++    private boolean volumedownBound;
+ 
      /**
 -     * Sets the authentication token.
 -     * 
 -     * @param authenticationToken
 -     *            the authentication token
 -     * @param host
 -     *            the host
 -     * @param realm
 -     *            the realm
 -     */
 +    * Sets the authentication token.
 +    * 
 +    * @param authenticationToken
 +    * @param host
 +    * @param realm
 +    */
      public void setAuthenticationToken(AuthenticationToken authenticationToken, String host,
String realm) {
 -        
 -        if(host == null) {
 -            host = "";
 -        }
 -        
 -        if(realm == null) {
 -            realm = "";
 +        if (this.appView != null && this.appView.viewClient != null) {
 +            this.appView.viewClient.setAuthenticationToken(authenticationToken, host, realm);
          }
 -        
 -        authenticationTokens.put(host.concat(realm), authenticationToken);
      }
 -    
 +
      /**
       * Removes the authentication token.
 -     * 
 +     *
       * @param host
 -     *            the host
       * @param realm
 -     *            the realm
 +     * 
       * @return the authentication token or null if did not exist
       */
      public AuthenticationToken removeAuthenticationToken(String host, String realm) {
@@@ -817,9 -1093,58 +821,41 @@@
      }
  
      /**
 -     * Called when a key is pressed. (Key DOWN)
++    * Called when a key is pressed. (Key DOWN)
+      *
+      * @param keyCode
+      * @param event
+      */
+     @Override
+     public boolean onKeyDown(int keyCode, KeyEvent event) {
+         if (this.appView == null) {
+             return super.onKeyDown(keyCode, event);
+         }
+ 
+         // If volumedown key
+         if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
+             if (this.volumedownBound==true) {
+                 // only override default behaviour is event bound
+                 this.appView.loadUrl("javascript:cordova.fireDocumentEvent('volumedownbutton');");
+                 return true;
+             }
+         }
+ 
+         // If volumeup key
+         else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
+             if (this.volumeupBound==true) {
+                 // only override default behaviour is event bound
+                 this.appView.loadUrl("javascript:cordova.fireDocumentEvent('volumeupbutton');");
+                 return true;
+             }
+         }
+         return false;
+     }
+ 
+     /**
 -     * Any calls to Activity.startActivityForResult must use method below, so 
 -     * the result can be routed to them correctly.  
 -     * 
 -     * This is done to eliminate the need to modify DroidGap.java to receive activity results.
 -     * 
 -     * @param intent            The intent to start
 -     * @param requestCode       Identifies who to send the result to
 -     * 
 -     * @throws RuntimeException
 -     */
 -    @Override
 -    public void startActivityForResult(Intent intent, int requestCode) throws RuntimeException
{
 -        LOG.d(TAG, "DroidGap.startActivityForResult(intent,%d)", requestCode);
 -        super.startActivityForResult(intent, requestCode);
 -    }
 -
 -    /**
       * 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
       * @param intent            The intent to start
       * @param requestCode       The request code that is passed to callback to identify
the activity
@@@ -970,51 -1424,32 +1006,61 @@@
          return true;
      }
  
 +    /**
 +     * Get Activity context.
 +     * 
 +     * @return
 +     */
      public Context getContext() {
 -      return this;
 +        return this.getContext();
      }
  
 +    /**
 +     * Override the backbutton.
 +     * 
 +     * @param override
 +     */
      public void bindBackButton(boolean override) {
 -      // TODO Auto-generated method stub
 -      this.bound = override;
 +        this.bound = override;
      }
  
 +    /**
 +     * Determine of backbutton is overridden.
 +     * 
 +     * @return
 +     */
      public boolean isBackButtonBound() {
 -      // TODO Auto-generated method stub
 -      return this.bound;
 +        return this.bound;
 +    }
 +
 +    /**
 +     * Load the specified URL in the Cordova webview or a new browser instance.
 +     * 
 +     * NOTE: If openExternal is false, only URLs listed in whitelist can be loaded.
 +     *
 +     * @param url           The url to load.
 +     * @param openExternal  Load url in browser instead of Cordova webview.
 +     * @param clearHistory  Clear the history stack, so new page becomes top of history
 +     * @param params        DroidGap parameters for new app
 +     */
 +    public void showWebPage(String url, boolean openExternal, boolean clearHistory, HashMap<String,
Object> params) {
 +        if (this.appView != null) {
 +            appView.showWebPage(url, openExternal, clearHistory, params);
 +        }
      }
  
+     public void bindButton(String button, boolean override) {
+       // TODO Auto-generated method stub
+       if (button.compareTo("volumeup")==0) {
+         this.volumeupBound = override;
+       }
+       else if (button.compareTo("volumedown")==0) {
+         this.volumedownBound = override;
+       }
+     }
+ 
      protected Dialog splashDialog;
 -    
 +
      /**
       * Removes the Dialog that displays the splash screen
       */


Mime
View raw message