Search in sources :

Example 1 with AppMenuObserver

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();
                }
            }
        }
    });
}
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)

Example 2 with AppMenuObserver

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);
}
Also used : AppMenuButtonHelper(org.chromium.chrome.browser.appmenu.AppMenuButtonHelper) AppMenuObserver(org.chromium.chrome.browser.appmenu.AppMenuObserver)

Aggregations

AppMenuObserver (org.chromium.chrome.browser.appmenu.AppMenuObserver)2 MenuItem (android.view.MenuItem)1 View (android.view.View)1 AppMenuButtonHelper (org.chromium.chrome.browser.appmenu.AppMenuButtonHelper)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