Search in sources :

Example 1 with PanelState

use of org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState in project AndroidChromium by JackyAndroid.

the class OverlayPanelBase method updatePanelForHeight.

// ============================================================================================
// UI Update Handling
// ============================================================================================
/**
     * Updates the UI state for a given |height|.
     *
     * @param height The Overlay Panel height.
     */
private void updatePanelForHeight(float height) {
    PanelState endState = findLargestPanelStateFromHeight(height);
    PanelState startState = getPreviousPanelState(endState);
    float percentage = getStateCompletion(height, startState, endState);
    updatePanelSize(height);
    if (endState == PanelState.CLOSED || endState == PanelState.PEEKED) {
        updatePanelForCloseOrPeek(percentage);
    } else if (endState == PanelState.EXPANDED) {
        updatePanelForExpansion(percentage);
    } else if (endState == PanelState.MAXIMIZED) {
        updatePanelForMaximization(percentage);
    }
}
Also used : PanelState(org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState)

Example 2 with PanelState

use of org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState in project AndroidChromium by JackyAndroid.

the class OverlayPanelBase method findNearestPanelStateFromHeight.

/**
     * Finds the state which has the nearest height compared to a given
     * |desiredPanelHeight|.
     *
     * @param desiredPanelHeight The height to compare to.
     * @param velocity The velocity of the swipe if applicable. The swipe is upward if less than 0.
     * @return The nearest panel state.
     */
protected PanelState findNearestPanelStateFromHeight(float desiredPanelHeight, float velocity) {
    // If the panel was flung hard enough to make the desired height negative, it's closed.
    if (desiredPanelHeight < 0)
        return PanelState.CLOSED;
    // First, find the two states that the desired panel height is between.
    PanelState nextState = PanelState.values()[0];
    PanelState prevState = nextState;
    for (PanelState state : PanelState.values()) {
        if (!isValidUiState(state)) {
            continue;
        }
        prevState = nextState;
        nextState = state;
        // this to work.
        if (desiredPanelHeight >= getPanelHeightFromState(prevState) && desiredPanelHeight < getPanelHeightFromState(nextState)) {
            break;
        }
    }
    // If the desired height is close enough to a certain state, depending on the direction of
    // the velocity, move to that state.
    float lowerBound = getPanelHeightFromState(prevState);
    float distance = getPanelHeightFromState(nextState) - lowerBound;
    float thresholdToNextState = velocity < 0.0f ? getThresholdToNextState() : 1.0f - getThresholdToNextState();
    if ((desiredPanelHeight - lowerBound) / distance > thresholdToNextState) {
        return nextState;
    } else {
        return prevState;
    }
}
Also used : PanelState(org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState)

Example 3 with PanelState

use of org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState in project AndroidChromium by JackyAndroid.

the class OverlayPanelAnimation method getProjectedState.

/**
     * @param velocity The given velocity.
     * @return The projected state the Panel will be if the given velocity is applied.
     */
protected PanelState getProjectedState(float velocity) {
    final float kickY = calculateAnimationDisplacement(velocity, BASE_ANIMATION_DURATION_MS);
    final float projectedHeight = getHeight() - kickY;
    // Calculate the projected state the Panel will be at the end of the fling movement and the
    // duration of the animation given the current velocity and the projected displacement.
    PanelState projectedState = findNearestPanelStateFromHeight(projectedHeight, velocity);
    return projectedState;
}
Also used : PanelState(org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState)

Example 4 with PanelState

use of org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState in project AndroidChromium by JackyAndroid.

the class OverlayPanelAnimation method animateToNearestState.

// ============================================================================================
// Animation Helpers
// ============================================================================================
/**
     * Animates the Panel to its nearest state.
     */
protected void animateToNearestState() {
    // Calculate the nearest state from the current position, and then calculate the duration
    // of the animation that will start with a desired initial velocity and move the desired
    // amount of dps (displacement).
    final PanelState nearestState = findNearestPanelStateFromHeight(getHeight(), 0.0f);
    final float displacement = getPanelHeightFromState(nearestState) - getHeight();
    final long duration = calculateAnimationDuration(INITIAL_ANIMATION_VELOCITY_DP_PER_SECOND, displacement);
    animatePanelToState(nearestState, StateChangeReason.SWIPE, duration);
}
Also used : PanelState(org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState)

Example 5 with PanelState

use of org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState in project AndroidChromium by JackyAndroid.

the class OverlayPanelAnimation method animateToProjectedState.

/**
     * Animates the Panel to its projected state, given a particular vertical |velocity|.
     *
     * @param velocity The velocity of the gesture in dps per second.
     */
protected void animateToProjectedState(float velocity) {
    PanelState projectedState = getProjectedState(velocity);
    final float displacement = getPanelHeightFromState(projectedState) - getHeight();
    final long duration = calculateAnimationDuration(velocity, displacement);
    animatePanelToState(projectedState, StateChangeReason.FLING, duration);
}
Also used : PanelState(org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState)

Aggregations

PanelState (org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState)6 InfoBarContainer (org.chromium.chrome.browser.infobar.InfoBarContainer)1