80,472
社区成员




@Override
public void onOptionsMenuClosed(Menu menu) {
mOptionsMenuOpen = false;
if (!mInLoad) {
hideFakeTitleBar();
} else if (!mIconView) {
// The page is currently loading, and we are in expanded mode, so
// we were not showing the menu. Show it once again. It will be
// removed when the page finishes.
showFakeTitleBar();
}
}
private void hideFakeTitleBar() {
if (mFakeTitleBar.getParent() == null) return;
WindowManager.LayoutParams params = (WindowManager.LayoutParams)
mFakeTitleBar.getLayoutParams();
WebView mainView = mTabControl.getCurrentWebView();
// Although we decided whether or not to animate based on the current
// scroll position, the scroll position may have changed since the
// fake title bar was displayed. Make sure it has the appropriate
// animation/lack thereof before removing.
params.windowAnimations = mainView != null && mainView.getScrollY() == 0
? 0 : R.style.TitleBar;
WindowManager manager
= (WindowManager) getSystemService(Context.WINDOW_SERVICE);
manager.updateViewLayout(mFakeTitleBar, params);
manager.removeView(mFakeTitleBar);
}
/**
* Special method for the fake title bar to call when displaying its context
* menu, since it is in its own Window, and its parent does not show a
* context menu.
*/
/* package */ void showTitleBarContextMenu() {
if (null == mTitleBar.getParent()) {
return;
}
openContextMenu(mTitleBar);
}
@Override
public void onContextMenuClosed(Menu menu) {
super.onContextMenuClosed(menu);
if (mInLoad) {
showFakeTitleBar();
}
}
private void showFakeTitleBar() {
if (mFakeTitleBar.getParent() == null && mActiveTabsPage == null
&& !mActivityInPause) {
WebView mainView = mTabControl.getCurrentWebView();
// if there is no current WebView, don't show the faked title bar;
if (mainView == null) {
return;
}
WindowManager manager
= (WindowManager) getSystemService(Context.WINDOW_SERVICE);
// Add the title bar to the window manager so it can receive touches
// while the menu is up
WindowManager.LayoutParams params
= new WindowManager.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_APPLICATION,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);
params.gravity = Gravity.TOP;
boolean atTop = mainView.getScrollY() == 0;
params.windowAnimations = atTop ? 0 : R.style.TitleBar;
manager.addView(mFakeTitleBar, params);
}
}