org.chromium.chrome.browser.compositor.layouts.components.LayoutTab Java Examples

The following examples show how to use org.chromium.chrome.browser.compositor.layouts.components.LayoutTab. 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: LayoutManagerChrome.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void startHiding(int nextTabId, boolean hintAtTabSelection) {
    super.startHiding(nextTabId, hintAtTabSelection);

    Layout layoutBeingHidden = getActiveLayout();
    if (isOverviewLayout(layoutBeingHidden)) {
        boolean showToolbar = true;
        if (mEnableAnimations && layoutBeingHidden == mOverviewLayout) {
            final LayoutTab tab = layoutBeingHidden.getLayoutTab(nextTabId);
            showToolbar = tab != null ? !tab.showToolbar() : true;
        }

        boolean creatingNtp = layoutBeingHidden == mOverviewLayout && mCreatingNtp;

        for (OverviewModeObserver observer : mOverviewModeObservers) {
            observer.onOverviewModeStartedHiding(showToolbar, creatingNtp);
        }
    }
}
 
Example #2
Source File: LayoutManagerChrome.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void initLayoutTabFromHost(final int tabId) {
    super.initLayoutTabFromHost(tabId);

    if (getTabModelSelector() == null || getActiveLayout() == null) return;

    TabModelSelector selector = getTabModelSelector();
    Tab tab = selector.getTabById(tabId);
    if (tab == null) return;

    LayoutTab layoutTab = getExistingLayoutTab(tabId);
    if (layoutTab == null) return;

    if (mTitleCache != null && layoutTab.isTitleNeeded()) {
        mTitleCache.getUpdatedTitle(tab, "");
    }
}
 
Example #3
Source File: LayoutManagerChrome.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void startHiding(int nextTabId, boolean hintAtTabSelection) {
    super.startHiding(nextTabId, hintAtTabSelection);

    Layout layoutBeingHidden = getActiveLayout();
    if (isOverviewLayout(layoutBeingHidden)) {
        boolean showToolbar = true;
        if (mEnableAnimations && layoutBeingHidden == mOverviewLayout) {
            final LayoutTab tab = layoutBeingHidden.getLayoutTab(nextTabId);
            showToolbar = tab != null ? !tab.showToolbar() : true;
        }

        boolean creatingNtp = layoutBeingHidden == mOverviewLayout && mCreatingNtp;

        for (OverviewModeObserver observer : mOverviewModeObservers) {
            observer.onOverviewModeStartedHiding(showToolbar, creatingNtp);
        }
    }
}
 
Example #4
Source File: StaticLayout.java    From delion with Apache License 2.0 6 votes vote down vote up
private void setStaticTab(final int id) {
    if (mLayoutTabs != null && mLayoutTabs.length > 0 && mLayoutTabs[0].getId() == id) {
        if (!mLayoutTabs[0].shouldStall()) setPostHideState();
        return;
    }
    TabModel model = mTabModelSelector.getModelForTabId(id);
    if (model == null) return;
    updateCacheVisibleIds(new LinkedList<Integer>(Arrays.asList(id)));
    if (mLayoutTabs == null || mLayoutTabs.length != 1) mLayoutTabs = new LayoutTab[1];
    mLayoutTabs[0] = createLayoutTab(id, model.isIncognito(), NO_CLOSE_BUTTON, NO_TITLE);
    mLayoutTabs[0].setDrawDecoration(false);
    if (mLayoutTabs[0].shouldStall()) {
        setPreHideState();
        mHandler.postDelayed(mUnstallRunnable, HIDE_TIMEOUT_MS);
    } else {
        setPostHideState();
    }
    requestRender();
}
 
Example #5
Source File: LayoutManagerDocumentTabSwitcher.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void initLayoutTabFromHost(final int tabId) {
    if (getTabModelSelector() == null || getActiveLayout() == null) return;

    TabModelSelector selector = ChromeApplication.getDocumentTabModelSelector();
    Tab tab = selector.getTabById(tabId);
    if (tab == null) return;

    LayoutTab layoutTab = getExistingLayoutTab(tabId);
    if (layoutTab == null) return;

    if (mTitleCache != null && layoutTab.isTitleNeeded()) {
        mTitleCache.getUpdatedTitle(tab, "");
    }
    super.initLayoutTabFromHost(tabId);
}
 
