android.graphics.PorterDuff Java Examples
The following examples show how to use
android.graphics.PorterDuff.
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: Switch.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public void setChecked(boolean checked) { super.setChecked(checked); checked = isChecked(); if (attachedToWindow && wasLayout) { animateThumbToCheckedState(checked); } else { cancelPositionAnimator(); setThumbPosition(checked ? 1 : 0); } if (mTrackDrawable != null) { mTrackDrawable.setColorFilter(new PorterDuffColorFilter(checked ? Theme.getColor(Theme.key_switchTrackChecked) : Theme.getColor(Theme.key_switchTrack), PorterDuff.Mode.MULTIPLY)); } if (mThumbDrawable != null) { mThumbDrawable.setColorFilter(new PorterDuffColorFilter(checked ? Theme.getColor(Theme.key_switchThumbChecked) : Theme.getColor(Theme.key_switchThumb), PorterDuff.Mode.MULTIPLY)); } }
Example #2
Source File: LocationPoweredCell.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public LocationPoweredCell(Context context) { super(context); LinearLayout linearLayout = new LinearLayout(context); addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER)); textView = new TextView(context); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText3)); textView.setText("Powered by"); linearLayout.addView(textView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT)); imageView = new ImageView(context); imageView.setImageResource(R.drawable.foursquare); imageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText3), PorterDuff.Mode.MULTIPLY)); imageView.setPadding(0, AndroidUtilities.dp(2), 0, 0); linearLayout.addView(imageView, LayoutHelper.createLinear(35, LayoutHelper.WRAP_CONTENT)); textView2 = new TextView(context); textView2.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView2.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText3)); textView2.setText("Foursquare"); linearLayout.addView(textView2, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT)); }
Example #3
Source File: ActionBarMenuItem.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public ActionBarMenuItem(Context context, ActionBarMenu menu, int backgroundColor, int iconColor) { super(context); if (backgroundColor != 0) { setBackgroundDrawable(Theme.createSelectorDrawable(backgroundColor)); } parentMenu = menu; iconView = new ImageView(context); iconView.setScaleType(ImageView.ScaleType.CENTER); addView(iconView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); if (iconColor != 0) { iconView.setColorFilter(new PorterDuffColorFilter(iconColor, PorterDuff.Mode.MULTIPLY)); } }
Example #4
Source File: UserCell.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public void setIsAdmin(int value) { if (adminImage == null) return; adminText.setVisibility(value != 0 ? VISIBLE : GONE); adminImage.setVisibility(value != 0 ? VISIBLE : GONE); nameTextView.setPadding(LocaleController.isRTL && value != 0 ? AndroidUtilities.dp(16) : 0, 0, !LocaleController.isRTL && value != 0 ? AndroidUtilities.dp(16) : 0, 0); if (value == 1) { setTag(Theme.key_profile_creatorIcon); adminImage.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_profile_creatorIcon), PorterDuff.Mode.MULTIPLY)); adminText.setText(LocaleController.getString("Creator", R.string.Creator)); } else if (value == 2) { setTag(Theme.key_profile_adminIcon); adminImage.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_profile_adminIcon), PorterDuff.Mode.MULTIPLY)); adminText.setText(LocaleController.getString("Admin", R.string.Admin)); } }
Example #5
Source File: TypingIndicatorView.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
private void initialize(@Nullable AttributeSet attrs) { inflate(getContext(), R.layout.typing_indicator_view, this); setWillNotDraw(false); dot1 = findViewById(R.id.typing_dot1); dot2 = findViewById(R.id.typing_dot2); dot3 = findViewById(R.id.typing_dot3); if (attrs != null) { TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.TypingIndicatorView, 0, 0); int tint = typedArray.getColor(R.styleable.TypingIndicatorView_typingIndicator_tint, Color.WHITE); typedArray.recycle(); dot1.getBackground().setColorFilter(tint, PorterDuff.Mode.MULTIPLY); dot2.getBackground().setColorFilter(tint, PorterDuff.Mode.MULTIPLY); dot3.getBackground().setColorFilter(tint, PorterDuff.Mode.MULTIPLY); } }
Example #6
Source File: ContactPreference.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
public void setState(boolean secure, boolean blocked) { this.secure = secure; if (secureCallButton != null) secureCallButton.setVisibility(secure && !blocked ? View.VISIBLE : View.GONE); if (secureVideoButton != null) secureVideoButton.setVisibility(secure && !blocked ? View.VISIBLE : View.GONE); if (callButton != null) callButton.setVisibility(secure || blocked ? View.GONE : View.VISIBLE); if (messageButton != null) messageButton.setVisibility(blocked ? View.GONE : View.VISIBLE); int color; if (secure) { color = getContext().getResources().getColor(R.color.core_ultramarine); } else { color = getContext().getResources().getColor(R.color.grey_600); } if (messageButton != null) messageButton.setColorFilter(color, PorterDuff.Mode.SRC_IN); if (secureCallButton != null) secureCallButton.setColorFilter(color, PorterDuff.Mode.SRC_IN); if (secureVideoButton != null) secureVideoButton.setColorFilter(color, PorterDuff.Mode.SRC_IN); if (callButton != null) callButton.setColorFilter(color, PorterDuff.Mode.SRC_IN); }
Example #7
Source File: ColorDialogPreference.java From LokiBoard-Android-Keylogger with Apache License 2.0 | 6 votes |
@Override protected View onCreateDialogView() { final View view = super.onCreateDialogView(); mSeekBarRed = (SeekBar)view.findViewById(R.id.seek_bar_dialog_bar_red); mSeekBarRed.setMax(255); mSeekBarRed.setOnSeekBarChangeListener(this); mSeekBarRed.getProgressDrawable().setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN); mSeekBarRed.getThumb().setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN); mSeekBarGreen = (SeekBar)view.findViewById(R.id.seek_bar_dialog_bar_green); mSeekBarGreen.setMax(255); mSeekBarGreen.setOnSeekBarChangeListener(this); mSeekBarGreen.getThumb().setColorFilter(Color.GREEN, PorterDuff.Mode.SRC_IN); mSeekBarGreen.getProgressDrawable().setColorFilter(Color.GREEN, PorterDuff.Mode.SRC_IN); mSeekBarBlue = (SeekBar)view.findViewById(R.id.seek_bar_dialog_bar_blue); mSeekBarBlue.setMax(255); mSeekBarBlue.setOnSeekBarChangeListener(this); mSeekBarBlue.getThumb().setColorFilter(Color.BLUE, PorterDuff.Mode.SRC_IN); mSeekBarBlue.getProgressDrawable().setColorFilter(Color.BLUE, PorterDuff.Mode.SRC_IN); mValueView = (TextView)view.findViewById(R.id.seek_bar_dialog_value); return view; }
Example #8
Source File: ManageChatTextCell.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public ManageChatTextCell(Context context) { super(context); textView = new SimpleTextView(context); textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText)); textView.setTextSize(16); textView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); addView(textView); valueTextView = new SimpleTextView(context); valueTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteValueText)); valueTextView.setTextSize(16); valueTextView.setGravity(LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT); addView(valueTextView); imageView = new ImageView(context); imageView.setScaleType(ImageView.ScaleType.CENTER); imageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteGrayIcon), PorterDuff.Mode.MULTIPLY)); addView(imageView); }
Example #9
Source File: ShapeScrim.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
public ShapeScrim(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); if (attrs != null) { TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ShapeScrim, 0, 0); String shapeName = typedArray.getString(R.styleable.ShapeScrim_shape); if ("square".equalsIgnoreCase(shapeName)) this.shape = ShapeType.SQUARE; else if ("circle".equalsIgnoreCase(shapeName)) this.shape = ShapeType.CIRCLE; else this.shape = ShapeType.SQUARE; this.radius = typedArray.getFloat(R.styleable.ShapeScrim_radius, 0.4f); typedArray.recycle(); } else { this.shape = ShapeType.SQUARE; this.radius = 0.4f; } this.eraser = new Paint(); this.eraser.setColor(0xFFFFFFFF); this.eraser.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); }
Example #10
Source File: AlertDialogsHelper.java From leafpicrevived with GNU General Public License v3.0 | 6 votes |
public static AlertDialog getProgressDialog(final ThemedActivity activity, String title, String message) { AlertDialog.Builder progressDialog = new AlertDialog.Builder(activity, activity.getDialogStyle()); View dialogLayout = activity.getLayoutInflater().inflate(com.alienpants.leafpicrevived.R.layout.dialog_progress, null); TextView dialogTitle = dialogLayout.findViewById(R.id.progress_dialog_title); TextView dialogMessage = dialogLayout.findViewById(R.id.progress_dialog_text); dialogTitle.setBackgroundColor(activity.getPrimaryColor()); ((CardView) dialogLayout.findViewById(com.alienpants.leafpicrevived.R.id.progress_dialog_card)).setCardBackgroundColor(activity.getCardBackgroundColor()); ((ProgressBar) dialogLayout.findViewById(com.alienpants.leafpicrevived.R.id.progress_dialog_loading)).getIndeterminateDrawable().setColorFilter(activity.getPrimaryColor(), android.graphics .PorterDuff.Mode.SRC_ATOP); dialogTitle.setText(title); dialogMessage.setText(message); dialogMessage.setTextColor(activity.getTextColor()); progressDialog.setCancelable(false); progressDialog.setView(dialogLayout); return progressDialog.create(); }
Example #11
Source File: AccountBillingInfoFragment.java From arcusandroid with Apache License 2.0 | 6 votes |
private void setUpYearSpinner() { boolean isSettingsVariant = variant == ScreenVariant.SETTINGS; adapter = new SpinnerAdapter( //context getActivity(), //spinner closed state (view) R.layout.spinner_item_state_closed, //model getResources().getStringArray(R.array .account_registration_exp_year_list), //color scheme isSettingsVariant ); adapter.setDisabledItems(0); expYear.setAdapter(adapter); if (isSettingsVariant) { expYear.getBackground().setColorFilter(getResources().getColor(R.color.overlay_white_with_50), PorterDuff.Mode.SRC_ATOP); } }
Example #12
Source File: ProxySettingsActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public TypeCell(Context context) { super(context); setWillNotDraw(false); textView = new TextView(context); textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText)); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setLines(1); textView.setMaxLines(1); textView.setSingleLine(true); textView.setEllipsize(TextUtils.TruncateAt.END); textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 23 + 48 : 17, 0, LocaleController.isRTL ? 17 : 23, 0)); checkImage = new ImageView(context); checkImage.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_featuredStickers_addedIcon), PorterDuff.Mode.MULTIPLY)); checkImage.setImageResource(R.drawable.sticker_added); addView(checkImage, LayoutHelper.createFrame(19, 14, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 18, 0, 18, 0)); }
Example #13
Source File: CropImage.java From giffun with Apache License 2.0 | 6 votes |
/** * Create a new bitmap that has all pixels beyond the oval shape transparent. Old bitmap is * recycled. */ public static Bitmap toOvalBitmap(@NonNull Bitmap bitmap) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); Bitmap output = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(output); int color = 0xff424242; Paint paint = new Paint(); paint.setAntiAlias(true); canvas.drawARGB(0, 0, 0, 0); paint.setColor(color); RectF rect = new RectF(0, 0, width, height); canvas.drawOval(rect, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); canvas.drawBitmap(bitmap, 0, 0, paint); bitmap.recycle(); return output; }
Example #14
Source File: DrawableTintingFragment.java From graphics-samples with Apache License 2.0 | 6 votes |
/** * Update the tint of the image with the color set in the seekbars and selected blend mode. * The seekbars are set to a maximum of 255, with one for each of the four components of the * ARGB color. (Alpha, Red, Green, Blue.) Once a color has been computed using * {@link Color#argb(int, int, int, int)}, it is set togethe with the blend mode on the background * image using * {@link android.widget.ImageView#setColorFilter(int, android.graphics.PorterDuff.Mode)}. */ public void updateTint(int color, PorterDuff.Mode mode) { // Set the color hint of the image: ARGB mHintColor = color; // Set the color tint mode based on the selection of the Spinner mMode = mode; // Log selection Log.d(TAG, String.format("Updating tint with color [ARGB: %d,%d,%d,%d] and mode [%s]", Color.alpha(color), Color.red(color), Color.green(color), Color.blue(color), mode.toString())); // Apply the color tint for the selected tint mode mImage.setColorFilter(color, mMode); // Update the text for each label with the value of each channel mAlphaText.setText(getString(R.string.value_alpha, Color.alpha(color))); mRedText.setText(getString(R.string.value_red, Color.red(color))); mGreenText.setText(getString(R.string.value_green, Color.green(color))); mBlueText.setText(getString(R.string.value_blue, Color.blue(color))); }
Example #15
Source File: ActionBarPopupWindow.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public ActionBarPopupWindowLayout(Context context) { super(context); backgroundDrawable = getResources().getDrawable(R.drawable.popup_fixed).mutate(); backgroundDrawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_actionBarDefaultSubmenuBackground), PorterDuff.Mode.MULTIPLY)); setPadding(AndroidUtilities.dp(8), AndroidUtilities.dp(8), AndroidUtilities.dp(8), AndroidUtilities.dp(8)); setWillNotDraw(false); try { scrollView = new ScrollView(context); scrollView.setVerticalScrollBarEnabled(false); addView(scrollView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT)); } catch (Throwable e) { FileLog.e(e); } linearLayout = new LinearLayout(context); linearLayout.setOrientation(LinearLayout.VERTICAL); if (scrollView != null) { scrollView.addView(linearLayout, new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); } else { addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT)); } }
Example #16
Source File: CropImage.java From Lassi-Android with MIT License | 6 votes |
/** * Create a new bitmap that has all pixels beyond the oval shape transparent. Old bitmap is * recycled. */ public static Bitmap toOvalBitmap(@NonNull Bitmap bitmap) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); Bitmap output = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(output); int color = 0xff424242; Paint paint = new Paint(); paint.setAntiAlias(true); canvas.drawARGB(0, 0, 0, 0); paint.setColor(color); RectF rect = new RectF(0, 0, width, height); canvas.drawOval(rect, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); canvas.drawBitmap(bitmap, 0, 0, paint); bitmap.recycle(); return output; }
Example #17
Source File: AudioCell.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void setPlayDrawable(boolean play) { Drawable circle = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(46), Theme.getColor(Theme.key_musicPicker_buttonBackground), Theme.getColor(Theme.key_musicPicker_buttonBackground)); Drawable drawable = getResources().getDrawable(play ? R.drawable.audiosend_pause : R.drawable.audiosend_play); drawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_musicPicker_buttonIcon), PorterDuff.Mode.MULTIPLY)); CombinedDrawable combinedDrawable = new CombinedDrawable(circle, drawable); combinedDrawable.setCustomSize(AndroidUtilities.dp(46), AndroidUtilities.dp(46)); playButton.setBackgroundDrawable(combinedDrawable); }
Example #18
Source File: AlertDialogsHelper.java From leafpicrevived with GNU General Public License v3.0 | 5 votes |
public static AlertDialog getInsertTextDialog(ThemedActivity activity, EditText editText, @StringRes int title) { AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(activity, activity.getDialogStyle()); View dialogLayout = activity.getLayoutInflater().inflate(com.alienpants.leafpicrevived.R.layout.dialog_insert_text, null); TextView textViewTitle = dialogLayout.findViewById(R.id.rename_title); ((CardView) dialogLayout.findViewById(com.alienpants.leafpicrevived.R.id.dialog_chose_provider_title)).setCardBackgroundColor(activity.getCardBackgroundColor()); textViewTitle.setBackgroundColor(activity.getPrimaryColor()); textViewTitle.setText(title); ThemeHelper.setCursorColor(editText, activity.getTextColor()); FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); editText.setLayoutParams(layoutParams); editText.setSingleLine(true); editText.getBackground().mutate().setColorFilter(activity.getTextColor(), PorterDuff.Mode.SRC_IN); editText.setTextColor(activity.getTextColor()); try { Field f = TextView.class.getDeclaredField("mCursorDrawableRes"); f.setAccessible(true); f.set(editText, null); } catch (Exception ignored) { } ((RelativeLayout) dialogLayout.findViewById(com.alienpants.leafpicrevived.R.id.container_edit_text)).addView(editText); dialogBuilder.setView(dialogLayout); return dialogBuilder.create(); }
Example #19
Source File: SegmentedButton.java From SegmentedButton with Apache License 2.0 | 5 votes |
/** * Set the drawable tint color to the specified color * * This drawable tint color will be the color applied to the drawable when the button is selected * * @param tint color for the drawable tint */ public void setSelectedDrawableTint(final @ColorInt int tint) { hasSelectedDrawableTint = true; selectedDrawableTint = tint; // Create color filter for the tint color selectedDrawableColorFilter = new PorterDuffColorFilter(tint, PorterDuff.Mode.SRC_IN); invalidate(); }
Example #20
Source File: CircularDisplayMask.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
public CircularDisplayMask(DisplayContent dc, int zOrder, int screenOffset, int maskThickness) { final Display display = dc.getDisplay(); mScreenSize = new Point(); display.getSize(mScreenSize); if (mScreenSize.x != mScreenSize.y + screenOffset) { Slog.w(TAG, "Screen dimensions of displayId = " + display.getDisplayId() + "are not equal, circularMask will not be drawn."); mDimensionsUnequal = true; } SurfaceControl ctrl = null; try { ctrl = dc.makeOverlay() .setName("CircularDisplayMask") .setSize(mScreenSize.x, mScreenSize.y) // not a typo .setFormat(PixelFormat.TRANSLUCENT) .build(); ctrl.setLayerStack(display.getLayerStack()); ctrl.setLayer(zOrder); ctrl.setPosition(0, 0); ctrl.show(); mSurface.copyFrom(ctrl); } catch (OutOfResourcesException e) { } mSurfaceControl = ctrl; mDrawNeeded = true; mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); mScreenOffset = screenOffset; mMaskThickness = maskThickness; }
Example #21
Source File: DrawerAddCell.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override protected void onAttachedToWindow() { super.onAttachedToWindow(); textView.setTextColor(Theme.getColor(Theme.key_chats_menuItemText)); textView.setText(LocaleController.getString("AddAccount", R.string.AddAccount)); Drawable drawable = getResources().getDrawable(R.drawable.account_add); if (drawable != null) { drawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_menuItemIcon), PorterDuff.Mode.MULTIPLY)); } textView.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null); }
Example #22
Source File: ScratchView.java From react-native-scratch with MIT License | 5 votes |
private void init() { setFocusable(true); setFocusableInTouchMode(true); setOnTouchListener(this); imagePaint.setAntiAlias(true); imagePaint.setFilterBitmap(true); pathPaint.setAlpha(0); pathPaint.setStyle(Paint.Style.STROKE); pathPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); pathPaint.setAntiAlias(true); setLayerType(View.LAYER_TYPE_SOFTWARE, null); }
Example #23
Source File: TintHelper.java From a with GNU General Public License v3.0 | 5 votes |
@CheckResult @Nullable public static Drawable createTintedDrawable(@Nullable Drawable drawable, @ColorInt int color) { if (drawable == null) return null; drawable = DrawableCompat.wrap(drawable.mutate()); DrawableCompat.setTintMode(drawable, PorterDuff.Mode.SRC_IN); DrawableCompat.setTint(drawable, color); return drawable; }
Example #24
Source File: ImageUtils.java From Android-utils with Apache License 2.0 | 5 votes |
public static Bitmap drawColor(@NonNull final Bitmap src, @ColorInt final int color, final boolean recycle) { if (isEmptyBitmap(src)) return null; Bitmap ret = recycle ? src : src.copy(src.getConfig(), true); Canvas canvas = new Canvas(ret); canvas.drawColor(color, PorterDuff.Mode.DARKEN); return ret; }
Example #25
Source File: Switch.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void checkColorFilters() { if (mTrackDrawable != null) { mTrackDrawable.setColorFilter(new PorterDuffColorFilter(isChecked() ? Theme.getColor(Theme.key_switchTrackChecked) : Theme.getColor(Theme.key_switchTrack), PorterDuff.Mode.MULTIPLY)); } if (mThumbDrawable != null) { mThumbDrawable.setColorFilter(new PorterDuffColorFilter(isChecked() ? Theme.getColor(Theme.key_switchThumbChecked) : Theme.getColor(Theme.key_switchThumb), PorterDuff.Mode.MULTIPLY)); } }
Example #26
Source File: AdminedChannelCell.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public AdminedChannelCell(Context context, View.OnClickListener onClickListener) { super(context); avatarDrawable = new AvatarDrawable(); avatarImageView = new BackupImageView(context); avatarImageView.setRoundRadius(AndroidUtilities.dp(24)); addView(avatarImageView, LayoutHelper.createFrame(48, 48, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 12, 12, LocaleController.isRTL ? 12 : 0, 0)); nameTextView = new SimpleTextView(context); nameTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText)); nameTextView.setTextSize(17); nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP); addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 20, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 62 : 73, 15.5f, LocaleController.isRTL ? 73 : 62, 0)); statusTextView = new SimpleTextView(context); statusTextView.setTextSize(14); statusTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText)); statusTextView.setLinkTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteLinkText)); statusTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP); addView(statusTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 20, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 62 : 73, 38.5f, LocaleController.isRTL ? 73 : 62, 0)); deleteButton = new ImageView(context); deleteButton.setScaleType(ImageView.ScaleType.CENTER); deleteButton.setImageResource(R.drawable.msg_panel_clear); deleteButton.setOnClickListener(onClickListener); deleteButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText), PorterDuff.Mode.MULTIPLY)); addView(deleteButton, LayoutHelper.createFrame(48, 48, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, LocaleController.isRTL ? 7 : 0, 12, LocaleController.isRTL ? 0 : 7, 0)); }
Example #27
Source File: GlowableImageView.java From arcusandroid with Apache License 2.0 | 5 votes |
private void drawGlow(int strength) { // Nothing to draw yet if (viewWidth <= 0 || viewHeight <= 0) return; // Calculate glow ring's center and radius int centerX = viewWidth / 2; int centerY = viewHeight / 2; int stroke = getGlowStrokeForMode(mode, strength); int radius = getGlowRadiusForMode(mode, strength); // Create a canvas to paint on if necessary if (mRecycledBitmap == null || mRecycledBitmap.getWidth() != viewWidth || mRecycledBitmap.getHeight() != viewHeight) { mRecycledBitmap = Bitmap.createBitmap(viewWidth, viewHeight, Bitmap.Config.ARGB_8888); } mCanvas = new Canvas(mRecycledBitmap); mCanvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR); // Provision the paint if (!mode.equals(GlowMode.OPEN_CLOSE)) { mPaint.setShadowLayer(stroke, 0, 0, white60); } mPaint.setStrokeWidth(stroke); // Draw the circle on the canvas; don't draw if stroke is zero. Some Android versions render // a faint line instead of nothing when stroke == 0 if (stroke > 0) { mCanvas.drawCircle(centerX, centerY, radius, mPaint); } // Then apply the canvas as the view's background setBackground(new BitmapDrawable(getResources(), mRecycledBitmap)); currentStrength = strength; }
Example #28
Source File: SettingsPlaceFragment.java From arcusandroid with Apache License 2.0 | 5 votes |
protected void setUpStateSpinner(PlaceModel place) { String[] states = getResources().getStringArray(R.array.states); List<String> stateList = Arrays.asList(states); state.setAdapter(new SpinnerAdapter(getActivity(), R.layout.spinner_item_state_closed, states, true)); state.getBackground().setColorFilter(spinnerColor, PorterDuff.Mode.SRC_ATOP); selectedStateIndex = stateList.indexOf(place.getState()); if (selectedStateIndex != -1) { state.setSelection(selectedStateIndex, false); } }
Example #29
Source File: WallpaperManager.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private FastBitmapDrawable(Bitmap bitmap) { mBitmap = bitmap; mWidth = bitmap.getWidth(); mHeight = bitmap.getHeight(); setBounds(0, 0, mWidth, mHeight); mPaint = new Paint(); mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC)); }
Example #30
Source File: SearchActivity.java From MarketAndroidApp with Apache License 2.0 | 5 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_search); //设置从别的页面传过来的搜索内容 Intent intent = getIntent(); searchContent = intent.getStringExtra("content"); //绑定控件 init(); //初始化数据 initData(); //给Toolbar添加返回按钮 mToolbar.setTitle("商品搜索");//设置ToolBar的标题 mToolbar.setTitleTextColor(Color.WHITE); //返回按钮颜色显示不正常时,以下三行是修改回退按钮为白色的逻辑 Drawable upArrow = ContextCompat.getDrawable(SearchActivity.this, R.drawable.abc_ic_ab_back_material); upArrow.setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_ATOP); mToolbar.setNavigationIcon(upArrow); mToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //返回按鈕点击事件,关闭当前activity finish(); } }); }