@Override
protected void onDraw(Canvas canvas) {
int pic=SkinMan.currentSkin.actionPicture();
Drawable backgroundDrawable = pic!=0 ? ContextCompat.getDrawable(getContext(), pic) : ApplicationLoader.getCachedWallpaper();
int color = ApplicationLoader.getServiceMessageColor();
if (currentColor != color) {
currentColor = color;
shadowView.getDrawable().setColorFilter(new PorterDuffColorFilter(color | 0xff000000, PorterDuff.Mode.MULTIPLY));
}
if (ApplicationLoader.isCustomTheme() || pic !=0 && backgroundDrawable != null) {
phoneTextView.setTextColor(0xffffffff);
shadowView.setVisibility(VISIBLE);
if (backgroundDrawable instanceof ColorDrawable) {
backgroundDrawable.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight());
backgroundDrawable.draw(canvas);
} else if (backgroundDrawable instanceof BitmapDrawable) {
Bitmap bitmap = ((BitmapDrawable) backgroundDrawable).getBitmap();
float scaleX = (float) getMeasuredWidth() / (float) bitmap.getWidth();
float scaleY = (float) getMeasuredHeight() / (float) bitmap.getHeight();
float scale = scaleX < scaleY ? scaleY : scaleX;
int width = (int) (getMeasuredWidth() / scale);
int height = (int) (getMeasuredHeight() / scale);
int x = (bitmap.getWidth() - width) / 2;
int y = (bitmap.getHeight() - height) / 2;
srcRect.set(x, y, x + width, y + height);
destRect.set(0, 0, getMeasuredWidth(), getMeasuredHeight());
canvas.drawBitmap(bitmap, srcRect, destRect, paint);
}
} else {
shadowView.setVisibility(INVISIBLE);
phoneTextView.setTextColor(0xffc2e5ff);
super.onDraw(canvas);
}
}
java类android.graphics.PorterDuffColorFilter的实例源码
DrawerProfileCell.java 文件源码
项目:airgram
阅读 30
收藏 0
点赞 0
评论 0
BGASwipeBackLayout2.java 文件源码
项目:WechatChatroomHelper
阅读 34
收藏 0
点赞 0
评论 0
private void dimChildView(View v, float mag, int fadeColor) {
final LayoutParams lp = (LayoutParams) v.getLayoutParams();
if (mag > 0 && fadeColor != 0) {
final int baseAlpha = (fadeColor & 0xff000000) >>> 24;
int imag = (int) (baseAlpha * mag);
int color = imag << 24 | (fadeColor & 0xffffff);
if (lp.dimPaint == null) {
lp.dimPaint = new Paint();
}
lp.dimPaint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_OVER));
if (ViewCompat.getLayerType(v) != ViewCompat.LAYER_TYPE_HARDWARE) {
ViewCompat.setLayerType(v, ViewCompat.LAYER_TYPE_HARDWARE, lp.dimPaint);
}
invalidateChildRegion(v);
} else if (ViewCompat.getLayerType(v) != ViewCompat.LAYER_TYPE_NONE) {
if (lp.dimPaint != null) {
lp.dimPaint.setColorFilter(null);
}
final DisableLayerRunnable dlr = new DisableLayerRunnable(v);
mPostedRunnables.add(dlr);
ViewCompat.postOnAnimation(this, dlr);
}
}
HoldingDrawable.java 文件源码
项目:HoldingButton
阅读 38
收藏 0
点赞 0
评论 0
public void setIcon(Bitmap bitmap) {
if (bitmap != null) {
mIconWidth = bitmap.getWidth();
mIconHeight = bitmap.getHeight();
mIconShader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
mIconShader.setLocalMatrix(mIconMatrix);
mIconPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mIconPaint.setShader(mIconShader);
mIconPaint.setColorFilter(new PorterDuffColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN));
invalidateSelf();
} else {
mIconWidth = 0;
mIconHeight = 0;
mIconShader = null;
mIconMatrix = null;
mIconPaint = null;
}
}
TintLayerDrawable.java 文件源码
项目:android_ui
阅读 42
收藏 0
点赞 0
评论 0
/**
* Updates tint of a layer with the specified <var>layerId</var> of the wrapped drawable
* depends on the specified <var>stateSet</var>.
*
* @param layerId Id of the desired layer of which tint to update.
* @param stateSet State set to properly resolve tint color.
* @return {@code True} if tint has ben updated, {@code false} otherwise.
*/
private boolean updateDrawableLayerTint(int layerId, int[] stateSet) {
if ((mPrivateFlags & PFLAG_HAS_COLOR_FILTER) == 0) {
final Drawable drawable = ((LayerDrawable) mDrawable).findDrawableByLayerId(layerId);
if (drawable == null) {
return false;
}
final DrawableLayerTint layerTint = mDrawableLayerTints != null ? mDrawableLayerTints.get(layerId) : null;
if (layerTint != null && layerTint.tintList != null && layerTint.tintMode != null) {
final int tintColor = layerTint.tintList.getColorForState(stateSet, layerTint.currentTint);
if (tintColor != layerTint.currentTint || (mPrivateFlags & PFLAG_TINT_COLOR_CACHING_ENABLED) == 0) {
drawable.setColorFilter(new PorterDuffColorFilter(tintColor, layerTint.tintMode));
layerTint.currentTint = tintColor;
}
} else {
drawable.clearColorFilter();
}
return true;
}
return false;
}
TintDrawable.java 文件源码
项目:android_ui
阅读 38
收藏 0
点赞 0
评论 0
/**
* Updates tint of the wrapped drawable depends on the specified <var>stateSet</var>.
*
* @param stateSet State set to properly resolve tint color.
* @return {@code True} if tint has ben updated, {@code false} otherwise.
*/
private boolean updateTint(int[] stateSet) {
if ((mPrivateFlags & PFLAG_HAS_COLOR_FILTER) == 0) {
if (mTintList != null && mTintMode != null) {
final int tintColor = mTintList.getColorForState(stateSet, mCurrentTint);
if (tintColor != mCurrentTint || (mPrivateFlags & PFLAG_TINT_COLOR_CACHING_ENABLED) == 0) {
super.setColorFilter(new PorterDuffColorFilter(tintColor, mTintMode));
this.mCurrentTint = tintColor;
}
} else {
super.clearColorFilter();
}
}
return false;
}
ShadowParentView.java 文件源码
项目:react-native-andorid-shadow
阅读 35
收藏 0
点赞 0
评论 0
private void decodeShadowBounds() {
if (hasShadowColor) {
shadowDrawable.setColorFilter(new PorterDuffColorFilter(shadowColor, PorterDuff.Mode.SRC_IN));
}
Rect pad = new Rect();
shadowDrawable.getPadding(pad);
View view = getChildAt(0);
Rect bounds = new Rect(view.getLeft()-pad.left, view.getTop()-pad.top,
view.getRight()+pad.right, view.getBottom()+pad.bottom);
shadowPadding = Math.max(Math.max(pad.left,pad.top),Math.max(pad.right,pad.bottom));
shadowDrawable.setBounds(bounds);
}
ScribbleToolbar.java 文件源码
项目:PeSanKita-android
阅读 38
收藏 0
点赞 0
评论 0
private void setBrushSelected(boolean enabled) {
if (enabled) {
this.textView.setBackground(null);
this.textView.setColorFilter(new PorterDuffColorFilter(foregroundUnselectedTint, PorterDuff.Mode.MULTIPLY));
this.brushView.setBackground(background);
this.brushView.setColorFilter(new PorterDuffColorFilter(foregroundSelectedTint, PorterDuff.Mode.MULTIPLY));
this.stickerView.setBackground(null);
this.stickerView.setColorFilter(new PorterDuffColorFilter(foregroundUnselectedTint, PorterDuff.Mode.MULTIPLY));
this.separatorView.setVisibility(View.VISIBLE);
this.undoView.setVisibility(View.VISIBLE);
this.deleteView.setVisibility(View.GONE);
this.selected = Selected.BRUSH;
} else {
this.brushView.setBackground(null);
this.brushView.setColorFilter(new PorterDuffColorFilter(foregroundUnselectedTint, PorterDuff.Mode.MULTIPLY));
this.separatorView.setVisibility(View.GONE);
this.undoView.setVisibility(View.GONE);
this.selected = Selected.NONE;
}
}
ScribbleToolbar.java 文件源码
项目:PeSanKita-android
阅读 31
收藏 0
点赞 0
评论 0
public void setTextSelected(boolean enabled) {
if (enabled) {
this.brushView.setBackground(null);
this.brushView.setColorFilter(new PorterDuffColorFilter(foregroundUnselectedTint, PorterDuff.Mode.MULTIPLY));
this.textView.setBackground(background);
this.textView.setColorFilter(new PorterDuffColorFilter(foregroundSelectedTint, PorterDuff.Mode.MULTIPLY));
this.stickerView.setBackground(null);
this.stickerView.setColorFilter(new PorterDuffColorFilter(foregroundUnselectedTint, PorterDuff.Mode.MULTIPLY));
this.separatorView.setVisibility(View.VISIBLE);
this.undoView.setVisibility(View.GONE);
this.deleteView.setVisibility(View.VISIBLE);
this.selected = Selected.TEXT;
} else {
this.textView.setBackground(null);
this.textView.setColorFilter(new PorterDuffColorFilter(foregroundUnselectedTint, PorterDuff.Mode.MULTIPLY));
this.separatorView.setVisibility(View.GONE);
this.deleteView.setVisibility(View.GONE);
this.selected = Selected.NONE;
}
}
ScribbleToolbar.java 文件源码
项目:PeSanKita-android
阅读 35
收藏 0
点赞 0
评论 0
public void setStickerSelected(boolean enabled) {
if (enabled) {
this.brushView.setBackground(null);
this.brushView.setColorFilter(new PorterDuffColorFilter(foregroundUnselectedTint, PorterDuff.Mode.MULTIPLY));
this.textView.setBackground(null);
this.textView.setColorFilter(new PorterDuffColorFilter(foregroundUnselectedTint, PorterDuff.Mode.MULTIPLY));
this.separatorView.setVisibility(View.VISIBLE);
this.undoView.setVisibility(View.GONE);
this.deleteView.setVisibility(View.VISIBLE);
this.selected = Selected.STICKER;
} else {
this.separatorView.setVisibility(View.GONE);
this.deleteView.setVisibility(View.GONE);
this.selected = Selected.NONE;
}
}
ResideLayout.java 文件源码
项目:AppFirCloud
阅读 31
收藏 0
点赞 0
评论 0
private void dimChildView(View v, float mag, int fadeColor) {
final LayoutParams lp = (LayoutParams) v.getLayoutParams();
if (mag > 0 && fadeColor != 0) {
final int baseAlpha = (fadeColor & 0xff000000) >>> 24;
int imag = (int) (baseAlpha * mag);
int color = imag << 24 | (fadeColor & 0xffffff);
if (lp.dimPaint == null) {
lp.dimPaint = new Paint();
}
lp.dimPaint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_OVER));
if (ViewCompat.getLayerType(v) != ViewCompat.LAYER_TYPE_HARDWARE) {
ViewCompat.setLayerType(v, ViewCompat.LAYER_TYPE_HARDWARE, lp.dimPaint);
}
invalidateChildRegion(v);
} else if (ViewCompat.getLayerType(v) != ViewCompat.LAYER_TYPE_NONE) {
if (lp.dimPaint != null) {
lp.dimPaint.setColorFilter(null);
}
final DisableLayerRunnable dlr = new DisableLayerRunnable(v);
mPostedRunnables.add(dlr);
ViewCompat.postOnAnimation(this, dlr);
}
}
DrawerActionCell.java 文件源码
项目:airgram
阅读 32
收藏 0
点赞 0
评论 0
public void setTextAndIcon(String text, int resId) {
try {
textView.setText(text);
Drawable d= ContextCompat.getDrawable(getContext(), resId);
d.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP));
textView.setCompoundDrawablesWithIntrinsicBounds(d, null, null, null);
} catch (Throwable e) {
FileLog.e("tmessages", e);
}
}
Switch.java 文件源码
项目:airgram
阅读 40
收藏 0
点赞 0
评论 0
@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 ? 0xffa0d6fa : 0xffc7c7c7, PorterDuff.Mode.MULTIPLY));
}
if (mThumbDrawable != null) {
mThumbDrawable.setColorFilter(new PorterDuffColorFilter(checked ? 0xff45abef : 0xffededed, PorterDuff.Mode.MULTIPLY));
}
}
ResideLayout.java 文件源码
项目:RX_Demo
阅读 41
收藏 0
点赞 0
评论 0
private void dimChildView(View v, float mag, int fadeColor) {
final LayoutParams lp = (LayoutParams) v.getLayoutParams();
if (mag > 0 && fadeColor != 0) {
final int baseAlpha = (fadeColor & 0xff000000) >>> 24;
int imag = (int) (baseAlpha * mag);
int color = imag << 24 | (fadeColor & 0xffffff);
if (lp.dimPaint == null) {
lp.dimPaint = new Paint();
}
lp.dimPaint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_OVER));
if (ViewCompat.getLayerType(v) != ViewCompat.LAYER_TYPE_HARDWARE) {
ViewCompat.setLayerType(v, ViewCompat.LAYER_TYPE_HARDWARE, lp.dimPaint);
}
invalidateChildRegion(v);
} else if (ViewCompat.getLayerType(v) != ViewCompat.LAYER_TYPE_NONE) {
if (lp.dimPaint != null) {
lp.dimPaint.setColorFilter(null);
}
final DisableLayerRunnable dlr = new DisableLayerRunnable(v);
mPostedRunnables.add(dlr);
ViewCompat.postOnAnimation(this, dlr);
}
}
BaseFragment.java 文件源码
项目:argus-android
阅读 40
收藏 0
点赞 0
评论 0
private void applyTheme(final View view) {
ArgusTheme theme = Argus.getInstance().getArgusTheme();
if (theme.getLogo() != 0) {
ImageView iv = (ImageView) view.findViewById(R.id.iv_logo);
if (iv != null) {
iv.setImageResource(theme.getLogo());
}
}
PorterDuffColorFilter filter = new PorterDuffColorFilter(
ViewUtils.fetchAccentColor(getContext()), PorterDuff.Mode.MULTIPLY);
ContextCompat.getDrawable(getContext(), R.drawable.email_icon).setColorFilter(filter);
ContextCompat.getDrawable(getContext(), R.drawable.password_icon).setColorFilter(filter);
ContextCompat.getDrawable(getContext(), R.drawable.icn_show_pwd).setColorFilter(filter);
ContextCompat.getDrawable(getContext(), R.drawable.ic_hide_pwd).setColorFilter(filter);
}
ColorFilterTransformation.java 文件源码
项目:Picasso-transformations
阅读 37
收藏 0
点赞 0
评论 0
@Override public Bitmap transform(Bitmap source) {
int width = source.getWidth();
int height = source.getHeight();
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setColorFilter(new PorterDuffColorFilter(mColor, PorterDuff.Mode.SRC_ATOP));
canvas.drawBitmap(source, 0, 0, paint);
source.recycle();
return bitmap;
}
Timber6.java 文件源码
项目:Hello-Music-droid
阅读 39
收藏 0
点赞 0
评论 0
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(
R.layout.fragment_timber6, container, false);
setMusicStateListener();
setSongDetails(rootView);
initGestures(rootView.findViewById(R.id.album_art));
((SeekBar) rootView.findViewById(R.id.song_progress)).getProgressDrawable().setColorFilter(new PorterDuffColorFilter(Color.WHITE, PorterDuff.Mode.MULTIPLY));
((SeekBar) rootView.findViewById(R.id.song_progress)).getThumb().setColorFilter(new PorterDuffColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP));
nextSong = (TextView) rootView.findViewById(R.id.title_next);
nextArt = (CircleImageView) rootView.findViewById(R.id.album_art_next);
rootView.findViewById(R.id.nextView).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
MusicPlayer.setQueuePosition(MusicPlayer.getQueuePosition() + 1);
}
});
return rootView;
}
ScribbleToolbar.java 文件源码
项目:Cable-Android
阅读 44
收藏 0
点赞 0
评论 0
public void setStickerSelected(boolean enabled) {
if (enabled) {
this.brushView.setBackground(null);
this.brushView.setColorFilter(new PorterDuffColorFilter(foregroundUnselectedTint, PorterDuff.Mode.MULTIPLY));
this.textView.setBackground(null);
this.textView.setColorFilter(new PorterDuffColorFilter(foregroundUnselectedTint, PorterDuff.Mode.MULTIPLY));
this.separatorView.setVisibility(View.VISIBLE);
this.undoView.setVisibility(View.GONE);
this.deleteView.setVisibility(View.VISIBLE);
this.selected = Selected.STICKER;
} else {
this.separatorView.setVisibility(View.GONE);
this.deleteView.setVisibility(View.GONE);
this.selected = Selected.NONE;
}
}
ColoringTest.java 文件源码
项目:silly-android
阅读 33
收藏 0
点赞 0
评论 0
/**
* Tests the {@link Coloring#colorVectorDrawable(VectorDrawable, int)} method.
* <p>
* Unfortunately {@link VectorDrawable#setColorFilter(int, PorterDuff.Mode)} is not mocked in Android JAR yet.
*/
@Test
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public final void testColorVectorDrawable() {
try {
final VectorDrawable vectorDrawable = new VectorDrawable();
assertNotNull("VectorDrawable is null", vectorDrawable);
final VectorDrawable colored = Coloring.colorVectorDrawable(vectorDrawable, Color.RED);
final PorterDuff.Mode mode = PorterDuff.Mode.SRC_ATOP;
assertEquals("Vector color filter does not match", new PorterDuffColorFilter(Color.RED, mode), colored.getColorFilter());
} catch (RuntimeException e) {
boolean knownIssue = e.getMessage().contains("not mocked");
if (!knownIssue) {
e.printStackTrace();
}
assertTrue("Unknown error: " + e.getMessage(), knownIssue);
}
}
BGASwipeBackLayout.java 文件源码
项目:WechatChatroomHelper
阅读 30
收藏 0
点赞 0
评论 0
private void dimChildView(View v, float mag, int fadeColor) {
final LayoutParams lp = (LayoutParams) v.getLayoutParams();
if (mag > 0 && fadeColor != 0) {
final int baseAlpha = (fadeColor & 0xff000000) >>> 24;
int imag = (int) (baseAlpha * mag);
int color = imag << 24 | (fadeColor & 0xffffff);
if (lp.dimPaint == null) {
lp.dimPaint = new Paint();
}
lp.dimPaint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_OVER));
if (ViewCompat.getLayerType(v) != ViewCompat.LAYER_TYPE_HARDWARE) {
ViewCompat.setLayerType(v, ViewCompat.LAYER_TYPE_HARDWARE, lp.dimPaint);
}
invalidateChildRegion(v);
} else if (ViewCompat.getLayerType(v) != ViewCompat.LAYER_TYPE_NONE) {
if (lp.dimPaint != null) {
lp.dimPaint.setColorFilter(null);
}
final DisableLayerRunnable dlr = new DisableLayerRunnable(v);
mPostedRunnables.add(dlr);
ViewCompat.postOnAnimation(this, dlr);
}
}
SlidingPaneLayout.java 文件源码
项目:letv
阅读 34
收藏 0
点赞 0
评论 0
private void dimChildView(View v, float mag, int fadeColor) {
LayoutParams lp = (LayoutParams) v.getLayoutParams();
if (mag > 0.0f && fadeColor != 0) {
int color = (((int) (((float) ((-16777216 & fadeColor) >>> 24)) * mag)) << 24) | (ViewCompat.MEASURED_SIZE_MASK & fadeColor);
if (lp.dimPaint == null) {
lp.dimPaint = new Paint();
}
lp.dimPaint.setColorFilter(new PorterDuffColorFilter(color, Mode.SRC_OVER));
if (ViewCompat.getLayerType(v) != 2) {
ViewCompat.setLayerType(v, 2, lp.dimPaint);
}
invalidateChildRegion(v);
} else if (ViewCompat.getLayerType(v) != 0) {
if (lp.dimPaint != null) {
lp.dimPaint.setColorFilter(null);
}
DisableLayerRunnable dlr = new DisableLayerRunnable(v);
this.mPostedRunnables.add(dlr);
ViewCompat.postOnAnimation(this, dlr);
}
}
ColorFilterTransformation.java 文件源码
项目:Glide-transformations
阅读 36
收藏 0
点赞 0
评论 0
@Override
public Resource<Bitmap> transform(Resource<Bitmap> resource, int outWidth, int outHeight) {
Bitmap source = resource.get();
int width = source.getWidth();
int height = source.getHeight();
Bitmap.Config config =
source.getConfig() != null ? source.getConfig() : Bitmap.Config.ARGB_8888;
Bitmap bitmap = mBitmapPool.get(width, height, config);
if (bitmap == null) {
bitmap = Bitmap.createBitmap(width, height, config);
}
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setColorFilter(new PorterDuffColorFilter(mColor, PorterDuff.Mode.SRC_ATOP));
canvas.drawBitmap(source, 0, 0, paint);
return BitmapResource.obtain(bitmap, mBitmapPool);
}
BoxFingerprint.java 文件源码
项目:PasscodeView
阅读 29
收藏 0
点赞 0
评论 0
@SuppressWarnings("deprecation")
@Override
void draw(@NonNull Canvas canvas) {
if (isFingerPrintBoxVisible) {
//Show fingerprint icon
Drawable d = getContext().getResources().getDrawable(R.drawable.ic_fingerprint);
d.setBounds((int) (mBounds.exactCenterX() - mBounds.height() / 4),
mBounds.top + 15,
(int) (mBounds.exactCenterX() + mBounds.height() / 4),
mBounds.top + mBounds.height() / 2 + 15);
d.setColorFilter(new PorterDuffColorFilter(mStatusTextPaint.getColor(), PorterDuff.Mode.SRC_ATOP));
d.draw(canvas);
//Show finger print text
canvas.drawText(mCurrentStatusText,
mBounds.exactCenterX(),
(float) (mBounds.top + (mBounds.height() / 1.3) - ((mStatusTextPaint.descent() + mStatusTextPaint.ascent()) / 2)),
mStatusTextPaint);
}
}
ToolbarColorizeHelper.java 文件源码
项目:IdeaTrackerPlus
阅读 36
收藏 0
点赞 0
评论 0
/**
* It's important to set overflowDescription atribute in styles, so we can grab the reference
* to the overflow icon. Check: res/values/styles.xml
*
* @param activity
* @param colorFilter
*/
private static void setOverflowButtonColor(final Activity activity, final PorterDuffColorFilter colorFilter) {
final String overflowDescription = activity.getString(R.string.abc_action_menu_overflow_description);
final ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
final ViewTreeObserver viewTreeObserver = decorView.getViewTreeObserver();
viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
final ArrayList<View> outViews = new ArrayList<View>();
decorView.findViewsWithText(outViews, overflowDescription,
View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
if (outViews.isEmpty()) {
return;
}
AppCompatImageView overflow = (AppCompatImageView) outViews.get(0);
overflow.setColorFilter(colorFilter);
removeOnGlobalLayoutListener(decorView, this);
}
});
}
Slate.java 文件源码
项目:PlusGram
阅读 30
收藏 0
点赞 0
评论 0
public void setPenColor(int color) {
mPenColor = color;
if (color == 0) {
// eraser: DST_OUT
mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
mPaint.setColor(Color.BLACK);
} else {
mPaint.setXfermode(null);
//mPaint.setColor(color);
mPaint.setColor(Color.BLACK); // or collor? or color & (mInkDensity << 24)?
mPaint.setAlpha(mInkDensity);
// mPaint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN));
mPaint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP));
}
}
ToolButton.java 文件源码
项目:PlusGram
阅读 38
收藏 0
点赞 0
评论 0
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (mPaint == null) return;
float x = 0.5f * getWidth();
float y = 0.5f * getHeight();
float r = Math.min(getWidth() - getPaddingLeft() - getPaddingRight(),
getHeight() - getPaddingTop() - getPaddingBottom()) * 0.5f;
int color = mFgColor.getColorForState(getDrawableState(), mFgColor.getDefaultColor());
mPaint.setColor(color);
mPaint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); // SRC_IN ??
tmpRF.set(x - r, y - r, x + r, y + r);
canvas.drawBitmap(icon, frame, tmpRF, mPaint);
}
ThemeUtils.java 文件源码
项目:Xndroid
阅读 37
收藏 0
点赞 0
评论 0
/**
* Gets the icon with an applied color filter
* for the correct theme.
*
* @param context the context to use.
* @param res the drawable resource to use.
* @param dark true for icon suitable for use with a dark theme,
* false for icon suitable for use with a light theme.
* @return a themed icon.
*/
@NonNull
public static Bitmap getThemedBitmap(@NonNull Context context, @DrawableRes int res, boolean dark) {
int color = dark ? getIconDarkThemeColor(context) : getIconLightThemeColor(context);
Bitmap sourceBitmap = getBitmapFromVectorDrawable(context, res);
Bitmap resultBitmap = Bitmap.createBitmap(sourceBitmap.getWidth(), sourceBitmap.getHeight(),
Bitmap.Config.ARGB_8888);
Paint p = new Paint();
ColorFilter filter = new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN);
p.setColorFilter(filter);
Canvas canvas = new Canvas(resultBitmap);
canvas.drawBitmap(sourceBitmap, 0, 0, p);
sourceBitmap.recycle();
return resultBitmap;
}
ToolbarColorizeHelper.java 文件源码
项目:RetroMusicPlayer
阅读 37
收藏 0
点赞 0
评论 0
/**
* It's important to set overflowDescription atribute in styles, so we can grab the reference
* to the overflow icon. Check: res/values/styles.xml
*
* @param activity
* @param colorFilter
*/
private static void setOverflowButtonColor(final Activity activity, final PorterDuffColorFilter colorFilter) {
final String overflowDescription = activity.getString(R.string.abc_action_menu_overflow_description);
final ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
final ViewTreeObserver viewTreeObserver = decorView.getViewTreeObserver();
viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
final ArrayList<View> outViews = new ArrayList<View>();
decorView.findViewsWithText(outViews, overflowDescription,
View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
if (outViews.isEmpty()) {
return;
}
final ActionMenuView overflowViewParent = (ActionMenuView) outViews.get(0).getParent();
overflowViewParent.getOverflowIcon().setColorFilter(colorFilter);
removeOnGlobalLayoutListener(decorView, this);
}
});
}
ScribbleToolbar.java 文件源码
项目:Cable-Android
阅读 38
收藏 0
点赞 0
评论 0
public void setTextSelected(boolean enabled) {
if (enabled) {
this.brushView.setBackground(null);
this.brushView.setColorFilter(new PorterDuffColorFilter(foregroundUnselectedTint, PorterDuff.Mode.MULTIPLY));
this.textView.setBackground(background);
this.textView.setColorFilter(new PorterDuffColorFilter(foregroundSelectedTint, PorterDuff.Mode.MULTIPLY));
this.stickerView.setBackground(null);
this.stickerView.setColorFilter(new PorterDuffColorFilter(foregroundUnselectedTint, PorterDuff.Mode.MULTIPLY));
this.separatorView.setVisibility(View.VISIBLE);
this.undoView.setVisibility(View.GONE);
this.deleteView.setVisibility(View.VISIBLE);
this.selected = Selected.TEXT;
} else {
this.textView.setBackground(null);
this.textView.setColorFilter(new PorterDuffColorFilter(foregroundUnselectedTint, PorterDuff.Mode.MULTIPLY));
this.separatorView.setVisibility(View.GONE);
this.deleteView.setVisibility(View.GONE);
this.selected = Selected.NONE;
}
}
ATButton.java 文件源码
项目:Assertive-Touch
阅读 34
收藏 0
点赞 0
评论 0
public void setBackgroundColor(int color) {
Drawable mDrawable = mApp.getResources().getDrawable(R.drawable.circle_button);
mDrawable.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN));
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
quickActionButton.setBackgroundDrawable(mDrawable);
} else {
quickActionButton.setBackground(mDrawable);
}
}
Blur.java 文件源码
项目:GitHub
阅读 48
收藏 0
点赞 0
评论 0
public static Bitmap of(Context context, Bitmap source, BlurFactor factor) {
int width = factor.width / factor.sampling;
int height = factor.height / factor.sampling;
if (Helper.hasZero(width, height)) {
return null;
}
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
canvas.scale(1 / (float) factor.sampling, 1 / (float) factor.sampling);
Paint paint = new Paint();
paint.setFlags(Paint.FILTER_BITMAP_FLAG | Paint.ANTI_ALIAS_FLAG);
PorterDuffColorFilter filter =
new PorterDuffColorFilter(factor.color, PorterDuff.Mode.SRC_ATOP);
paint.setColorFilter(filter);
canvas.drawBitmap(source, 0, 0, paint);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
try {
bitmap = Blur.rs(context, bitmap, factor.radius);
} catch (RSRuntimeException e) {
bitmap = Blur.stack(bitmap, factor.radius, true);
}
} else {
bitmap = Blur.stack(bitmap, factor.radius, true);
}
if (factor.sampling == BlurFactor.DEFAULT_SAMPLING) {
return bitmap;
} else {
Bitmap scaled = Bitmap.createScaledBitmap(bitmap, factor.width, factor.height, true);
bitmap.recycle();
return scaled;
}
}