Example #6
Source File: SimpleAnimationLayout.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Set up for the tab closing animation
 */
@Override
public void onTabClosing(long time, int id) {
    reset();

    // Make sure any currently running animations can't influence tab if we are reusing it.
    forceAnimationToFinish();

    // Create the {@link LayoutTab} for the tab before it is destroyed.
    TabModel model = mTabModelSelector.getModelForTabId(id);
    if (model != null) {
        mClosedTab = createLayoutTab(id, model.isIncognito(), NO_CLOSE_BUTTON, NO_TITLE);
        mClosedTab.setBorderAlpha(0.0f);
        mLayoutTabs = new LayoutTab[] {mClosedTab};
        updateCacheVisibleIds(new LinkedList<Integer>(Arrays.asList(id)));
    } else {
        mLayoutTabs = null;
        mClosedTab = null;
    }
    // Only close the id at the end when we are done querying the model.
    super.onTabClosing(time, id);
}
 
Example #7
Source File: StackLayout.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes the {@link LayoutTab} a few at a time. This function is to be called once a
 * frame.
 * The logic of that function is not as trivial as it should be because the input array we want
 * to initialize the tab from keeps getting reordered from calls to call. This is needed to
 * get the highest priority tab initialized first.
 *
 * @param sortedPriorityArray The array of all the {@link StackTab} sorted by priority.
 */
private void updateDelayedLayoutTabInit(StackTab[] sortedPriorityArray) {
    if (!mDelayedLayoutTabInitRequired) return;

    int initialized = 0;
    final int count = sortedPriorityArray.length;
    for (int i = 0; i < count; i++) {
        if (initialized >= LAYOUTTAB_ASYNCHRONOUS_INITIALIZATION_BATCH_SIZE) return;

        LayoutTab layoutTab = sortedPriorityArray[i].getLayoutTab();
        // The actual initialization is done by the parent class.
        if (super.initLayoutTabFromHost(layoutTab)) {
            initialized++;
        }
    }
    if (initialized == 0) mDelayedLayoutTabInitRequired = false;
}
 
Example #8
Source File: LayoutManagerChrome.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void startHiding(int nextTabId, boolean hintAtTabSelection) {
    super.startHiding(nextTabId, hintAtTabSelection);

    Layout layoutBeingHidden = getActiveLayout();
    if (isOverviewLayout(layoutBeingHidden)) {
        boolean showToolbar = true;
        if (mEnableAnimations && layoutBeingHidden == mOverviewLayout) {
            final LayoutTab tab = layoutBeingHidden.getLayoutTab(nextTabId);
            showToolbar = tab != null ? !tab.showToolbar() : true;
        }

        boolean creatingNtp = layoutBeingHidden == mOverviewLayout && mCreatingNtp;

        for (OverviewModeObserver observer : mOverviewModeObservers) {
            observer.onOverviewModeStartedHiding(showToolbar, creatingNtp);
        }
    }
}
 
Example #9
Source File: Stack.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
private void updateCurrentMode(int orientation) {
    mCurrentMode = orientation;
    mDiscardDirection = getDefaultDiscardDirection();
    setWarpState(true, false);
    final float opaqueTopPadding = mBorderTopPadding - mBorderTransparentTop;
    mAnimationFactory = StackAnimation.createAnimationFactory(mLayout.getWidth(),
            mLayout.getHeight(), mLayout.getHeightMinusBrowserControls(), mBorderTopPadding,
            opaqueTopPadding, mBorderLeftPadding, mCurrentMode);
    float dpToPx = mLayout.getContext().getResources().getDisplayMetrics().density;
    mViewAnimationFactory = new StackViewAnimation(dpToPx, mLayout.getWidth());
    if (mStackTabs == null) return;
    float width = mLayout.getWidth();
    float height = mLayout.getHeightMinusBrowserControls();
    for (int i = 0; i < mStackTabs.length; i++) {
        LayoutTab tab = mStackTabs[i].getLayoutTab();
        if (tab == null) continue;
        tab.setMaxContentWidth(width);
        tab.setMaxContentHeight(height);
    }
}
 
