Search in sources :

Example 1 with ControlContainer

use of org.chromium.chrome.browser.widget.ControlContainer in project AndroidChromium by JackyAndroid.

the class ChromeActivity method setTabModelSelector.

/**
     * Sets the {@link TabModelSelector} owned by this {@link ChromeActivity}.
     * @param tabModelSelector A {@link TabModelSelector} instance.
     */
protected void setTabModelSelector(TabModelSelector tabModelSelector) {
    mTabModelSelector = tabModelSelector;
    if (mTabModelSelectorTabObserver != null)
        mTabModelSelectorTabObserver.destroy();
    mTabModelSelectorTabObserver = new TabModelSelectorTabObserver(tabModelSelector) {

        @Override
        public void didFirstVisuallyNonEmptyPaint(Tab tab) {
            if (DataUseTabUIManager.checkAndResetDataUseTrackingStarted(tab) && DataUseTabUIManager.shouldShowDataUseStartedUI()) {
                mDataUseSnackbarController.showDataUseTrackingStartedBar();
            } else if (DataUseTabUIManager.shouldShowDataUseEndedUI() && DataUseTabUIManager.shouldShowDataUseEndedSnackbar(getApplicationContext()) && DataUseTabUIManager.checkAndResetDataUseTrackingEnded(tab)) {
                mDataUseSnackbarController.showDataUseTrackingEndedBar();
            }
        }

        @Override
        public void onShown(Tab tab) {
            setStatusBarColor(tab, tab.getThemeColor());
        }

        @Override
        public void onHidden(Tab tab) {
            mDataUseSnackbarController.dismissDataUseBar();
        }

        @Override
        public void onDestroyed(Tab tab) {
            mDataUseSnackbarController.dismissDataUseBar();
        }

        @Override
        public void onLoadStopped(Tab tab, boolean toDifferentDocument) {
            postDeferredStartupIfNeeded();
        }

        @Override
        public void onPageLoadFinished(Tab tab) {
            postDeferredStartupIfNeeded();
            OfflinePageUtils.showOfflineSnackbarIfNecessary(ChromeActivity.this, tab);
        }

        @Override
        public void onCrash(Tab tab, boolean sadTabShown) {
            postDeferredStartupIfNeeded();
        }

        @Override
        public void onDidChangeThemeColor(Tab tab, int color) {
            if (getActivityTab() != tab)
                return;
            setStatusBarColor(tab, color);
            if (getToolbarManager() == null)
                return;
            getToolbarManager().updatePrimaryColor(color, true);
            ControlContainer controlContainer = (ControlContainer) findViewById(R.id.control_container);
            controlContainer.getToolbarResourceAdapter().invalidate(null);
        }
    };
    if (mAssistStatusHandler != null) {
        mAssistStatusHandler.setTabModelSelector(tabModelSelector);
    }
}
Also used : Tab(org.chromium.chrome.browser.tab.Tab) ToolbarControlContainer(org.chromium.chrome.browser.toolbar.ToolbarControlContainer) ControlContainer(org.chromium.chrome.browser.widget.ControlContainer) TabModelSelectorTabObserver(org.chromium.chrome.browser.tabmodel.TabModelSelectorTabObserver) SuppressLint(android.annotation.SuppressLint)

Example 2 with ControlContainer

use of org.chromium.chrome.browser.widget.ControlContainer in project AndroidChromium by JackyAndroid.

the class ToolbarSceneLayer method update.

/**
     * Update the toolbar and progress bar layers.
     *
     * @param topControlsBackgroundColor The background color of the top controls.
     * @param topControlsUrlBarAlpha The alpha of the URL bar.
     * @param fullscreenManager A ChromeFullscreenManager instance.
     * @param resourceManager A ResourceManager for loading static resources.
     * @param forceHideAndroidTopControls True if the Android top controls are being hidden.
     * @param sizingFlags The sizing flags for the toolbar.
     * @param isTablet If the device is a tablet.
     */
