org.chromium.chrome.browser.fullscreen.FullscreenManager Java Examples

The following examples show how to use org.chromium.chrome.browser.fullscreen.FullscreenManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TabWebContentsObserver.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void didNavigateMainFrame(String url, String baseUrl,
        boolean isNavigationToDifferentPage, boolean isFragmentNavigation, int statusCode) {
    FullscreenManager fullscreenManager = mTab.getFullscreenManager();
    if (isNavigationToDifferentPage && fullscreenManager != null) {
        fullscreenManager.setPersistentFullscreenMode(false);
    }

    RewindableIterator<TabObserver> observers = mTab.getTabObservers();
    while (observers.hasNext()) {
        observers.next().onDidNavigateMainFrame(
                mTab, url, baseUrl, isNavigationToDifferentPage,
                isFragmentNavigation, statusCode);
    }

    mTab.stopSwipeRefreshHandler();
}
 
Example #2
Source File: ToolbarManager.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Triggered when the URL input field has gained or lost focus.
 * @param hasFocus Whether the URL field has gained focus.
 */
@Override
public void onUrlFocusChange(boolean hasFocus) {
    mToolbar.onUrlFocusChange(hasFocus);

    if (mFindToolbarManager != null && hasFocus) mFindToolbarManager.hideToolbar();

    if (mControlsVisibilityDelegate == null) return;
    if (hasFocus) {
        mFullscreenFocusToken = mControlsVisibilityDelegate
                .showControlsPersistentAndClearOldToken(mFullscreenFocusToken);
    } else {
        mControlsVisibilityDelegate.hideControlsPersistent(mFullscreenFocusToken);
        mFullscreenFocusToken = FullscreenManager.INVALID_TOKEN;
    }

    mUrlFocusChangedCallback.onResult(hasFocus);
}
 
Example #3
Source File: Tab.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * @param manager The fullscreen manager that should be notified of changes to this tab (if
 *                set to null, no more updates will come from this tab).
 */
public void setFullscreenManager(FullscreenManager manager) {
    mFullscreenManager = manager;
    if (mFullscreenManager != null) {
        boolean topOffsetsInitialized = !Float.isNaN(mPreviousTopControlsOffsetY)
                && !Float.isNaN(mPreviousContentOffsetY);
        boolean bottomOffsetsInitialized =
                !Float.isNaN(mPreviousBottomControlsOffsetY);
        boolean isChromeHomeEnabled = FeatureUtilities.isChromeHomeEnabled();

        // Make sure the dominant control offsets have been set.
        if ((!topOffsetsInitialized && !isChromeHomeEnabled)
                || (!bottomOffsetsInitialized && isChromeHomeEnabled)) {
            mFullscreenManager.setPositionsForTabToNonFullscreen();
        } else {
            mFullscreenManager.setPositionsForTab(mPreviousTopControlsOffsetY,
                    mPreviousBottomControlsOffsetY,
                    mPreviousContentOffsetY);
        }
        updateFullscreenEnabledState();
    }
}
 
Example #4
Source File: LayoutManagerChrome.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isSwipeEnabled(ScrollDirection direction) {
    FullscreenManager manager = mHost.getFullscreenManager();
    if (getActiveLayout() != mStaticLayout
            || !DeviceClassManager.enableToolbarSwipe()
            || (manager != null && manager.getPersistentFullscreenMode())) {
        return false;
    }

    if (direction == ScrollDirection.DOWN) {
        boolean isAccessibility = AccessibilityUtil.isAccessibilityEnabled();
        return mOverviewLayout != null && !isAccessibility;
    }

    return direction == ScrollDirection.LEFT || direction == ScrollDirection.RIGHT;
}
 
Example #5
Source File: ToolbarManager.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Triggered when the URL input field has gained or lost focus.
 * @param hasFocus Whether the URL field has gained focus.
 */
@Override
public void onUrlFocusChange(boolean hasFocus) {
    mToolbar.onUrlFocusChange(hasFocus);

    if (mFindToolbarManager != null && hasFocus) mFindToolbarManager.hideToolbar();

    if (mControlsVisibilityDelegate == null) return;
    if (hasFocus) {
        mFullscreenFocusToken = mControlsVisibilityDelegate
                .showControlsPersistentAndClearOldToken(mFullscreenFocusToken);
    } else {
        mControlsVisibilityDelegate.hideControlsPersistent(mFullscreenFocusToken);
        mFullscreenFocusToken = FullscreenManager.INVALID_TOKEN;
    }
}
 