Example #10
Source File: Stack.java    From 365browser with Apache License 2.0 6 votes vote down vote up
private void updateCurrentMode(int orientation) {
    mCurrentMode = orientation;
    mDiscardDirection = getDefaultDiscardDirection();
    setWarpState(true, false);
    final float opaqueTopPadding = mBorderTopPadding - mBorderTransparentTop;
    mAnimationFactory = StackAnimation.createAnimationFactory(this, mLayout.getWidth(),
            mLayout.getHeight(), mLayout.getHeightMinusBrowserControls(), mBorderTopPadding,
            opaqueTopPadding, mBorderLeftPadding, mCurrentMode);
    float dpToPx = mLayout.getContext().getResources().getDisplayMetrics().density;
    mViewAnimationFactory = new StackViewAnimation(dpToPx, mLayout.getWidth());
    if (mStackTabs == null) return;
    float width = mLayout.getWidth();
    for (int i = 0; i < mStackTabs.length; i++) {
        LayoutTab tab = mStackTabs[i].getLayoutTab();
        if (tab == null) continue;
        tab.setMaxContentWidth(width);
        tab.setMaxContentHeight(getMaxTabHeight());
    }
}
 
Example #11
Source File: StaticLayout.java    From 365browser with Apache License 2.0 6 votes vote down vote up
private void setStaticTab(final int id) {
    if (mLayoutTabs != null && mLayoutTabs.length > 0 && mLayoutTabs[0].getId() == id) {
        if (!mLayoutTabs[0].shouldStall()) setPostHideState();
        return;
    }
    TabModel model = mTabModelSelector.getModelForTabId(id);
    if (model == null) return;

    updateCacheVisibleIdsAndPrimary(new LinkedList<Integer>(Arrays.asList(id)), id);

    if (mLayoutTabs == null || mLayoutTabs.length != 1) mLayoutTabs = new LayoutTab[1];
    mLayoutTabs[0] = createLayoutTab(id, model.isIncognito(), NO_CLOSE_BUTTON, NO_TITLE);
    mLayoutTabs[0].setDrawDecoration(false);
    if (mLayoutTabs[0].shouldStall()) {
        setPreHideState();
        mHandler.postDelayed(mUnstallRunnable, HIDE_TIMEOUT_MS);
    } else {
        setPostHideState();
    }
    requestRender();
}
 
Example #12
Source File: SimpleAnimationLayout.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Set up for the tab closing animation
 */
@Override
public void onTabClosing(long time, int id) {
    reset();

    // Make sure any currently running animations can't influence tab if we are reusing it.
    forceAnimationToFinish();

    // Create the {@link LayoutTab} for the tab before it is destroyed.
    TabModel model = mTabModelSelector.getModelForTabId(id);
    if (model != null) {
        mClosedTab = createLayoutTab(id, model.isIncognito(), NO_CLOSE_BUTTON, NO_TITLE);
        mClosedTab.setBorderAlpha(0.0f);
        mLayoutTabs = new LayoutTab[] {mClosedTab};
        updateCacheVisibleIds(new LinkedList<Integer>(Arrays.asList(id)));
    } else {
        mLayoutTabs = null;
        mClosedTab = null;
    }
    // Only close the id at the end when we are done querying the model.
    super.onTabClosing(time, id);
}
 
Example #13
Source File: StackLayout.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes the {@link LayoutTab} a few at a time. This function is to be called once a
 * frame.
 * The logic of that function is not as trivial as it should be because the input array we want
 * to initialize the tab from keeps getting reordered from calls to call. This is needed to
 * get the highest priority tab initialized first.
 *
 * @param sortedPriorityArray The array of all the {@link StackTab} sorted by priority.
 */
private void updateDelayedLayoutTabInit(StackTab[] sortedPriorityArray) {
    if (!mDelayedLayoutTabInitRequired) return;

    int initialized = 0;
    final int count = sortedPriorityArray.length;
    for (int i = 0; i < count; i++) {
        if (initialized >= LAYOUTTAB_ASYNCHRONOUS_INITIALIZATION_BATCH_SIZE) return;

        LayoutTab layoutTab = sortedPriorityArray[i].getLayoutTab();
        // The actual initialization is done by the parent class.
        if (super.initLayoutTabFromHost(layoutTab)) {
            initialized++;
        }
    }
    if (initialized == 0) mDelayedLayoutTabInitRequired = false;
}
 
