Java Code Examples for org.chromium.chrome.browser.util.FeatureUtilities#isChromeHomeEnabled()

The following examples show how to use org.chromium.chrome.browser.util.FeatureUtilities#isChromeHomeEnabled() . 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: 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 2
Source File: NativePageFactory.java    From 365browser with Apache License 2.0 6 votes vote down vote up
protected NativePage buildNewTabPage(ChromeActivity activity, Tab tab,
        TabModelSelector tabModelSelector) {
    if (FeatureUtilities.isChromeHomeEnabled()) {
        if (tab.isIncognito()) {
            return new ChromeHomeIncognitoNewTabPage(activity, tab, tabModelSelector,
                    ((ChromeTabbedActivity) activity).getLayoutManager());
        } else {
            return new ChromeHomeNewTabPage(activity, tab, tabModelSelector,
                    ((ChromeTabbedActivity) activity).getLayoutManager());
        }
    } else if (tab.isIncognito()) {
        return new IncognitoNewTabPage(activity);
    } else {
        return new NewTabPage(activity, new TabShim(tab), tabModelSelector);
    }
}
 
Example 3
Source File: StackLayout.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void onTabCreated(long time, int id, int tabIndex, int sourceId, boolean newIsIncognito,
        boolean background, float originX, float originY) {
    super.onTabCreated(
            time, id, tabIndex, sourceId, newIsIncognito, background, originX, originY);
    startHiding(id, false);
    mStacks[getTabStackIndex(id)].tabCreated(time, id);
    startMarginAnimation(false);
    uiPreemptivelySelectTabModel(newIsIncognito);

    // TODO(twellington): Add a proper tab creation animation rather than disabling the current
    //                    animation.
    if (FeatureUtilities.isChromeHomeEnabled()) {
        onUpdateAnimation(System.currentTimeMillis(), true);
    }
}
 
Example 4
Source File: ChromeTabbedActivity.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
protected int getToolbarLayoutId() {
    if (DeviceFormFactor.isTablet(getApplicationContext())) return R.layout.toolbar_tablet;

    if (FeatureUtilities.isChromeHomeEnabled()) return R.layout.bottom_toolbar_phone;
    return R.layout.toolbar_phone;
}
 
Example 5
Source File: NewTabPageView.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void onUrlFocusAnimationChanged() {
    if (mDisableUrlFocusChangeAnimations || FeatureUtilities.isChromeHomeEnabled()
            || mIsMovingNewTabPageView) {
        return;
    }

    // Translate so that the search box is at the top, but only upwards.
    float percent = mSearchProviderHasLogo ? mUrlFocusChangePercent : 0;
    int basePosition = mRecyclerView.computeVerticalScrollOffset()
            + mNewTabPageLayout.getPaddingTop();
    int target = Math.max(basePosition,
                mSearchBoxView.getBottom() - mSearchBoxView.getPaddingBottom());

    mNewTabPageLayout.setTranslationY(percent * (basePosition - target));
}
 
Example 6
Source File: ToolbarSceneLayer.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onSizeChanged(
        float width, float height, float visibleViewportOffsetY, int orientation) {
    // If Chrome Home is enabled, a size change means the toolbar is now in a different
    // location so a render is needed.
    if (FeatureUtilities.isChromeHomeEnabled()) mRenderHost.requestRender();
}
 
Example 7
Source File: OverviewListLayout.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void adjustForFullscreen() {
    if (mTabModelWrapper == null) return;
    FrameLayout.LayoutParams params =
            (FrameLayout.LayoutParams) mTabModelWrapper.getLayoutParams();
    if (params == null) return;

    int margin = (int) ((getHeight() - getHeightMinusBrowserControls()) * mDpToPx);
    if (FeatureUtilities.isChromeHomeEnabled()) {
        params.bottomMargin = margin;
    } else {
        params.topMargin = margin;
    }
    mTabModelWrapper.setLayoutParams(params);
}
 
Example 8
Source File: SelectableListLayout.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void setEmptyOrLoadingViewStyle(View view) {
    if (!FeatureUtilities.isChromeHomeEnabled()) return;

    ((FrameLayout.LayoutParams) view.getLayoutParams()).gravity = Gravity.CENTER_HORIZONTAL;
    ApiCompatibilityUtils.setPaddingRelative(view, ApiCompatibilityUtils.getPaddingStart(view),
            view.getPaddingTop() + mChromeHomeEmptyAndLoadingViewTopPadding,
            ApiCompatibilityUtils.getPaddingEnd(view), view.getPaddingBottom());
}
 
