org.chromium.chrome.browser.compositor.layouts.phone.stack.StackAnimation.OverviewAnimationType Java Examples

The following examples show how to use org.chromium.chrome.browser.compositor.layouts.phone.stack.StackAnimation.OverviewAnimationType. 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: StackViewAnimation.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * The wrapper method responsible for delegating animation requests to the appropriate helper
 * method.
 * @param type       The type of animation to be created.  This is what determines which helper
 *                   method is called.
 * @param tabs       The tabs that make up the current stack.
 * @param container  The {@link ViewGroup} that {@link View}s can be added to/removed from.
 * @param model      The {@link TabModel} that this animation will influence.
 * @param focusIndex The index of the tab that is the focus of this animation.
 * @return           The resulting {@link Animator} that will animate the Android views.
 */
public Animator createAnimatorForType(OverviewAnimationType type, StackTab[] tabs,
        ViewGroup container, TabModel model, int focusIndex) {
    Animator animator = null;

    if (model != null) {
        switch (type) {
            case NEW_TAB_OPENED:
                animator = createNewTabOpenedAnimator(tabs, container, model, focusIndex);
                break;
            default:
                break;
        }
    }

    return animator;
}
 
Example #2
Source File: StackViewAnimation.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * The wrapper method responsible for delegating animation requests to the appropriate helper
 * method.
 * @param type       The type of animation to be created.  This is what determines which helper
 *                   method is called.
 * @param tabs       The tabs that make up the current stack.
 * @param container  The {@link ViewGroup} that {@link View}s can be added to/removed from.
 * @param model      The {@link TabModel} that this animation will influence.
 * @param focusIndex The index of the tab that is the focus of this animation.
 * @return           The resulting {@link Animator} that will animate the Android views.
 */
public Animator createAnimatorForType(OverviewAnimationType type, StackTab[] tabs,
        ViewGroup container, TabModel model, int focusIndex) {
    Animator animator = null;

    if (model != null) {
        switch (type) {
            case NEW_TAB_OPENED:
                animator = createNewTabOpenedAnimator(tabs, container, model, focusIndex);
                break;
            default:
                break;
        }
    }

    return animator;
}
 
Example #3
Source File: Stack.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Reverts the closure of the tab specified by {@code tabId}.  This will run an undiscard
 * animation on that tab.
 * @param time  The current time of the app in ms.
 * @param tabId The id of the tab to animate.
 */
public void undoClosure(long time, int tabId) {
    createStackTabs(true);
    if (mStackTabs == null) return;

    for (int i = 0; i < mStackTabs.length; i++) {
        StackTab tab = mStackTabs[i];

        if (tab.getId() == tabId) {
            tab.setDiscardAmount(getDiscardRange());
            tab.setDying(false);
            tab.getLayoutTab().setMaxContentHeight(mLayout.getHeightMinusBrowserControls());
        }
    }

    mSpacing = computeSpacing(mStackTabs.length);
    startAnimation(time, OverviewAnimationType.UNDISCARD);
}
 
Example #4
Source File: Stack.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Reverts the closure of the tab specified by {@code tabId}.  This will run an undiscard
 * animation on that tab.
 * @param time  The current time of the app in ms.
 * @param tabId The id of the tab to animate.
 */
public void undoClosure(long time, int tabId) {
    createStackTabs(true);
    if (mStackTabs == null) return;

    for (int i = 0; i < mStackTabs.length; i++) {
        StackTab tab = mStackTabs[i];

        if (tab.getId() == tabId) {
            tab.setDiscardAmount(getDiscardRange());
            tab.setDying(false);
            tab.getLayoutTab().setMaxContentHeight(mLayout.getHeightMinusTopControls());
        }
    }

    mSpacing = computeSpacing(mStackTabs.length);
    startAnimation(time, OverviewAnimationType.UNDISCARD);
}
 
Example #5
Source File: StackViewAnimation.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * The wrapper method responsible for delegating animation requests to the appropriate helper
 * method.
 * @param type       The type of animation to be created.  This is what determines which helper
 *                   method is called.
 * @param tabs       The tabs that make up the current stack.
 * @param container  The {@link ViewGroup} that {@link View}s can be added to/removed from.
 * @param model      The {@link TabModel} that this animation will influence.
 * @param focusIndex The index of the tab that is the focus of this animation.
 * @return           The resulting {@link Animator} that will animate the Android views.
 */
