org.chromium.chrome.browser.omnibox.LocationBarLayout Java Examples

The following examples show how to use org.chromium.chrome.browser.omnibox.LocationBarLayout. 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: SearchWidgetProvider.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/** Attempts to update the cached search engine name. */
public static void updateCachedEngineName() {
    ThreadUtils.assertOnUiThread();
    if (!LibraryLoader.isInitialized()) return;

    // Getting an instance of the TemplateUrlService requires that the native library be
    // loaded, but the TemplateUrlService also itself needs to be initialized.
    TemplateUrlService service = TemplateUrlService.getInstance();
    if (!service.isLoaded()) return;

    // Update the URL that we show for zero-suggest.
    String searchEngineUrl = service.getSearchEngineUrlFromTemplateUrl(
            service.getDefaultSearchEngineTemplateUrl().getKeyword());
    sDefaultSearchEngineUrl =
            LocationBarLayout.splitPathFromUrlDisplayText(searchEngineUrl).first;

    updateCachedEngineName(service.getDefaultSearchEngineTemplateUrl().getShortName());
}
 
Example #3
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 #4
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 #5
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 #6
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 #7
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();
}