Adjust LED colors

pull/437/head
Alex Baker 8 years ago
parent 5f74a510e9
commit 8d09920b3d

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

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

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

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

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

@ -132,23 +132,13 @@
</string-array>
<string-array name="led">
<item>@string/theme_yellow</item>
<item>@string/theme_blue_grey</item>
<item>@string/theme_white</item>
<item>@string/theme_red</item>
<item>@string/theme_pink</item>
<item>@string/theme_purple</item>
<item>@string/theme_deep_purple</item>
<item>@string/theme_indigo</item>
<item>@string/theme_blue</item>
<item>@string/theme_light_blue</item>
<item>@string/theme_cyan</item>
<item>@string/theme_teal</item>
<item>@string/theme_green</item>
<item>@string/theme_light_green</item>
<item>@string/theme_lime</item>
<item>@string/theme_amber</item>
<item>@string/theme_orange</item>
<item>@string/theme_deep_orange</item>
<item>@string/theme_yellow</item>
<item>@string/theme_green</item>
<item>@string/theme_blue</item>
<item>@string/theme_purple</item>
</string-array>
<string-array name="widget_background">

@ -82,6 +82,14 @@
<color name="blue_grey_500">#607d8b</color>
<color name="blue_grey_700">#455a64</color>
<color name="led_red">#ff0000</color>
<color name="led_orange">#ff4500</color>
<color name="led_yellow">#ffff00</color>
<color name="led_green">#00ff00</color>
<color name="led_blue">#0000ff</color>
<color name="led_purple">#800080</color>
<color name="led_white">#ffffff</color>
<color name="black_primary">#000000</color>
<color name="black_primary_dark">#000000</color>
<color name="black_accent">#ffffff</color>

@ -879,6 +879,7 @@ File %1$s contained %2$s.\n\n
<string name="theme_blue_grey">Blue Grey</string>
<string name="theme_black">Black</string>
<string name="theme_dark_grey">Dark Grey</string>
<string name="theme_white">White</string>
<string name="theme_light">Light</string>
<string name="theme_dark">Dark</string>
<string name="theme_wallpaper">Wallpaper</string>

@ -67,12 +67,15 @@
<PreferenceCategory
android:title="@string/led_notification">
<Preference
android:selectable="false"
android:summary="@string/hardware_support_required" />
<CheckBoxPreference
android:defaultValue="true"
android:dependency="@string/p_rmd_enabled"
android:key="@string/p_led_notification"
android:title="@string/enabled"
android:summary="@string/hardware_support_required"/>
android:title="@string/enabled"/>
<Preference
android:key="@string/p_led_color"

Loading…
Cancel
Save