public Animator createAnimatorForType(OverviewAnimationType type, StackTab[] tabs,
        ViewGroup container, TabModel model, int focusIndex) {
    Animator animator = null;

    if (model != null) {
        switch (type) {
            case NEW_TAB_OPENED:
                animator = createNewTabOpenedAnimator(tabs, container, model, focusIndex);
                break;
            default:
                break;
        }
    }

    return animator;
}
 
Example #6
Source File: Stack.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Reverts the closure of the tab specified by {@code tabId}.  This will run an undiscard
 * animation on that tab.
 * @param time  The current time of the app in ms.
 * @param tabId The id of the tab to animate.
 */
public void undoClosure(long time, int tabId) {
    createStackTabs(true);
    if (mStackTabs == null) return;

    for (int i = 0; i < mStackTabs.length; i++) {
        StackTab tab = mStackTabs[i];

        if (tab.getId() == tabId) {
            tab.setDiscardAmount(getDiscardRange());
            tab.setDying(false);
            tab.getLayoutTab().setMaxContentHeight(getMaxTabHeight());
        }
    }

    mSpacing = computeSpacing(mStackTabs.length);
    startAnimation(time, OverviewAnimationType.UNDISCARD);
}
 
Example #7
Source File: Stack.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private boolean allowOverscroll() {
    // All the animations that want to leave the tilt value to be set by the overscroll must
    // be added here.
    return (mOverviewAnimationType == OverviewAnimationType.NONE
                   || mOverviewAnimationType == OverviewAnimationType.VIEW_MORE
                   || mOverviewAnimationType == OverviewAnimationType.ENTER_STACK)
            && mPinch0TabIndex < 0;
}
 
Example #8
Source File: Stack.java    From delion with Apache License 2.0 5 votes vote down vote up
private boolean allowOverscroll() {
    // All the animations that want to leave the tilt value to be set by the overscroll must
    // be added here.
    return (mOverviewAnimationType == OverviewAnimationType.NONE
                   || mOverviewAnimationType == OverviewAnimationType.VIEW_MORE
                   || mOverviewAnimationType == OverviewAnimationType.ENTER_STACK)
            && mPinch0TabIndex < 0;
}
 
Example #9
Source File: Stack.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Called on touch click event.
 *
 * @param time The current time of the app in ms.
 * @param x    The x coordinate in pixel inside the stack view.
 * @param y    The y coordinate in pixel inside the stack view.
 */
public void click(long time, float x, float y) {
    if (mOverviewAnimationType != OverviewAnimationType.NONE
            && mOverviewAnimationType != OverviewAnimationType.DISCARD
            && mOverviewAnimationType != OverviewAnimationType.UNDISCARD
            && mOverviewAnimationType != OverviewAnimationType.DISCARD_ALL) {
        return;
    }
    int clicked = getTabIndexAtPositon(x, y, LayoutTab.getTouchSlop());
    if (clicked >= 0) {
        // Check if the click was within the boundaries of the close button defined by its
        // visible coordinates.
        boolean isRtl =
                !((mCurrentMode == Orientation.PORTRAIT) ^ LocalizationUtils.isLayoutRtl());
        if (mStackTabs[clicked].getLayoutTab().checkCloseHitTest(x, y, isRtl)) {
            // Tell the model to close the tab because the close button was pressed.  The model
            // will then trigger a notification which will start the actual close process here
            // if necessary.
            StackTab tab = mStackTabs[clicked];
            final float halfCloseBtnWidth = LayoutTab.CLOSE_BUTTON_WIDTH_DP / 2.f;
            final float halfCloseBtnHeight = mBorderTopPadding / 2.f;
            final float contentWidth = tab.getLayoutTab().getOriginalContentWidth();

            tab.setDiscardOriginY(halfCloseBtnHeight);
            tab.setDiscardOriginX(isRtl ? halfCloseBtnWidth : contentWidth - halfCloseBtnWidth);
            tab.setDiscardFromClick(true);
            mLayout.uiRequestingCloseTab(time, tab.getId());
            RecordUserAction.record("MobileStackViewCloseTab");
            RecordUserAction.record("MobileTabClosed");
        } else {
            // Let the model know that a new {@link LayoutTab} was selected. The model will
            // notify us if we need to do anything visual. setIndex() will possibly switch the
            // models and broadcast the event.
            mLayout.uiSelectingTab(time, mStackTabs[clicked].getId());
        }
    }
}
 
