Java Code Examples for android.support.v4.graphics.drawable.DrawableCompat#setTint()

The following examples show how to use android.support.v4.graphics.drawable.DrawableCompat#setTint() . 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: ListItemDecorator.java    From Capstone-Project with MIT License 6 votes vote down vote up
public ListItemDecorator(Context context, int dividerLeftPaddingDp) {
    super();
    mSpacingPx = ScreenUtils.dpToPxInt(context, 16);
    mDividerLeftPadding = ScreenUtils.dpToPxInt(context, dividerLeftPaddingDp);
    final TypedArray styledAttributes = context.obtainStyledAttributes(ATTRS);
    mDivider = styledAttributes.getDrawable(0);
    switch (PredatorSharedPreferences.getCurrentTheme(context)) {
        case DARK:
            DrawableCompat.setTint(mDivider, ContextCompat.getColor(context, R.color.material_grey_400));
            break;
        case AMOLED:
            DrawableCompat.setTint(mDivider, ContextCompat.getColor(context, R.color.material_grey_400));
            break;
    }
    styledAttributes.recycle();
}
 
Example 2
Source File: InitdFragment.java    From KernelAdiutor with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected Drawable getTopFabDrawable() {
    Drawable drawable = DrawableCompat.wrap(
            ContextCompat.getDrawable(getActivity(), R.drawable.ic_add));
    DrawableCompat.setTint(drawable, Color.WHITE);
    return drawable;
}
 
Example 3
Source File: ExpandedAlarmViewHolder.java    From ClockPlus with GNU General Public License v3.0 5 votes vote down vote up
private void bindRingtone() {
    int iconTint = Utils.getTextColorFromThemeAttr(getContext(), R.attr.themedIconTint);

    Drawable ringtoneIcon = mRingtone.getCompoundDrawablesRelative()[0/*start*/];
    ringtoneIcon = DrawableCompat.wrap(ringtoneIcon.mutate());
    DrawableCompat.setTint(ringtoneIcon, iconTint);
    mRingtone.setCompoundDrawablesRelativeWithIntrinsicBounds(ringtoneIcon, null, null, null);

    String title = RingtoneManager.getRingtone(getContext(),
            getSelectedRingtoneUri()).getTitle(getContext());
    mRingtone.setText(title);
}
 
Example 4
Source File: WeatherAdapter.java    From Travel-Mate with MIT License 5 votes vote down vote up
@Override
public void onBindViewHolder(@NonNull WeatherHolder holder, int position) {
    Weather weather = mWeatherForecast.get(position);

    holder.dayOfWeek.setText(weather.getDayOfWeek());
    holder.minTemp.setText(String.valueOf(weather.getMinTemp()));
    holder.maxTemp.setText(String.valueOf(weather.getMaxTemp()));
    holder.date.setText(weather.getDate());
    holder.icon.setImageResource(weather.getImageId());
    DrawableCompat.setTint(holder.icon.getDrawable(), ContextCompat.getColor(mContext, android.R.color.white));

    setAnimation(holder.itemView, position);

}
 
Example 5
Source File: ImageUtils.java    From Crasher with Apache License 2.0 5 votes vote down vote up
public static Drawable getVectorDrawable(Context context, @DrawableRes int resId, @ColorInt int color) {
    VectorDrawableCompat drawable = null;
    try {
        drawable = VectorDrawableCompat.create(context.getResources(), resId, context.getTheme());
    } catch (Exception ignored) {
    }

    if (drawable != null) {
        Drawable icon = drawable.getCurrent();
        DrawableCompat.setTint(icon, color);
        return icon;
    }

    return new ColorDrawable(color);
}
 
Example 6
Source File: ImageCropperFragment.java    From CVScanner with GNU General Public License v3.0 5 votes vote down vote up
private void initializeViews(View view){
    mImageView = view.findViewById(R.id.cropImageView);
    mRotateLeft = view.findViewById(R.id.item_rotate_left);
    mRotateRight = view.findViewById(R.id.item_rotate_right);
    mSave = view.findViewById(R.id.item_save);

    mImageView.setHost(this);

    Bundle extras = getArguments();

    if(extras.containsKey(ARG_SRC_IMAGE_URI)){
        imageUri = Uri.parse(extras.getString(ARG_SRC_IMAGE_URI));
    }

    int buttonTintColor = getResources().getColor(extras.getInt(ARG_SAVE_IMAGE_COLOR_RES, R.color.colorAccent));
    int secondaryBtnTintColor = getResources().getColor(extras.getInt(ARG_RT_IMAGE_COLOR_RES, R.color.colorPrimary));
    Drawable saveBtnDrawable = getResources().getDrawable(extras.getInt(ARG_SAVE_IMAGE_RES, R.drawable.ic_check_circle));
    Drawable rotateLeftDrawable = getResources().getDrawable(extras.getInt(ARG_RT_LEFT_IMAGE_RES, R.drawable.ic_rotate_left));
    Drawable rotateRightDrawable = getResources().getDrawable(extras.getInt(ARG_RT_RIGHT_IMAGE_RES, R.drawable.ic_rotate_right));
    
    DrawableCompat.setTint(rotateLeftDrawable, secondaryBtnTintColor);
    mRotateLeft.setImageDrawable(rotateLeftDrawable);

    DrawableCompat.setTint(rotateRightDrawable, secondaryBtnTintColor);
    mRotateRight.setImageDrawable(rotateRightDrawable);

    DrawableCompat.setTint(saveBtnDrawable, buttonTintColor);
    mSave.setImageDrawable(saveBtnDrawable);
}
 
