Bug 993261 - Remove legacy code for redirecting key events to URL bar. r=lucasr

This commit is contained in:
Jim Chen 2014-05-15 14:06:00 +02:00
Родитель ae43efa29c
Коммит 9ae694cea2
3 изменённых файлов: 1 добавлений и 58 удалений

Просмотреть файл

@ -362,11 +362,6 @@ abstract public class BrowserApp extends GeckoApp
if (!mBrowserToolbar.isEditing() && onKey(null, keyCode, event)) {
return true;
}
if (mBrowserToolbar.onKey(keyCode, event)) {
return true;
}
return super.onKeyDown(keyCode, event);
}

Просмотреть файл

@ -417,37 +417,6 @@ public class BrowserToolbar extends ThemedRelativeLayout
return urlDisplayLayout.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 urlEditLayout.onKey(keyCode, event);
}
return false;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
// If the motion event has occured below the toolbar (due to the scroll

Просмотреть файл

@ -108,27 +108,6 @@ public class ToolbarEditLayout extends ThemedLinearLayout {
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());
@ -144,4 +123,4 @@ public class ToolbarEditLayout extends ThemedLinearLayout {
String getText() {
return mEditText.getText().toString();
}
}
}