private void update(int topControlsBackgroundColor, float topControlsUrlBarAlpha, ChromeFullscreenManager fullscreenManager, ResourceManager resourceManager, boolean forceHideAndroidTopControls, int sizingFlags, boolean isTablet) {
    if (!DeviceClassManager.enableFullscreen())
        return;
    if (fullscreenManager == null)
        return;
    ControlContainer toolbarContainer = fullscreenManager.getControlContainer();
    if (!isTablet && toolbarContainer != null) {
        if (mProgressBarDrawingInfo == null)
            mProgressBarDrawingInfo = new DrawingInfo();
        toolbarContainer.getProgressBarDrawingInfo(mProgressBarDrawingInfo);
    } else {
        assert mProgressBarDrawingInfo == null;
    }
    float offset = fullscreenManager.getControlOffset();
    boolean useTexture = fullscreenManager.drawControlsAsTexture() || offset == 0 || forceHideAndroidTopControls;
    fullscreenManager.setHideTopControlsAndroidView(forceHideAndroidTopControls);
    if ((sizingFlags & SizingFlags.REQUIRE_FULLSCREEN_SIZE) != 0 && (sizingFlags & SizingFlags.ALLOW_TOOLBAR_HIDE) == 0 && (sizingFlags & SizingFlags.ALLOW_TOOLBAR_ANIMATE) == 0) {
        useTexture = false;
    }
    nativeUpdateToolbarLayer(mNativePtr, resourceManager, R.id.control_container, topControlsBackgroundColor, R.drawable.textbox, topControlsUrlBarAlpha, offset, useTexture, forceHideAndroidTopControls);
    if (mProgressBarDrawingInfo == null)
        return;
    nativeUpdateProgressBar(mNativePtr, mProgressBarDrawingInfo.progressBarRect.left, mProgressBarDrawingInfo.progressBarRect.top, mProgressBarDrawingInfo.progressBarRect.width(), mProgressBarDrawingInfo.progressBarRect.height(), mProgressBarDrawingInfo.progressBarColor, mProgressBarDrawingInfo.progressBarBackgroundRect.left, mProgressBarDrawingInfo.progressBarBackgroundRect.top, mProgressBarDrawingInfo.progressBarBackgroundRect.width(), mProgressBarDrawingInfo.progressBarBackgroundRect.height(), mProgressBarDrawingInfo.progressBarBackgroundColor);
}
Also used : DrawingInfo(org.chromium.chrome.browser.widget.ClipDrawableProgressBar.DrawingInfo) ControlContainer(org.chromium.chrome.browser.widget.ControlContainer)

Example 3 with ControlContainer

use of org.chromium.chrome.browser.widget.ControlContainer in project AndroidChromium by JackyAndroid.

the class FullScreenActivity method finishNativeInitialization.

@Override
public void finishNativeInitialization() {
    mTab = createTab();
    getTabModelSelector().setTab(mTab);
    mTab.show(TabSelectionType.FROM_NEW);
    ControlContainer controlContainer = (ControlContainer) findViewById(R.id.control_container);
    initializeCompositorContent(new LayoutManagerDocument(getCompositorViewHolder()), (View) controlContainer, (ViewGroup) findViewById(android.R.id.content), controlContainer);
    getActivityTab().setFullscreenManager(getFullscreenManager());
    super.finishNativeInitialization();
}
Also used : ControlContainer(org.chromium.chrome.browser.widget.ControlContainer) LayoutManagerDocument(org.chromium.chrome.browser.compositor.layouts.LayoutManagerDocument)

Aggregations

ControlContainer (org.chromium.chrome.browser.widget.ControlContainer)3 SuppressLint (android.annotation.SuppressLint)1 LayoutManagerDocument (org.chromium.chrome.browser.compositor.layouts.LayoutManagerDocument)1 Tab (org.chromium.chrome.browser.tab.Tab)1 TabModelSelectorTabObserver (org.chromium.chrome.browser.tabmodel.TabModelSelectorTabObserver)1 ToolbarControlContainer (org.chromium.chrome.browser.toolbar.ToolbarControlContainer)1 DrawingInfo (org.chromium.chrome.browser.widget.ClipDrawableProgressBar.DrawingInfo)1