Bug 920791 - Hide banner when URL bar is focused. r=lucasr

This commit is contained in:
Joshua Dover 2014-01-30 10:45:31 -08:00
parent b4b53f4dd3
commit a7052884e7
4 changed files with 31 additions and 6 deletions

View File

@ -520,6 +520,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);
}
}
});
// Intercept key events for gamepad shortcuts
mBrowserToolbar.setOnKeyListener(this);

View File

@ -97,13 +97,13 @@ public class HomeBanner extends LinearLayout
GeckoAppShell.getEventDispatcher().unregisterEventListener("HomeBanner:Data", this);
}
public void showBanner() {
public void show() {
if (!mDismissed) {
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("HomeBanner:Get", null));
}
}
public void hideBanner() {
public void hide() {
animateDown();
}

View File

@ -288,9 +288,9 @@ public class HomePager extends ViewPager {
}
if (mHomeBanner != null) {
if (item == mDefaultPanelIndex) {
mHomeBanner.showBanner();
mHomeBanner.show();
} else {
mHomeBanner.hideBanner();
mHomeBanner.hide();
}
}
}
@ -315,6 +315,14 @@ public class HomePager extends ViewPager {
return super.dispatchTouchEvent(event);
}
public void onToolbarFocusChange(boolean hasFocus) {
if (hasFocus) {
mHomeBanner.hide();
} else if (mDefaultPanelIndex == getCurrentItem() || getAdapter().getCount() == 0) {
mHomeBanner.show();
}
}
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.
@ -396,9 +404,9 @@ public class HomePager extends ViewPager {
if (mHomeBanner != null) {
if (position == mDefaultPanelIndex) {
mHomeBanner.showBanner();
mHomeBanner.show();
} else {
mHomeBanner.hideBanner();
mHomeBanner.hide();
}
}
}

View File

@ -142,6 +142,7 @@ public class BrowserToolbar extends GeckoRelativeLayout
private OnFilterListener mFilterListener;
private OnStartEditingListener mStartEditingListener;
private OnStopEditingListener mStopEditingListener;
private OnFocusChangeListener mFocusChangeListener;
final private BrowserApp mActivity;
private boolean mHasSoftMenuButton;
@ -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);
}
}
});
@ -793,6 +797,10 @@ public class BrowserToolbar extends GeckoRelativeLayout
mStopEditingListener = listener;
}
public void setOnFocusChangeListener(OnFocusChangeListener listener) {
mFocusChangeListener = listener;
}
private void showUrlEditLayout() {
setUrlEditLayoutVisibility(true, null);
}