当前位置: 首页>>代码示例>>Java>>正文


Java ApiCompatibilityUtils.getColor方法代码示例

本文整理汇总了Java中org.chromium.base.ApiCompatibilityUtils.getColor方法的典型用法代码示例。如果您正苦于以下问题:Java ApiCompatibilityUtils.getColor方法的具体用法?Java ApiCompatibilityUtils.getColor怎么用?Java ApiCompatibilityUtils.getColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.chromium.base.ApiCompatibilityUtils的用法示例。


在下文中一共展示了ApiCompatibilityUtils.getColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: RecentTabsPage

import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
/**
 * Constructor returns an instance of RecentTabsPage.
 *
 * @param activity The activity this view belongs to.
 * @param recentTabsManager The RecentTabsManager which provides the model data.
 */
public RecentTabsPage(Activity activity, RecentTabsManager recentTabsManager) {
    mActivity = activity;
    mRecentTabsManager = recentTabsManager;

    mTitle = activity.getResources().getString(R.string.recent_tabs);
    mThemeColor = ApiCompatibilityUtils.getColor(
            activity.getResources(), R.color.default_primary_color);
    mRecentTabsManager.setUpdatedCallback(this);
    LayoutInflater inflater = LayoutInflater.from(activity);
    mView = (ViewGroup) inflater.inflate(R.layout.recent_tabs_page, null);
    mListView = (ExpandableListView) mView.findViewById(R.id.odp_listview);
    mAdapter = buildAdapter(activity, recentTabsManager);
    mListView.setAdapter(mAdapter);
    mListView.setOnChildClickListener(this);
    mListView.setGroupIndicator(null);
    mListView.setOnGroupCollapseListener(this);
    mListView.setOnGroupExpandListener(this);
    mListView.setOnCreateContextMenuListener(this);

    mView.addOnAttachStateChangeListener(this);
    ApplicationStatus.registerStateListenerForActivity(this, activity);
    // {@link #mInForeground} will be updated once the view is attached to the window.

    onUpdated();
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:32,代码来源:RecentTabsPage.java

示例2: AddExceptionPreference

import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
/**
 * Construct a AddException preference.
 * @param context The current context.
 * @param key The key to use for the preference.
 * @param message The custom message to show in the dialog.
 * @param callback A callback to receive notifications that an exception has been added.
 */
public AddExceptionPreference(
        Context context, String key, String message, SiteAddedCallback callback) {
    super(context);
    mDialogMessage = message;
    mSiteAddedCallback = callback;
    setOnPreferenceClickListener(this);

    setKey(key);
    Resources resources = getContext().getResources();
    mPrefAccentColor = ApiCompatibilityUtils.getColor(resources, R.color.pref_accent_color);

    Drawable plusIcon = ApiCompatibilityUtils.getDrawable(resources, R.drawable.plus);
    plusIcon.mutate();
    plusIcon.setColorFilter(mPrefAccentColor, PorterDuff.Mode.SRC_IN);
    setIcon(plusIcon);

    setTitle(resources.getString(R.string.website_settings_add_site));
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:26,代码来源:AddExceptionPreference.java

示例3: createButtonForLayout

import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
/**
 * Creates a standardized Button that can be used for DualControlLayouts showing buttons.
 *
 * @param isPrimary Whether or not the button is meant to act as a "Confirm" button.
 * @param text      Text to display on the button.
 * @param listener  Listener to alert when the button has been clicked.
 * @return Button that can be used in the view.
 */
public static Button createButtonForLayout(
        Context context, boolean isPrimary, String text, OnClickListener listener) {
    int lightActiveColor =
            ApiCompatibilityUtils.getColor(context.getResources(), R.color.light_active_color);

    if (isPrimary) {
        ButtonCompat primaryButton = new ButtonCompat(context, lightActiveColor, false);
        primaryButton.setId(R.id.button_primary);
        primaryButton.setOnClickListener(listener);
        primaryButton.setText(text);
        primaryButton.setTextColor(Color.WHITE);
        return primaryButton;
    } else {
        Button secondaryButton = ButtonCompat.createBorderlessButton(context);
        secondaryButton.setId(R.id.button_secondary);
        secondaryButton.setOnClickListener(listener);
        secondaryButton.setText(text);
        secondaryButton.setTextColor(lightActiveColor);
        return secondaryButton;
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:30,代码来源:DualControlLayout.java

示例4: ClearBrowsingDataAdapter

import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
private ClearBrowsingDataAdapter(
        String[] domains, String[] faviconURLs, Resources resources) {
    super(getActivity(), R.layout.confirm_important_sites_list_row, domains);
    mDomains = domains;
    mFaviconURLs = faviconURLs;
    mFaviconSize = resources.getDimensionPixelSize(R.dimen.default_favicon_size);
    mCornerRadius = resources.getDimensionPixelSize(R.dimen.default_favicon_corner_radius);
    int textSize = resources.getDimensionPixelSize(R.dimen.default_favicon_icon_text_size);
    int iconColor = ApiCompatibilityUtils.getColor(
            resources, R.color.default_favicon_background_color);
    mIconGenerator = new RoundedIconGenerator(
            mFaviconSize, mFaviconSize, mCornerRadius, iconColor, textSize);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:14,代码来源:ConfirmImportantSitesDialogFragment.java

示例5: convertOptionToString

import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
private CharSequence convertOptionToString(PaymentOption item, boolean useBoldLabel) {
    SpannableStringBuilder builder = new SpannableStringBuilder(item.getLabel());
    if (useBoldLabel) {
        builder.setSpan(
                new StyleSpan(android.graphics.Typeface.BOLD), 0, builder.length(), 0);
    }

    if (!TextUtils.isEmpty(item.getSublabel())) {
        if (builder.length() > 0) builder.append("\n");
        builder.append(item.getSublabel());
    }

    if (!TextUtils.isEmpty(item.getTertiaryLabel())) {
        if (builder.length() > 0) builder.append("\n");
        builder.append(item.getTertiaryLabel());
    }

    if (!item.isComplete() && !TextUtils.isEmpty(item.getEditMessage())) {
        if (builder.length() > 0) builder.append("\n");
        String editMessage = item.getEditMessage();
        builder.append(editMessage);
        Object foregroundSpanner = new ForegroundColorSpan(ApiCompatibilityUtils.getColor(
                getContext().getResources(), R.color.google_blue_700));
        Object sizeSpanner = new AbsoluteSizeSpan(14, true);
        int startIndex = builder.length() - editMessage.length();
        builder.setSpan(foregroundSpanner, startIndex, builder.length(), 0);
        builder.setSpan(sizeSpanner, startIndex, builder.length(), 0);
    }

    return builder;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:32,代码来源:PaymentRequestSection.java

示例6: setSecurityDescription

import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
/**
 * Sets the connection security summary and detailed description strings. These strings may be
 * overridden based on the state of the Android UI.
 */
@CalledByNative
private void setSecurityDescription(String summary, String details) {
    // Display the appropriate connection message.
    SpannableStringBuilder messageBuilder = new SpannableStringBuilder();
    if (mContentPublisher != null) {
        messageBuilder.append(
                mContext.getString(R.string.page_info_domain_hidden, mContentPublisher));
    } else if (isShowingOfflinePage()) {
        messageBuilder.append(String.format(
                mContext.getString(R.string.page_info_connection_offline),
                mOfflinePageCreationDate));
    } else {
        if (!TextUtils.equals(summary, details)) {
            mConnectionSummary.setVisibility(View.VISIBLE);
            mConnectionSummary.setText(summary);
        }
        messageBuilder.append(details);
    }

    if (isConnectionDetailsLinkVisible()) {
        messageBuilder.append(" ");
        SpannableString detailsText = new SpannableString(
                mContext.getString(R.string.page_info_details_link));
        final ForegroundColorSpan blueSpan = new ForegroundColorSpan(
                ApiCompatibilityUtils.getColor(mContext.getResources(),
                        R.color.website_settings_popup_text_link));
        detailsText.setSpan(
                blueSpan, 0, detailsText.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
        messageBuilder.append(detailsText);
    }
    mConnectionMessage.setText(messageBuilder);
    if (isConnectionDetailsLinkVisible()) mConnectionMessage.setOnClickListener(this);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:38,代码来源:WebsiteSettingsPopup.java

示例7: getDisabledIcon

import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
/**
 * Returns the Drawable object of the icon for a content type with a disabled tint.
 */
public static Drawable getDisabledIcon(int contentType, Resources resources) {
    Drawable icon = ApiCompatibilityUtils.getDrawable(resources, getIcon(contentType));
    icon.mutate();
    int disabledColor = ApiCompatibilityUtils.getColor(resources,
            R.color.primary_text_disabled_material_light);
    icon.setColorFilter(disabledColor, PorterDuff.Mode.SRC_IN);
    return icon;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:12,代码来源:ContentSettingsResources.java

示例8: getDisabledInAndroidIcon

import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
/**
 * Returns the icon for permissions that have been disabled by Android.
 */
Drawable getDisabledInAndroidIcon(Activity activity) {
    Drawable icon = ApiCompatibilityUtils.getDrawable(activity.getResources(),
            R.drawable.exclamation_triangle);
    icon.mutate();
    int disabledColor = ApiCompatibilityUtils.getColor(activity.getResources(),
            R.color.pref_accent_color);
    icon.setColorFilter(disabledColor, PorterDuff.Mode.SRC_IN);
    return icon;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:13,代码来源:SiteSettingsCategory.java

示例9: getStatusColor

import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
@Override
protected int getStatusColor(boolean failed, boolean incognito) {
    if (!failed && incognito) {
        return ApiCompatibilityUtils.getColor(getContext().getResources(),
                R.color.find_in_page_results_status_white_color);
    }

    return super.getStatusColor(failed, incognito);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:10,代码来源:FindToolbarPhone.java

示例10: updateInternal

import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
private boolean updateInternal(Snackbar snackbar, boolean animate) {
    if (mSnackbar == snackbar) return false;
    mSnackbar = snackbar;
    mMessageView.setMaxLines(snackbar.getSingleLine() ? 1 : MAX_LINES);
    mMessageView.setTemplate(snackbar.getTemplateText());
    setViewText(mMessageView, snackbar.getText(), animate);
    String actionText = snackbar.getActionText();

    int backgroundColor = snackbar.getBackgroundColor();
    if (backgroundColor == 0) {
        backgroundColor = ApiCompatibilityUtils.getColor(mView.getResources(),
                R.color.snackbar_background_color);
    }

    if (mIsTablet) {
        // On tablet, snackbars have rounded corners.
        mView.setBackgroundResource(R.drawable.snackbar_background_tablet);
        GradientDrawable backgroundDrawable = (GradientDrawable) mView.getBackground().mutate();
        backgroundDrawable.setColor(backgroundColor);
    } else {
        mView.setBackgroundColor(backgroundColor);
    }

    if (actionText != null) {
        mActionButtonView.setVisibility(View.VISIBLE);
        setViewText(mActionButtonView, snackbar.getActionText(), animate);
    } else {
        mActionButtonView.setVisibility(View.GONE);
    }
    Bitmap profileImage = snackbar.getProfileImage();
    if (profileImage != null) {
        mProfileImageView.setVisibility(View.VISIBLE);
        mProfileImageView.setImageBitmap(profileImage);
    } else {
        mProfileImageView.setVisibility(View.GONE);
    }
    return true;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:39,代码来源:SnackbarView.java

示例11: setGroupTitle

import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
/**
 * Set the title for the preference group.
 * @param resourceId The resource id of the text to use.
 * @param count The number of entries the preference group contains.
 */
public void setGroupTitle(int resourceId, int count) {
    SpannableStringBuilder spannable =
            new SpannableStringBuilder(getContext().getResources().getString(resourceId));
    String prefCount = String.format(Locale.getDefault(), " - %d", count);
    spannable.append(prefCount);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        spannable.setSpan(new StyleSpan(android.graphics.Typeface.BOLD),
                   0,
                   spannable.length() - prefCount.length(),
                   Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    } else {
        spannable.setSpan(new TypefaceSpan("sans-serif-medium"),
                   0,
                   spannable.length() - prefCount.length(),
                   Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    }

    // Color the first part of the title blue.
    ForegroundColorSpan blueSpan = new ForegroundColorSpan(
            ApiCompatibilityUtils.getColor(getContext().getResources(),
                    R.color.pref_accent_color));
    spannable.setSpan(blueSpan, 0, spannable.length() - prefCount.length(),
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    // Gray out the total count of items.
    int gray = ApiCompatibilityUtils.getColor(getContext().getResources(),
            R.color.expandable_group_dark_gray);
    spannable.setSpan(new ForegroundColorSpan(gray),
               spannable.length() - prefCount.length(),
               spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    setTitle(spannable);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:39,代码来源:ExpandablePreferenceGroup.java

示例12: setPrimaryColor

import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
/**
 * Sets the primary color and changes the state for isUsingBrandColor.
 * @param color The primary color for the current tab.
 */
public void setPrimaryColor(int color) {
    mPrimaryColor = color;
    Context context = ContextUtils.getApplicationContext();
    mIsUsingBrandColor = !isIncognito()
            && mPrimaryColor != ApiCompatibilityUtils.getColor(context.getResources(),
                    R.color.default_primary_color)
            && getTab() != null && !getTab().isNativePage();
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:13,代码来源:ToolbarModelImpl.java

示例13: ToolbarModelImpl

import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
/**
 * Default constructor for this class.
 */
public ToolbarModelImpl() {
    super();
    mPrimaryColor = ApiCompatibilityUtils.getColor(
            ContextUtils.getApplicationContext().getResources(),
            R.color.default_primary_color);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:10,代码来源:ToolbarModelImpl.java

示例14: updateTaskDescription

import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
private void updateTaskDescription() {
    String title = null;
    if (!TextUtils.isEmpty(mWebappInfo.shortName())) {
        title = mWebappInfo.shortName();
    } else if (getActivityTab() != null) {
        title = getActivityTab().getTitle();
    }

    Bitmap icon = null;
    if (mWebappInfo.icon() != null) {
        icon = mWebappInfo.icon();
    } else if (getActivityTab() != null) {
        icon = mLargestFavicon;
    }

    if (mBrandColor == null && mWebappInfo.hasValidThemeColor()) {
        mBrandColor = (int) mWebappInfo.themeColor();
    }

    int taskDescriptionColor =
            ApiCompatibilityUtils.getColor(getResources(), R.color.default_primary_color);
    int statusBarColor = Color.BLACK;
    if (mBrandColor != null) {
        taskDescriptionColor = mBrandColor;
        statusBarColor = ColorUtils.getDarkenedColorForStatusBar(mBrandColor);
    }

    ApiCompatibilityUtils.setTaskDescription(this, title, icon,
            ColorUtils.getOpaqueColor(taskDescriptionColor));
    ApiCompatibilityUtils.setStatusBarColor(getWindow(), statusBarColor);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:32,代码来源:WebappActivity.java

示例15: postInflationStartup

import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
@Override
public void postInflationStartup() {
    super.postInflationStartup();

    getToolbarManager().setCloseButtonDrawable(mIntentDataProvider.getCloseButtonDrawable());
    getToolbarManager().setShowTitle(mIntentDataProvider.getTitleVisibilityState()
            == CustomTabsIntent.SHOW_PAGE_TITLE);
    if (CustomTabsConnection.getInstance(getApplication())
            .shouldHideDomainForSession(mSession)) {
        getToolbarManager().setUrlBarHidden(true);
    }
    int toolbarColor = mIntentDataProvider.getToolbarColor();
    getToolbarManager().updatePrimaryColor(toolbarColor, false);
    if (!mIntentDataProvider.isOpenedByChrome()) {
        getToolbarManager().setShouldUpdateToolbarPrimaryColor(false);
    }
    if (toolbarColor != ApiCompatibilityUtils.getColor(
            getResources(), R.color.default_primary_color)) {
        ApiCompatibilityUtils.setStatusBarColor(getWindow(),
                ColorUtils.getDarkenedColorForStatusBar(toolbarColor));
    }

    // Setting task title and icon to be null will preserve the client app's title and icon.
    ApiCompatibilityUtils.setTaskDescription(this, null, null, toolbarColor);
    showCustomButtonOnToolbar();
    mBottomBarDelegate = new CustomTabBottomBarDelegate(this, mIntentDataProvider);
    mBottomBarDelegate.showBottomBarIfNecessary();
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:29,代码来源:CustomTabActivity.java


注:本文中的org.chromium.base.ApiCompatibilityUtils.getColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。