Example #10
Source File: Stack.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Called when the swipe animation get initiated. It gives a chance to initialize everything.
 * @param time      The current time of the app in ms.
 * @param direction The direction the swipe is in.
 * @param x         The horizontal coordinate the swipe started at in dp.
 * @param y         The vertical coordinate the swipe started at in dp.
 */
public void swipeStarted(long time, ScrollDirection direction, float x, float y) {
    if (direction != ScrollDirection.DOWN) return;

    // Turn off warping the tabs because we need them to track the user's finger.
    setWarpState(false, false);

    // Restart the enter stack animation with the new warp values.
    startAnimation(time, OverviewAnimationType.ENTER_STACK);

    // Update the scroll offset to put the focused tab at the top.
    final int index = mTabModel.index();

    if (mCurrentMode == Orientation.PORTRAIT) {
        mScrollOffset = -index * mSpacing;
    } else {
        mScrollOffset = -index * mSpacing + x - LANDSCAPE_SWIPE_DRAG_TAB_OFFSET_DP;
        mScrollOffset =
                MathUtils.clamp(mScrollOffset, getMinScroll(false), getMaxScroll(false));
    }
    setScrollTarget(mScrollOffset, true);

    // Don't let the tabs even out during this scroll.
    mEvenOutProgress = 1.f;

    // Set up the tracking scroll parameters.
    mSwipeUnboundScrollOffset = mScrollOffset;
    mSwipeBoundedScrollOffset = mScrollOffset;

    // Reset other state.
    mSwipeIsCancelable = false;
    mSwipeCanScroll = false;
    mInSwipe = true;
}
 
Example #11
Source File: Stack.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Decide if the animation can be started without cleaning up the current animation.
 * @param time              The current time of the app in ms.
 * @param type              The type of the animation to start.
 * @param sourceIndex       The source index needed by some animation types.
 * @param finishImmediately Whether the animation jumps straight to the end.
 * @return                  true, if we can start the animation without cleaning up the current
 *                          animation.
 */
private boolean canUpdateAnimation(
        long time, OverviewAnimationType type, int sourceIndex, boolean finishImmediately) {
    if (mAnimationFactory != null) {
        if ((mOverviewAnimationType == OverviewAnimationType.DISCARD
                    || mOverviewAnimationType == OverviewAnimationType.UNDISCARD
                    || mOverviewAnimationType == OverviewAnimationType.DISCARD_ALL)
                && (type == OverviewAnimationType.DISCARD
                           || type == OverviewAnimationType.UNDISCARD
                           || type == OverviewAnimationType.DISCARD_ALL)) {
            return true;
        }
    }
    return false;
}
 
Example #12
Source File: Stack.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Triggers the closing motions.
 *
 * @param time The current time of the app in ms.
 * @param id The id of the tab that get closed.
 */
public void tabClosingEffect(long time, int id) {
    if (mStackTabs == null) return;

    // |id| cannot be used to access the particular tab in the model.
    // The tab is already gone from the model by this point.

    int newIndex = 0;
    boolean needAnimation = false;
    for (int i = 0; i < mStackTabs.length; ++i) {
        if (mStackTabs[i].getId() == id) {
            // Mark the {@link StackTab} as dying so that when the animation is
            // finished we can clear it out of the stack. This supports
            // multiple {@link StackTab} deletions.
            needAnimation |= !mStackTabs[i].isDying();
            mStackTabs[i].setDying(true);
        } else {
            // Update the {@link StackTab} with a new index here.  This makes sure the
            // {@link LayoutTab} end up in the proper place.
            mStackTabs[i].setNewIndex(newIndex++);
        }
    }

    if (needAnimation) {
        mScrollOffsetForDyingTabs = mScrollOffset;
        mSpacing = computeSpacing(newIndex);

        startAnimation(time, OverviewAnimationType.DISCARD);
    }

    if (newIndex == 0) {
        mIsDying = true;
    }
}
 
