下面列出了怎么用android.graphics.PorterDuff的API类实例代码及写法,或者点击链接到github查看源代码。
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));
}
}
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));
}
}
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);
}
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);
}
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);
}
}
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));
}
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();
}
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);
}
}
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));
}
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));
}
}
/**
* 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;
}
/**
* 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)));
}
/**
* 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;
}
@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;
}
@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));
}
}
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));
}
void showProgressBar(Message msg, ProgressView progressView, ImageView imgView, View errView) {
if (msg != null && progressView != null) {
if (msg.getSentStatus() == GlobalParams.SEND_ING) {
if (msg.getMessageId() != -1) {
setProgress(msg, progressView);
if (imgView != null) {
imgView.setColorFilter(Color.DKGRAY, PorterDuff.Mode.MULTIPLY);
}
} else {
//FIXME this should be "Failed" - fix the DB bug
LogUtil.i(TAG, "send file failed");
progressView.setSuccess();
if (imgView != null) {
imgView.clearColorFilter();
}
}
} else {
if (msg.getMessageId() != -1) {
if (msg.isMine()) {
LogUtil.i(TAG, "the file is mine");
} else {
//todo: no need confirm,receive
//State.transferManager()
// .acceptFile((FriendKey) msg.key(), msg.messageId(),
// TokApplication.getInstance());
}
if (imgView != null) {
imgView.setColorFilter(Color.DKGRAY, PorterDuff.Mode.MULTIPLY);
}
} else {
//fileHolder.setProgressText(R.string.file_rejected)
LogUtil.i(TAG, "the file is success");
progressView.setSuccess();
if (imgView != null) {
imgView.clearColorFilter();
}
}
}
}
}
public VideoTimelinePlayView(Context context) {
super(context);
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(0xffffffff);
paint2 = new Paint();
paint2.setColor(0x7f000000);
drawableLeft = context.getResources().getDrawable(R.drawable.video_cropleft);
drawableLeft.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.MULTIPLY));
drawableRight = context.getResources().getDrawable(R.drawable.video_cropright);
drawableRight.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.MULTIPLY));
}
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();
}
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));
}
}
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));
}
/**
* 设置MENU图标颜色
*/
@Override
public boolean onCreateOptionsMenu(Menu menu) {
int primaryTextColor = MaterialValueHelper.getPrimaryTextColor(this, ColorUtil.isColorLight(ThemeStore.primaryColor(this)));
for (int i = 0; i < menu.size(); i++) {
Drawable drawable = menu.getItem(i).getIcon();
if (drawable != null) {
drawable.mutate();
drawable.setColorFilter(primaryTextColor, PorterDuff.Mode.SRC_ATOP);
}
}
return super.onCreateOptionsMenu(menu);
}
public AlertDialog(Context context, int progressStyle) {
super(context, R.style.TransparentDialog);
backgroundPaddings = new Rect();
shadowDrawable = context.getResources().getDrawable(R.drawable.popup_fixed_alert).mutate();
shadowDrawable.setColorFilter(new PorterDuffColorFilter(getThemeColor(Theme.key_dialogBackground), PorterDuff.Mode.MULTIPLY));
shadowDrawable.getPadding(backgroundPaddings);
progressViewStyle = progressStyle;
}
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);
}
private void animateVerifiedSuccess() {
Bitmap qrBitmap = ((BitmapDrawable)qrCode.getDrawable()).getBitmap();
Bitmap qrSuccess = createVerifiedBitmap(qrBitmap.getWidth(), qrBitmap.getHeight(), R.drawable.ic_check_white_48dp);
qrVerified.setImageBitmap(qrSuccess);
qrVerified.getBackground().setColorFilter(getResources().getColor(R.color.green_500), PorterDuff.Mode.MULTIPLY);
animateVerified();
}
private void animateVerifiedFailure() {
Bitmap qrBitmap = ((BitmapDrawable)qrCode.getDrawable()).getBitmap();
Bitmap qrSuccess = createVerifiedBitmap(qrBitmap.getWidth(), qrBitmap.getHeight(), R.drawable.ic_close_white_48dp);
qrVerified.setImageBitmap(qrSuccess);
qrVerified.getBackground().setColorFilter(getResources().getColor(R.color.red_500), PorterDuff.Mode.MULTIPLY);
animateVerified();
}
private Bitmap getCircleBitmap(final int radius) {
final Bitmap output = Bitmap.createBitmap(originBitmap.getWidth(), originBitmap.getHeight(), Bitmap.Config.ARGB_8888);
final Canvas canvas = new Canvas(output);
final Paint paint = new Paint();
final Rect rect = new Rect((int)(x - radius), (int)(y - radius), (int)(x + radius), (int)(y + radius));
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
canvas.drawCircle(x, y, radius, paint);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(originBitmap, rect, rect, paint);
return output;
}
public void setImageResource(int resId, int color) {
Drawable drawable = getResources().getDrawable(resId);
if (drawable != null) {
drawable.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
}
imageReceiver.setImageBitmap(drawable);
invalidate();
}
public AccountSelectCell(Context context) {
super(context);
avatarDrawable = new AvatarDrawable();
avatarDrawable.setTextSize(AndroidUtilities.dp(12));
imageView = new BackupImageView(context);
imageView.setRoundRadius(AndroidUtilities.dp(18));
addView(imageView, LayoutHelper.createFrame(36, 36, Gravity.LEFT | Gravity.TOP, 10, 10, 0, 0));
textView = new TextView(context);
textView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem));
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
textView.setLines(1);
textView.setMaxLines(1);
textView.setSingleLine(true);
textView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
textView.setEllipsize(TextUtils.TruncateAt.END);
addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 61, 0, 56, 0));
checkImageView = new ImageView(context);
checkImageView.setImageResource(R.drawable.account_check);
checkImageView.setScaleType(ImageView.ScaleType.CENTER);
checkImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_menuItemCheck), PorterDuff.Mode.MULTIPLY));
addView(checkImageView, LayoutHelper.createFrame(40, LayoutHelper.MATCH_PARENT, Gravity.RIGHT | Gravity.TOP, 0, 0, 6, 0));
}
public CornerMask(@NonNull View view) {
view.setLayerType(View.LAYER_TYPE_HARDWARE, null);
clearPaint.setColor(Color.BLACK);
clearPaint.setStyle(Paint.Style.FILL);
clearPaint.setAntiAlias(true);
clearPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
}