|
|
|
@ -1,8 +1,16 @@
|
|
|
|
package org.tasks.tags;
|
|
|
|
package org.tasks.tags;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastLollipop;
|
|
|
|
import static org.tasks.preferences.ResourceResolver.getData;
|
|
|
|
import static org.tasks.preferences.ResourceResolver.getData;
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Context;
|
|
|
|
|
|
|
|
import android.graphics.Bitmap;
|
|
|
|
|
|
|
|
import android.graphics.Bitmap.Config;
|
|
|
|
|
|
|
|
import android.graphics.Canvas;
|
|
|
|
|
|
|
|
import android.graphics.Paint;
|
|
|
|
|
|
|
|
import android.graphics.PorterDuff;
|
|
|
|
|
|
|
|
import android.graphics.PorterDuffColorFilter;
|
|
|
|
|
|
|
|
import android.graphics.drawable.BitmapDrawable;
|
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
|
import android.os.Parcel;
|
|
|
|
import android.os.Parcel;
|
|
|
|
import android.os.Parcelable;
|
|
|
|
import android.os.Parcelable;
|
|
|
|
@ -118,14 +126,23 @@ public class CheckBoxTriStates extends AppCompatCheckBox {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Drawable original = getResources().getDrawable(btnDrawable);
|
|
|
|
Drawable original = getResources().getDrawable(btnDrawable);
|
|
|
|
Drawable drawable = original.mutate();
|
|
|
|
Drawable drawable;
|
|
|
|
drawable.setAlpha(alpha);
|
|
|
|
int color = state == State.UNCHECKED
|
|
|
|
DrawableCompat.setTint(
|
|
|
|
|
|
|
|
drawable,
|
|
|
|
|
|
|
|
state == State.UNCHECKED
|
|
|
|
|
|
|
|
? getResources().getColor(R.color.icon_tint)
|
|
|
|
? getResources().getColor(R.color.icon_tint)
|
|
|
|
: getData(getContext(), R.attr.colorAccent));
|
|
|
|
: getData(getContext(), R.attr.colorAccent);
|
|
|
|
|
|
|
|
if (atLeastLollipop()) {
|
|
|
|
|
|
|
|
drawable = original.mutate();
|
|
|
|
|
|
|
|
DrawableCompat.setTint(drawable, color);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Bitmap bitmap = ((BitmapDrawable) original).getBitmap();
|
|
|
|
|
|
|
|
Paint paint = new Paint();
|
|
|
|
|
|
|
|
paint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN));
|
|
|
|
|
|
|
|
Bitmap bitmapResult = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
|
|
|
|
|
|
|
|
Canvas canvas = new Canvas(bitmapResult);
|
|
|
|
|
|
|
|
canvas.drawBitmap(bitmap, 0, 0, paint);
|
|
|
|
|
|
|
|
drawable = new BitmapDrawable(getContext().getResources(), bitmapResult);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
drawable.setAlpha(alpha);
|
|
|
|
setButtonDrawable(drawable);
|
|
|
|
setButtonDrawable(drawable);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|