Example 9
Source File: Stack.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * @return The maximum height of a layout tab in the tab switcher.
 */
public float getMaxTabHeight() {
    if (FeatureUtilities.isChromeHomeEnabled() && mCurrentMode == Orientation.PORTRAIT) {
        return mLayout.getHeight();
    }
    return mLayout.getHeightMinusBrowserControls();
}
 
Example 10
Source File: LayoutManagerChromePhone.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isSwipeEnabled(ScrollDirection direction) {
    if (direction == ScrollDirection.DOWN && FeatureUtilities.isChromeHomeEnabled()) {
        return false;
    }

    return super.isSwipeEnabled(direction);
}
 
Example 11
Source File: ChromeTabbedActivity.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
protected int getToolbarLayoutId() {
    if (DeviceFormFactor.isTablet()) return R.layout.toolbar_tablet;

    if (FeatureUtilities.isChromeHomeEnabled()) return R.layout.bottom_toolbar_phone;
    return R.layout.toolbar_phone;
}
 
Example 12
Source File: ChromeTabbedActivity.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
protected int getControlContainerLayoutId() {
    if (FeatureUtilities.isChromeHomeEnabled()) {
        return R.layout.bottom_control_container;
    }
    return R.layout.control_container;
}
 
Example 13
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 14
Source File: ChromeTabbedActivity.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
protected int getControlContainerLayoutId() {
    if (FeatureUtilities.isChromeHomeEnabled()) {
        return R.layout.bottom_control_container;
    }
    return R.layout.control_container;
}
 
Example 15
Source File: StackAnimationPortrait.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
protected ChromeAnimation<?> createTabFocusedAnimatorSet(
        StackTab[] tabs, int focusIndex, int spacing, float warpSize) {
    ChromeAnimation<Animatable<?>> set = new ChromeAnimation<Animatable<?>>();
    for (int i = 0; i < tabs.length; ++i) {
        StackTab tab = tabs[i];
        LayoutTab layoutTab = tab.getLayoutTab();

        addTiltScrollAnimation(set, layoutTab, 0.0f, TAB_FOCUSED_ANIMATION_DURATION, 0);
        addAnimation(set, tab, DISCARD_AMOUNT, tab.getDiscardAmount(), 0.0f,
                TAB_FOCUSED_ANIMATION_DURATION, 0);

        if (i < focusIndex) {
            // For tabs above the focused tab move them up to 0.
            addAnimation(set, tab, SCROLL_OFFSET, tab.getScrollOffset(),
                    tab.getScrollOffset() - mHeight - spacing, TAB_FOCUSED_ANIMATION_DURATION,
                    0);
        } else if (i > focusIndex) {
            // We also need to animate the Y Translation to move them down
            // off the screen.
            float coveringTabPosition = layoutTab.getY();
            float distanceToBorder = MathUtils.clamp(mHeight - coveringTabPosition, 0, mHeight);
            float delay = TAB_FOCUSED_MAX_DELAY * distanceToBorder / mHeight;
            addAnimation(set, tab, Y_IN_STACK_OFFSET, tab.getYInStackOffset(),
                    tab.getYInStackOffset() + mHeight,
                    (TAB_FOCUSED_ANIMATION_DURATION - (long) delay), (long) delay);
        } else {
            // This is the focused tab.  We need to scale it back to
            // 1.0f, move it to the top of the screen, and animate the
            // YTranslation so that it looks like it is zooming into the
            // full screen view.
            tab.setXOutOfStack(0.0f);
            tab.setYOutOfStack(0.0f);
            layoutTab.setBorderScale(1.f);

            addAnimation(set, tab, SCROLL_OFFSET, tab.getScrollOffset(),
                    Math.max(0.0f, tab.getScrollOffset() - mWidth - spacing),
                    TAB_FOCUSED_ANIMATION_DURATION, 0);
            addAnimation(
                    set, tab, SCALE, tab.getScale(), 1.0f, TAB_FOCUSED_ANIMATION_DURATION, 0);
            int tabYInfluenceDuration = FeatureUtilities.isChromeHomeEnabled()
                    ? TAB_FOCUSED_ANIMATION_DURATION
                    : TAB_FOCUSED_Y_STACK_DURATION;
            addAnimation(set, tab, Y_IN_STACK_INFLUENCE, tab.getYInStackInfluence(), 0.0f,
                    tabYInfluenceDuration, 0);
            addAnimation(set, tab.getLayoutTab(), MAX_CONTENT_HEIGHT,
                    tab.getLayoutTab().getMaxContentHeight(),
                    tab.getLayoutTab().getUnclampedOriginalContentHeight(),
                    TAB_FOCUSED_ANIMATION_DURATION, 0);
            tab.setYOutOfStack(getStaticTabPosition());
            if (layoutTab.shouldStall()) {
                addAnimation(set, layoutTab, SATURATION, 1.0f, 0.0f,
                        TAB_FOCUSED_BORDER_ALPHA_DURATION, TAB_FOCUSED_BORDER_ALPHA_DELAY);
            }
            addAnimation(set, tab.getLayoutTab(), TOOLBAR_ALPHA, layoutTab.getToolbarAlpha(),
                    1.f, TAB_FOCUSED_TOOLBAR_ALPHA_DURATION, TAB_FOCUSED_TOOLBAR_ALPHA_DELAY);
            addAnimation(set, tab.getLayoutTab(), TOOLBAR_Y_OFFSET,
                    getToolbarOffsetToLineUpWithBorder(), 0.f,
                    TAB_FOCUSED_TOOLBAR_ALPHA_DURATION, TAB_FOCUSED_TOOLBAR_ALPHA_DELAY);
            addAnimation(set, tab.getLayoutTab(), SIDE_BORDER_SCALE, 1.f, 0.f,
                    TAB_FOCUSED_TOOLBAR_ALPHA_DURATION, TAB_FOCUSED_TOOLBAR_ALPHA_DELAY);
        }
    }

    return set;
}
 
