Bug 697773 - Cannot type in AwesomeBar URL bar with hard keyboard. r=blassey
authorAlex Pakhotin <alexp@mozilla.com>
Tue, 08 Nov 2011 17:33:27 -0800
changeset 83453 2f8943cd9e177b13c5259ebb660a48c14ab65e8c
parent 83452 16ab009adcb0bc7962d5521b9a24d7f35ce166d4
child 83454 e25866d64478e432d3a100ce12935548ce09d17a
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersblassey
bugs697773
milestone10.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 697773 - Cannot type in AwesomeBar URL bar with hard keyboard. r=blassey
embedding/android/AwesomeBar.java
--- a/embedding/android/AwesomeBar.java
+++ b/embedding/android/AwesomeBar.java
@@ -144,13 +144,32 @@ public class AwesomeBar extends Activity
         resultIntent.putExtra(URL_KEY, url);
         resultIntent.putExtra(TYPE_KEY, mType);
 
         setResult(Activity.RESULT_OK, resultIntent);
         finish();
     }
 
     @Override
+    public boolean onKeyDown(int keyCode, KeyEvent event) {
+        // This method is called only if the key event was not handled
+        // by any of the views, which usually means the edit box lost focus
+        if (keyCode == KeyEvent.KEYCODE_BACK ||
+            keyCode == KeyEvent.KEYCODE_DPAD_UP ||
+            keyCode == KeyEvent.KEYCODE_DPAD_DOWN ||
+            keyCode == KeyEvent.KEYCODE_DPAD_LEFT ||
+            keyCode == KeyEvent.KEYCODE_DPAD_RIGHT ||
+            keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
+            return super.onKeyDown(keyCode, event);
+        } else {
+            // Return focus to the edit box, and dispatch the event to it
+            mText.requestFocusFromTouch();
+            mText.dispatchKeyEvent(event);
+            return true;
+        }
+    }
+
+    @Override
     public void onDestroy() {
         super.onDestroy();
         mAwesomeTabs.destroy();
     }
 }