Example 7
Source File: BackupFragment.java    From KernelAdiutor with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected Drawable getTopFabDrawable() {
    Drawable drawable = DrawableCompat.wrap(
            ContextCompat.getDrawable(getActivity(), R.drawable.ic_add));
    DrawableCompat.setTint(drawable, Color.WHITE);
    return drawable;
}
 
Example 8
Source File: MultiContactPickerActivity.java    From MultiContactPicker with Apache License 2.0 5 votes vote down vote up
private void setSearchIconColor(MenuItem menuItem, final Integer color) {
    if(color != null) {
        Drawable drawable = menuItem.getIcon();
        if (drawable != null) {
            drawable = DrawableCompat.wrap(drawable);
            DrawableCompat.setTint(drawable.mutate(), color);
            menuItem.setIcon(drawable);
        }
    }
}
 
Example 9
Source File: VectorDrawableCompat.java    From VectorChildFinder with Apache License 2.0 5 votes vote down vote up
@SuppressLint("NewApi")
@Override
public void setTint(int tint) {
    if (mDelegateDrawable != null) {
        DrawableCompat.setTint(mDelegateDrawable, tint);
        return;
    }

    setTintList(ColorStateList.valueOf(tint));
}
 
Example 10
Source File: DrawMeShapeText.java    From DrawMe with Apache License 2.0 5 votes vote down vote up
private Drawable tintDrawable(Drawable drawable, int tintColor, int tintMode) {
    if (drawable == null || tintColor == 0) return drawable;

    Drawable wrapDrawable = DrawableCompat.wrap(drawable).mutate();
    DrawableCompat.setTint(wrapDrawable, tintColor);

    PorterDuff.Mode mode = intToMode(tintMode);
    if (mode != null && mode != PorterDuff.Mode.CLEAR)
        DrawableCompat.setTintMode(wrapDrawable, mode);
    return wrapDrawable;
}
 
Example 11
Source File: LoginFragment.java    From masterpassword with GNU General Public License v3.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_login, container, false);
    ButterKnife.bind(this, rootView);
    Drawable wrapped = DrawableCompat.wrap(ContextCompat.getDrawable(getContext(), R.drawable.ic_go));
    DrawableCompat.setTint(wrapped, ContextCompat.getColor(getContext(), R.color.login_icon_tint));
    loginButton.setImageDrawable(wrapped);
    wrapped = DrawableCompat.wrap(ContextCompat.getDrawable(getContext(), R.drawable.ic_fingerprint_black_24dp));
    DrawableCompat.setTint(wrapped, ContextCompat.getColor(getContext(), R.color.login_icon_tint));
    fingerprintIcon.setImageDrawable(wrapped);
    return rootView;
}
 
Example 12
Source File: ThemeUtil.java    From talk-android with MIT License 5 votes vote down vote up
public static Drawable getThemeDrawable(Resources res, @DrawableRes int drawableResId, String themeColor) {
        Drawable drawable = DrawableCompat.wrap(res.getDrawable(drawableResId).mutate());
        int color = res.getColor(getThemeColorRes(themeColor));
//        DrawableCompat.setTint(drawable, color);
        DrawableCompat.setTint(drawable, res.getColor(R.color.colorPrimary));
        DrawableCompat.setTintMode(drawable, PorterDuff.Mode.SRC_IN);
        return drawable;
    }
 
Example 13
Source File: MessageAdapter.java    From ChatView with MIT License 4 votes vote down vote up
public void setSeekBarThumbColor(int color){
    Drawable backgroundDrawable1 = DrawableCompat.wrap(audioSeekbar.getThumb()).mutate();
    DrawableCompat.setTint(backgroundDrawable1,color);
}
 
Example 14
Source File: PaddingDrawable.java    From MDPreference with Apache License 2.0 4 votes vote down vote up
@Override
public void setTint(int tint) {
    if(mDrawable != null)
        DrawableCompat.setTint(mDrawable, tint);
}
 
Example 15
Source File: IconUtils.java    From FireFiles with Apache License 2.0 4 votes vote down vote up
public static Drawable applyTint(Context context, int drawableId, int tintColorId) {
    final Drawable icon = getDrawable(context, drawableId);
    icon.mutate();
    DrawableCompat.setTint(DrawableCompat.wrap(icon), tintColorId);
    return icon;
}
 
Example 16
Source File: CommonActivity.java    From Sofia with Apache License 2.0 4 votes vote down vote up
private void setToolbarStatusBarAlpha(int color) {
    DrawableCompat.setTint(mToolbar.getBackground().mutate(), color);
    Sofia.with(this)
            .statusBarBackground(color);
}
 
Example 17
Source File: MessageAdapter.java    From ChatView with MIT License 4 votes vote down vote up
public void setBackgroundColor(int color){
    Drawable backgroundDrawable = DrawableCompat.wrap(audioSeekbar.getBackground()).mutate();
    DrawableCompat.setTint(backgroundDrawable,color);
}
 
Example 18
Source File: ViewUtils.java    From tribbble with Apache License 2.0 4 votes vote down vote up
public static void tintDrawable(TextView textView, int position) {
    DrawableCompat.setTint(textView.getCompoundDrawables()[position], color(R.color.textNormal));
}
 
Example 19
Source File: MessageAdapter.java    From ChatView with MIT License 4 votes vote down vote up
public void setBackgroundColor(int color){
    Drawable backgroundDrawable = DrawableCompat.wrap(leftIV.getBackground()).mutate();
    DrawableCompat.setTint(backgroundDrawable,color);
}
 
Example 20
Source File: MessageAdapter.java    From ChatView with MIT License 4 votes vote down vote up
public void setBackgroundColor(int color){
    Drawable backgroundDrawable = DrawableCompat.wrap(rightIV.getBackground()).mutate();
    DrawableCompat.setTint(backgroundDrawable,color);
}