Example 16
Source File: StackAnimationLandscape.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
protected ChromeAnimation<?> createTabFocusedAnimatorSet(
        StackTab[] tabs, int focusIndex, int spacing, float warpSize) {
    ChromeAnimation<Animatable<?>> set = new ChromeAnimation<Animatable<?>>();
    for (int i = 0; i < tabs.length; ++i) {
        StackTab tab = tabs[i];
        LayoutTab layoutTab = tab.getLayoutTab();

        addTiltScrollAnimation(set, layoutTab, 0.0f, TAB_FOCUSED_ANIMATION_DURATION, 0);
        addAnimation(set, tab, DISCARD_AMOUNT, tab.getDiscardAmount(), 0.0f,
                TAB_FOCUSED_ANIMATION_DURATION, 0);

        if (i < focusIndex) {
            // For tabs left of the focused tab move them left to 0.
            addAnimation(set, tab, SCROLL_OFFSET, tab.getScrollOffset(),
                    Math.max(0.0f, tab.getScrollOffset() - mWidth - spacing),
                    TAB_FOCUSED_ANIMATION_DURATION, 0);
        } else if (i > focusIndex) {
            // We also need to animate the X Translation to move them right
            // off the screen.
            float coveringTabPosition = layoutTab.getX();
            float distanceToBorder = LocalizationUtils.isLayoutRtl()
                    ? coveringTabPosition + layoutTab.getScaledContentWidth()
                    : mWidth - coveringTabPosition;
            float clampedDistanceToBorder = MathUtils.clamp(distanceToBorder, 0, mWidth);
            float delay = TAB_FOCUSED_MAX_DELAY * clampedDistanceToBorder / mWidth;
            addAnimation(set, tab, X_IN_STACK_OFFSET, tab.getXInStackOffset(),
                    tab.getXInStackOffset()
                            + (LocalizationUtils.isLayoutRtl() ? -mWidth : mWidth),
                    (TAB_FOCUSED_ANIMATION_DURATION - (long) delay), (long) delay);
        } else {
            // This is the focused tab.  We need to scale it back to
            // 1.0f, move it to the top of the screen, and animate the
            // X Translation so that it looks like it is zooming into the
            // full screen view.  We move the card to the top left and extend it out so
            // it becomes a full card.
            tab.setXOutOfStack(0);
            tab.setYOutOfStack(0.0f);
            layoutTab.setBorderScale(1.f);

            addAnimation(set, tab, SCROLL_OFFSET, tab.getScrollOffset(),
                    StackTab.screenToScroll(0, warpSize), TAB_FOCUSED_ANIMATION_DURATION, 0);
            addAnimation(
                    set, tab, SCALE, tab.getScale(), 1.0f, TAB_FOCUSED_ANIMATION_DURATION, 0);
            addAnimation(set, tab, X_IN_STACK_INFLUENCE, tab.getXInStackInfluence(), 0.0f,
                    TAB_FOCUSED_ANIMATION_DURATION, 0);
            int tabYInfluenceDuration = FeatureUtilities.isChromeHomeEnabled()
                    ? TAB_FOCUSED_ANIMATION_DURATION
                    : TAB_FOCUSED_Y_STACK_DURATION;
            addAnimation(set, tab, Y_IN_STACK_INFLUENCE, tab.getYInStackInfluence(), 0.0f,
                    tabYInfluenceDuration, 0);

            addAnimation(set, tab.getLayoutTab(), MAX_CONTENT_HEIGHT,
                    tab.getLayoutTab().getMaxContentHeight(),
                    tab.getLayoutTab().getUnclampedOriginalContentHeight(),
                    TAB_FOCUSED_ANIMATION_DURATION, 0);
            tab.setYOutOfStack(getStaticTabPosition());

            if (layoutTab.shouldStall()) {
                addAnimation(set, layoutTab, SATURATION, 1.0f, 0.0f,
                        TAB_FOCUSED_BORDER_ALPHA_DURATION, TAB_FOCUSED_BORDER_ALPHA_DELAY);
            }
            addAnimation(set, tab.getLayoutTab(), TOOLBAR_ALPHA, layoutTab.getToolbarAlpha(),
                    1.f, TAB_FOCUSED_TOOLBAR_ALPHA_DURATION, TAB_FOCUSED_TOOLBAR_ALPHA_DELAY);
            addAnimation(set, tab.getLayoutTab(), TOOLBAR_Y_OFFSET,
                    getToolbarOffsetToLineUpWithBorder(), 0.f,
                    TAB_FOCUSED_TOOLBAR_ALPHA_DURATION, TAB_FOCUSED_TOOLBAR_ALPHA_DELAY);
            addAnimation(set, tab.getLayoutTab(), SIDE_BORDER_SCALE, 1.f, 0.f,
                    TAB_FOCUSED_TOOLBAR_ALPHA_DURATION, TAB_FOCUSED_TOOLBAR_ALPHA_DELAY);
        }
    }

    return set;
}
 
