diff --git a/framework/assets/js/cordova.android.js b/framework/assets/js/cordova.android.js index 16dab290..ae20b290 100644 --- a/framework/assets/js/cordova.android.js +++ b/framework/assets/js/cordova.android.js @@ -1,6 +1,6 @@ -// commit 347de1a785b7ecbe86c2189343ab2549a9297f9b +// commit 25033fceac7c800623f1f16881b784d19eba69cc -// File generated at :: Fri Jun 08 2012 16:17:50 GMT-0700 (PDT) +// File generated at :: Thu Jun 21 2012 10:45:32 GMT-0700 (PDT) /* Licensed to the Apache Software Foundation (ASF) under one @@ -190,7 +190,9 @@ var cordova = { fireDocumentEvent: function(type, data) { var evt = createEvent(type, data); if (typeof documentEventHandlers[type] != 'undefined') { - documentEventHandlers[type].fire(evt); + setTimeout(function() { + documentEventHandlers[type].fire(evt); + }, 0); } else { document.dispatchEvent(evt); } @@ -198,7 +200,9 @@ var cordova = { fireWindowEvent: function(type, data) { var evt = createEvent(type,data); if (typeof windowEventHandlers[type] != 'undefined') { - windowEventHandlers[type].fire(evt); + setTimeout(function() { + windowEventHandlers[type].fire(evt); + }, 0); } else { window.dispatchEvent(evt); } @@ -953,8 +957,7 @@ module.exports = function(success, fail, service, action, args) { // If a result was returned if (r.length > 0) { - var v; - eval("v="+r+";"); + var v = JSON.parse(r); // If status is OK, then return value back to caller if (v.status === cordova.callbackStatus.OK) { @@ -1067,28 +1070,6 @@ module.exports = { cordova.addDocumentEventHandler('menubutton'); cordova.addDocumentEventHandler('searchbutton'); - function bindButtonChannel(buttonName) { - // generic button bind used for volumeup/volumedown buttons - return cordova.addDocumentEventHandler(buttonName + 'button', { - onSubscribe:function() { - // If we just attached the first handler, let native know we need to override the button. - if (this.numHandlers === 1) { - exec(null, null, "App", "overrideButton", [buttonName, true]); - } - }, - onUnsubscribe:function() { - // If we just detached the last handler, let native know we no longer override the volumeup button. - if (this.numHandlers === 0) { - exec(null, null, "App", "overrideButton", [buttonName, false]); - } - } - }); - - } - // Inject a listener for the volume buttons on the document. - var volumeUpButtonChannel = bindButtonChannel('volumeup'); - var volumeDownButtonChannel = bindButtonChannel('volumedown'); - // Figure out if we need to shim-in localStorage and WebSQL // support from the native side. var storage = require('cordova/plugin/android/storage'); @@ -1308,7 +1289,7 @@ cameraExport.getPicture = function(successCallback, errorCallback, options) { cameraExport.cleanup = function(successCallback, errorCallback) { exec(successCallback, errorCallback, "Camera", "cleanup", []); -} +}; module.exports = cameraExport; }); @@ -2628,7 +2609,8 @@ module.exports = FileSystem; // file: lib/common/plugin/FileTransfer.js define("cordova/plugin/FileTransfer", function(require, exports, module) { -var exec = require('cordova/exec'); +var exec = require('cordova/exec'), + FileTransferError = require('cordova/plugin/FileTransferError'); /** * FileTransfer uploads a file to a remote server. @@ -2647,6 +2629,8 @@ var FileTransfer = function() {}; * @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false */ FileTransfer.prototype.upload = function(filePath, server, successCallback, errorCallback, options, trustAllHosts) { + // sanity parameter checking + if (!filePath || !server) throw new Error("FileTransfer.upload requires filePath and server URL parameters at the minimum."); // check for options var fileKey = null; var fileName = null; @@ -2668,7 +2652,12 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro } } - exec(successCallback, errorCallback, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode]); + var fail = function(e) { + var error = new FileTransferError(e.code, e.source, e.target, e.http_status); + errorCallback(error); + }; + + exec(successCallback, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode]); }; /** @@ -2679,6 +2668,8 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro * @param errorCallback {Function} Callback to be invoked upon error */ FileTransfer.prototype.download = function(source, target, successCallback, errorCallback) { + // sanity parameter checking + if (!source || !target) throw new Error("FileTransfer.download requires source URI and target URI parameters at the minimum."); var win = function(result) { var entry = null; if (result.isDirectory) { @@ -2693,6 +2684,12 @@ FileTransfer.prototype.download = function(source, target, successCallback, erro entry.fullPath = result.fullPath; successCallback(entry); }; + + var fail = function(e) { + var error = new FileTransferError(e.code, e.source, e.target, e.http_status); + errorCallback(error); + }; + exec(win, errorCallback, 'FileTransfer', 'download', [source, target]); }; @@ -2706,8 +2703,11 @@ define("cordova/plugin/FileTransferError", function(require, exports, module) { * FileTransferError * @constructor */ -var FileTransferError = function(code) { +var FileTransferError = function(code, source, target, status) { this.code = code || null; + this.source = source || null; + this.target = target || null; + this.http_status = status || null; }; FileTransferError.FILE_NOT_FOUND_ERR = 1; @@ -2715,6 +2715,7 @@ FileTransferError.INVALID_URL_ERR = 2; FileTransferError.CONNECTION_ERR = 3; module.exports = FileTransferError; + }); // file: lib/common/plugin/FileUploadOptions.js @@ -3665,21 +3666,6 @@ module.exports = { exec(null, null, "App", "overrideBackbutton", [override]); }, - /** - * Override the default behavior of the Android volume button. - * If overridden, when the volume button is pressed, the "volume[up|down]button" JavaScript event will be fired. - * - * Note: The user should not have to call this method. Instead, when the user - * registers for the "volume[up|down]button" event, this is automatically done. - * - * @param button volumeup, volumedown - * @param override T=override, F=cancel override - */ - overrideButton:function(button, override) { - exec(null, null, "App", "overrideButton", [button, override]); - }, - - /** * Exit and terminate the application. */ @@ -5509,6 +5495,9 @@ define("cordova/plugin/splashscreen", function(require, exports, module) { var exec = require('cordova/exec'); var splashscreen = { + show:function() { + exec(null, null, "SplashScreen", "show", []); + }, hide:function() { exec(null, null, "SplashScreen", "hide", []); } diff --git a/framework/src/org/apache/cordova/App.java b/framework/src/org/apache/cordova/App.java index 7b3dc063..8d0895b0 100755 --- a/framework/src/org/apache/cordova/App.java +++ b/framework/src/org/apache/cordova/App.java @@ -188,7 +188,7 @@ public class App extends Plugin { */ public void overrideBackbutton(boolean override) { LOG.i("App", "WARNING: Back Button Default Behaviour will be overridden. The backbutton event will be fired!"); - this.cordova.bindBackButton(override); + webView.bindButton(override); } /** @@ -200,7 +200,7 @@ public class App extends Plugin { */ public void overrideButton(String button, boolean override) { LOG.i("DroidGap", "WARNING: Volume Button Default Behaviour will be overridden. The volume event will be fired!"); - this.cordova.bindButton(button, override); + webView.bindButton(button, override); } /** * Return whether the Android back button is overridden by the user. diff --git a/framework/src/org/apache/cordova/CameraLauncher.java b/framework/src/org/apache/cordova/CameraLauncher.java index e9f4ea8f..3b720b71 100755 --- a/framework/src/org/apache/cordova/CameraLauncher.java +++ b/framework/src/org/apache/cordova/CameraLauncher.java @@ -42,6 +42,8 @@ import android.database.Cursor; import android.graphics.Bitmap; import android.graphics.Matrix; import android.graphics.Bitmap.CompressFormat; +import android.media.MediaScannerConnection; +import android.media.MediaScannerConnection.MediaScannerConnectionClient; import android.net.Uri; import android.os.Environment; import android.provider.MediaStore; @@ -52,7 +54,7 @@ import android.util.Log; * and returns the captured image. When the camera view is closed, the screen displayed before * the camera view was shown is redisplayed. */ -public class CameraLauncher extends Plugin { +public class CameraLauncher extends Plugin implements MediaScannerConnectionClient { private static final int DATA_URL = 0; // Return base64 encoded string private static final int FILE_URI = 1; // Return file uri (content://media/external/images/media/2 for Android) @@ -79,9 +81,12 @@ public class CameraLauncher extends Plugin { private Uri imageUri; // Uri of captured image private int encodingType; // Type of encoding to use private int mediaType; // What type of media to retrieve + private boolean saveToPhotoAlbum; // Should the picture be saved to the device's photo album public String callbackId; private int numPics; + + private MediaScannerConnection conn; // Used to update gallery app with newly-written files //This should never be null! //private CordovaInterface cordova; @@ -117,6 +122,7 @@ public class CameraLauncher extends Plugin { if (action.equals("takePicture")) { int srcType = CAMERA; int destType = FILE_URI; + this.saveToPhotoAlbum = false; this.targetHeight = 0; this.targetWidth = 0; this.encodingType = JPEG; @@ -130,6 +136,7 @@ public class CameraLauncher extends Plugin { this.targetHeight = args.getInt(4); this.encodingType = args.getInt(5); this.mediaType = args.getInt(6); + this.saveToPhotoAlbum = args.getBoolean(9); if (srcType == CAMERA) { this.takePicture(destType, encodingType); @@ -195,9 +202,9 @@ public class CameraLauncher extends Plugin { private File createCaptureFile(int encodingType) { File photo = null; if (encodingType == JPEG) { - photo = new File(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()), "Pic.jpg"); + photo = new File(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()), ".Pic.jpg"); } else if (encodingType == PNG) { - photo = new File(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()), "Pic.png"); + photo = new File(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()), ".Pic.png"); } else { throw new IllegalArgumentException("Invalid Encoding Type: " + encodingType); } @@ -303,7 +310,7 @@ public class CameraLauncher extends Plugin { ExifHelper exif = new ExifHelper(); try { if (this.encodingType == JPEG) { - exif.createInFile(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()) + "/Pic.jpg"); + exif.createInFile(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()) + "/.Pic.jpg"); exif.readExifData(); } } catch (IOException e) { @@ -326,21 +333,26 @@ public class CameraLauncher extends Plugin { // If sending filename back else if (destType == FILE_URI) { - // Create entry in media store for image - // (Don't use insertImage() because it uses default compression setting of 50 - no way to change it) - ContentValues values = new ContentValues(); - values.put(android.provider.MediaStore.Images.Media.MIME_TYPE, "image/jpeg"); - Uri uri = null; - try { - uri = this.cordova.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); - } catch (UnsupportedOperationException e) { - LOG.d(LOG_TAG, "Can't write to external media storage."); + Uri uri; + if (!this.saveToPhotoAlbum) { + uri = Uri.fromFile(new File("/data/data/" + this.cordova.getActivity().getPackageName() + "/", (new File(FileUtils.stripFileProtocol(this.imageUri.toString()))).getName())); + } else { + // Create entry in media store for image + // (Don't use insertImage() because it uses default compression setting of 50 - no way to change it) + ContentValues values = new ContentValues(); + values.put(android.provider.MediaStore.Images.Media.MIME_TYPE, "image/jpeg"); + try { - uri = this.cordova.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, values); - } catch (UnsupportedOperationException ex) { - LOG.d(LOG_TAG, "Can't write to internal media storage."); - this.failPicture("Error capturing image - no media storage found."); - return; + uri = this.cordova.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); + } catch (UnsupportedOperationException e) { + LOG.d(LOG_TAG, "Can't write to external media storage."); + try { + uri = this.cordova.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, values); + } catch (UnsupportedOperationException ex) { + LOG.d(LOG_TAG, "Can't write to internal media storage."); + this.failPicture("Error capturing image - no media storage found."); + return; + } } } @@ -357,33 +369,37 @@ public class CameraLauncher extends Plugin { os.close(); fis.close(); - checkForDuplicateImage(FILE_URI); - this.success(new PluginResult(PluginResult.Status.OK, uri.toString()), this.callbackId); - return; + } else { + + bitmap = scaleBitmap(getBitmapFromResult(intent)); + + // Add compressed version of captured image to returned media store Uri + OutputStream os = this.cordova.getActivity().getContentResolver().openOutputStream(uri); + bitmap.compress(Bitmap.CompressFormat.JPEG, this.mQuality, os); + os.close(); + + // Restore exif data to file + + if (this.encodingType == JPEG) { + String exifPath; + if (this.saveToPhotoAlbum) { + exifPath = FileUtils.getRealPathFromURI(uri, this.cordova); + } else { + exifPath = uri.getPath(); + } + exif.createOutFile(exifPath); + exif.writeExifData(); + } + } - - bitmap = scaleBitmap(getBitmapFromResult(intent)); - - // Add compressed version of captured image to returned media store Uri - OutputStream os = this.cordova.getActivity().getContentResolver().openOutputStream(uri); - bitmap.compress(Bitmap.CompressFormat.JPEG, this.mQuality, os); - os.close(); - - // Restore exif data to file - if (this.encodingType == JPEG) { - exif.createOutFile(FileUtils.getRealPathFromURI(uri, this.cordova)); - exif.writeExifData(); - } - // Send Uri back to JavaScript for viewing image this.success(new PluginResult(PluginResult.Status.OK, uri.toString()), this.callbackId); } - bitmap.recycle(); + + this.cleanup(FILE_URI, this.imageUri, bitmap); bitmap = null; - System.gc(); - - checkForDuplicateImage(FILE_URI); + } catch (IOException e) { e.printStackTrace(); this.failPicture("Error capturing image."); @@ -514,6 +530,22 @@ public class CameraLauncher extends Plugin { null, null); } + + /** + * Cleans up after picture taking. Checking for duplicates and that kind of stuff. + */ + private void cleanup(int imageType, Uri oldImage, Bitmap bitmap) { + bitmap.recycle(); + + // Clean up initial camera-written image file. + (new File(FileUtils.stripFileProtocol(oldImage.toString()))).delete(); + + checkForDuplicateImage(imageType); + // Scan for the gallery to update pic refs in gallery + this.scanForGallery(); + + System.gc(); + } /** * Used to find out if we are in a situation where the Camera Intent adds to images @@ -584,4 +616,24 @@ public class CameraLauncher extends Plugin { public void failPicture(String err) { this.error(new PluginResult(PluginResult.Status.ERROR, err), this.callbackId); } + + private void scanForGallery() { + if(this.conn!=null) this.conn.disconnect(); + this.conn = new MediaScannerConnection(this.ctx.getActivity().getApplicationContext(), this); + conn.connect(); + } + + public void onMediaScannerConnected() { + try{ + this.conn.scanFile(this.imageUri.toString(), "image/*"); + } catch (java.lang.IllegalStateException e){ + e.printStackTrace(); + LOG.d(LOG_TAG, "Can;t scan file in MediaScanner aftering taking picture"); + } + + } + + public void onScanCompleted(String path, Uri uri) { + this.conn.disconnect(); + } } diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java index 3337be23..f9edbbe5 100755 --- a/framework/src/org/apache/cordova/CordovaWebView.java +++ b/framework/src/org/apache/cordova/CordovaWebView.java @@ -39,6 +39,7 @@ import android.net.Uri; import android.os.Bundle; import android.util.AttributeSet; import android.util.Log; +import android.view.KeyEvent; import android.view.WindowManager; import android.webkit.WebSettings; import android.webkit.WebView; @@ -51,8 +52,12 @@ public class CordovaWebView extends WebView { /** The whitelist **/ private ArrayList whiteList = new ArrayList(); private HashMap whiteListCache = new HashMap(); + private ArrayList keyDownCodes = new ArrayList(); + private ArrayList keyUpCodes = new ArrayList(); + public PluginManager pluginManager; public CallbackServer callbackServer; + /** Actvities and other important classes **/ private CordovaInterface cordova; @@ -70,6 +75,12 @@ public class CordovaWebView extends WebView { // Flag to track that a loadUrl timeout occurred int loadUrlTimeout = 0; + private boolean bound; + + private boolean volumedownBound; + + private boolean volumeupBound; + /** * Constructor. * @@ -660,4 +671,104 @@ public class CordovaWebView extends WebView { } return p.toString(); } + + /* + * onKeyDown + */ + + @Override + public boolean onKeyDown(int keyCode, KeyEvent event) + { + if(keyDownCodes.contains(keyCode)) + { + if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { + // only override default behaviour is event bound + LOG.d(TAG, "Down Key Hit"); + this.loadUrl("javascript:cordova.fireDocumentEvent('volumedownbutton');"); + return true; + } + // If volumeup key + else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { + LOG.d(TAG, "Up Key Hit"); + this.loadUrl("javascript:cordova.fireDocumentEvent('volumeupbutton');"); + return true; + } + else + { + //Do some other stuff! + } + } + return false; + } + + @Override + public boolean onKeyUp(int keyCode, KeyEvent event) + { + + Log.d(TAG, "KeyDown has been triggered on the view"); + + // If back key + if (keyCode == KeyEvent.KEYCODE_BACK) { + // If back key is bound, then send event to JavaScript + if (this.bound) { + this.loadUrl("javascript:cordova.fireDocumentEvent('backbutton');"); + return true; + } else { + // If not bound + // Go to previous page in webview if it is possible to go back + if (this.backHistory()) { + return true; + } + // If not, then invoke default behaviour + else { + //this.activityState = ACTIVITY_EXITING; + return false; + } + } + } + // Legacy + else if (keyCode == KeyEvent.KEYCODE_MENU) { + this.loadUrl("javascript:cordova.fireDocumentEvent('menubutton');"); + return super.onKeyUp(keyCode, event); + } + // If search key + else if (keyCode == KeyEvent.KEYCODE_SEARCH) { + this.loadUrl("javascript:cordova.fireDocumentEvent('searchbutton');"); + return true; + } + else if(keyUpCodes.contains(keyCode)) + { + //What the hell should this do? + } + + + Log.d(TAG, "KeyUp has been triggered on the view"); + return false; + } + + public void bindButton(boolean override) + { + this.bound = override; + } + + public void bindButton(String button, boolean override) { + // TODO Auto-generated method stub + if (button.compareTo("volumeup")==0) { + keyDownCodes.add(KeyEvent.KEYCODE_VOLUME_UP); + } + else if (button.compareTo("volumedown")==0) { + keyDownCodes.add(KeyEvent.KEYCODE_VOLUME_DOWN); + } + } + + public void bindButton(int keyCode, boolean keyDown, boolean override) { + if(keyDown) + { + keyDownCodes.add(keyCode); + } + else + { + keyUpCodes.add(keyCode); + } + } } diff --git a/framework/src/org/apache/cordova/CordovaWebViewClient.java b/framework/src/org/apache/cordova/CordovaWebViewClient.java index c9a32611..4934c8f3 100755 --- a/framework/src/org/apache/cordova/CordovaWebViewClient.java +++ b/framework/src/org/apache/cordova/CordovaWebViewClient.java @@ -21,20 +21,26 @@ package org.apache.cordova; import java.util.Hashtable; import org.apache.cordova.api.CordovaInterface; +import java.io.IOException; +import java.io.InputStream; + import org.apache.cordova.api.LOG; import org.json.JSONException; import org.json.JSONObject; +import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; +import android.content.res.AssetManager; import android.graphics.Bitmap; import android.net.Uri; import android.net.http.SslError; import android.view.View; import android.webkit.HttpAuthHandler; import android.webkit.SslErrorHandler; +import android.webkit.WebResourceResponse; import android.webkit.WebView; import android.webkit.WebViewClient; @@ -241,6 +247,7 @@ public class CordovaWebViewClient extends WebViewClient { * Notify the host application that a page has finished loading. * This method is called only for main frame. When onPageFinished() is called, the rendering picture may not be updated yet. * + * * @param view The webview initiating the callback. * @param url The url of the page. */ @@ -344,6 +351,7 @@ public class CordovaWebViewClient extends WebViewClient { final String packageName = this.cordova.getActivity().getPackageName(); final PackageManager pm = this.cordova.getActivity().getPackageManager(); + ApplicationInfo appInfo; try { appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA); @@ -451,4 +459,43 @@ public class CordovaWebViewClient extends WebViewClient { this.authenticationTokens.clear(); } + @Override + public WebResourceResponse shouldInterceptRequest(WebView view, String url) { + if(url.contains("?") || url.contains("#")){ + return generateWebResourceResponse(url); + } else { + return super.shouldInterceptRequest(view, url); + } + } + + private WebResourceResponse generateWebResourceResponse(String url) { + final String ANDROID_ASSET = "file:///android_asset/"; + if (url.startsWith(ANDROID_ASSET)) { + String niceUrl = url; + niceUrl = url.replaceFirst(ANDROID_ASSET, ""); + if(niceUrl.contains("?")){ + niceUrl = niceUrl.split("\\?")[0]; + } + else if(niceUrl.contains("#")) + { + niceUrl = niceUrl.split("#")[0]; + } + + String mimetype = null; + if(niceUrl.endsWith(".html")){ + mimetype = "text/html"; + } + + try { + AssetManager assets = cordova.getActivity().getAssets(); + Uri uri = Uri.parse(niceUrl); + InputStream stream = assets.open(uri.getPath(), AssetManager.ACCESS_STREAMING); + WebResourceResponse response = new WebResourceResponse(mimetype, "UTF-8", stream); + return response; + } catch (IOException e) { + LOG.e("generateWebResourceResponse", e.getMessage(), e); + } + } + return null; + } } diff --git a/framework/src/org/apache/cordova/DroidGap.java b/framework/src/org/apache/cordova/DroidGap.java index a5e2a7d1..8b26f375 100755 --- a/framework/src/org/apache/cordova/DroidGap.java +++ b/framework/src/org/apache/cordova/DroidGap.java @@ -784,87 +784,7 @@ public class DroidGap extends Activity implements CordovaInterface { super.finish(); } - /** - * Called when a key is released. (Key UP) - * - * @param keyCode - * @param event - */ - @Override - public boolean onKeyUp(int keyCode, KeyEvent event) { - if (this.appView == null) { - return super.onKeyUp(keyCode, event); - } - - // If back key - if (keyCode == KeyEvent.KEYCODE_BACK) { - // If back key is bound, then send event to JavaScript - if (this.bound) { - this.appView.loadUrl("javascript:cordova.fireDocumentEvent('backbutton');"); - return true; - } else { - // If not bound - // 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 - else if (keyCode == KeyEvent.KEYCODE_MENU) { - this.appView.loadUrl("javascript:cordova.fireDocumentEvent('menubutton');"); - return super.onKeyUp(keyCode, event); - } - - // If search key - else if (keyCode == KeyEvent.KEYCODE_SEARCH) { - this.appView.loadUrl("javascript:cordova.fireDocumentEvent('searchbutton');"); - return true; - } - - return false; - } - - /** - * 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 - LOG.d(TAG, "Down Key Hit"); - 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 - LOG.d(TAG, "Up Key Hit"); - this.appView.loadUrl("javascript:cordova.fireDocumentEvent('volumeupbutton');"); - return true; - } - } - return super.onKeyDown(keyCode, event); - } - + /** * Launch an activity for which you would like a result when it finished. When this activity exits, * your onActivityResult() method will be called. diff --git a/framework/src/org/apache/cordova/api/CordovaInterface.java b/framework/src/org/apache/cordova/api/CordovaInterface.java index 64a2743e..480b17d8 100755 --- a/framework/src/org/apache/cordova/api/CordovaInterface.java +++ b/framework/src/org/apache/cordova/api/CordovaInterface.java @@ -44,19 +44,6 @@ public interface CordovaInterface { */ abstract public void setActivityResultCallback(IPlugin plugin); - /** - * Causes the Activity to override the back button behavior. - * - * @param override - */ - public abstract void bindBackButton(boolean override); - - /** - * A hook required to check if the Back Button is bound. - * - * @return - */ - public abstract boolean isBackButtonBound(); /** * Get the Android activity. @@ -77,5 +64,4 @@ public interface CordovaInterface { */ public Object onMessage(String id, Object data); - public abstract void bindButton(String button, boolean override); }