Reduce accent brightness in dark mode

pull/935/head
Alex Baker 4 years ago
parent c3b6ac7b8c
commit 158621d6a9

@ -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
}

@ -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

@ -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;
}

@ -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<ThemeBase> themes = new ArrayList<>();
private final List<ThemeColor> colors = new ArrayList<>();
private final List<ThemeAccent> accents = new ArrayList<>();
private final List<WidgetTheme> 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<ThemeAccent> getAccents() {
return copyOf(accents);
}
public List<ThemeColor> getColors() {
return copyOf(colors);
}

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AmberAccent" parent="BlackTint">
<item name="colorSecondary">@color/amber_a100</item>
</style>
<style name="BlueAccent" parent="BlackTint">
<item name="colorSecondary">@color/blue_a100</item>
</style>
<style name="BlueGreyAccent" parent="BlackTint">
<item name="colorSecondary">@color/blue_grey_100</item>
</style>
<style name="CyanAccent" parent="BlackTint">
<item name="colorSecondary">@color/cyan_a100</item>
</style>
<style name="DeepOrangeAccent" parent="BlackTint">
<item name="colorSecondary">@color/deep_orange_a100</item>
</style>
<style name="DeepPurpleAccent" parent="BlackTint">
<item name="colorSecondary">@color/deep_purple_a100</item>
</style>
<style name="GreenAccent" parent="BlackTint">
<item name="colorSecondary">@color/green_a100</item>
</style>
<style name="IndigoAccent" parent="BlackTint">
<item name="colorSecondary">@color/indigo_a100</item>
</style>
<style name="LightBlueAccent" parent="BlackTint">
<item name="colorSecondary">@color/light_blue_a100</item>
</style>
<style name="LightGreenAccent" parent="BlackTint">
<item name="colorSecondary">@color/light_green_a100</item>
</style>
<style name="LimeAccent" parent="BlackTint">
<item name="colorSecondary">@color/lime_a100</item>
</style>
<style name="OrangeAccent" parent="BlackTint">
<item name="colorSecondary">@color/orange_a100</item>
</style>
<style name="PinkAccent" parent="BlackTint">
<item name="colorSecondary">@color/pink_a100</item>
</style>
<style name="PurpleAccent" parent="BlackTint">
<item name="colorSecondary">@color/purple_a100</item>
</style>
<style name="RedAccent" parent="BlackTint">
<item name="colorSecondary">@color/red_a100</item>
</style>
<style name="TealAccent" parent="BlackTint">
<item name="colorSecondary">@color/teal_a100</item>
</style>
<style name="YellowAccent" parent="BlackTint">
<item name="colorSecondary">@color/yellow_a100</item>
</style>
</resources>

@ -8,51 +8,67 @@
<color name="red_500">#f44336</color>
<color name="red_a400">#ff1744</color>
<color name="red_a100">#FF8A80</color>
<color name="pink_500">#e91e63</color>
<color name="pink_a400">#f50057</color>
<color name="pink_a100">#FF80AB</color>
<color name="purple_500">#9c27b0</color>
<color name="purple_a400">#d500f9</color>
<color name="purple_a100">#EA80FC</color>
<color name="deep_purple_500">#673ab7</color>
<color name="deep_purple_a400">#651fff</color>
<color name="deep_purple_a100">#B388FF</color>
<color name="indigo_500">#3f51b5</color>
<color name="indigo_a400">#3d5afe</color>
<color name="indigo_a100">#8C9EFF</color>
<color name="blue_500">#2196f3</color>
<color name="blue_a400">#2979ff</color>
<color name="blue_a100">#82B1FF</color>
<color name="light_blue_500">#03a9f4</color>
<color name="light_blue_a400">#00b0ff</color>
<color name="light_blue_a100">#80D8FF</color>
<color name="cyan_500">#00bcd4</color>
<color name="cyan_a400">#00e5ff</color>
<color name="cyan_a100">#84FFFF</color>
<color name="teal_500">#009688</color>
<color name="teal_a400">#1de9b6</color>
<color name="teal_a100">#A7FFEB</color>
<color name="green_500">#4caf50</color>
<color name="green_a400">#00e676</color>
<color name="green_a100">#B9F6CA</color>
<color name="light_green_500">#8bc34a</color>
<color name="light_green_a400">#76ff03</color>
<color name="light_green_a100">#CCFF90</color>
<color name="lime_500">#cddc39</color>
<color name="lime_a400">#c6ff00</color>
<color name="lime_a100">#F4FF81</color>
<color name="yellow_500">#ffeb3b</color>
<color name="yellow_a400">#ffea00</color>
<color name="yellow_a100">#FFFF8D</color>
<color name="amber_500">#ffc107</color>
<color name="amber_a400">#ffc400</color>
<color name="amber_a100">#FFE57F</color>
<color name="orange_500">#ff9800</color>
<color name="orange_a400">#ff9100</color>
<color name="orange_a100">#FFD180</color>
<color name="deep_orange_500">#ff5722</color>
<color name="deep_orange_a400">#ff3d00</color>
<color name="deep_orange_a100">#FF9E80</color>
<color name="brown_500">#795548</color>
@ -60,6 +76,7 @@
<color name="grey_800">#424242</color>
<color name="grey_900">#212121</color>
<color name="blue_grey_100">#CFD8DC</color>
<color name="blue_grey_400">#78909c</color>
<color name="blue_grey_500">#607d8b</color>

Loading…
Cancel
Save