Example #14
Source File: StaticTabSceneLayer.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Update {@link StaticTabSceneLayer} with the given parameters.
 *
 * @param dpToPx            The ratio of dp to px.
 * @param contentViewport   The viewport of the content.
 * @param layerTitleCache   The LayerTitleCache.
 * @param tabContentManager The TabContentManager.
 * @param fullscreenManager The FullscreenManager.
 * @param layoutTab         The LayoutTab.
 */
public void update(float dpToPx, Rect contentViewport, LayerTitleCache layerTitleCache,
        TabContentManager tabContentManager, ChromeFullscreenManager fullscreenManager,
        LayoutTab layoutTab) {
    if (layoutTab == null) {
        return;
    }

    float contentOffset =
            fullscreenManager != null ? fullscreenManager.getContentOffset() : 0.f;

    // TODO(dtrainor, clholgat): remove "* dpToPx" once the native part is fully supporting dp.
    nativeUpdateTabLayer(mNativePtr, contentViewport.left, contentViewport.top,
            contentViewport.width(), contentViewport.height(), tabContentManager,
            layoutTab.getId(), mResToolbarControlContainer, layoutTab.canUseLiveTexture(),
            layoutTab.getBackgroundColor(), layoutTab.getRenderX() * dpToPx,
            layoutTab.getRenderY() * dpToPx, layoutTab.getScaledContentWidth() * dpToPx,
            layoutTab.getScaledContentHeight() * dpToPx, contentOffset,
            layoutTab.getStaticToViewBlend(), layoutTab.getSaturation(),
            layoutTab.getBrightness());
}
 
Example #15
Source File: StaticTabSceneLayer.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Update {@link StaticTabSceneLayer} with the given parameters.
 *
 * @param dpToPx            The ratio of dp to px.
 * @param contentViewport   The viewport of the content.
 * @param layerTitleCache   The LayerTitleCache.
 * @param tabContentManager The TabContentManager.
 * @param fullscreenManager The FullscreenManager.
 * @param layoutTab         The LayoutTab.
 */
public void update(float dpToPx, Rect contentViewport, LayerTitleCache layerTitleCache,
        TabContentManager tabContentManager, ChromeFullscreenManager fullscreenManager,
        LayoutTab layoutTab) {
    if (layoutTab == null) {
        return;
    }

    float contentOffset =
            fullscreenManager != null ? fullscreenManager.getContentOffset() : 0.f;

    // TODO(dtrainor, clholgat): remove "* dpToPx" once the native part is fully supporting dp.
    nativeUpdateTabLayer(mNativePtr, contentViewport.left, contentViewport.top,
            contentViewport.width(), contentViewport.height(), tabContentManager,
            layoutTab.getId(), mResToolbarControlContainer, layoutTab.canUseLiveTexture(),
            layoutTab.getBackgroundColor(), layoutTab.getRenderX() * dpToPx,
            layoutTab.getRenderY() * dpToPx, layoutTab.getScaledContentWidth() * dpToPx,
            layoutTab.getScaledContentHeight() * dpToPx, contentOffset,
            layoutTab.getStaticToViewBlend(), layoutTab.getSaturation(),
            layoutTab.getBrightness());
}
 
