Java Code Examples for org.chromium.chrome.browser.ntp.NewTabPage#setUrlFocusChangeAnimationPercent()

The following examples show how to use org.chromium.chrome.browser.ntp.NewTabPage#setUrlFocusChangeAnimationPercent() . 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: LocationBarTablet.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Updates percentage of current the URL focus change animation.
 * @param percent 1.0 is 100% focused, 0 is completely unfocused.
 */
private void setUrlFocusChangePercent(float percent) {
    mUrlFocusChangePercent = percent;

    NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab();
    if (ntp != null) ntp.setUrlFocusChangeAnimationPercent(percent);
}
 
Example 2
Source File: LocationBarTablet.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Updates percentage of current the URL focus change animation.
 * @param percent 1.0 is 100% focused, 0 is completely unfocused.
 */
private void setUrlFocusChangePercent(float percent) {
    mUrlFocusChangePercent = percent;

    NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab();
    if (ntp != null) ntp.setUrlFocusChangeAnimationPercent(percent);
}
 
Example 3
Source File: LocationBarTablet.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Updates percentage of current the URL focus change animation.
 * @param percent 1.0 is 100% focused, 0 is completely unfocused.
 */
private void setUrlFocusChangePercent(float percent) {
    mUrlFocusChangePercent = percent;

    NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab();
    if (ntp != null) ntp.setUrlFocusChangeAnimationPercent(percent);
}
 
Example 4
Source File: ToolbarPhone.java    From delion with Apache License 2.0 4 votes vote down vote up
private void updateUrlExpansionAnimation() {
    if (mIsInTabSwitcherMode || isTabSwitcherAnimationRunning()) {
        mToolbarButtonsContainer.setVisibility(VISIBLE);
        return;
    }

    mLocationBarBackgroundOffset.setEmpty();

    FrameLayout.LayoutParams locationBarLayoutParams =
            getFrameLayoutParams(mPhoneLocationBar);
    int currentLeftMargin = locationBarLayoutParams.leftMargin;
    int currentWidth = locationBarLayoutParams.width;

    float inversePercent = 1f - mUrlExpansionPercent;
    float locationBarTranslationX = mUnfocusedLocationBarLayoutLeft - currentLeftMargin;
    boolean isLocationBarRtl = ApiCompatibilityUtils.isLayoutRtl(mPhoneLocationBar);
    if (isLocationBarRtl) {
        locationBarTranslationX += mUnfocusedLocationBarLayoutWidth - currentWidth;
    }
    locationBarTranslationX *= inversePercent;

    mPhoneLocationBar.setTranslationX(locationBarTranslationX);

    // Negate the location bar translation to keep the URL action container in the same
    // place during the focus expansion.
    if (!isLocationBarRtl || ApiCompatibilityUtils.isLayoutRtl(this)) {
        mUrlActionsContainer.setTranslationX(-locationBarTranslationX);
    }

    mPhoneLocationBar.setUrlFocusChangePercent(mUrlExpansionPercent);

    // Ensure the buttons are invisible after focusing the omnibox to prevent them from
    // accepting click events.
    int toolbarButtonVisibility = mUrlExpansionPercent == 1f ? INVISIBLE : VISIBLE;
    mToolbarButtonsContainer.setVisibility(toolbarButtonVisibility);
    if (mReturnButton.getVisibility() != GONE) {
        mReturnButton.setVisibility(toolbarButtonVisibility);
    }
    if (mHomeButton.getVisibility() != GONE) {
        mHomeButton.setVisibility(toolbarButtonVisibility);
    }

    // Force an invalidation of the location bar to properly handle the clipping of the URL
    // bar text as a result of the url action container translations.
    mPhoneLocationBar.invalidate();
    invalidate();

    Tab currentTab = getToolbarDataProvider().getTab();
    if (currentTab == null) return;

    NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab();
    // Explicitly use the focus change percentage here because it applies scroll compensation
    // that only applies during focus animations.
    if (ntp != null && mUrlFocusChangeInProgress) {
        ntp.setUrlFocusChangeAnimationPercent(mUrlFocusChangePercent);
    }

    if (!isLocationBarShownInNTP()) {
        // Reset these values in case we transitioned to a different page during the
        // transition.
        resetNtpAnimationValues();
        return;
    }

    updateNtpTransitionAnimation();
}
 
