mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-25 06:10:35 +00:00
Bug 887051 - Fix gamepad action key behavior in AwesomeScreen. r=kats
This commit is contained in:
parent
b3422100d6
commit
0d693e50c5
@ -195,7 +195,7 @@ public class AwesomeBar extends GeckoActivity
|
||||
mText.setOnKeyListener(new View.OnKeyListener() {
|
||||
@Override
|
||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_ENTER || GamepadUtils.isActionKey(event)) {
|
||||
if (keyCode == KeyEvent.KEYCODE_ENTER) {
|
||||
if (event.getAction() != KeyEvent.ACTION_DOWN)
|
||||
return true;
|
||||
|
||||
@ -463,7 +463,8 @@ public class AwesomeBar extends GeckoActivity
|
||||
keyCode == KeyEvent.KEYCODE_DPAD_CENTER ||
|
||||
keyCode == KeyEvent.KEYCODE_DEL ||
|
||||
keyCode == KeyEvent.KEYCODE_VOLUME_UP ||
|
||||
keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
|
||||
keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ||
|
||||
GamepadUtils.isActionKey(event)) {
|
||||
return super.onKeyDown(keyCode, event);
|
||||
} else if (keyCode == KeyEvent.KEYCODE_SEARCH) {
|
||||
mText.setText("");
|
||||
|
@ -139,7 +139,6 @@ public class AllPagesTab extends AwesomeBarTab implements GeckoEventListener {
|
||||
handleItemClick(parent, view, position, id);
|
||||
}
|
||||
});
|
||||
list.setOnKeyListener(GamepadUtils.getListItemClickDispatcher());
|
||||
|
||||
AwesomeBarCursorAdapter adapter = getCursorAdapter();
|
||||
list.setAdapter(adapter);
|
||||
|
@ -76,7 +76,6 @@ public class BookmarksTab extends AwesomeBarTab {
|
||||
handleItemClick(parent, view, position, id);
|
||||
}
|
||||
});
|
||||
list.setOnKeyListener(GamepadUtils.getListItemClickDispatcher());
|
||||
|
||||
if (mShowReadingList) {
|
||||
String title = getResources().getString(R.string.bookmarks_folder_reading_list);
|
||||
|
@ -18,7 +18,6 @@ public final class GamepadUtils {
|
||||
private static final int SONY_XPERIA_GAMEPAD_DEVICE_ID = 196611;
|
||||
|
||||
private static View.OnKeyListener sClickDispatcher;
|
||||
private static View.OnKeyListener sListItemClickDispatcher;
|
||||
|
||||
private GamepadUtils() {
|
||||
}
|
||||
@ -81,26 +80,6 @@ public final class GamepadUtils {
|
||||
return sClickDispatcher;
|
||||
}
|
||||
|
||||
public static View.OnKeyListener getListItemClickDispatcher() {
|
||||
if (sListItemClickDispatcher == null) {
|
||||
sListItemClickDispatcher = new View.OnKeyListener() {
|
||||
@Override
|
||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||
if (isActionKeyDown(event) && (v instanceof ListView)) {
|
||||
ListView view = (ListView)v;
|
||||
AdapterView.OnItemClickListener listener = view.getOnItemClickListener();
|
||||
if (listener != null) {
|
||||
listener.onItemClick(view, view.getSelectedView(), view.getSelectedItemPosition(), view.getSelectedItemId());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
return sListItemClickDispatcher;
|
||||
}
|
||||
|
||||
public static KeyEvent translateSonyXperiaGamepadKeys(int keyCode, KeyEvent event) {
|
||||
// The cross and circle button mappings may be swapped in the different regions so
|
||||
// determine if they are swapped so the proper key codes can be mapped to the keys
|
||||
|
Loading…
x
Reference in New Issue
Block a user