Minor fix to deal with weird keyboard focus issues and the back button. CB-1146

This commit is contained in:
Joe Bowser 2012-07-27 10:33:38 -07:00
parent 401584dbd8
commit 893ecec55e
2 changed files with 22 additions and 1 deletions

View File

@ -81,6 +81,8 @@ public class CordovaWebView extends WebView {
private boolean volumeupBound; private boolean volumeupBound;
private boolean handleButton = false;
/** /**
* Constructor. * Constructor.
* *
@ -749,7 +751,6 @@ public class CordovaWebView extends WebView {
return super.onKeyUp(keyCode, event); return super.onKeyUp(keyCode, event);
} }
Log.d(TAG, "KeyUp has been triggered on the view"); Log.d(TAG, "KeyUp has been triggered on the view");
return false; return false;
} }
@ -788,6 +789,7 @@ public class CordovaWebView extends WebView {
public void handlePause(boolean keepRunning) public void handlePause(boolean keepRunning)
{ {
LOG.d(TAG, "Handle the pause");
// Send pause event to JavaScript // Send pause event to JavaScript
this.loadUrl("javascript:try{cordova.fireDocumentEvent('pause');}catch(e){console.log('exception firing pause event from native');};"); this.loadUrl("javascript:try{cordova.fireDocumentEvent('pause');}catch(e){console.log('exception firing pause event from native');};");
@ -843,4 +845,8 @@ public class CordovaWebView extends WebView {
this.pluginManager.onNewIntent(intent); this.pluginManager.onNewIntent(intent);
} }
} }
public boolean hadKeyEvent() {
return handleButton;
}
} }

View File

@ -1032,5 +1032,20 @@ public class DroidGap extends Activity implements CordovaInterface {
} }
return null; return null;
} }
/*
* (non-Javadoc)
* @see android.app.Activity#onKeyUp(int, android.view.KeyEvent)
*/
@Override
public boolean onKeyUp(int keyCode, KeyEvent event)
{
if (appView.backHistory() || keyCode != KeyEvent.KEYCODE_BACK)
return appView.onKeyUp(keyCode, event);
else
return super.onKeyUp(keyCode, event);
}
} }