Example 5
Source File: ToolbarPhone.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * Updates the parameters relating to expanding the location bar, as the result of either a
 * focus change or scrolling the New Tab Page.
 */
private void updateUrlExpansionAnimation() {
    if (mTabSwitcherState != STATIC_TAB) {
        mToolbarButtonsContainer.setVisibility(VISIBLE);
        return;
    }

    FrameLayout.LayoutParams locationBarLayoutParams = getFrameLayoutParams(mLocationBar);
    int currentLeftMargin = locationBarLayoutParams.leftMargin;
    int currentWidth = locationBarLayoutParams.width;

    float locationBarBaseTranslationX = mUnfocusedLocationBarLayoutLeft - currentLeftMargin;
    boolean isLocationBarRtl = ApiCompatibilityUtils.isLayoutRtl(mLocationBar);
    if (isLocationBarRtl) {
        locationBarBaseTranslationX += mUnfocusedLocationBarLayoutWidth - currentWidth;
    }
    locationBarBaseTranslationX *= 1f - mUrlExpansionPercent;

    mLocationBarBackgroundNtpOffset.setEmpty();
    mLocationBarNtpOffsetLeft = 0;
    mLocationBarNtpOffsetRight = 0;

    Tab currentTab = getToolbarDataProvider().getTab();
    if (currentTab != null) {
        NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab();
        if (ntp != null) {
            ntp.setUrlFocusChangeAnimationPercent(mUrlFocusChangePercent);
        }

        if (isLocationBarShownInNTP()) {
            updateNtpTransitionAnimation();
        } else {
            // Reset these values in case we transitioned to a different page during the
            // transition.
            resetNtpAnimationValues();
        }
    }

    boolean isRtl = ApiCompatibilityUtils.isLayoutRtl(this);

    float locationBarTranslationX;
    // Get the padding straight from the location bar instead of
    // |mLocationBarBackgroundPadding|, because it might be different in incognito mode.
    if (isRtl) {
        locationBarTranslationX = locationBarBaseTranslationX
                + mLocationBarNtpOffsetRight - mLocationBar.getPaddingRight();
    } else {
        locationBarTranslationX = locationBarBaseTranslationX
                + mLocationBarNtpOffsetLeft + mLocationBar.getPaddingLeft();
    }
    mLocationBar.setTranslationX(locationBarTranslationX);

    // Negate the location bar translation to keep the URL action container in the same
    // place during the focus expansion.
    float urlActionsTranslationX = 0;
    if (!isLocationBarRtl || isRtl) {
        urlActionsTranslationX = -locationBarBaseTranslationX;
    }

    if (isRtl) {
        urlActionsTranslationX += mLocationBarNtpOffsetLeft - mLocationBarNtpOffsetRight;
    } else {
        urlActionsTranslationX += mLocationBarNtpOffsetRight - mLocationBarNtpOffsetLeft;
    }
    mUrlActionContainer.setTranslationX(urlActionsTranslationX);

    mLocationBar.setUrlFocusChangePercent(mUrlExpansionPercent);

    // Ensure the buttons are invisible after focusing the omnibox to prevent them from
    // accepting click events.
    int toolbarButtonVisibility = mUrlExpansionPercent == 1f ? INVISIBLE : VISIBLE;
    mToolbarButtonsContainer.setVisibility(toolbarButtonVisibility);
    if (mHomeButton.getVisibility() != GONE) {
        mHomeButton.setVisibility(toolbarButtonVisibility);
    }

    // Force an invalidation of the location bar to properly handle the clipping of the URL
    // bar text as a result of the url action container translations.
    mLocationBar.invalidate();
    invalidate();
}