Fix plumbing of key events to instance webview

This commit is contained in:
Ian Clelland 2014-05-20 15:16:10 -04:00
parent c66135d4de
commit 857d841adb
2 changed files with 16 additions and 17 deletions

View File

@ -19,7 +19,6 @@
package org.apache.cordova; package org.apache.cordova;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
@ -60,9 +59,6 @@ public class AndroidCordovaWebView extends CordovaWebView {
public static final String TAG = "CordovaWebView"; public static final String TAG = "CordovaWebView";
public static final String CORDOVA_VERSION = "3.6.0-dev"; public static final String CORDOVA_VERSION = "3.6.0-dev";
private ArrayList<Integer> keyDownCodes = new ArrayList<Integer>();
private ArrayList<Integer> keyUpCodes = new ArrayList<Integer>();
private boolean paused; private boolean paused;
private BroadcastReceiver receiver; private BroadcastReceiver receiver;
@ -550,24 +546,13 @@ public class AndroidCordovaWebView extends CordovaWebView {
@Override @Override
public void bindButton(String button, boolean override) { public void bindButton(String button, boolean override) {
if (button.compareTo("volumeup")==0) { if (button.compareTo("volumeup")==0) {
keyDownCodes.add(KeyEvent.KEYCODE_VOLUME_UP); webview.bindButton(KeyEvent.KEYCODE_VOLUME_UP, true);
} }
else if (button.compareTo("volumedown")==0) { else if (button.compareTo("volumedown")==0) {
keyDownCodes.add(KeyEvent.KEYCODE_VOLUME_DOWN); webview.bindButton(KeyEvent.KEYCODE_VOLUME_DOWN, true);
} }
} }
private void bindButton(int keyCode, boolean keyDown, boolean override) {
if(keyDown)
{
keyDownCodes.add(keyCode);
}
else
{
keyUpCodes.add(keyCode);
}
}
@Override @Override
public boolean isBackButtonBound() public boolean isBackButtonBound()
{ {

View File

@ -337,6 +337,20 @@ public class AndroidWebView extends WebView {
return false; return false;
} }
/*
* Add a key code to either the keyUp or keyDown handler lists.
*/
void bindButton(int keyCode, boolean keyDown) {
if(keyDown)
{
keyDownCodes.add(keyCode);
}
else
{
keyUpCodes.add(keyCode);
}
}
/* /*
* onKeyDown * onKeyDown
*/ */