Example #13
Source File: Stack.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Get called on down touch event.
 *
 * @param time The current time of the app in ms.
 */
public void onDown(long time) {
    mDragLock = DragLock.NONE;
    if (mOverviewAnimationType == OverviewAnimationType.NONE) {
        stopScrollingMovement(time);
    }
    // Resets the scrolling state.
    mScrollingTab = null;
    commitDiscard(time, false);
}
 
Example #14
Source File: Stack.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Get called on long press touch event.
 *
 * @param time The current time of the app in ms.
 * @param x The x coordinate in pixel inside the stack view.
 * @param y The y coordinate in pixel inside the stack view.
 */
public void onLongPress(long time, float x, float y) {
    if (mOverviewAnimationType == OverviewAnimationType.NONE) {
        mLongPressSelected = getTabIndexAtPositon(x, y);
        if (mLongPressSelected >= 0) {
            startAnimation(time, OverviewAnimationType.VIEW_MORE, mLongPressSelected, false);
            mEvenOutProgress = 0.0f;
        }
    }
}
 
Example #15
Source File: Stack.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Called on touch up or cancel event.
 */
public void onUpOrCancel(long time) {
    // Make sure the bottom tab always goes back to the top of the screen.
    if (mPinch0TabIndex >= 0) {
        startAnimation(time, OverviewAnimationType.REACH_TOP);
        requestUpdate();
    }
    // Commit or uncommit discard tab
    commitDiscard(time, true);

    resetInputActionIndices();

    springBack(time);
}
 
Example #16
Source File: Stack.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Cancel scrolling animation which is a part of discarding animation.
 * @return true if the animation is canceled, false, if there is nothing to cancel.
 */
private boolean cancelDiscardScrollingAnimation() {
    if (mOverviewAnimationType == OverviewAnimationType.DISCARD
            || mOverviewAnimationType == OverviewAnimationType.UNDISCARD
            || mOverviewAnimationType == OverviewAnimationType.DISCARD_ALL) {
        mTabAnimations.cancel(null, StackTab.Property.SCROLL_OFFSET);
        return true;
    }
    return false;
}
 
Example #17
Source File: Stack.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Called on touch click event.
 *
 * @param time The current time of the app in ms.
 * @param x    The x coordinate in pixel inside the stack view.
 * @param y    The y coordinate in pixel inside the stack view.
 */
public void click(long time, float x, float y) {
    if (mOverviewAnimationType != OverviewAnimationType.NONE
            && mOverviewAnimationType != OverviewAnimationType.DISCARD
            && mOverviewAnimationType != OverviewAnimationType.UNDISCARD
            && mOverviewAnimationType != OverviewAnimationType.DISCARD_ALL) {
        return;
    }
    int clicked = getTabIndexAtPositon(x, y, LayoutTab.getTouchSlop());
    if (clicked >= 0) {
        // Check if the click was within the boundaries of the close button defined by its
        // visible coordinates.
        boolean isRtl =
                !((mCurrentMode == Orientation.PORTRAIT) ^ LocalizationUtils.isLayoutRtl());
        if (mStackTabs[clicked].getLayoutTab().checkCloseHitTest(x, y, isRtl)) {
            // Tell the model to close the tab because the close button was pressed.  The model
            // will then trigger a notification which will start the actual close process here
            // if necessary.
            StackTab tab = mStackTabs[clicked];
            final float halfCloseBtnWidth = LayoutTab.CLOSE_BUTTON_WIDTH_DP / 2.f;
            final float halfCloseBtnHeight = mBorderTopPadding / 2.f;
            final float contentWidth = tab.getLayoutTab().getOriginalContentWidth();

            tab.setDiscardOriginY(halfCloseBtnHeight);
            tab.setDiscardOriginX(isRtl ? halfCloseBtnWidth : contentWidth - halfCloseBtnWidth);
            tab.setDiscardFromClick(true);
            mLayout.uiRequestingCloseTab(time, tab.getId());
            RecordUserAction.record("MobileStackViewCloseTab");
            RecordUserAction.record("MobileTabClosed");
        } else {
            // Let the model know that a new {@link LayoutTab} was selected. The model will
            // notify us if we need to do anything visual. setIndex() will possibly switch the
            // models and broadcast the event.
            mLayout.uiSelectingTab(time, mStackTabs[clicked].getId());
        }
    }
}
 