Example #16
Source File: LayoutManagerDocument.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void initLayoutTabFromHost(final int tabId) {
    if (getTabModelSelector() == null || getActiveLayout() == null) return;

    TabModelSelector selector = getTabModelSelector();
    Tab tab = selector.getTabById(tabId);
    if (tab == null) return;

    LayoutTab layoutTab = mTabCache.get(tabId);
    if (layoutTab == null) return;

    String url = tab.getUrl();
    boolean isNativePage = url != null && url.startsWith(UrlConstants.CHROME_NATIVE_SCHEME);
    int themeColor = tab.getThemeColor();
    // TODO(xingliu): Remove this override themeColor for Blimp tabs. See crbug.com/644774.
    if (tab.isBlimpTab() && tab.getBlimpContents() != null) {
        themeColor = tab.getBlimpContents().getThemeColor();
    }

    boolean canUseLiveTexture = tab.isBlimpTab()
            || tab.getContentViewCore() != null && !tab.isShowingSadTab() && !isNativePage;

    boolean needsUpdate = layoutTab.initFromHost(tab.getBackgroundColor(), tab.shouldStall(),
            canUseLiveTexture, themeColor, ColorUtils.getTextBoxColorForToolbarBackground(
                                mContext.getResources(), tab, themeColor),
            ColorUtils.getTextBoxAlphaForToolbarBackground(tab));
    if (needsUpdate) requestUpdate();

    mHost.requestRender();
}
 
Example #17
Source File: SimpleAnimationLayout.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Animate the closing of a tab
 */
@Override
public void onTabClosed(long time, int id, int nextId, boolean incognito) {
    super.onTabClosed(time, id, nextId, incognito);

    if (mClosedTab != null) {
        TabModel nextModel = mTabModelSelector.getModelForTabId(nextId);
        if (nextModel != null) {
            LayoutTab nextLayoutTab =
                    createLayoutTab(nextId, nextModel.isIncognito(), NO_CLOSE_BUTTON, NO_TITLE);
            nextLayoutTab.setDrawDecoration(false);

            mLayoutTabs = new LayoutTab[] {nextLayoutTab, mClosedTab};
            updateCacheVisibleIds(
                    new LinkedList<Integer>(Arrays.asList(nextId, mClosedTab.getId())));
        } else {
            mLayoutTabs = new LayoutTab[] {mClosedTab};
        }

        forceAnimationToFinish();
        mAnimatedTab = mClosedTab;
        addToAnimation(this, Property.DISCARD_AMOUNT, 0, getDiscardRange(),
                TAB_CLOSED_ANIMATION_DURATION, 0, false,
                BakedBezierInterpolator.FADE_OUT_CURVE);

        mClosedTab = null;
        if (nextModel != null) {
            mTabModelSelector.selectModel(nextModel.isIncognito());
        }
    }
    startHiding(nextId, false);
}
 
Example #18
Source File: ToolbarSwipeLayout.java    From delion with Apache License 2.0 5 votes vote down vote up
private void prepareLayoutTabForSwipe(LayoutTab layoutTab, boolean anonymizeToolbar) {
    assert layoutTab != null;
    if (layoutTab.shouldStall()) layoutTab.setSaturation(0.0f);
    layoutTab.setScale(1.f);
    layoutTab.setBorderScale(1.f);
    layoutTab.setDecorationAlpha(0.f);
    layoutTab.setY(0.f);
    layoutTab.setShowToolbar(mMoveToolbar);
    layoutTab.setAnonymizeToolbar(anonymizeToolbar && ANONYMIZE_NON_FOCUSED_TAB);
}
 
Example #19
Source File: SimpleAnimationLayout.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Animate opening a tab in the foreground.
 *
 * @param id             The id of the new tab to animate.
 * @param sourceId       The id of the tab that spawned this new tab.
 * @param newIsIncognito true if the new tab is an incognito tab.
 * @param originX        The X coordinate of the last touch down event that spawned this tab.
 * @param originY        The Y coordinate of the last touch down event that spawned this tab.
 */