Example #6
Source File: ToolbarManager.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * 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 (mControlsVisibilityDelegate == null) return;
            if (isVisible) {
                mFullscreenMenuToken =
                        mControlsVisibilityDelegate.showControlsPersistentAndClearOldToken(
                                mFullscreenMenuToken);
            } else {
                mControlsVisibilityDelegate.hideControlsPersistent(mFullscreenMenuToken);
                mFullscreenMenuToken = FullscreenManager.INVALID_TOKEN;
            }
        }
    });
    mAppMenuButtonHelper = new AppMenuButtonHelper(menuHandler);
    mAppMenuButtonHelper.setOnAppMenuShownListener(new Runnable() {
        @Override
        public void run() {
            RecordUserAction.record("MobileToolbarShowMenu");
        }
    });
    mLocationBar.setMenuButtonHelper(mAppMenuButtonHelper);
}
 
Example #7
Source File: LayoutManagerChrome.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isSwipeEnabled(ScrollDirection direction) {
    FullscreenManager manager = mHost.getFullscreenManager();
    if (getActiveLayout() != mStaticLayout
            || !DeviceClassManager.enableToolbarSwipe(
                       FeatureUtilities.isDocumentMode(mHost.getContext()))
            || (manager != null && manager.getPersistentFullscreenMode())) {
        return false;
    }

    boolean isAccessibility =
            DeviceClassManager.isAccessibilityModeEnabled(mHost.getContext());
    return direction == ScrollDirection.LEFT || direction == ScrollDirection.RIGHT
            || (direction == ScrollDirection.DOWN && mOverviewLayout != null
                       && !isAccessibility);
}
 
Example #8
Source File: ToolbarManager.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Triggered when the URL input field has gained or lost focus.
 * @param hasFocus Whether the URL field has gained focus.
 */
@Override
public void onUrlFocusChange(boolean hasFocus) {
    mToolbar.onUrlFocusChange(hasFocus);

    if (mFindToolbarManager != null && hasFocus) mFindToolbarManager.hideToolbar();

    if (mFullscreenManager == null) return;
    if (hasFocus) {
        mFullscreenFocusToken = mFullscreenManager.showControlsPersistentAndClearOldToken(
                mFullscreenFocusToken);
    } else {
        mFullscreenManager.hideControlsPersistent(mFullscreenFocusToken);
        mFullscreenFocusToken = FullscreenManager.INVALID_TOKEN;
    }
}
 
Example #9
Source File: ToolbarManager.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #10
Source File: TabWebContentsObserver.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void didNavigateMainFrame(String url, String baseUrl,
        boolean isNavigationToDifferentPage, boolean isFragmentNavigation, int statusCode) {
    FullscreenManager fullscreenManager = mTab.getFullscreenManager();
    if (isNavigationToDifferentPage && fullscreenManager != null) {
        fullscreenManager.setPersistentFullscreenMode(false);
    }

    RewindableIterator<TabObserver> observers = mTab.getTabObservers();
    while (observers.hasNext()) {
        observers.next().onDidNavigateMainFrame(
                mTab, url, baseUrl, isNavigationToDifferentPage,
                isFragmentNavigation, statusCode);
    }

    mTab.stopSwipeRefreshHandler();
}
 
Example #11
Source File: Tab.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void onSystemUiVisibilityChange(int visibility) {
    FullscreenManager fullscreenManager = getFullscreenManager();
    if (fullscreenManager != null) {
        fullscreenManager.onContentViewSystemUiVisibilityChange(visibility);
    }
}
 
Example #12
Source File: ToolbarManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * 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 (mControlsVisibilityDelegate == null) return;
            if (isVisible) {
                mFullscreenMenuToken =
                        mControlsVisibilityDelegate.showControlsPersistentAndClearOldToken(
                                mFullscreenMenuToken);
            } else {
                mControlsVisibilityDelegate.hideControlsPersistent(mFullscreenMenuToken);
                mFullscreenMenuToken = FullscreenManager.INVALID_TOKEN;
            }
        }

        @Override
        public void onMenuHighlightChanged(boolean highlighting) {
            mToolbar.setMenuButtonHighlight(highlighting);

            if (mControlsVisibilityDelegate == null) return;
            if (highlighting) {
                mFullscreenHighlightToken =
                        mControlsVisibilityDelegate.showControlsPersistentAndClearOldToken(
                                mFullscreenHighlightToken);
            } else {
                mControlsVisibilityDelegate.hideControlsPersistent(mFullscreenHighlightToken);
                mFullscreenHighlightToken = FullscreenManager.INVALID_TOKEN;
            }
        }
    });
    mAppMenuButtonHelper = new AppMenuButtonHelper(menuHandler);
    mAppMenuButtonHelper.setOnAppMenuShownListener(new Runnable() {
        @Override
        public void run() {
            RecordUserAction.record("MobileToolbarShowMenu");
            mToolbar.onMenuShown();
        }
    });
}
 
