mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 855016 - Allow gamepad action button to trigger the row items on about:home. r=sriram
This commit is contained in:
parent
680343c1d7
commit
af2eae9ced
@ -12,6 +12,7 @@ import org.mozilla.gecko.db.BrowserDB.URLColumns;
|
|||||||
import org.mozilla.gecko.db.BrowserDB.TopSitesCursorWrapper;
|
import org.mozilla.gecko.db.BrowserDB.TopSitesCursorWrapper;
|
||||||
import org.mozilla.gecko.sync.setup.SyncAccounts;
|
import org.mozilla.gecko.sync.setup.SyncAccounts;
|
||||||
import org.mozilla.gecko.util.ActivityResultHandler;
|
import org.mozilla.gecko.util.ActivityResultHandler;
|
||||||
|
import org.mozilla.gecko.util.GamepadUtils;
|
||||||
import org.mozilla.gecko.util.ThreadUtils;
|
import org.mozilla.gecko.util.ThreadUtils;
|
||||||
import org.mozilla.gecko.util.UiAsyncTask;
|
import org.mozilla.gecko.util.UiAsyncTask;
|
||||||
|
|
||||||
@ -616,6 +617,7 @@ public class AboutHomeContent extends ScrollView
|
|||||||
mUriLoadCallback.callback(homepageUrl);
|
mUriLoadCallback.callback(homepageUrl);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
row.setOnKeyListener(GamepadUtils.getClickDispatcher());
|
||||||
|
|
||||||
Favicons favicons = Favicons.getInstance();
|
Favicons favicons = Favicons.getInstance();
|
||||||
favicons.loadFavicon(pageUrl, iconUrl, true,
|
favicons.loadFavicon(pageUrl, iconUrl, true,
|
||||||
@ -681,6 +683,7 @@ public class AboutHomeContent extends ScrollView
|
|||||||
Tabs.getInstance().loadUrl(url, flags);
|
Tabs.getInstance().loadUrl(url, flags);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
container.setOnKeyListener(GamepadUtils.getClickDispatcher());
|
||||||
|
|
||||||
mLastTabs.addItem(container);
|
mLastTabs.addItem(container);
|
||||||
}
|
}
|
||||||
@ -752,6 +755,7 @@ public class AboutHomeContent extends ScrollView
|
|||||||
row.setTag(tab.url);
|
row.setTag(tab.url);
|
||||||
mRemoteTabs.addItem(row);
|
mRemoteTabs.addItem(row);
|
||||||
row.setOnClickListener(mRemoteTabClickListener);
|
row.setOnClickListener(mRemoteTabClickListener);
|
||||||
|
row.setOnKeyListener(GamepadUtils.getClickDispatcher());
|
||||||
}
|
}
|
||||||
|
|
||||||
mRemoteTabs.setSubtitle(client);
|
mRemoteTabs.setSubtitle(client);
|
||||||
|
@ -8,8 +8,11 @@ package org.mozilla.gecko.util;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.view.InputDevice;
|
import android.view.InputDevice;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
public final class GamepadUtils {
|
public final class GamepadUtils {
|
||||||
|
private static View.OnKeyListener sClickDispatcher;
|
||||||
|
|
||||||
private GamepadUtils() {
|
private GamepadUtils() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,4 +30,19 @@ public final class GamepadUtils {
|
|||||||
public static boolean isBackKey(KeyEvent event) {
|
public static boolean isBackKey(KeyEvent event) {
|
||||||
return (isGamepadKey(event) && (event.getKeyCode() == KeyEvent.KEYCODE_BUTTON_B));
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user