Example 17
Source File: ChromeTabbedActivity.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
protected ChromeFullscreenManager createFullscreenManager() {
    return new ChromeFullscreenManager(this, FeatureUtilities.isChromeHomeEnabled());
}
 
Example 18
Source File: NewTabPage.java    From 365browser with Apache License 2.0 4 votes vote down vote up
private boolean isInSingleUrlBarMode(Context context) {
    if (DeviceFormFactor.isTablet()) return false;
    if (FeatureUtilities.isChromeHomeEnabled()) return false;
    return mSearchProviderHasLogo;
}
 
Example 19
Source File: ChromeTabbedActivity.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
protected ChromeFullscreenManager createFullscreenManager() {
    return new ChromeFullscreenManager(this, FeatureUtilities.isChromeHomeEnabled());
}
 
Example 20
Source File: ToolbarPhone.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
protected void dispatchDraw(Canvas canvas) {
    if (!mTextureCaptureMode && mToolbarBackground.getColor() != Color.TRANSPARENT) {
        // Update to compensate for orientation changes.
        mToolbarBackground.setBounds(0, 0, getWidth(), getHeight());
        mToolbarBackground.draw(canvas);
    }

    if (mLocationBarBackground != null
            && (mLocationBar.getVisibility() == VISIBLE || mTextureCaptureMode)) {
        updateLocationBarBackgroundBounds(mLocationBarBackgroundBounds, mVisualState);
    }

    if (mTextureCaptureMode) {
        drawTabSwitcherAnimationOverlay(canvas, 0.f);
    } else {
        boolean tabSwitcherAnimationFinished = false;
        if (mTabSwitcherModeAnimation != null) {
            tabSwitcherAnimationFinished = !mTabSwitcherModeAnimation.isRunning();

            // Perform the fade logic before super.dispatchDraw(canvas) so that we can properly
            // set the values before the draw happens.
            if (!mAnimateNormalToolbar || FeatureUtilities.isChromeHomeEnabled()) {
                drawTabSwitcherFadeAnimation(
                        tabSwitcherAnimationFinished, mTabSwitcherModePercent);
            }
        }

        super.dispatchDraw(canvas);

        if (mTabSwitcherModeAnimation != null) {
            // Perform the overlay logic after super.dispatchDraw(canvas) as we need to draw on
            // top of the current views.
            if (mAnimateNormalToolbar) {
                drawTabSwitcherAnimationOverlay(canvas, mTabSwitcherModePercent);
            }

            // Clear the animation.
            if (tabSwitcherAnimationFinished) mTabSwitcherModeAnimation = null;
        }
    }
}