Example #13
Source File: Tab.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onSystemUiVisibilityChange(int visibility) {
    FullscreenManager fullscreenManager = getFullscreenManager();
    if (fullscreenManager != null) {
        fullscreenManager.onContentViewSystemUiVisibilityChange(visibility);
    }
}
 
Example #14
Source File: Tab.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onChildViewAdded(View parent, View child) {
    FullscreenManager fullscreenManager = getFullscreenManager();
    if (fullscreenManager != null) {
        fullscreenManager.updateContentViewChildrenState();
    }
}
 
Example #15
Source File: Tab.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onChildViewRemoved(View parent, View child) {
    FullscreenManager fullscreenManager = getFullscreenManager();
    if (fullscreenManager != null) {
        fullscreenManager.updateContentViewChildrenState();
    }
}
 
Example #16
Source File: LayoutManagerDocument.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isSwipeEnabled(ScrollDirection direction) {
    FullscreenManager manager = mHost.getFullscreenManager();
    if (getActiveLayout() != mStaticLayout
            || !FeatureUtilities.isDocumentModeEligible(mHost.getContext())
            || !DeviceClassManager.enableToolbarSwipe(
                       FeatureUtilities.isDocumentMode(mHost.getContext()))
            || (manager != null && manager.getPersistentFullscreenMode())) {
        return false;
    }

    return direction == ScrollDirection.LEFT || direction == ScrollDirection.RIGHT;
}
 
Example #17
Source File: LayoutManagerDocument.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isSwipeEnabled(ScrollDirection direction) {
    FullscreenManager manager = mHost.getFullscreenManager();
    if (getActiveLayout() != mStaticLayout
            || !FeatureUtilities.isDocumentModeEligible(mHost.getContext())
            || !DeviceClassManager.enableToolbarSwipe()
            || (manager != null && manager.getPersistentFullscreenMode())) {
        return false;
    }

    return direction == ScrollDirection.LEFT || direction == ScrollDirection.RIGHT;
}
 
Example #18
Source File: Tab.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Triggers the hiding logic for the view backing the tab.
 */
public final void hide() {
    try {
        TraceEvent.begin("Tab.hide");
        if (isHidden()) return;
        mIsHidden = true;

        if (mContentViewCore != null) mContentViewCore.onHide();

        // Clean up any fullscreen state that might impact other tabs.
        if (mFullscreenManager != null) {
            mFullscreenManager.setPersistentFullscreenMode(false);
            mFullscreenManager.hideControlsPersistent(mFullscreenHungRendererToken);
            mFullscreenHungRendererToken = FullscreenManager.INVALID_TOKEN;
        }

        if (mTabUma != null) mTabUma.onHide();

        mTabRedirectHandler.clear();

        cancelEnableFullscreenLoadDelay();

        // Allow this tab's NativePage to be frozen if it stays hidden for a while.
        NativePageAssassin.getInstance().tabHidden(this);

        for (TabObserver observer : mObservers) observer.onHidden(this);
    } finally {
        TraceEvent.end("Tab.hide");
    }
}
 
Example #19
Source File: Tab.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void onSystemUiVisibilityChange(int visibility) {
    FullscreenManager fullscreenManager = getFullscreenManager();
    if (fullscreenManager != null) {
        fullscreenManager.onContentViewSystemUiVisibilityChange(visibility);
    }
}
 
Example #20
Source File: Tab.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void onChildViewAdded(View parent, View child) {
    FullscreenManager fullscreenManager = getFullscreenManager();
    if (fullscreenManager != null) {
        fullscreenManager.updateContentViewChildrenState();
    }
}
 
Example #21
Source File: Tab.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void onChildViewRemoved(View parent, View child) {
    FullscreenManager fullscreenManager = getFullscreenManager();
    if (fullscreenManager != null) {
        fullscreenManager.updateContentViewChildrenState();
    }
}
 
Example #22
Source File: Tab.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * @param manager The fullscreen manager that should be notified of changes to this tab (if
 *                set to null, no more updates will come from this tab).
 */
