Bug 993261 - Remove legacy code for redirecting key events to URL bar. r=lucasr, a=sledru
authorJim Chen <nchen@mozilla.com>
Thu, 15 May 2014 14:06:00 +0200
changeset 192346 869aefb78e22
parent 192345 3fb029a11c05
child 192347 d520b0344613
push id3577
push userryanvm@gmail.com
push date2014-05-21 13:10 +0000
Treeherderresults
reviewerslucasr, sledru
bugs993261
milestone30.0
Bug 993261 - Remove legacy code for redirecting key events to URL bar. r=lucasr, a=sledru
mobile/android/base/BrowserApp.java
mobile/android/base/toolbar/BrowserToolbar.java
mobile/android/base/toolbar/ToolbarEditLayout.java
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -343,21 +343,16 @@ abstract public class BrowserApp extends
         return false;
     }
 
     @Override
     public boolean onKeyDown(int keyCode, KeyEvent event) {
         if (!mBrowserToolbar.isEditing() && onKey(null, keyCode, event)) {
             return true;
         }
-
-        if (mBrowserToolbar.onKey(keyCode, event)) {
-            return true;
-        }
-
         return super.onKeyDown(keyCode, event);
     }
 
     void handleReaderListStatusRequest(final String url) {
         ThreadUtils.postToBackgroundThread(new Runnable() {
             @Override
             public void run() {
                 final int inReadingList = BrowserDB.isReadingListItem(getContentResolver(), url) ? 1 : 0;
--- a/mobile/android/base/toolbar/BrowserToolbar.java
+++ b/mobile/android/base/toolbar/BrowserToolbar.java
@@ -378,47 +378,16 @@ public class BrowserToolbar extends Geck
         if (isEditing()) {
             stopEditing();
             return true;
         }
 
         return mUrlDisplayLayout.dismissSiteIdentityPopup();
     }
 
-    public boolean onKey(int keyCode, KeyEvent event) {
-        if (event.getAction() != KeyEvent.ACTION_DOWN) {
-            return false;
-        }
-
-        // Galaxy Note sends key events for the stylus that are outside of the
-        // valid keyCode range (see bug 758427)
-        if (keyCode > KeyEvent.getMaxKeyCode()) {
-            return true;
-        }
-
-        // 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_MENU ||
-            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 ||
-            keyCode == KeyEvent.KEYCODE_DEL ||
-            keyCode == KeyEvent.KEYCODE_VOLUME_UP ||
-            keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
-            return false;
-        } else if (isEditing()) {
-            return mUrlEditLayout.onKey(keyCode, event);
-        }
-
-        return false;
-    }
-
     @Override
     public boolean onTouchEvent(MotionEvent event) {
         // If the motion event has occured below the toolbar (due to the scroll
         // offset), let it pass through to the page.
         if (event != null && event.getY() > getHeight() + ViewHelper.getTranslationY(this)) {
             return false;
         }
 
--- a/mobile/android/base/toolbar/ToolbarEditLayout.java
+++ b/mobile/android/base/toolbar/ToolbarEditLayout.java
@@ -155,45 +155,24 @@ public class ToolbarEditLayout extends G
     void setOnDismissListener(OnDismissListener listener) {
         mEditText.setOnDismissListener(listener);
     }
 
     void setOnFilterListener(OnFilterListener listener) {
         mEditText.setOnFilterListener(listener);
     }
 
-    boolean onKey(int keyCode, KeyEvent event) {
-        final int prevSelStart = mEditText.getSelectionStart();
-        final int prevSelEnd = mEditText.getSelectionEnd();
-
-        // Manually dispatch the key event to the edit text. If selection changed as
-        // a result of the key event, then give focus back to mEditText
-        mEditText.dispatchKeyEvent(event);
-
-        final int curSelStart = mEditText.getSelectionStart();
-        final int curSelEnd = mEditText.getSelectionEnd();
-
-        if (prevSelStart != curSelStart || prevSelEnd != curSelEnd) {
-            mEditText.requestFocusFromTouch();
-
-            // Restore the selection, which gets lost due to the focus switch
-            mEditText.setSelection(curSelStart, curSelEnd);
-        }
-
-        return true;
-    }
-
     void onEditSuggestion(String suggestion) {
         mEditText.setText(suggestion);
         mEditText.setSelection(mEditText.getText().length());
         mEditText.requestFocus();
 
         showSoftInput();
     }
 
     void setText(String text) {
         mEditText.setText(text);
     }
 
     String getText() {
         return mEditText.getText().toString();
     }
-}
\ No newline at end of file
+}