private void tabCreatedInForeground(
        int id, int sourceId, boolean newIsIncognito, float originX, float originY) {
    LayoutTab newLayoutTab = createLayoutTab(id, newIsIncognito, NO_CLOSE_BUTTON, NO_TITLE);
    if (mLayoutTabs == null || mLayoutTabs.length == 0) {
        mLayoutTabs = new LayoutTab[] {newLayoutTab};
    } else {
        mLayoutTabs = new LayoutTab[] {mLayoutTabs[0], newLayoutTab};
    }
    updateCacheVisibleIds(new LinkedList<Integer>(Arrays.asList(id, sourceId)));

    newLayoutTab.setBorderAlpha(0.0f);
    newLayoutTab.setStaticToViewBlend(1.f);

    forceAnimationToFinish();

    Interpolator interpolator = BakedBezierInterpolator.TRANSFORM_CURVE;
    addToAnimation(newLayoutTab, LayoutTab.Property.SCALE, 0.f, 1.f,
            FOREGROUND_ANIMATION_DURATION, 0, false, interpolator);
    addToAnimation(newLayoutTab, LayoutTab.Property.ALPHA, 0.f, 1.f,
            FOREGROUND_ANIMATION_DURATION, 0, false, interpolator);
    addToAnimation(newLayoutTab, LayoutTab.Property.X, originX, 0.f,
            FOREGROUND_ANIMATION_DURATION, 0, false, interpolator);
    addToAnimation(newLayoutTab, LayoutTab.Property.Y, originY, 0.f,
            FOREGROUND_ANIMATION_DURATION, 0, false, interpolator);

    mTabModelSelector.selectModel(newIsIncognito);
    startHiding(id, false);

    if (mForegroundTabCreationAnimationDisabled) forceAnimationToFinish();
}
 
Example #20
Source File: StackAnimation.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Responsible for generating the animations that make all the tabs do a full roll.
 *
 * @param tabs The tabs that make up the stack. These are the tabs that will be affected by the
 *             animations.
 * @return     The TabSwitcherAnimation instance that will tween the tabs to create the
 *             appropriate animation.
 */
protected ChromeAnimation<?> createFullRollAnimatorSet(StackTab[] tabs) {
    ChromeAnimation<Animatable<?>> set = new ChromeAnimation<Animatable<?>>();

    for (int i = 0; i < tabs.length; ++i) {
        LayoutTab layoutTab = tabs[i].getLayoutTab();
        // Set the pivot
        layoutTab.setTiltX(layoutTab.getTiltX(), layoutTab.getScaledContentHeight() / 2.0f);
        layoutTab.setTiltY(layoutTab.getTiltY(), layoutTab.getScaledContentWidth() / 2.0f);
        // Create the angle animation
        addTiltScrollAnimation(set, layoutTab, -360.0f, FULL_ROLL_ANIMATION_DURATION, 0);
    }

    return set;
}
 
Example #21
Source File: ToolbarSwipeLayout.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private void prepareLayoutTabForSwipe(LayoutTab layoutTab, boolean anonymizeToolbar) {
    assert layoutTab != null;
    if (layoutTab.shouldStall()) layoutTab.setSaturation(0.0f);
    layoutTab.setScale(1.f);
    layoutTab.setBorderScale(1.f);
    layoutTab.setDecorationAlpha(0.f);
    layoutTab.setY(0.f);
    layoutTab.setShowToolbar(mMoveToolbar);
    layoutTab.setAnonymizeToolbar(anonymizeToolbar && ANONYMIZE_NON_FOCUSED_TAB);
}
 
Example #22
Source File: Layout.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * @param id The id of the {@link LayoutTab} to search for.
 * @return   A {@link LayoutTab} represented by a {@link Tab} with an id of {@code id}.
 */
public LayoutTab getLayoutTab(int id) {
    if (mLayoutTabs != null) {
        for (int i = 0; i < mLayoutTabs.length; i++) {
            if (mLayoutTabs[i].getId() == id) return mLayoutTabs[i];
        }
    }
    return null;
}
 
Example #23
Source File: StaticLayout.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    mUnstalling = false;
    if (mLayoutTabs == null || mLayoutTabs.length == 0) return;
    addToAnimation(mLayoutTabs[0], LayoutTab.Property.SATURATION,
            mLayoutTabs[0].getSaturation(), 1.0f, HIDE_DURATION_MS, 0);
    addToAnimation(mLayoutTabs[0], LayoutTab.Property.STATIC_TO_VIEW_BLEND,
            mLayoutTabs[0].getStaticToViewBlend(), 0.0f, HIDE_DURATION_MS, 0);
    mLayoutTabs[0].setShouldStall(false);
}
 