public void setFullscreenManager(FullscreenManager manager) {
    mFullscreenManager = manager;
    if (mFullscreenManager != null) {
        boolean topOffsetsInitialized = !Float.isNaN(mPreviousTopControlsOffsetY)
                && !Float.isNaN(mPreviousContentOffsetY);
        boolean bottomOffsetsInitialized =
                !Float.isNaN(mPreviousBottomControlsOffsetY);
        boolean isChromeHomeEnabled = FeatureUtilities.isChromeHomeEnabled();

        // Make sure the dominant control offsets have been set.
        if ((!topOffsetsInitialized && !isChromeHomeEnabled)
                || (!bottomOffsetsInitialized && isChromeHomeEnabled)) {
            mFullscreenManager.setPositionsForTabToNonFullscreen();
        } else {
            mFullscreenManager.setPositionsForTab(mPreviousTopControlsOffsetY,
                    mPreviousBottomControlsOffsetY,
                    mPreviousContentOffsetY);
        }
        updateFullscreenEnabledState();
    }

    // For blimp mode, offset the blimp view by the height of browser controls. This will ensure
    // that the view doesn't get clipped at the bottom of the page and also the touch offsets
    // would work correctly.
    if (getBlimpContents() != null && mFullscreenManager != null) {
        ViewGroup blimpView = getBlimpContents().getView();
        FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) blimpView.getLayoutParams();
        if (lp == null) {
            lp = new FrameLayout.LayoutParams(
                    LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
        }

        lp.topMargin = mFullscreenManager.getTopControlsHeight();
        blimpView.setLayoutParams(lp);
    }
}
 
Example #23
Source File: Tab.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Clears hung renderer state.
 */
private void clearHungRendererState() {
    if (mFullscreenManager == null) return;

    mFullscreenManager.hideControlsPersistent(mFullscreenHungRendererToken);
    mFullscreenHungRendererToken = FullscreenManager.INVALID_TOKEN;
    updateFullscreenEnabledState();
}
 
Example #24
Source File: LayoutManagerDocument.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isSwipeEnabled(ScrollDirection direction) {
    FullscreenManager manager = mHost.getFullscreenManager();
    if (getActiveLayout() != mStaticLayout
            || !FeatureUtilities.isDocumentModeEligible(mHost.getContext())
            || !DeviceClassManager.enableToolbarSwipe()
            || (manager != null && manager.getPersistentFullscreenMode())) {
        return false;
    }

    return direction == ScrollDirection.LEFT || direction == ScrollDirection.RIGHT;
}
 
Example #25
Source File: Tab.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void onChildViewAdded(View parent, View child) {
    FullscreenManager fullscreenManager = getFullscreenManager();
    if (fullscreenManager != null) {
        fullscreenManager.updateContentViewChildrenState();
    }
}
 
Example #26
Source File: LayoutManagerChrome.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isSwipeEnabled(ScrollDirection direction) {
    FullscreenManager manager = mHost.getFullscreenManager();
    if (getActiveLayout() != mStaticLayout
            || !DeviceClassManager.enableToolbarSwipe()
            || (manager != null && manager.getPersistentFullscreenMode())) {
        return false;
    }

    boolean isAccessibility =
            DeviceClassManager.isAccessibilityModeEnabled(mHost.getContext());
    return direction == ScrollDirection.LEFT || direction == ScrollDirection.RIGHT
            || (direction == ScrollDirection.DOWN && mOverviewLayout != null
                       && !isAccessibility);
}
 
Example #27
Source File: Tab.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void onChildViewRemoved(View parent, View child) {
    FullscreenManager fullscreenManager = getFullscreenManager();
    if (fullscreenManager != null) {
        fullscreenManager.updateContentViewChildrenState();
    }
}
 
Example #28
Source File: Tab.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * @param manager The fullscreen manager that should be notified of changes to this tab (if
 *                set to null, no more updates will come from this tab).
 */
public void setFullscreenManager(FullscreenManager manager) {
    mFullscreenManager = manager;
    if (mFullscreenManager != null) {
        if (Float.isNaN(mPreviousFullscreenTopControlsOffsetY)
                || Float.isNaN(mPreviousFullscreenContentOffsetY)) {
            mFullscreenManager.setPositionsForTabToNonFullscreen();
        } else {
            mFullscreenManager.setPositionsForTab(
                    mPreviousFullscreenTopControlsOffsetY, mPreviousFullscreenContentOffsetY);
        }
        mFullscreenManager.showControlsTransient();
        updateFullscreenEnabledState();
    }
}
 
Example #29
Source File: Tab.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * @return An instance of a {@link FullscreenManager}.
 */
protected FullscreenManager getFullscreenManager() {
    return mFullscreenManager;
}
 
Example #30
Source File: LayoutManagerDocument.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isSwipeEnabled(ScrollDirection direction) {
    FullscreenManager fullscreenManager = mHost.getFullscreenManager();
    return direction == ScrollDirection.DOWN && fullscreenManager != null
            && fullscreenManager.getPersistentFullscreenMode();
}