diff --git a/mobile/android/base/AboutHomeContent.java b/mobile/android/base/AboutHomeContent.java index 7268645aa7c..0e505264a56 100644 --- a/mobile/android/base/AboutHomeContent.java +++ b/mobile/android/base/AboutHomeContent.java @@ -12,6 +12,7 @@ import org.mozilla.gecko.db.BrowserDB.URLColumns; import org.mozilla.gecko.db.BrowserDB.TopSitesCursorWrapper; import org.mozilla.gecko.sync.setup.SyncAccounts; import org.mozilla.gecko.util.ActivityResultHandler; +import org.mozilla.gecko.util.GamepadUtils; import org.mozilla.gecko.util.ThreadUtils; import org.mozilla.gecko.util.UiAsyncTask; @@ -616,6 +617,7 @@ public class AboutHomeContent extends ScrollView mUriLoadCallback.callback(homepageUrl); } }); + row.setOnKeyListener(GamepadUtils.getClickDispatcher()); Favicons favicons = Favicons.getInstance(); favicons.loadFavicon(pageUrl, iconUrl, true, @@ -681,6 +683,7 @@ public class AboutHomeContent extends ScrollView Tabs.getInstance().loadUrl(url, flags); } }); + container.setOnKeyListener(GamepadUtils.getClickDispatcher()); mLastTabs.addItem(container); } @@ -752,6 +755,7 @@ public class AboutHomeContent extends ScrollView row.setTag(tab.url); mRemoteTabs.addItem(row); row.setOnClickListener(mRemoteTabClickListener); + row.setOnKeyListener(GamepadUtils.getClickDispatcher()); } mRemoteTabs.setSubtitle(client); diff --git a/mobile/android/base/util/GamepadUtils.java b/mobile/android/base/util/GamepadUtils.java index f78faf328ab..d1407af4981 100644 --- a/mobile/android/base/util/GamepadUtils.java +++ b/mobile/android/base/util/GamepadUtils.java @@ -8,8 +8,11 @@ package org.mozilla.gecko.util; import android.os.Build; import android.view.InputDevice; import android.view.KeyEvent; +import android.view.View; public final class GamepadUtils { + private static View.OnKeyListener sClickDispatcher; + private GamepadUtils() { } @@ -27,4 +30,19 @@ public final class GamepadUtils { public static boolean isBackKey(KeyEvent event) { return (isGamepadKey(event) && (event.getKeyCode() == KeyEvent.KEYCODE_BUTTON_B)); } + + public static View.OnKeyListener getClickDispatcher() { + if (sClickDispatcher == null) { + sClickDispatcher = new View.OnKeyListener() { + @Override + public boolean onKey(View v, int keyCode, KeyEvent event) { + if (event.getAction() == KeyEvent.ACTION_DOWN && isActionKey(event)) { + return v.performClick(); + } + return false; + } + }; + } + return sClickDispatcher; + } }