Mutate drawables before tinting

pull/413/head 4.8.21
Alex Baker 10 years ago
parent 14746d1f27
commit 5ac2db645f

@ -32,8 +32,8 @@ android {
defaultConfig {
applicationId "org.tasks"
versionCode 413
versionName "4.8.20"
versionCode 414
versionName "4.8.21"
minSdkVersion 14
targetSdkVersion 24
multiDexEnabled true

@ -64,7 +64,7 @@ public final class TaskerSettingsActivity extends AbstractFragmentPluginAppCompa
}
updateView();
toolbar.setNavigationIcon(DrawableCompat.wrap(getResources().getDrawable(R.drawable.ic_close_24dp)));
toolbar.setNavigationIcon(getResources().getDrawable(R.drawable.ic_close_24dp));
toolbar.setOnMenuItemClickListener(this);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override

@ -58,8 +58,8 @@ public class FilterSettingsActivity extends ThemedInjectingAppCompatActivity imp
filter = getIntent().getParcelableExtra(TOKEN_FILTER);
final boolean backButtonSavesTask = preferences.backButtonSavesTask();
toolbar.setNavigationIcon(DrawableCompat.wrap(getResources().getDrawable(
backButtonSavesTask ? R.drawable.ic_close_24dp : R.drawable.ic_save_24dp)));
toolbar.setNavigationIcon(getResources().getDrawable(
backButtonSavesTask ? R.drawable.ic_close_24dp : R.drawable.ic_save_24dp));
toolbar.setTitle(filter.listingTitle);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override

@ -131,8 +131,8 @@ public final class TaskEditFragment extends InjectingFragment implements Toolbar
}
final boolean backButtonSavesTask = preferences.backButtonSavesTask();
toolbar.setNavigationIcon(DrawableCompat.wrap(getResources().getDrawable(
backButtonSavesTask ? R.drawable.ic_close_24dp : R.drawable.ic_save_24dp)));
toolbar.setNavigationIcon(getResources().getDrawable(
backButtonSavesTask ? R.drawable.ic_close_24dp : R.drawable.ic_save_24dp));
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

@ -171,6 +171,7 @@ public final class TagsControlSet extends TaskEditControlFragment {
ThemeColor themeColor = themeCache.getThemeColor(tagData.getColor() >= 0 ? tagData.getColor() : 19);
view.setText(tagData.getName());
Drawable drawable = DrawableCompat.wrap(getResources().getDrawable(R.drawable.ic_label_24dp));
drawable.mutate();
DrawableCompat.setTint(drawable, themeColor.getPrimaryColor());
view.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
return view;

@ -243,6 +243,7 @@ public class CommentBarFragment extends TaskEditControlFragment {
TypedValue typedValue = new TypedValue();
getActivity().getTheme().resolveAttribute(R.attr.actionBarPrimaryText, typedValue, true);
Drawable drawable = DrawableCompat.wrap(getResources().getDrawable(R.drawable.ic_camera_alt_black_24dp));
drawable.mutate();
DrawableCompat.setTint(drawable, typedValue.data);
pictureButton.setImageDrawable(drawable);
}

@ -383,6 +383,7 @@ public class DeadlineControlSet extends TaskEditControlFragment {
private Drawable getUnderline(int color) {
Drawable drawable = DrawableCompat.wrap(context.getResources().getDrawable(R.drawable.textfield_underline_black));
drawable.mutate();
DrawableCompat.setTint(drawable, color);
return drawable;
}

@ -59,9 +59,7 @@ public class MenuColorizer {
}
public static void colorToolbar(Toolbar toolbar, int color) {
Drawable wrapped = DrawableCompat.wrap(toolbar.getNavigationIcon());
DrawableCompat.setTint(wrapped, color);
toolbar.setNavigationIcon(wrapped);
toolbar.setNavigationIcon(colorDrawable(toolbar.getNavigationIcon(), color));
toolbar.setTitleTextColor(color);
colorMenu(toolbar.getMenu(), color);
}
@ -82,12 +80,14 @@ public class MenuColorizer {
/** Sets a color filter on a {@link MenuItem} */
private static void colorMenuItem(final MenuItem menuItem, final int color) {
final Drawable drawable = menuItem.getIcon();
colorDrawable(menuItem.getIcon(), color);
}
private static Drawable colorDrawable(Drawable drawable, int color) {
if (drawable != null) {
// If we don't mutate the drawable, then all drawable's with this id will have a color
// filter applied to it.
drawable.mutate();
drawable.setColorFilter(color, PorterDuff.Mode.SRC_IN);
}
return drawable;
}
}

Loading…
Cancel
Save