Example #24
Source File: StaticLayout.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    mUnstalling = false;
    if (mLayoutTabs == null || mLayoutTabs.length == 0) return;
    addToAnimation(mLayoutTabs[0], LayoutTab.Property.SATURATION,
            mLayoutTabs[0].getSaturation(), 1.0f, HIDE_DURATION_MS, 0);
    addToAnimation(mLayoutTabs[0], LayoutTab.Property.STATIC_TO_VIEW_BLEND,
            mLayoutTabs[0].getStaticToViewBlend(), 0.0f, HIDE_DURATION_MS, 0);
    mLayoutTabs[0].setShouldStall(false);
}
 
Example #25
Source File: StackLayout.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private int appendVisibleLayoutTabs(long time, int stackIndex, LayoutTab[] tabs, int tabIndex) {
    final StackTab[] stackTabs = mStacks[stackIndex].getTabs();
    if (stackTabs != null) {
        for (int i = 0; i < stackTabs.length; i++) {
            LayoutTab t = stackTabs[i].getLayoutTab();
            if (t.isVisible()) tabs[tabIndex++] = t;
        }
    }
    return tabIndex;
}
 
Example #26
Source File: SimpleAnimationLayout.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Animate opening a tab in the foreground.
 *
 * @param id             The id of the new tab to animate.
 * @param sourceId       The id of the tab that spawned this new tab.
 * @param newIsIncognito true if the new tab is an incognito tab.
 * @param originX        The X coordinate of the last touch down event that spawned this tab.
 * @param originY        The Y coordinate of the last touch down event that spawned this tab.
 */
private void tabCreatedInForeground(
        int id, int sourceId, boolean newIsIncognito, float originX, float originY) {
    LayoutTab newLayoutTab = createLayoutTab(id, newIsIncognito, NO_CLOSE_BUTTON, NO_TITLE);
    if (mLayoutTabs == null || mLayoutTabs.length == 0) {
        mLayoutTabs = new LayoutTab[] {newLayoutTab};
    } else {
        mLayoutTabs = new LayoutTab[] {mLayoutTabs[0], newLayoutTab};
    }
    updateCacheVisibleIds(new LinkedList<Integer>(Arrays.asList(id, sourceId)));

    newLayoutTab.setBorderAlpha(0.0f);
    newLayoutTab.setStaticToViewBlend(1.f);

    forceAnimationToFinish();

    Interpolator interpolator = BakedBezierInterpolator.TRANSFORM_CURVE;
    addToAnimation(newLayoutTab, LayoutTab.Property.SCALE, 0.f, 1.f,
            FOREGROUND_ANIMATION_DURATION, 0, false, interpolator);
    addToAnimation(newLayoutTab, LayoutTab.Property.ALPHA, 0.f, 1.f,
            FOREGROUND_ANIMATION_DURATION, 0, false, interpolator);
    addToAnimation(newLayoutTab, LayoutTab.Property.X, originX, 0.f,
            FOREGROUND_ANIMATION_DURATION, 0, false, interpolator);
    addToAnimation(newLayoutTab, LayoutTab.Property.Y, originY, 0.f,
            FOREGROUND_ANIMATION_DURATION, 0, false, interpolator);

    mTabModelSelector.selectModel(newIsIncognito);
    startHiding(id, false);
}
 
Example #27
Source File: CompositorView.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Converts the layout into compositor layers. This is to be called on every frame the layout
 * is changing.
 * @param provider               Provides the layout to be rendered.
 * @param forRotation            Whether or not this is a special draw during a rotation.
 */
