mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 920791 - Hide banner when keyboard is focused. r=margaret
This commit is contained in:
parent
60f34eaeca
commit
c4a9d96b4d
@ -507,6 +507,15 @@ abstract public class BrowserApp extends GeckoApp
|
||||
}
|
||||
});
|
||||
|
||||
mBrowserToolbar.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
if (isHomePagerVisible()) {
|
||||
mHomePager.onToolbarFocusChange(hasFocus);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mBrowserToolbar.setOnStartEditingListener(new BrowserToolbar.OnStartEditingListener() {
|
||||
public void onStartEditing() {
|
||||
// Temporarily disable doorhanger notifications.
|
||||
|
@ -244,6 +244,12 @@ public class HomePager extends ViewPager {
|
||||
return super.dispatchTouchEvent(event);
|
||||
}
|
||||
|
||||
public void onToolbarFocusChange(boolean hasFocus) {
|
||||
// We should only enable the banner if the toolbar is not focused and we are on the default page
|
||||
final boolean enabled = !hasFocus && getCurrentItem() == mDefaultPageIndex;
|
||||
mHomeBanner.setEnabled(enabled);
|
||||
}
|
||||
|
||||
private void updateUiFromPanelConfigs(List<PanelConfig> panelConfigs) {
|
||||
// We only care about the adapter if HomePager is currently
|
||||
// loaded, which means it's visible in the activity.
|
||||
|
@ -22,6 +22,10 @@ public class testHomeBanner extends UITest {
|
||||
|
||||
// These test methods depend on being run in this order.
|
||||
addBannerTest();
|
||||
|
||||
// Make sure the banner hides when the user starts interacting with the url bar.
|
||||
hideOnToolbarFocusTest();
|
||||
|
||||
// TODO: API doesn't actually support this but it used to work due to how the banner was
|
||||
// part of TopSitesPanel's lifecycle
|
||||
// removeBannerTest();
|
||||
@ -96,6 +100,18 @@ public class testHomeBanner extends UITest {
|
||||
mAboutHome.assertBannerNotVisible();
|
||||
}
|
||||
|
||||
private void hideOnToolbarFocusTest() {
|
||||
NavigationHelper.enterAndLoadUrl("about:home");
|
||||
mAboutHome.assertVisible()
|
||||
.assertBannerVisible();
|
||||
|
||||
mToolbar.enterEditingMode();
|
||||
mAboutHome.assertBannerNotVisible();
|
||||
|
||||
mToolbar.dismissEditingMode();
|
||||
mAboutHome.assertBannerVisible();
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the roboextender page to add a message to the banner.
|
||||
*/
|
||||
|
@ -137,6 +137,7 @@ public class BrowserToolbar extends GeckoRelativeLayout
|
||||
private OnCommitListener mCommitListener;
|
||||
private OnDismissListener mDismissListener;
|
||||
private OnFilterListener mFilterListener;
|
||||
private OnFocusChangeListener mFocusChangeListener;
|
||||
private OnStartEditingListener mStartEditingListener;
|
||||
private OnStopEditingListener mStopEditingListener;
|
||||
|
||||
@ -315,6 +316,9 @@ public class BrowserToolbar extends GeckoRelativeLayout
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
setSelected(hasFocus);
|
||||
if (mFocusChangeListener != null) {
|
||||
mFocusChangeListener.onFocusChange(v, hasFocus);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -785,6 +789,10 @@ public class BrowserToolbar extends GeckoRelativeLayout
|
||||
mUrlEditLayout.setOnFilterListener(listener);
|
||||
}
|
||||
|
||||
public void setOnFocusChangeListener(OnFocusChangeListener listener) {
|
||||
mFocusChangeListener = listener;
|
||||
}
|
||||
|
||||
public void setOnStartEditingListener(OnStartEditingListener listener) {
|
||||
mStartEditingListener = listener;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user