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


Java ApiCompatibilityUtils类代码示例

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


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

示例1: onFinishInflate

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
@Override
public void onFinishInflate() {
    super.onFinishInflate();
    mDeviceIcon = (ImageView) findViewById(R.id.device_icon);
    mTimeLabel = (TextView) findViewById(R.id.time_label);
    mDeviceLabel = (TextView) findViewById(R.id.device_label);
    mExpandCollapseIcon = (ImageView) findViewById(R.id.expand_collapse_icon);

    // Create drawable for expand/collapse arrow.
    LevelListDrawable collapseIcon = new LevelListDrawable();
    collapseIcon.addLevel(DRAWABLE_LEVEL_COLLAPSED, DRAWABLE_LEVEL_COLLAPSED,
            TintedDrawable.constructTintedDrawable(getResources(), R.drawable.ic_expanded));
    TintedDrawable collapse =
            TintedDrawable.constructTintedDrawable(getResources(), R.drawable.ic_collapsed);
    collapse.setTint(
            ApiCompatibilityUtils.getColorStateList(getResources(), R.color.blue_mode_tint));
    collapseIcon.addLevel(DRAWABLE_LEVEL_EXPANDED, DRAWABLE_LEVEL_EXPANDED, collapse);
    mExpandCollapseIcon.setImageDrawable(collapseIcon);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:20,代码来源:RecentTabsGroupView.java

示例2: onMeasure

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int width = MeasureSpec.getSize(widthMeasureSpec);
    int height = MeasureSpec.getSize(heightMeasureSpec);

    if (width >= 2 * mIllustration.getWidth() && width > height) {
        mPromoContent.setOrientation(LinearLayout.HORIZONTAL);
        setMaxChildWidth(mMaxChildWidthHorizontal);
        ApiCompatibilityUtils.setPaddingRelative(
                mIllustration, 0, 0, mIllustrationPaddingSide, 0);
    } else {
        mPromoContent.setOrientation(LinearLayout.VERTICAL);
        setMaxChildWidth(mMaxChildWidth);
        mIllustration.setPadding(0, 0, 0, mIllustrationPaddingBottom);
    }

    setMaxChildHeight(height - mFrameHeightMargin);
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:20,代码来源:DataReductionPromoView.java

示例3: updateSyncSummaryAndIcon

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
/**
 * Updates the summary and icon for this preference to reflect the current state of syncing.
 */
public void updateSyncSummaryAndIcon() {
    setSummary(getSyncStatusSummary(getContext()));

    if (SyncPreference.showSyncErrorIcon(getContext())) {
        setIcon(ApiCompatibilityUtils.getDrawable(
                getContext().getResources(), R.drawable.sync_error));
    } else {
        // Sets preference icon and tints it to blue.
        Drawable icon = ApiCompatibilityUtils.getDrawable(
                getContext().getResources(), R.drawable.permission_background_sync);
        icon.setColorFilter(ApiCompatibilityUtils.getColor(
                                    getContext().getResources(), R.color.light_active_color),
                PorterDuff.Mode.SRC_IN);
        setIcon(icon);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:20,代码来源:SyncPreference.java

示例4: 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

示例5: initialize

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
/**
 * Initializes the view with the correct strings.
 *
 * @param title   Title of the webpage.
 * @param origin  Origin of the webpage.
 */
public void initialize(String title, String origin) {
    ((TextView) findViewById(R.id.page_title)).setText(title);
    ((TextView) findViewById(R.id.hostname)).setText(origin);

    // Remove the close button, then expand the page information to take up the space formerly
    // occupied by the X.
    View toRemove = findViewById(R.id.close_button);
    ((ViewGroup) toRemove.getParent()).removeView(toRemove);

    int titleEndMargin = getContext().getResources().getDimensionPixelSize(
            R.dimen.payments_section_large_spacing);
    View pageInfoGroup = findViewById(R.id.page_info);
    ApiCompatibilityUtils.setMarginEnd(
            (MarginLayoutParams) pageInfoGroup.getLayoutParams(), titleEndMargin);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:22,代码来源:PaymentRequestUiErrorView.java

示例6: onFinishInflate

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
@Override
protected void onFinishInflate() {
    super.onFinishInflate();

    LayoutInflater.from(getContext()).inflate(R.layout.selectable_list_layout, this);

    mEmptyView = (TextView) findViewById(R.id.empty_view);
    mLoadingView = (LoadingView) findViewById(R.id.loading_view);
    mLoadingView.showLoadingUI();

    mToolbarStub = (ViewStub) findViewById(R.id.action_bar_stub);

    FadingShadowView shadow = (FadingShadowView) findViewById(R.id.shadow);
    if (DeviceFormFactor.isLargeTablet(getContext())) {
        shadow.setVisibility(View.GONE);
    } else {
        shadow.init(ApiCompatibilityUtils.getColor(getResources(),
                R.color.toolbar_shadow_color), FadingShadow.POSITION_TOP);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:21,代码来源:SelectableListLayout.java

示例7: setUpIcons

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
/**
 * Sets compound drawables (icons) for different kinds of list entries,
 * i.e. New Folder, Normal and Selected.
 */
private void setUpIcons(FolderListEntry entry, TextView textView) {
    int iconId = 0;
    if (entry.mType == FolderListEntry.TYPE_NORMAL) {
        iconId = R.drawable.bookmark_folder;
    } else if (entry.mType == FolderListEntry.TYPE_NEW_FOLDER) {
        // For new folder, start_icon is different.
        iconId = R.drawable.bookmark_add_folder;
    }

    Drawable drawableStart = TintedDrawable.constructTintedDrawable(textView.getResources(),
            iconId);
    // Selected entry has an end_icon, a blue check mark.
    Drawable drawableEnd = entry.mIsSelected ? ApiCompatibilityUtils.getDrawable(
            textView.getResources(), R.drawable.ic_check_googblue_24dp) : null;
    ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(textView,
            drawableStart, null, drawableEnd, null);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:22,代码来源:BookmarkFolderSelectActivity.java

示例8: onFinishInflate

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    mItemsContainer = (BookmarkRecyclerView) findViewById(R.id.bookmark_items_container);
    TextView emptyView = (TextView) findViewById(R.id.bookmark_empty_view);
    emptyView.setText(R.string.bookmarks_folder_empty);
    mItemsContainer.setEmptyView(emptyView);
    mActionBar = (BookmarkActionBar) findViewById(R.id.bookmark_action_bar);
    mLoadingView = (LoadingView) findViewById(R.id.bookmark_initial_loading_view);
    FadingShadowView shadow = (FadingShadowView) findViewById(R.id.shadow);
    if (DeviceFormFactor.isLargeTablet(getContext())) {
        shadow.setVisibility(View.GONE);
    } else {
        shadow.init(ApiCompatibilityUtils.getColor(getResources(),
                R.color.toolbar_shadow_color), FadingShadow.POSITION_TOP);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:18,代码来源:BookmarkContentView.java

示例9: 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

示例10: getShareIntent

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
@VisibleForTesting
public static Intent getShareIntent(Activity activity, String title, String text, String url,
        Uri offlineUri, Uri screenshotUri) {
    if (!TextUtils.isEmpty(url)) {
        url = DomDistillerUrlUtils.getOriginalUrlFromDistillerUrl(url);
        if (!TextUtils.isEmpty(text)) {
            // Concatenate text and URL with a space.
            text = text + " " + url;
        } else {
            text = url;
        }
    }

    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.addFlags(ApiCompatibilityUtils.getActivityNewDocumentFlag());
    intent.putExtra(Intent.EXTRA_SUBJECT, title);
    intent.putExtra(Intent.EXTRA_TEXT, text);
    intent.putExtra(EXTRA_TASK_ID, activity.getTaskId());

    if (screenshotUri != null) {
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    }
    if (screenshotUri != null) {
        // To give read access to an Intent target, we need to put |screenshotUri| in clipData
        // because adding Intent.FLAG_GRANT_READ_URI_PERMISSION doesn't work for
        // EXTRA_SHARE_SCREENSHOT_AS_STREAM.
        intent.setClipData(ClipData.newRawUri("", screenshotUri));
        intent.putExtra(EXTRA_SHARE_SCREENSHOT_AS_STREAM, screenshotUri);
    }
    if (offlineUri == null) {
        intent.setType("text/plain");
    } else {
        intent.setType("multipart/related");
        intent.putExtra(Intent.EXTRA_STREAM, offlineUri);
    }
    return intent;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:38,代码来源:ShareHelper.java

示例11: showSnackbar

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
/**
 * Displays Auto sign-in snackbar, which communicates to the users that they
 * were signed in to the web site.
 */
@CalledByNative
private static void showSnackbar(Tab tab, String text) {
    SnackbarManager snackbarManager = tab.getSnackbarManager();
    if (snackbarManager == null) return;
    AutoSigninSnackbarController snackbarController =
            new AutoSigninSnackbarController(snackbarManager, tab);
    Snackbar snackbar = Snackbar.make(text, snackbarController, Snackbar.TYPE_NOTIFICATION,
            Snackbar.UMA_AUTO_LOGIN);
    Resources resources = tab.getWindowAndroid().getActivity().get().getResources();
    int backgroundColor = ApiCompatibilityUtils.getColor(resources, R.color.light_active_color);
    Bitmap icon = BitmapFactory.decodeResource(
            resources, R.drawable.account_management_no_picture);
    snackbar.setSingleLine(false).setBackgroundColor(backgroundColor).setProfileImage(icon);
    snackbarManager.showSnackbar(snackbar);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:20,代码来源:AutoSigninSnackbarController.java

示例12: BasicNativePage

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
public BasicNativePage(Activity activity, Tab tab) {
    initialize(activity, tab);
    mActivity = activity;
    mTab = tab;
    mBackgroundColor = ApiCompatibilityUtils.getColor(activity.getResources(),
            R.color.default_primary_color);
    mThemeColor = ApiCompatibilityUtils.getColor(
            activity.getResources(), R.color.default_primary_color);

    Resources res = mActivity.getResources();

    LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT);
    layoutParams.setMargins(0,
            res.getDimensionPixelSize(R.dimen.tab_strip_height)
            + res.getDimensionPixelSize(R.dimen.toolbar_height_no_shadow),
            0, 0);
    getView().setLayoutParams(layoutParams);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:20,代码来源:BasicNativePage.java

示例13: initialize

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
@UiThread
public void initialize(Context context, final BookmarkId folderId,
        BookmarkLoaderCallback callback) {
    mCallback = callback;

    Resources res = context.getResources();
    mLargeIconBridge = new LargeIconBridge(
            Profile.getLastUsedProfile().getOriginalProfile());
    mMinIconSizeDp = (int) res.getDimension(R.dimen.default_favicon_min_size);
    mDisplayedIconSize = res.getDimensionPixelSize(R.dimen.default_favicon_size);
    mCornerRadius = res.getDimensionPixelSize(R.dimen.default_favicon_corner_radius);
    int textSize = res.getDimensionPixelSize(R.dimen.default_favicon_icon_text_size);
    int iconColor =
            ApiCompatibilityUtils.getColor(res, R.color.default_favicon_background_color);
    mIconGenerator = new RoundedIconGenerator(mDisplayedIconSize, mDisplayedIconSize,
            mCornerRadius, iconColor, textSize);

    mRemainingTaskCount = 1;
    mBookmarkModel = new BookmarkModel();
    mBookmarkModel.runAfterBookmarkModelLoaded(new Runnable() {
        @Override
        public void run() {
            loadBookmarks(folderId);
        }
    });
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:27,代码来源:BookmarkWidgetService.java

示例14: registerForBeam

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
/**
 * If the device has NFC, construct a BeamCallback and pass it to Android.
 *
 * @param activity Activity that is sending out beam messages.
 * @param provider Provider that returns the URL that should be shared.
 */
public static void registerForBeam(final Activity activity, final BeamProvider provider) {
    final NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(activity);
    if (nfcAdapter == null) return;
    if (ApiCompatibilityUtils.checkPermission(
            activity, Manifest.permission.NFC, Process.myPid(), Process.myUid())
            == PackageManager.PERMISSION_DENIED) {
        return;
    }
    try {
        final BeamCallback beamCallback = new BeamCallback(activity, provider);
        nfcAdapter.setNdefPushMessageCallback(beamCallback, activity);
        nfcAdapter.setOnNdefPushCompleteCallback(beamCallback, activity);
    } catch (IllegalStateException e) {
        Log.w("BeamController", "NFC registration failure. Can't retry, giving up.");
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:23,代码来源:BeamController.java

示例15: setupImageButton

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
private void setupImageButton(TintedImageButton button, final MenuItem item) {
    // Store and recover the level of image as button.setimageDrawable
    // resets drawable to default level.
    int currentLevel = item.getIcon().getLevel();
    button.setImageDrawable(item.getIcon());
    item.getIcon().setLevel(currentLevel);
    if (item.isChecked()) {
        button.setTint(ApiCompatibilityUtils.getColorStateList(
                button.getResources(), R.color.blue_mode_tint));
    }
    button.setEnabled(item.isEnabled());
    button.setFocusable(item.isEnabled());
    button.setContentDescription(item.getTitleCondensed());

    button.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mAppMenu.onItemClick(item);
        }
    });

    // Menu items may be hidden by command line flags before they get to this point.
    button.setVisibility(item.isVisible() ? View.VISIBLE : View.GONE);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:25,代码来源:AppMenuAdapter.java


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