public void finalizeLayers(final LayoutProvider provider, boolean forRotation,
        final DrawingInfo progressBarDrawingInfo) {
    TraceEvent.begin("CompositorView:finalizeLayers");
    Layout layout = provider.getActiveLayout();
    if (layout == null || mNativeCompositorView == 0) {
        TraceEvent.end("CompositorView:finalizeLayers");
        return;
    }

    if (!mPreloadedResources) {
        // Attempt to prefetch any necessary resources
        mResourceManager.preloadResources(AndroidResourceType.STATIC,
                StaticResourcePreloads.getSynchronousResources(getContext()),
                StaticResourcePreloads.getAsynchronousResources(getContext()));
        mPreloadedResources = true;
    }

    // IMPORTANT: Do not do anything that impacts the compositor layer tree before this line.
    // If you do, you could inadvertently trigger follow up renders.  For further information
    // see dtrainor@, tedchoc@, or klobag@.

    provider.getViewportPixel(mCacheViewport);

    nativeSetLayoutBounds(mNativeCompositorView);

    SceneLayer sceneLayer =
            provider.getUpdatedActiveSceneLayer(mCacheViewport, mLayerTitleCache,
                    mTabContentManager, mResourceManager, provider.getFullscreenManager());

    nativeSetSceneLayer(mNativeCompositorView, sceneLayer);

    final LayoutTab[] tabs = layout.getLayoutTabsToRender();
    final int tabsCount = tabs != null ? tabs.length : 0;
    mLastLayerCount = tabsCount;
    TabModelImpl.flushActualTabSwitchLatencyMetric();
    nativeFinalizeLayers(mNativeCompositorView);
    TraceEvent.end("CompositorView:finalizeLayers");
}
 
Example #28
Source File: SimpleAnimationLayout.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Animate the closing of a tab
 */
@Override
public void onTabClosed(long time, int id, int nextId, boolean incognito) {
    super.onTabClosed(time, id, nextId, incognito);

    if (mClosedTab != null) {
        TabModel nextModel = mTabModelSelector.getModelForTabId(nextId);
        if (nextModel != null) {
            LayoutTab nextLayoutTab =
                    createLayoutTab(nextId, nextModel.isIncognito(), NO_CLOSE_BUTTON, NO_TITLE);
            nextLayoutTab.setDrawDecoration(false);

            mLayoutTabs = new LayoutTab[] {nextLayoutTab, mClosedTab};
            updateCacheVisibleIds(
                    new LinkedList<Integer>(Arrays.asList(nextId, mClosedTab.getId())));
        } else {
            mLayoutTabs = new LayoutTab[] {mClosedTab};
        }

        forceAnimationToFinish();
        mAnimatedTab = mClosedTab;
        addToAnimation(this, Property.DISCARD_AMOUNT, 0, getDiscardRange(),
                TAB_CLOSED_ANIMATION_DURATION, 0, false,
                BakedBezierInterpolator.FADE_OUT_CURVE);

        mClosedTab = null;
        if (nextModel != null) {
            mTabModelSelector.selectModel(nextModel.isIncognito());
        }
    }
    startHiding(nextId, false);
}
 
Example #29
Source File: StackLayout.java    From delion with Apache License 2.0 5 votes vote down vote up
private int appendVisibleLayoutTabs(long time, int stackIndex, LayoutTab[] tabs, int tabIndex) {
    final StackTab[] stackTabs = mStacks[stackIndex].getTabs();
    if (stackTabs != null) {
        for (int i = 0; i < stackTabs.length; i++) {
            LayoutTab t = stackTabs[i].getLayoutTab();
            if (t.isVisible()) tabs[tabIndex++] = t;
        }
    }
    return tabIndex;
}
 
Example #30
Source File: LayoutManagerDocument.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void initLayoutTabFromHost(final int tabId) {
    if (getTabModelSelector() == null || getActiveLayout() == null) return;

    TabModelSelector selector = getTabModelSelector();
    Tab tab = selector.getTabById(tabId);
    if (tab == null) return;

    LayoutTab layoutTab = mTabCache.get(tabId);
    if (layoutTab == null) return;

    String url = tab.getUrl();
    boolean isNativePage = url != null && url.startsWith(UrlConstants.CHROME_NATIVE_URL_PREFIX);
    int themeColor = tab.getThemeColor();

    boolean canUseLiveTexture =
            tab.getContentViewCore() != null && !tab.isShowingSadTab() && !isNativePage;

    boolean isNtp = tab.getNativePage() instanceof NewTabPage;
    boolean needsUpdate = layoutTab.initFromHost(tab.getBackgroundColor(), tab.shouldStall(),
            canUseLiveTexture, themeColor,
            ColorUtils.getTextBoxColorForToolbarBackground(
                    mContext.getResources(), isNtp, themeColor),
            ColorUtils.getTextBoxAlphaForToolbarBackground(tab));
    if (needsUpdate) requestUpdate();

    mHost.requestRender();
}