Search in sources :

Example 1 with ToolbarManager

use of org.chromium.chrome.browser.toolbar.ToolbarManager 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();
                }
            }
        }
    });
}
Also used : AppMenuObserver(org.chromium.chrome.browser.appmenu.AppMenuObserver) ToolbarManager(org.chromium.chrome.browser.toolbar.ToolbarManager) MenuItem(android.view.MenuItem) DistilledPagePrefsView(org.chromium.chrome.browser.dom_distiller.DistilledPagePrefsView) View(android.view.View) ContentVideoView(org.chromium.content.browser.ContentVideoView) ToolbarControlContainer(org.chromium.chrome.browser.toolbar.ToolbarControlContainer)

Aggregations

MenuItem (android.view.MenuItem)1 View (android.view.View)1 AppMenuObserver (org.chromium.chrome.browser.appmenu.AppMenuObserver)1 DistilledPagePrefsView (org.chromium.chrome.browser.dom_distiller.DistilledPagePrefsView)1 ToolbarControlContainer (org.chromium.chrome.browser.toolbar.ToolbarControlContainer)1 ToolbarManager (org.chromium.chrome.browser.toolbar.ToolbarManager)1 ContentVideoView (org.chromium.content.browser.ContentVideoView)1