diff --git a/app/src/main/java/org/tasks/dialogs/ColorPalettePicker.kt b/app/src/main/java/org/tasks/dialogs/ColorPalettePicker.kt index 275bbce50..b12fbaea5 100644 --- a/app/src/main/java/org/tasks/dialogs/ColorPalettePicker.kt +++ b/app/src/main/java/org/tasks/dialogs/ColorPalettePicker.kt @@ -18,6 +18,7 @@ import org.tasks.billing.Inventory import org.tasks.billing.PurchaseDialog import org.tasks.injection.DialogFragmentComponent import org.tasks.injection.InjectingDialogFragment +import org.tasks.themes.ThemeAccent import org.tasks.themes.ThemeCache import org.tasks.themes.ThemeColor import javax.inject.Inject @@ -70,7 +71,9 @@ class ColorPalettePicker : InjectingDialogFragment() { palette = arguments!!.getSerializable(EXTRA_PALETTE) as ColorPickerAdapter.Palette colors = when (palette) { ColorPickerAdapter.Palette.COLORS -> themeCache.colors - ColorPickerAdapter.Palette.ACCENTS -> themeCache.accents + ColorPickerAdapter.Palette.ACCENTS -> ThemeAccent.ACCENTS.mapIndexed { index, _ -> + ThemeAccent(context, index) + } ColorPickerAdapter.Palette.LAUNCHERS -> themeCache.colors.dropLast(1) ColorPickerAdapter.Palette.WIDGET_BACKGROUND -> themeCache.widgetThemes } diff --git a/app/src/main/java/org/tasks/injection/ActivityModule.java b/app/src/main/java/org/tasks/injection/ActivityModule.java index 1c6d6c06e..f53e92d2b 100644 --- a/app/src/main/java/org/tasks/injection/ActivityModule.java +++ b/app/src/main/java/org/tasks/injection/ActivityModule.java @@ -47,8 +47,8 @@ public class ActivityModule { @Provides @ActivityScope - public ThemeAccent getThemeAccent(ThemeCache themeCache, Preferences preferences) { - return themeCache.getThemeAccent(preferences.getInt(R.string.p_theme_accent, 1)); + public ThemeAccent getThemeAccent(Preferences preferences) { + return new ThemeAccent(activity, preferences.getInt(R.string.p_theme_accent, 1)); } @Provides diff --git a/app/src/main/java/org/tasks/themes/ThemeAccent.java b/app/src/main/java/org/tasks/themes/ThemeAccent.java index b2d96ed8d..f1f819c6a 100644 --- a/app/src/main/java/org/tasks/themes/ThemeAccent.java +++ b/app/src/main/java/org/tasks/themes/ThemeAccent.java @@ -1,14 +1,17 @@ package org.tasks.themes; +import android.content.Context; import android.content.res.Resources; import android.os.Parcel; import android.os.Parcelable; +import android.util.TypedValue; +import android.view.ContextThemeWrapper; import org.tasks.R; import org.tasks.dialogs.ColorPalettePicker.Pickable; public class ThemeAccent implements Pickable { - static final int[] ACCENTS = + public static final int[] ACCENTS = new int[] { R.style.BlueGreyAccent, R.style.RedAccent, @@ -42,12 +45,13 @@ public class ThemeAccent implements Pickable { }; private final int index; private final int style; - private final int accentColor; + @Deprecated private final int accentColor; - public ThemeAccent(int index, int accentColor) { + public ThemeAccent(Context context, int index) { this.index = index; this.style = ACCENTS[index]; - this.accentColor = accentColor; + Resources.Theme theme = new ContextThemeWrapper(context, ThemeAccent.ACCENTS[index]).getTheme(); + this.accentColor = resolveAttribute(theme, R.attr.colorSecondary); } private ThemeAccent(Parcel source) { @@ -56,6 +60,12 @@ public class ThemeAccent implements Pickable { accentColor = source.readInt(); } + private static int resolveAttribute(Resources.Theme theme, int attribute) { + TypedValue typedValue = new TypedValue(); + theme.resolveAttribute(attribute, typedValue, true); + return typedValue.data; + } + public void applyStyle(Resources.Theme theme) { theme.applyStyle(style, true); } @@ -81,6 +91,7 @@ public class ThemeAccent implements Pickable { return index; } + @Deprecated public int getAccentColor() { return accentColor; } diff --git a/app/src/main/java/org/tasks/themes/ThemeCache.java b/app/src/main/java/org/tasks/themes/ThemeCache.java index 7992771c0..6c1afcd1d 100644 --- a/app/src/main/java/org/tasks/themes/ThemeCache.java +++ b/app/src/main/java/org/tasks/themes/ThemeCache.java @@ -6,8 +6,6 @@ import static com.google.common.collect.ImmutableList.copyOf; import android.content.Context; import android.content.Intent; import android.content.res.Resources; -import android.util.TypedValue; -import android.view.ContextThemeWrapper; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatDelegate; import androidx.core.content.ContextCompat; @@ -27,7 +25,6 @@ public class ThemeCache { private final List themes = new ArrayList<>(); private final List colors = new ArrayList<>(); - private final List accents = new ArrayList<>(); private final List widgetThemes = new ArrayList<>(); private final ThemeColor untaggedColor; private final Preferences preferences; @@ -80,10 +77,6 @@ public class ThemeCache { colors.add( new ThemeColor(context, i, ContextCompat.getColor(context, ThemeColor.COLORS[i]))); } - for (int i = 0; i < ThemeAccent.ACCENTS.length; i++) { - Resources.Theme theme = new ContextThemeWrapper(context, ThemeAccent.ACCENTS[i]).getTheme(); - accents.add(new ThemeAccent(i, resolveAttribute(theme, R.attr.colorSecondary))); - } String[] widgetBackgroundNames = resources.getStringArray(R.array.widget_background); for (int i = 0; i < WidgetTheme.BACKGROUNDS.length; i++) { widgetThemes.add( @@ -98,12 +91,6 @@ public class ThemeCache { new ThemeColor(context, 19, getColor(context, R.color.tag_color_none_background)); } - private static int resolveAttribute(Resources.Theme theme, int attribute) { - TypedValue typedValue = new TypedValue(); - theme.resolveAttribute(attribute, typedValue, true); - return typedValue.data; - } - public WidgetTheme getWidgetTheme(int index) { return widgetThemes.get(index); } @@ -130,18 +117,10 @@ public class ThemeCache { return colors.get(index); } - public ThemeAccent getThemeAccent(int index) { - return accents.get(index); - } - public ThemeColor getUntaggedColor() { return untaggedColor; } - public List getAccents() { - return copyOf(accents); - } - public List getColors() { return copyOf(colors); } diff --git a/app/src/main/res/values-night/accents.xml b/app/src/main/res/values-night/accents.xml new file mode 100644 index 000000000..c30d18fec --- /dev/null +++ b/app/src/main/res/values-night/accents.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 0285d7b41..bfd04b371 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -8,51 +8,67 @@ #f44336 #ff1744 + #FF8A80 #e91e63 #f50057 + #FF80AB #9c27b0 #d500f9 + #EA80FC #673ab7 #651fff + #B388FF #3f51b5 #3d5afe + #8C9EFF #2196f3 #2979ff + #82B1FF #03a9f4 #00b0ff + #80D8FF #00bcd4 #00e5ff + #84FFFF #009688 #1de9b6 + #A7FFEB #4caf50 #00e676 + #B9F6CA #8bc34a #76ff03 + #CCFF90 #cddc39 #c6ff00 + #F4FF81 #ffeb3b #ffea00 + #FFFF8D #ffc107 #ffc400 + #FFE57F #ff9800 #ff9100 + #FFD180 #ff5722 #ff3d00 + #FF9E80 #795548 @@ -60,6 +76,7 @@ #424242 #212121 + #CFD8DC #78909c #607d8b