Java Code Examples for org.chromium.chrome.browser.omnibox.LocationBarLayout#getSecurityIconResource()

The following examples show how to use org.chromium.chrome.browser.omnibox.LocationBarLayout#getSecurityIconResource() . 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: CustomTabToolbar.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void updateSecurityIcon(int securityLevel) {
    if (mState == STATE_TITLE_ONLY) return;

    mSecurityIconType = securityLevel;

    if (securityLevel == ConnectionSecurityLevel.NONE) {
        mAnimDelegate.hideSecurityButton();
    } else {
        boolean isSmallDevice = !DeviceFormFactor.isTablet(getContext());
        int id = LocationBarLayout.getSecurityIconResource(securityLevel, isSmallDevice);
        if (id == 0) {
            mSecurityButton.setImageDrawable(null);
        } else {
            // ImageView#setImageResource is no-op if given resource is the current one.
            mSecurityButton.setImageResource(id);
            mSecurityButton.setTint(LocationBarLayout.getColorStateList(
                    securityLevel, getToolbarDataProvider(), getResources()));
        }
        mAnimDelegate.showSecurityButton();
    }
    mUrlBar.emphasizeUrl();
    mUrlBar.invalidate();
}
 
Example 2
Source File: WebappUrlBar.java    From delion with Apache License 2.0 5 votes vote down vote up
private void updateSecurityIcon(int securityLevel) {
    boolean isSmallDevice = !DeviceFormFactor.isTablet(getContext());
    mCurrentIconResource =
            LocationBarLayout.getSecurityIconResource(securityLevel, isSmallDevice);

    if (mCurrentIconResource != 0 && mIconResourceWidths.get(mCurrentIconResource, -1) == -1) {
        Drawable icon = ApiCompatibilityUtils.getDrawable(getResources(), mCurrentIconResource);
        mIconResourceWidths.put(mCurrentIconResource, icon.getIntrinsicWidth());
    }

    ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(mUrlBar,
            mCurrentIconResource, 0, 0, 0);
}
 
Example 3
Source File: WebappUrlBar.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private void updateSecurityIcon(int securityLevel) {
    boolean isSmallDevice = !DeviceFormFactor.isTablet(getContext());
    mCurrentIconResource =
            LocationBarLayout.getSecurityIconResource(securityLevel, isSmallDevice, false);

    if (mCurrentIconResource != 0 && mIconResourceWidths.get(mCurrentIconResource, -1) == -1) {
        Drawable icon = ApiCompatibilityUtils.getDrawable(getResources(), mCurrentIconResource);
        mIconResourceWidths.put(mCurrentIconResource, icon.getIntrinsicWidth());
    }

    ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(mUrlBar,
            mCurrentIconResource, 0, 0, 0);
}
 
Example 4
Source File: CustomTabToolbar.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void updateSecurityIcon(int securityLevel) {
    if (mState == STATE_TITLE_ONLY) return;

    mSecurityIconType = securityLevel;

    boolean isSmallDevice = !DeviceFormFactor.isTablet(getContext());
    boolean isOfflinePage = getCurrentTab() != null && getCurrentTab().isOfflinePage();

    int id = LocationBarLayout.getSecurityIconResource(
            securityLevel, isSmallDevice, isOfflinePage);
    boolean showSecurityButton = true;
    if (id == 0) {
        // Hide the button if we don't have an actual icon to display.
        showSecurityButton = false;
        mSecurityButton.setImageDrawable(null);
    } else {
        // ImageView#setImageResource is no-op if given resource is the current one.
        mSecurityButton.setImageResource(id);
        mSecurityButton.setTint(
                LocationBarLayout.getColorStateList(securityLevel, getToolbarDataProvider(),
                        getResources(), false /* omnibox is not opaque */));
    }

    mShowsOfflinePage = isOfflinePage;

    if (showSecurityButton) {
        mAnimDelegate.showSecurityButton();
    } else {
        mAnimDelegate.hideSecurityButton();
    }

    mUrlBar.emphasizeUrl();
    mUrlBar.invalidate();
}
 
Example 5
Source File: WebappUrlBar.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void updateSecurityIcon(int securityLevel) {
    boolean isSmallDevice = !DeviceFormFactor.isTablet();
    mCurrentIconResource =
            LocationBarLayout.getSecurityIconResource(securityLevel, isSmallDevice, false);

    if (mCurrentIconResource != 0 && mIconResourceWidths.get(mCurrentIconResource, -1) == -1) {
        Drawable icon = ApiCompatibilityUtils.getDrawable(getResources(), mCurrentIconResource);
        mIconResourceWidths.put(mCurrentIconResource, icon.getIntrinsicWidth());
    }

    ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(mUrlBar,
            mCurrentIconResource, 0, 0, 0);
}
 
Example 6
Source File: CustomTabToolbar.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void updateSecurityIcon(int securityLevel) {
    if (mState == STATE_TITLE_ONLY) return;

    mSecurityIconType = securityLevel;

    boolean isSmallDevice = !DeviceFormFactor.isTablet();
    boolean isOfflinePage =
            getCurrentTab() != null && OfflinePageUtils.isOfflinePage(getCurrentTab());

    int id = LocationBarLayout.getSecurityIconResource(
            securityLevel, isSmallDevice, isOfflinePage);
    boolean showSecurityButton = true;
    if (id == 0) {
        // Hide the button if we don't have an actual icon to display.
        showSecurityButton = false;
        mSecurityButton.setImageDrawable(null);
    } else {
        // ImageView#setImageResource is no-op if given resource is the current one.
        mSecurityButton.setImageResource(id);
        mSecurityButton.setTint(
                LocationBarLayout.getColorStateList(securityLevel, getToolbarDataProvider(),
                        getResources(), false /* omnibox is not opaque */));
    }

    mShowsOfflinePage = isOfflinePage;

    if (showSecurityButton) {
        mAnimDelegate.showSecurityButton();
    } else {
        mAnimDelegate.hideSecurityButton();
    }

    mUrlBar.emphasizeUrl();
    mUrlBar.invalidate();
}