Example #18
Source File: Stack.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Called when the swipe animation get initiated. It gives a chance to initialize everything.
 * @param time      The current time of the app in ms.
 * @param direction The direction the swipe is in.
 * @param x         The horizontal coordinate the swipe started at in dp.
 * @param y         The vertical coordinate the swipe started at in dp.
 */
public void swipeStarted(long time, ScrollDirection direction, float x, float y) {
    if (direction != ScrollDirection.DOWN) return;

    // Turn off warping the tabs because we need them to track the user's finger.
    setWarpState(false, false);

    // Restart the enter stack animation with the new warp values.
    startAnimation(time, OverviewAnimationType.ENTER_STACK);

    // Update the scroll offset to put the focused tab at the top.
    final int index = mTabModel.index();

    if (mCurrentMode == Orientation.PORTRAIT) {
        mScrollOffset = -index * mSpacing;
    } else {
        mScrollOffset = -index * mSpacing + x - LANDSCAPE_SWIPE_DRAG_TAB_OFFSET_DP;
        mScrollOffset =
                MathUtils.clamp(mScrollOffset, getMinScroll(false), getMaxScroll(false));
    }
    setScrollTarget(mScrollOffset, true);

    // Don't let the tabs even out during this scroll.
    mEvenOutProgress = 1.f;

    // Set up the tracking scroll parameters.
    mSwipeUnboundScrollOffset = mScrollOffset;
    mSwipeBoundedScrollOffset = mScrollOffset;

    // Reset other state.
    mSwipeIsCancelable = false;
    mSwipeCanScroll = false;
    mInSwipe = true;
}
 
Example #19
Source File: Stack.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private boolean allowOverscroll() {
    // All the animations that want to leave the tilt value to be set by the overscroll must
    // be added here.
    return (mOverviewAnimationType == OverviewAnimationType.NONE
                   || mOverviewAnimationType == OverviewAnimationType.VIEW_MORE
                   || mOverviewAnimationType == OverviewAnimationType.ENTER_STACK)
            && mPinch0TabIndex < 0;
}
 
Example #20
Source File: Stack.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Called on touch click event.
 *
 * @param time The current time of the app in ms.
 * @param x    The x coordinate in pixel inside the stack view.
 * @param y    The y coordinate in pixel inside the stack view.
 */
public void click(long time, float x, float y) {
    if (mOverviewAnimationType != OverviewAnimationType.NONE
            && mOverviewAnimationType != OverviewAnimationType.DISCARD
            && mOverviewAnimationType != OverviewAnimationType.UNDISCARD
            && mOverviewAnimationType != OverviewAnimationType.DISCARD_ALL) {
        return;
    }
    int clicked = getTabIndexAtPositon(x, y, LayoutTab.getTouchSlop());
    if (clicked >= 0) {
        // Check if the click was within the boundaries of the close button defined by its
        // visible coordinates.
        boolean isRtl =
                !((mCurrentMode == Orientation.PORTRAIT) ^ LocalizationUtils.isLayoutRtl());
        if (mStackTabs[clicked].getLayoutTab().checkCloseHitTest(x, y, isRtl)) {
            // Tell the model to close the tab because the close button was pressed.  The model
            // will then trigger a notification which will start the actual close process here
            // if necessary.
            StackTab tab = mStackTabs[clicked];
            final float halfCloseBtnWidth = LayoutTab.CLOSE_BUTTON_WIDTH_DP / 2.f;
            final float halfCloseBtnHeight = mBorderTopPadding / 2.f;
            final float contentWidth = tab.getLayoutTab().getOriginalContentWidth();

            tab.setDiscardOriginY(halfCloseBtnHeight);
            tab.setDiscardOriginX(isRtl ? halfCloseBtnWidth : contentWidth - halfCloseBtnWidth);
            tab.setDiscardFromClick(true);
            mLayout.uiRequestingCloseTab(time, tab.getId());
            RecordUserAction.record("MobileStackViewCloseTab");
            RecordUserAction.record("MobileTabClosed");
        } else {
            // Let the model know that a new {@link LayoutTab} was selected. The model will
            // notify us if we need to do anything visual. setIndex() will possibly switch the
            // models and broadcast the event.
            mLayout.uiSelectingTab(time, mStackTabs[clicked].getId());
        }
    }
}
 
