use of org.chromium.chrome.browser.appmenu.AppMenuObserver in project AndroidChromium by JackyAndroid.
the class ChromeActivity method initializeToolbar.
/**
* Constructs {@link ToolbarManager} and the handler necessary for controlling the menu on the
* {@link Toolbar}. Extending classes can override this call to avoid creating the toolbar.
*/
protected void initializeToolbar() {
final View controlContainer = findViewById(R.id.control_container);
assert controlContainer != null;
ToolbarControlContainer toolbarContainer = (ToolbarControlContainer) controlContainer;
mAppMenuPropertiesDelegate = createAppMenuPropertiesDelegate();
mAppMenuHandler = sAppMenuHandlerFactory.get(this, mAppMenuPropertiesDelegate, getAppMenuLayoutId());
mToolbarManager = new ToolbarManager(this, toolbarContainer, mAppMenuHandler, mAppMenuPropertiesDelegate, getCompositorViewHolder().getInvalidator());
mAppMenuHandler.addObserver(new AppMenuObserver() {
@Override
public void onMenuVisibilityChanged(boolean isVisible) {
if (isVisible && !isInOverviewMode()) {
// The app menu badge should be removed the first time the menu is opened.
if (mToolbarManager.getToolbar().isShowingAppMenuUpdateBadge()) {
mToolbarManager.getToolbar().removeAppMenuUpdateBadge(true);
mCompositorViewHolder.requestRender();
}
}
if (!isVisible) {
mAppMenuPropertiesDelegate.onMenuDismissed();
MenuItem updateMenuItem = mAppMenuHandler.getAppMenu().getMenu().findItem(R.id.update_menu_id);
if (updateMenuItem != null && updateMenuItem.isVisible()) {
UpdateMenuItemHelper.getInstance().onMenuDismissed();
}
}
}
});
}
use of org.chromium.chrome.browser.appmenu.AppMenuObserver in project AndroidChromium by JackyAndroid.
the class ToolbarManager method setMenuHandler.
/**
* Sets the handler for any special case handling related with the menu button.
* @param menuHandler The handler to be used.
*/
private void setMenuHandler(AppMenuHandler menuHandler) {
menuHandler.addObserver(new AppMenuObserver() {
@Override
public void onMenuVisibilityChanged(boolean isVisible) {
if (mFullscreenManager == null)
return;
if (isVisible) {
mFullscreenMenuToken = mFullscreenManager.showControlsPersistentAndClearOldToken(mFullscreenMenuToken);
} else {
mFullscreenManager.hideControlsPersistent(mFullscreenMenuToken);
mFullscreenMenuToken = FullscreenManager.INVALID_TOKEN;
}
}
});
mAppMenuButtonHelper = new AppMenuButtonHelper(menuHandler);
mAppMenuButtonHelper.setOnAppMenuShownListener(new Runnable() {
@Override
public void run() {
RecordUserAction.record("MobileToolbarShowMenu");
}
});
mLocationBar.setMenuButtonHelper(mAppMenuButtonHelper);
}
Aggregations