From 8d09920b3df18a0264453d8d4e24d1f3f5194821 Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Sun, 24 Jul 2016 20:41:23 -0500 Subject: [PATCH] Adjust LED colors --- .../astrid/reminders/ReminderPreferences.java | 4 ++-- src/main/java/org/tasks/Notifier.java | 2 +- .../org/tasks/dialogs/ColorPickerDialog.java | 14 +++++++---- src/main/java/org/tasks/themes/LEDColor.java | 24 ++++++------------- .../java/org/tasks/themes/ThemeCache.java | 4 ++++ src/main/res/values/arrays.xml | 20 ++++------------ src/main/res/values/colors.xml | 8 +++++++ src/main/res/values/strings.xml | 1 + src/main/res/xml/preferences_reminders.xml | 7 ++++-- 9 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/main/java/com/todoroo/astrid/reminders/ReminderPreferences.java b/src/main/java/com/todoroo/astrid/reminders/ReminderPreferences.java index 01c00d5da..86588dd14 100644 --- a/src/main/java/com/todoroo/astrid/reminders/ReminderPreferences.java +++ b/src/main/java/com/todoroo/astrid/reminders/ReminderPreferences.java @@ -180,7 +180,7 @@ public class ReminderPreferences extends InjectingPreferenceActivity { protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_LED_PICKER) { if (resultCode == RESULT_OK) { - preferences.setInt(R.string.p_led_color, data.getIntExtra(ColorPickerActivity.EXTRA_THEME_INDEX, 0)); + preferences.setInt(R.string.p_led_color, data.getIntExtra(ColorPickerActivity.EXTRA_THEME_INDEX, 4)); updateLEDColor(); } } else if (requestCode == REQUEST_QUIET_START) { @@ -222,7 +222,7 @@ public class ReminderPreferences extends InjectingPreferenceActivity { } private void updateLEDColor() { - int index = preferences.getInt(R.string.p_led_color); + int index = preferences.getInt(R.string.p_led_color, 4); LEDColor ledColor = themeCache.getLEDColor(index); findPreference(getString(R.string.p_led_color)).setSummary(ledColor.getName()); } diff --git a/src/main/java/org/tasks/Notifier.java b/src/main/java/org/tasks/Notifier.java index 7a61ce906..b397c1b2b 100644 --- a/src/main/java/org/tasks/Notifier.java +++ b/src/main/java/org/tasks/Notifier.java @@ -305,7 +305,7 @@ public class Notifier { notification.flags |= Notification.FLAG_NO_CLEAR; } if (preferences.getBoolean(R.string.p_led_notification, true)) { - int accent = preferences.getInt(R.string.p_led_color); + int accent = preferences.getInt(R.string.p_led_color, 4); LEDColor ledColor = themeCache.getLEDColor(accent); notification.flags |= Notification.FLAG_SHOW_LIGHTS; notification.ledOffMS = 5000; diff --git a/src/main/java/org/tasks/dialogs/ColorPickerDialog.java b/src/main/java/org/tasks/dialogs/ColorPickerDialog.java index 1b7559f8c..a48cca9a7 100644 --- a/src/main/java/org/tasks/dialogs/ColorPickerDialog.java +++ b/src/main/java/org/tasks/dialogs/ColorPickerDialog.java @@ -64,7 +64,7 @@ public class ColorPickerDialog extends InjectingDialogFragment { theme = theme.withBaseTheme(themeCache.getThemeBase(2)); } - final String[] themes = context.getResources().getStringArray(getNameRes(palette)); + final String[] themes = context.getResources().getStringArray(getNameRes()); final LayoutInflater inflater = theme.getLayoutInflater(context); adapter = new ArrayAdapter(context, R.layout.color_selection_row, themes) { @@ -77,7 +77,7 @@ public class ColorPickerDialog extends InjectingDialogFragment { ? R.drawable.ic_lens_black_24dp : R.drawable.ic_vpn_key_black_24dp); Drawable wrapped = DrawableCompat.wrap(original.mutate()); - DrawableCompat.setTint(wrapped, getDisplayColor(palette, position)); + DrawableCompat.setTint(wrapped, getDisplayColor(position)); if (atLeastJellybeanMR1()) { textView.setCompoundDrawablesRelativeWithIntrinsicBounds(wrapped, null, null, null); } else { @@ -92,7 +92,7 @@ public class ColorPickerDialog extends InjectingDialogFragment { .setAdapter(adapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - if (preferences.hasPurchase(R.string.p_purchased_themes) || which < 2) { + if (preferences.hasPurchase(R.string.p_purchased_themes) || which < getNumFree()) { callback.themePicked(palette, which); } else { callback.initiateThemePurchase(); @@ -139,7 +139,7 @@ public class ColorPickerDialog extends InjectingDialogFragment { component.inject(this); } - private int getNameRes(ColorPickerDialog.ColorPalette palette) { + private int getNameRes() { switch (palette) { case COLORS: return R.array.colors; @@ -154,7 +154,7 @@ public class ColorPickerDialog extends InjectingDialogFragment { } } - private int getDisplayColor(ColorPickerDialog.ColorPalette palette, int index) { + private int getDisplayColor(int index) { switch (palette) { case COLORS: return themeCache.getThemeColor(index).getPrimaryColor(); @@ -168,4 +168,8 @@ public class ColorPickerDialog extends InjectingDialogFragment { return themeCache.getThemeBase(index).getContentBackground(); } } + + private int getNumFree() { + return palette == ColorPalette.LED ? themeCache.getLEDColorCount() : 2; + } } diff --git a/src/main/java/org/tasks/themes/LEDColor.java b/src/main/java/org/tasks/themes/LEDColor.java index 4382eb6ca..cac2b8bb3 100644 --- a/src/main/java/org/tasks/themes/LEDColor.java +++ b/src/main/java/org/tasks/themes/LEDColor.java @@ -5,23 +5,13 @@ import org.tasks.R; public class LEDColor { public static final int[] LED_COLORS = new int[]{ - R.color.yellow_a400, - R.color.blue_grey_400, - R.color.red_a400, - R.color.pink_a400, - R.color.purple_a400, - R.color.deep_purple_a400, - R.color.indigo_a400, - R.color.blue_a400, - R.color.light_blue_a400, - R.color.cyan_a400, - R.color.teal_a400, - R.color.green_a400, - R.color.light_green_a400, - R.color.lime_a400, - R.color.amber_a400, - R.color.orange_a400, - R.color.deep_orange_a400 + R.color.led_white, + R.color.led_red, + R.color.led_orange, + R.color.led_yellow, + R.color.led_green, + R.color.led_blue, + R.color.led_purple }; private final String name; private final int color; diff --git a/src/main/java/org/tasks/themes/ThemeCache.java b/src/main/java/org/tasks/themes/ThemeCache.java index 7cb2c5d34..96c9571f8 100644 --- a/src/main/java/org/tasks/themes/ThemeCache.java +++ b/src/main/java/org/tasks/themes/ThemeCache.java @@ -89,6 +89,10 @@ public class ThemeCache { return led.get(index); } + public int getLEDColorCount() { + return led.size(); + } + private static int resolveAttribute(Resources.Theme theme, int attribute) { TypedValue typedValue = new TypedValue(); theme.resolveAttribute(attribute, typedValue, true); diff --git a/src/main/res/values/arrays.xml b/src/main/res/values/arrays.xml index 3538d72e0..04f2d1ffb 100644 --- a/src/main/res/values/arrays.xml +++ b/src/main/res/values/arrays.xml @@ -132,23 +132,13 @@ - @string/theme_yellow - @string/theme_blue_grey + @string/theme_white @string/theme_red - @string/theme_pink - @string/theme_purple - @string/theme_deep_purple - @string/theme_indigo - @string/theme_blue - @string/theme_light_blue - @string/theme_cyan - @string/theme_teal - @string/theme_green - @string/theme_light_green - @string/theme_lime - @string/theme_amber @string/theme_orange - @string/theme_deep_orange + @string/theme_yellow + @string/theme_green + @string/theme_blue + @string/theme_purple diff --git a/src/main/res/values/colors.xml b/src/main/res/values/colors.xml index 5abf3534e..38f9e6aa6 100644 --- a/src/main/res/values/colors.xml +++ b/src/main/res/values/colors.xml @@ -82,6 +82,14 @@ #607d8b #455a64 + #ff0000 + #ff4500 + #ffff00 + #00ff00 + #0000ff + #800080 + #ffffff + #000000 #000000 #ffffff diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index e62cd005f..a8feebd90 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -879,6 +879,7 @@ File %1$s contained %2$s.\n\n Blue Grey Black Dark Grey + White Light Dark Wallpaper diff --git a/src/main/res/xml/preferences_reminders.xml b/src/main/res/xml/preferences_reminders.xml index 877119689..c9b239140 100644 --- a/src/main/res/xml/preferences_reminders.xml +++ b/src/main/res/xml/preferences_reminders.xml @@ -67,12 +67,15 @@ + + + android:title="@string/enabled"/>