Example #21
Source File: Stack.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Called when the swipe animation get initiated. It gives a chance to initialize everything.
 * @param time      The current time of the app in ms.
 * @param direction The direction the swipe is in.
 * @param x         The horizontal coordinate the swipe started at in dp.
 * @param y         The vertical coordinate the swipe started at in dp.
 */
public void swipeStarted(long time, ScrollDirection direction, float x, float y) {
    if (direction != ScrollDirection.DOWN) return;

    // Turn off warping the tabs because we need them to track the user's finger.
    setWarpState(false, false);

    // Restart the enter stack animation with the new warp values.
    startAnimation(time, OverviewAnimationType.ENTER_STACK);

    // Update the scroll offset to put the focused tab at the top.
    final int index = mTabModel.index();

    if (mCurrentMode == Orientation.PORTRAIT) {
        mScrollOffset = -index * mSpacing;
    } else {
        mScrollOffset = -index * mSpacing + x - LANDSCAPE_SWIPE_DRAG_TAB_OFFSET_DP;
        mScrollOffset =
                MathUtils.clamp(mScrollOffset, getMinScroll(false), getMaxScroll(false));
    }
    setScrollTarget(mScrollOffset, true);

    // Don't let the tabs even out during this scroll.
    mEvenOutProgress = 1.f;

    // Set up the tracking scroll parameters.
    mSwipeUnboundScrollOffset = mScrollOffset;
    mSwipeBoundedScrollOffset = mScrollOffset;

    // Reset other state.
    mSwipeIsCancelable = false;
    mSwipeCanScroll = false;
    mInSwipe = true;
}
 
Example #22
Source File: Stack.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Triggers the closing motions.
 *
 * @param time The current time of the app in ms.
 * @param id The id of the tab that get closed.
 */
public void tabClosingEffect(long time, int id) {
    if (mStackTabs == null) return;

    // |id| cannot be used to access the particular tab in the model.
    // The tab is already gone from the model by this point.

    int newIndex = 0;
    boolean needAnimation = false;
    for (int i = 0; i < mStackTabs.length; ++i) {
        if (mStackTabs[i].getId() == id) {
            // Mark the {@link StackTab} as dying so that when the animation is
            // finished we can clear it out of the stack. This supports
            // multiple {@link StackTab} deletions.
            needAnimation |= !mStackTabs[i].isDying();
            mStackTabs[i].setDying(true);
        } else {
            // Update the {@link StackTab} with a new index here.  This makes sure the
            // {@link LayoutTab} end up in the proper place.
            mStackTabs[i].setNewIndex(newIndex++);
        }
    }

    if (needAnimation) {
        mScrollOffsetForDyingTabs = mScrollOffset;
        mSpacing = computeSpacing(newIndex);

        startAnimation(time, OverviewAnimationType.DISCARD);
    }

    if (newIndex == 0) {
        mIsDying = true;
    }
}
 
Example #23
Source File: Stack.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Animates all the tabs closing at once.
 *
 * @param time The current time of the app in ms.
 */
public void tabsAllClosingEffect(long time) {
    boolean needAnimation = false;

    if (mStackTabs != null) {
        for (int i = 0; i < mStackTabs.length; ++i) {
            needAnimation |= !mStackTabs[i].isDying();
            mStackTabs[i].setDying(true);
        }
    } else {
        // This needs to be set to true to handle the case where both the normal and incognito
        // tabs are being closed.
        needAnimation = true;
    }

    if (needAnimation) {
        mScrollOffsetForDyingTabs = mScrollOffset;
        mSpacing = computeSpacing(0);

        if (mStackTabs != null) {
            boolean isRtl =
                    !((mCurrentMode == Orientation.PORTRAIT) ^ LocalizationUtils.isLayoutRtl());
            for (int i = 0; i < mStackTabs.length; i++) {
                StackTab tab = mStackTabs[i];
                tab.setDiscardOriginY(0.f);
                tab.setDiscardOriginX(
                        isRtl ? 0.f : tab.getLayoutTab().getOriginalContentWidth());
                tab.setDiscardFromClick(true);
            }
        }
        startAnimation(time, OverviewAnimationType.DISCARD_ALL);
    }

    mIsDying = true;
}
 
Example #24
Source File: Stack.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Animates a new tab opening.
 *
 * @param time The current time of the app in ms.
 * @param id The id of the new tab to animate.
 */
public void tabCreated(long time, int id) {
    if (!createTabHelper(id)) return;

    mIsDying = false;
    finishAnimation(time);
    startAnimation(time, OverviewAnimationType.NEW_TAB_OPENED,
            TabModelUtils.getTabIndexById(mTabModel, id), TabModel.INVALID_TAB_INDEX, false);
}
 
Example #25
Source File: Stack.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Called set up the tab stack to the initial state when it is entered.
 *
 * @param time The current time of the app in ms.
 * @param focused Whether or not the stack was focused when entering.
 */
public void stackEntered(long time, boolean focused) {
    // Don't request new thumbnails until the animation is over. We should
    // have cached the visible ones already.
    boolean finishImmediately = !focused;
    mSpacing = computeSpacing(mStackTabs != null ? mStackTabs.length : 0);
    resetAllScrollOffset();
    startAnimation(time, OverviewAnimationType.ENTER_STACK, finishImmediately);
}
 
Example #26
Source File: Stack.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Decide if the animation can be started without cleaning up the current animation.
 * @param time              The current time of the app in ms.
 * @param type              The type of the animation to start.
 * @param sourceIndex       The source index needed by some animation types.
 * @param finishImmediately Whether the animation jumps straight to the end.
 * @return                  true, if we can start the animation without cleaning up the current
 *                          animation.
 */
private boolean canUpdateAnimation(
        long time, OverviewAnimationType type, int sourceIndex, boolean finishImmediately) {
    if (mAnimationFactory != null) {
        if ((mOverviewAnimationType == OverviewAnimationType.DISCARD
                    || mOverviewAnimationType == OverviewAnimationType.UNDISCARD
                    || mOverviewAnimationType == OverviewAnimationType.DISCARD_ALL)
                && (type == OverviewAnimationType.DISCARD
                           || type == OverviewAnimationType.UNDISCARD
                           || type == OverviewAnimationType.DISCARD_ALL)) {
            return true;
        }
    }
    return false;
}
 
Example #27
Source File: Stack.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Cancel scrolling animation which is a part of discarding animation.
 * @return true if the animation is canceled, false, if there is nothing to cancel.
 */
private boolean cancelDiscardScrollingAnimation() {
    if (mOverviewAnimationType == OverviewAnimationType.DISCARD
            || mOverviewAnimationType == OverviewAnimationType.UNDISCARD
            || mOverviewAnimationType == OverviewAnimationType.DISCARD_ALL) {
        mTabAnimations.cancel(null, StackTab.Property.SCROLL_OFFSET);
        return true;
    }
    return false;
}
 
Example #28
Source File: Stack.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Get called on down touch event.
 *
 * @param time The current time of the app in ms.
 */
public void onDown(long time) {
    mDragLock = DragLock.NONE;
    if (mOverviewAnimationType == OverviewAnimationType.NONE) {
        stopScrollingMovement(time);
    }
    // Resets the scrolling state.
    mScrollingTab = null;
    commitDiscard(time, false);
}
 
Example #29
Source File: Stack.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Get called on long press touch event.
 *
 * @param time The current time of the app in ms.
 * @param x The x coordinate in pixel inside the stack view.
 * @param y The y coordinate in pixel inside the stack view.
 */
public void onLongPress(long time, float x, float y) {
    if (mOverviewAnimationType == OverviewAnimationType.NONE) {
        mLongPressSelected = getTabIndexAtPositon(x, y);
        if (mLongPressSelected >= 0) {
            startAnimation(time, OverviewAnimationType.VIEW_MORE, mLongPressSelected, false);
            mEvenOutProgress = 0.0f;
        }
    }
}
 
Example #30
Source File: Stack.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Called on touch up or cancel event.
 */
public void onUpOrCancel(long time) {
    // Make sure the bottom tab always goes back to the top of the screen.
    if (mPinch0TabIndex >= 0) {
        startAnimation(time, OverviewAnimationType.REACH_TOP);
        requestUpdate();
    }
    // Commit or uncommit discard tab
    commitDiscard(time, true);

    resetInputActionIndices();

    springBack(time);
}