Add AppCompat Day/Night theme

pull/437/head
Alex Baker 8 years ago
parent 18d1ae5ec6
commit 2e9227a97a

@ -91,7 +91,7 @@
<application <application
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/LightBase" android:theme="@style/Tasks"
android:allowBackup="true" android:allowBackup="true"
android:name=".Tasks" android:name=".Tasks"
android:supportsRtl="true" android:supportsRtl="true"
@ -175,22 +175,22 @@
<activity <activity
android:name=".preferences.HelpAndFeedbackActivity" android:name=".preferences.HelpAndFeedbackActivity"
android:label="@string/help_and_feedback" android:label="@string/help_and_feedback"
android:theme="@style/LightBase" /> android:theme="@style/Tasks" />
<activity <activity
android:name=".preferences.BasicPreferences" android:name=".preferences.BasicPreferences"
android:label="@string/TLA_menu_settings" android:label="@string/TLA_menu_settings"
android:theme="@style/LightBase" /> android:theme="@style/Tasks" />
<activity <activity
android:name=".preferences.MiscellaneousPreferences" android:name=".preferences.MiscellaneousPreferences"
android:label="@string/miscellaneous" android:label="@string/miscellaneous"
android:theme="@style/LightBase" /> android:theme="@style/Tasks" />
<activity <activity
android:name=".preferences.BackupPreferences" android:name=".preferences.BackupPreferences"
android:label="@string/backup_BPr_header" android:label="@string/backup_BPr_header"
android:theme="@style/LightBase" /> android:theme="@style/Tasks" />
<!-- Activity that configures widget --> <!-- Activity that configures widget -->
<activity <activity
@ -276,21 +276,21 @@
<activity <activity
android:name=".preferences.AppearancePreferences" android:name=".preferences.AppearancePreferences"
android:label="@string/EPr_appearance_header" android:label="@string/EPr_appearance_header"
android:theme="@style/LightBase" /> android:theme="@style/Tasks" />
<activity <activity
android:name=".preferences.DateShortcutPreferences" android:name=".preferences.DateShortcutPreferences"
android:label="@string/date_shortcuts" android:label="@string/date_shortcuts"
android:theme="@style/LightBase" /> android:theme="@style/Tasks" />
<activity <activity
android:name="com.todoroo.astrid.core.DefaultsPreferences" android:name="com.todoroo.astrid.core.DefaultsPreferences"
android:label="@string/task_defaults" android:label="@string/task_defaults"
android:theme="@style/LightBase"/> android:theme="@style/Tasks"/>
<activity <activity
android:name="com.todoroo.astrid.activity.BeastModePreferences" android:name="com.todoroo.astrid.activity.BeastModePreferences"
android:theme="@style/LightBase"/> android:theme="@style/Tasks"/>
<activity <activity
android:name=".reminders.MissedCallActivity" android:name=".reminders.MissedCallActivity"
@ -318,7 +318,7 @@
<!-- custom filters --> <!-- custom filters -->
<activity <activity
android:name="com.todoroo.astrid.core.CustomFilterActivity" android:name="com.todoroo.astrid.core.CustomFilterActivity"
android:theme="@style/LightBase"/> android:theme="@style/Tasks"/>
<!-- alarms --> <!-- alarms -->
<receiver android:name="com.todoroo.astrid.alarms.AlarmTaskRepeatListener"> <receiver android:name="com.todoroo.astrid.alarms.AlarmTaskRepeatListener">
@ -360,7 +360,7 @@
<activity <activity
android:name="com.todoroo.astrid.gcal.CalendarReminderActivity" android:name="com.todoroo.astrid.gcal.CalendarReminderActivity"
android:theme="@style/LightDialogBase"/> android:theme="@style/TasksDialog"/>
<receiver android:name="com.todoroo.astrid.gcal.CalendarAlarmReceiver" /> <receiver android:name="com.todoroo.astrid.gcal.CalendarAlarmReceiver" />
@ -368,7 +368,7 @@
<activity <activity
android:name="com.todoroo.astrid.core.OldTaskPreferences" android:name="com.todoroo.astrid.core.OldTaskPreferences"
android:label="@string/EPr_manage_header" android:label="@string/EPr_manage_header"
android:theme="@style/LightBase"/> android:theme="@style/Tasks"/>
<activity <activity
android:name=".activities.ClearAllDataActivity" android:name=".activities.ClearAllDataActivity"
@ -403,7 +403,7 @@
android:name="com.todoroo.astrid.files.AACRecordingActivity" android:name="com.todoroo.astrid.files.AACRecordingActivity"
android:configChanges="orientation|screenSize" android:configChanges="orientation|screenSize"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:theme="@style/LightDialogBase" /> android:theme="@style/TasksDialog" />
<activity <activity
android:name=".files.MyFilePickerActivity" android:name=".files.MyFilePickerActivity"
@ -430,7 +430,7 @@
<activity <activity
android:name="com.todoroo.astrid.reminders.ReminderPreferences" android:name="com.todoroo.astrid.reminders.ReminderPreferences"
android:label="@string/notifications" android:label="@string/notifications"
android:theme="@style/LightBase"/> android:theme="@style/Tasks"/>
<activity <activity
android:name=".voice.VoiceCommandActivity" android:name=".voice.VoiceCommandActivity"

@ -162,7 +162,7 @@ public class FilterAdapter extends ArrayAdapter<FilterListItem> {
Filter selected = ((TaskListActivity) activity).getCurrentFilter(); Filter selected = ((TaskListActivity) activity).getCurrentFilter();
if (selected != null && selected.equals(viewHolder.item)) { if (selected != null && selected.equals(viewHolder.item)) {
convertView.setBackgroundColor(getData(activity, R.attr.drawer_background_selected)); convertView.setBackgroundColor(activity.getResources().getColor(R.color.drawer_color_selected));
} }
} }
break; break;
@ -324,7 +324,7 @@ public class FilterAdapter extends ArrayAdapter<FilterListItem> {
viewHolder.icon.setImageResource(filter.icon); viewHolder.icon.setImageResource(filter.icon);
viewHolder.icon.setColorFilter(filter.tint >= 0 viewHolder.icon.setColorFilter(filter.tint >= 0
? themeCache.getThemeColor(filter.tint).getPrimaryColor() ? themeCache.getThemeColor(filter.tint).getPrimaryColor()
: theme.getThemeBase().getTextColor()); : getContext().getResources().getColor(R.color.text_primary));
String title = filter.listingTitle; String title = filter.listingTitle;
if(!title.equals(viewHolder.name.getText())) { if(!title.equals(viewHolder.name.getText())) {
@ -339,7 +339,7 @@ public class FilterAdapter extends ArrayAdapter<FilterListItem> {
viewHolder.size.setVisibility(countInt > 0 ? View.VISIBLE : View.INVISIBLE); viewHolder.size.setVisibility(countInt > 0 ? View.VISIBLE : View.INVISIBLE);
if (selection == viewHolder.item) { if (selection == viewHolder.item) {
viewHolder.view.setBackgroundColor(getData(activity, R.attr.drawer_background_selected)); viewHolder.view.setBackgroundColor(activity.getResources().getColor(R.color.drawer_color_selected));
} }
} }

@ -470,11 +470,11 @@ public class RepeatControlSet extends TaskEditControlFragment {
protected void refreshDisplayView() { protected void refreshDisplayView() {
if (doRepeat) { if (doRepeat) {
displayView.setText(getRepeatString()); displayView.setText(getRepeatString());
displayView.setTextColor(theme.getThemeBase().getTextColorPrimary()); displayView.setTextColor(getResources().getColor(R.color.text_primary));
clear.setVisibility(View.VISIBLE); clear.setVisibility(View.VISIBLE);
} else { } else {
displayView.setText(R.string.repeat_never); displayView.setText(R.string.repeat_never);
displayView.setTextColor(theme.getThemeBase().getTextColorTertiary()); displayView.setTextColor(getResources().getColor(R.color.text_tertiary));
clear.setVisibility(View.GONE); clear.setVisibility(View.GONE);
} }
} }

@ -221,10 +221,10 @@ public class TimerControlSet extends TaskEditControlFragment {
if (!TextUtils.isEmpty(toDisplay)) { if (!TextUtils.isEmpty(toDisplay)) {
displayEdit.setText(toDisplay); displayEdit.setText(toDisplay);
displayEdit.setTextColor(theme.getThemeBase().getTextColorPrimary()); displayEdit.setTextColor(getResources().getColor(R.color.text_primary));
} else { } else {
displayEdit.setText(R.string.TEA_timer_controls); displayEdit.setText(R.string.TEA_timer_controls);
displayEdit.setTextColor(theme.getThemeBase().getTextColorTertiary()); displayEdit.setTextColor(getResources().getColor(R.color.text_tertiary));
} }
} }

@ -102,14 +102,14 @@ public class HideUntilControlSet extends TaskEditControlFragment implements OnIt
if (value.setting == Task.HIDE_UNTIL_NONE) { if (value.setting == Task.HIDE_UNTIL_NONE) {
clearButton.setVisibility(View.GONE); clearButton.setVisibility(View.GONE);
tv.setText(value.label); tv.setText(value.label);
tv.setTextColor(themeBase.getTextColorTertiary()); tv.setTextColor(getContext().getColor(R.color.text_tertiary));
} else { } else {
String display = value.label; String display = value.label;
if (value.setting != Task.HIDE_UNTIL_SPECIFIC_DAY && value.setting != Task.HIDE_UNTIL_SPECIFIC_DAY_TIME) { if (value.setting != Task.HIDE_UNTIL_SPECIFIC_DAY && value.setting != Task.HIDE_UNTIL_SPECIFIC_DAY_TIME) {
display = display.toLowerCase(); display = display.toLowerCase();
} }
tv.setText(getString(R.string.TEA_hideUntil_display, display)); tv.setText(getString(R.string.TEA_hideUntil_display, display));
tv.setTextColor(themeBase.getTextColorPrimary()); tv.setTextColor(getContext().getColor(R.color.text_primary));
} }
return tv; return tv;
} }

@ -15,6 +15,7 @@ import org.tasks.analytics.Tracker;
import org.tasks.injection.ApplicationComponent; import org.tasks.injection.ApplicationComponent;
import org.tasks.injection.InjectingApplication; import org.tasks.injection.InjectingApplication;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
import org.tasks.themes.ThemeCache;
import javax.inject.Inject; import javax.inject.Inject;
@ -36,6 +37,7 @@ public class Tasks extends InjectingApplication {
@Inject Tracker tracker; @Inject Tracker tracker;
@Inject FlavorSetup flavorSetup; @Inject FlavorSetup flavorSetup;
@Inject BuildSetup buildSetup; @Inject BuildSetup buildSetup;
@Inject ThemeCache themeCache;
@Override @Override
public void onCreate() { public void onCreate() {
@ -45,6 +47,8 @@ public class Tasks extends InjectingApplication {
flavorSetup.setup(); flavorSetup.setup();
tracker.setTrackingEnabled(preferences.isTrackingEnabled()); tracker.setTrackingEnabled(preferences.isTrackingEnabled());
themeCache.getThemeBase(preferences.getInt(R.string.p_theme, 0)).applyDayNightMode();
} }
@Override @Override

@ -130,7 +130,7 @@ public class ThemePickerDialog extends InjectingDialogFragment {
case ACCENTS: case ACCENTS:
return themeCache.getThemeAccent(index).getAccentColor(); return themeCache.getThemeAccent(index).getAccentColor();
case WIDGET_BACKGROUND: case WIDGET_BACKGROUND:
return themeCache.getWidgetBackground(index).getBackgroundColor(); return themeCache.getWidgetTheme(index).getBackgroundColor();
default: default:
return themeCache.getThemeBase(index).getContentBackground(); return themeCache.getThemeBase(index).getContentBackground();
} }

@ -5,7 +5,6 @@ import android.os.Bundle;
import com.nononsenseapps.filepicker.FilePickerActivity; import com.nononsenseapps.filepicker.FilePickerActivity;
import org.tasks.analytics.Tracker; import org.tasks.analytics.Tracker;
import org.tasks.injection.ActivityComponent;
import org.tasks.injection.ActivityModule; import org.tasks.injection.ActivityModule;
import org.tasks.injection.InjectingApplication; import org.tasks.injection.InjectingApplication;
import org.tasks.themes.Theme; import org.tasks.themes.Theme;

@ -42,6 +42,7 @@ public abstract class AppCompatPreferenceActivity extends PreferenceActivity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
getDelegate().installViewFactory(); getDelegate().installViewFactory();
getDelegate().onCreate(savedInstanceState); getDelegate().onCreate(savedInstanceState);
getDelegate().applyDayNight();
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
} }
@ -118,7 +119,7 @@ public abstract class AppCompatPreferenceActivity extends PreferenceActivity {
getDelegate().invalidateOptionsMenu(); getDelegate().invalidateOptionsMenu();
} }
private AppCompatDelegate getDelegate() { protected AppCompatDelegate getDelegate() {
if (mDelegate == null) { if (mDelegate == null) {
mDelegate = AppCompatDelegate.create(this, null); mDelegate = AppCompatDelegate.create(this, null);
} }

@ -4,6 +4,7 @@ import android.app.Activity;
import android.app.FragmentManager; import android.app.FragmentManager;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle; import android.os.Bundle;
import android.preference.Preference; import android.preference.Preference;
@ -24,6 +25,7 @@ import org.tasks.locale.Locale;
import org.tasks.locale.LocalePickerDialog; import org.tasks.locale.LocalePickerDialog;
import org.tasks.themes.ThemeAccent; import org.tasks.themes.ThemeAccent;
import org.tasks.themes.ThemeBase; import org.tasks.themes.ThemeBase;
import org.tasks.themes.ThemeCache;
import org.tasks.themes.ThemeColor; import org.tasks.themes.ThemeColor;
import javax.inject.Inject; import javax.inject.Inject;
@ -50,6 +52,8 @@ public abstract class BaseBasicPreferences extends InjectingPreferenceActivity i
@Inject ThemeAccent themeAccent; @Inject ThemeAccent themeAccent;
@Inject DialogBuilder dialogBuilder; @Inject DialogBuilder dialogBuilder;
@Inject Locale locale; @Inject Locale locale;
@Inject ThemeCache themeCache;
private Bundle result; private Bundle result;
@Override @Override
@ -172,6 +176,8 @@ public abstract class BaseBasicPreferences extends InjectingPreferenceActivity i
switch (palette) { switch (palette) {
case THEMES: case THEMES:
preferences.setInt(R.string.p_theme, index); preferences.setInt(R.string.p_theme, index);
themeBase = themeCache.getThemeBase(index);
themeBase.applyDayNightMode(getDelegate());
tracker.reportEvent(Tracking.Events.SET_THEME, Integer.toString(index)); tracker.reportEvent(Tracking.Events.SET_THEME, Integer.toString(index));
break; break;
case COLORS: case COLORS:

@ -36,7 +36,7 @@ public class Theme {
} }
public int getDialogStyle() { public int getDialogStyle() {
return themeBase.getDialogStyle(); return R.style.TasksDialog;
} }
public LayoutInflater getLayoutInflater(Context context) { public LayoutInflater getLayoutInflater(Context context) {
@ -59,7 +59,6 @@ public class Theme {
activity.getWindow().setFormat(PixelFormat.RGBA_8888); activity.getWindow().setFormat(PixelFormat.RGBA_8888);
} }
public void applyToContext(Context context) { public void applyToContext(Context context) {
Resources.Theme theme = context.getTheme(); Resources.Theme theme = context.getTheme();
themeColor.applyStyle(theme); themeColor.applyStyle(theme);

@ -2,41 +2,33 @@ package org.tasks.themes;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.support.v7.app.AppCompatDelegate;
import android.view.ContextThemeWrapper; import android.view.ContextThemeWrapper;
import org.tasks.R; import org.tasks.R;
public class ThemeBase { public class ThemeBase {
public static final int[] THEMES = new int[] { public static final int[] THEMES = new int[]{
R.style.LightOverride, R.style.TasksOverride,
R.style.BaseBlack, R.style.ThemeBlack,
R.style.DarkOverride, R.style.TasksOverride,
R.style.Wallpaper R.style.Wallpaper,
R.style.TasksOverride
}; };
private final String name; private final String name;
private final int index; private final int index;
private final int textColorPrimary;
private final int textColorSecondary;
private final int textColorTertiary;
private final int style; private final int style;
private final int dialogStyle;
private final int contentBackground; private final int contentBackground;
private final int textColor; private final int dayNightMode;
public ThemeBase(String name, int index, int dialogStyle, int contentBackground, public ThemeBase(String name, int index, int dayNightMode) {
int textColor, int textColorPrimary, int textColorSecondary,
int textColorTertiary) {
this.name = name; this.name = name;
this.index = index; this.index = index;
this.textColorPrimary = textColorPrimary; this.dayNightMode = dayNightMode;
this.textColorSecondary = textColorSecondary;
this.textColorTertiary = textColorTertiary;
this.style = THEMES[index]; this.style = THEMES[index];
this.dialogStyle = dialogStyle; this.contentBackground = 0;
this.contentBackground = contentBackground;
this.textColor = textColor;
} }
public String getName() { public String getName() {
@ -47,18 +39,10 @@ public class ThemeBase {
return index; return index;
} }
public int getDialogStyle() {
return dialogStyle;
}
public int getContentBackground() { public int getContentBackground() {
return contentBackground; return contentBackground;
} }
public int getTextColor() {
return textColor;
}
public boolean isDarkTheme() { public boolean isDarkTheme() {
return index > 0; return index > 0;
} }
@ -71,15 +55,12 @@ public class ThemeBase {
activity.setTheme(style); activity.setTheme(style);
} }
public int getTextColorPrimary() { public void applyDayNightMode() {
return textColorPrimary; AppCompatDelegate.setDefaultNightMode(dayNightMode);
}
public int getTextColorSecondary() {
return textColorSecondary;
} }
public int getTextColorTertiary() { public void applyDayNightMode(AppCompatDelegate delegate) {
return textColorTertiary; applyDayNightMode();
delegate.setLocalNightMode(dayNightMode);
} }
} }

@ -2,6 +2,7 @@ package org.tasks.themes;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import android.support.v7.app.AppCompatDelegate;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.ContextThemeWrapper; import android.view.ContextThemeWrapper;
@ -15,24 +16,18 @@ public class ThemeCache {
private final List<ThemeBase> themes = new ArrayList<>(); private final List<ThemeBase> themes = new ArrayList<>();
private final List<ThemeColor> colors = new ArrayList<>(); private final List<ThemeColor> colors = new ArrayList<>();
private final List<ThemeAccent> accents = new ArrayList<>(); private final List<ThemeAccent> accents = new ArrayList<>();
private final List<WidgetBackground> widgetBackgrounds = new ArrayList<>(); private final List<WidgetTheme> widgetThemes = new ArrayList<>();
private final ThemeColor untaggedColor; private final ThemeColor untaggedColor;
public ThemeCache(Context context) { public ThemeCache(Context context) {
Resources resources = context.getResources(); Resources resources = context.getResources();
String[] themeNames = resources.getStringArray(R.array.themes);
for (int i = 0 ; i < ThemeBase.THEMES.length ; i++) { themes.add(new ThemeBase(context.getString(R.string.theme_light), 0, AppCompatDelegate.MODE_NIGHT_NO));
Resources.Theme theme = new ContextThemeWrapper(context, ThemeBase.THEMES[i]).getTheme(); themes.add(new ThemeBase(context.getString(R.string.theme_black), 1, AppCompatDelegate.MODE_NIGHT_YES));
themes.add(new ThemeBase( themes.add(new ThemeBase(context.getString(R.string.theme_dark), 2, AppCompatDelegate.MODE_NIGHT_YES));
themeNames[i], themes.add(new ThemeBase(context.getString(R.string.theme_wallpaper), 3, AppCompatDelegate.MODE_NIGHT_YES));
i, themes.add(new ThemeBase(context.getString(R.string.theme_day_night), 4, AppCompatDelegate.MODE_NIGHT_AUTO));
resolveAttribute(theme, R.attr.alertDialogTheme),
resolveAttribute(theme, R.attr.asContentBackground),
resolveAttribute(theme, R.attr.asTextColor),
resolveAttribute(theme, android.R.attr.textColorPrimary),
resolveAttribute(theme, android.R.attr.textColorSecondary),
resolveAttribute(theme, android.R.attr.textColorTertiary)));
}
String[] colorNames = resources.getStringArray(R.array.colors); String[] colorNames = resources.getStringArray(R.array.colors);
for (int i = 0 ; i < ThemeColor.COLORS.length ; i++) { for (int i = 0 ; i < ThemeColor.COLORS.length ; i++) {
Resources.Theme theme = new ContextThemeWrapper(context, ThemeColor.COLORS[i]).getTheme(); Resources.Theme theme = new ContextThemeWrapper(context, ThemeColor.COLORS[i]).getTheme();
@ -53,15 +48,18 @@ public class ThemeCache {
resolveAttribute(theme, R.attr.colorAccent))); resolveAttribute(theme, R.attr.colorAccent)));
} }
String[] widgetBackgroundNames = resources.getStringArray(R.array.widget_background); String[] widgetBackgroundNames = resources.getStringArray(R.array.widget_background);
for (int i = 0 ; i < WidgetBackground.BACKGROUNDS.length ; i++) { for (int i = 0; i < WidgetTheme.BACKGROUNDS.length ; i++) {
widgetBackgrounds.add(new WidgetBackground( widgetThemes.add(new WidgetTheme(
widgetBackgroundNames[i], i, resources.getColor(WidgetBackground.BACKGROUNDS[i]))); widgetBackgroundNames[i],
i,
resources.getColor(WidgetTheme.BACKGROUNDS[i]),
resources.getColor(i == 0 ? R.color.black_87 : R.color.white_100)));
} }
untaggedColor = new ThemeColor(null, 19, resources.getColor(R.color.tag_color_none_background), 0, resources.getColor(R.color.black_87), false); untaggedColor = new ThemeColor(null, 19, resources.getColor(R.color.tag_color_none_background), 0, resources.getColor(R.color.black_87), false);
} }
public WidgetBackground getWidgetBackground(int index) { public WidgetTheme getWidgetTheme(int index) {
return widgetBackgrounds.get(index); return widgetThemes.get(index);
} }
public ThemeBase getThemeBase(int index) { public ThemeBase getThemeBase(int index) {

@ -2,26 +2,32 @@ package org.tasks.themes;
import org.tasks.R; import org.tasks.R;
public class WidgetBackground { public class WidgetTheme {
public static final int[] BACKGROUNDS = new int[] { public static final int[] BACKGROUNDS = new int[] {
R.color.md_light_background, R.color.widget_background_light,
android.R.color.black, R.color.widget_background_black,
R.color.md_dark_background R.color.widget_background_dark
}; };
private final String name; private final String name;
private final int index; private final int index;
private final int backgroundColor; private final int backgroundColor;
private final int textColor;
public WidgetBackground(String name, int index, int backgroundColor) { public WidgetTheme(String name, int index, int backgroundColor, int textColor) {
this.name = name; this.name = name;
this.index = index; this.index = index;
this.backgroundColor = backgroundColor; this.backgroundColor = backgroundColor;
this.textColor = textColor;
} }
public int getBackgroundColor() { public int getBackgroundColor() {
return backgroundColor; return backgroundColor;
} }
public int getTextColor() {
return textColor;
}
public String getName() { public String getName() {
return name; return name;
} }

@ -304,15 +304,15 @@ public class CalendarControlSet extends TaskEditControlFragment {
private void refreshDisplayView() { private void refreshDisplayView() {
if (!Strings.isNullOrEmpty(eventUri)) { if (!Strings.isNullOrEmpty(eventUri)) {
calendar.setText(R.string.gcal_TEA_showCalendar_label); calendar.setText(R.string.gcal_TEA_showCalendar_label);
calendar.setTextColor(themeBase.getTextColorPrimary()); calendar.setTextColor(getResources().getColor(R.color.text_primary));
cancelButton.setVisibility(View.VISIBLE); cancelButton.setVisibility(View.VISIBLE);
} else if (calendarName != null) { } else if (calendarName != null) {
calendar.setText(calendarName); calendar.setText(calendarName);
calendar.setTextColor(themeBase.getTextColorPrimary()); calendar.setTextColor(getResources().getColor(R.color.text_primary));
cancelButton.setVisibility(View.VISIBLE); cancelButton.setVisibility(View.VISIBLE);
} else { } else {
calendar.setText(R.string.gcal_TEA_addToCalendar_label); calendar.setText(R.string.gcal_TEA_addToCalendar_label);
calendar.setTextColor(themeBase.getTextColorTertiary()); calendar.setTextColor(getResources().getColor(R.color.text_tertiary));
cancelButton.setVisibility(View.GONE); cancelButton.setVisibility(View.GONE);
} }
} }

@ -141,11 +141,11 @@ public class DeadlineControlSet extends TaskEditControlFragment {
tv.setText(dueDateOptions.get(selectedItemPosition)); tv.setText(dueDateOptions.get(selectedItemPosition));
int textColor; int textColor;
if (date == 0) { if (date == 0) {
textColor = themeBase.getTextColorTertiary(); textColor = getResources().getColor(R.color.text_tertiary);
} else if (date < newDateTime().startOfDay().getMillis()) { } else if (date < newDateTime().startOfDay().getMillis()) {
textColor = overdueColor; textColor = overdueColor;
} else { } else {
textColor = themeBase.getTextColorPrimary(); textColor = getResources().getColor(R.color.text_primary);
} }
dueDateSpinner.setBackgroundDrawable(getUnderline(textColor)); dueDateSpinner.setBackgroundDrawable(getUnderline(textColor));
tv.setTextColor(textColor); tv.setTextColor(textColor);
@ -166,11 +166,11 @@ public class DeadlineControlSet extends TaskEditControlFragment {
tv.setText(dueTimeOptions.get(selectedItemPosition)); tv.setText(dueTimeOptions.get(selectedItemPosition));
int textColor; int textColor;
if (time == -1) { if (time == -1) {
textColor = themeBase.getTextColorTertiary(); textColor = getResources().getColor(R.color.text_tertiary);
} else if (newDateTime(date).withMillisOfDay(time).isBeforeNow()) { } else if (newDateTime(date).withMillisOfDay(time).isBeforeNow()) {
textColor = overdueColor; textColor = overdueColor;
} else { } else {
textColor = themeBase.getTextColorPrimary(); textColor = getResources().getColor(R.color.text_primary);
} }
tv.setTextColor(textColor); tv.setTextColor(textColor);
dueTimeSpinner.setBackgroundDrawable(getUnderline(textColor)); dueTimeSpinner.setBackgroundDrawable(getUnderline(textColor));

@ -13,8 +13,8 @@ import org.tasks.injection.ServiceComponent;
import org.tasks.locale.Locale; import org.tasks.locale.Locale;
import org.tasks.preferences.DefaultFilterProvider; import org.tasks.preferences.DefaultFilterProvider;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
import org.tasks.themes.ThemeBase;
import org.tasks.themes.ThemeCache; import org.tasks.themes.ThemeCache;
import org.tasks.themes.WidgetTheme;
import org.tasks.ui.WidgetCheckBoxes; import org.tasks.ui.WidgetCheckBoxes;
import javax.inject.Inject; import javax.inject.Inject;
@ -52,9 +52,9 @@ public class ScrollableWidgetUpdateService extends InjectingRemoteViewsService {
String filterId = (String) extras.get(FILTER_ID); String filterId = (String) extras.get(FILTER_ID);
int widgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID); int widgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID);
ThemeBase themeBase = themeCache.getThemeBase(preferences.getInt(WidgetConfigActivity.PREF_THEME + widgetId, 0)); WidgetTheme widgetTheme = themeCache.getWidgetTheme(preferences.getInt(WidgetConfigActivity.PREF_THEME + widgetId, 0));
return new ScrollableViewsFactory(subtasksHelper, preferences, locale.createConfigurationContext(getApplicationContext()), filterId, return new ScrollableViewsFactory(subtasksHelper, preferences, locale.createConfigurationContext(getApplicationContext()), filterId,
themeBase.getTextColor(), widgetId, database, taskService, defaultFilterProvider, widgetCheckBoxes); widgetTheme.getTextColor(), widgetId, database, taskService, defaultFilterProvider, widgetCheckBoxes);
} }
@Override @Override

@ -23,7 +23,7 @@ import org.tasks.preferences.DefaultFilterProvider;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
import org.tasks.themes.ThemeCache; import org.tasks.themes.ThemeCache;
import org.tasks.themes.ThemeColor; import org.tasks.themes.ThemeColor;
import org.tasks.themes.WidgetBackground; import org.tasks.themes.WidgetTheme;
import javax.inject.Inject; import javax.inject.Inject;
@ -100,7 +100,7 @@ public class TasksWidget extends InjectingAppWidgetProvider {
rvIntent.putExtra(ScrollableWidgetUpdateService.FILTER_ID, filterId); rvIntent.putExtra(ScrollableWidgetUpdateService.FILTER_ID, filterId);
rvIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, id); rvIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, id);
rvIntent.setData(Uri.parse(rvIntent.toUri(Intent.URI_INTENT_SCHEME))); rvIntent.setData(Uri.parse(rvIntent.toUri(Intent.URI_INTENT_SCHEME)));
WidgetBackground theme = themeCache.getWidgetBackground(preferences.getInt(WidgetConfigActivity.PREF_THEME + id, 0)); WidgetTheme theme = themeCache.getWidgetTheme(preferences.getInt(WidgetConfigActivity.PREF_THEME + id, 0));
ThemeColor color = themeCache.getThemeColor(preferences.getInt(WidgetConfigActivity.PREF_COLOR + id, 0)); ThemeColor color = themeCache.getThemeColor(preferences.getInt(WidgetConfigActivity.PREF_COLOR + id, 0));
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.scrollable_widget); RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.scrollable_widget);
if (atLeastJellybeanMR1()) { if (atLeastJellybeanMR1()) {

@ -174,7 +174,7 @@ public class WidgetConfigDialog extends InjectingDialogFragment implements SeekB
} }
private void updateTheme() { private void updateTheme() {
selectedTheme.setText(themeCache.getWidgetBackground(themeIndex).getName()); selectedTheme.setText(themeCache.getWidgetTheme(themeIndex).getName());
} }
private void updateColor() { private void updateColor() {

@ -5,7 +5,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
android:background="?attr/drawer_background" android:background="@color/drawer_color"
app:insetForeground="#4000"> app:insetForeground="#4000">
<ListView <ListView

@ -6,5 +6,5 @@
android:background="?attr/colorPrimary" android:background="?attr/colorPrimary"
android:elevation="@dimen/elevation_toolbar" android:elevation="@dimen/elevation_toolbar"
app:toolbarStyle="@style/Widget.AppCompat.Toolbar" app:toolbarStyle="@style/Widget.AppCompat.Toolbar"
app:popupTheme="?attr/popup_theme" app:popupTheme="@style/popup_overlay"
app:theme="?attr/overlay_theme" /> app:theme="?attr/overlay_theme" />

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="background_color">#303030</color>
<color name="background_color_dialog">#424242</color>
<color name="icon_tint">#ffffff</color>
<color name="drawer_color">#303030</color>
<color name="drawer_color_selected">#202020</color>
<color name="text_primary">#ffffffff</color> <!-- 100% white -->
<color name="text_secondary">#b3ffffff</color> <!-- 70% white -->
<color name="text_tertiary">#80ffffff</color> <!-- 50% white -->
<color name="divider">#1fffffff</color> <!-- 12% white -->
</resources>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="alpha_secondary" format="float" type="dimen">0.70</item>
<item name="alpha_disabled" format="float" type="dimen">0.50</item>
</resources>

@ -0,0 +1,3 @@
<resources>
<style name="popup_overlay" parent="ThemeOverlay.AppCompat" />
</resources>

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<style name="DarkOverride" parent="DarkBase"> <style name="TasksOverride" parent="Tasks">
<item name="android:windowDrawsSystemBarBackgrounds">true</item> <item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item> <item name="android:statusBarColor">@android:color/transparent</item>
</style> </style>

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="LightOverride" parent="LightBase">
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
</resources>

@ -85,6 +85,7 @@
<item>@string/theme_black</item> <item>@string/theme_black</item>
<item>@string/theme_dark</item> <item>@string/theme_dark</item>
<item>@string/theme_wallpaper</item> <item>@string/theme_wallpaper</item>
<item>@string/theme_day_night</item>
</string-array> </string-array>
<string-array name="colors"> <string-array name="colors">

@ -6,13 +6,10 @@
<resources> <resources>
<!-- theme attributes --> <!-- theme attributes -->
<attr name="drawer_background" format="color" />
<attr name="drawer_background_selected" format="color" />
<attr name="asContentBackground" format="color" /> <attr name="asContentBackground" format="color" />
<attr name="asTextColor" format="color" /> <attr name="asTextColor" format="color" />
<attr name="asTextColorHint" format="color" /> <attr name="asTextColorHint" format="color" />
<attr name="icon_tint" format="color"/> <attr name="icon_tint" format="color"/>
<attr name="popup_theme" format="reference" />
<attr name="overlay_theme" format="reference" /> <attr name="overlay_theme" format="reference" />
<attr name="actionBarPrimaryText" format="color" /> <attr name="actionBarPrimaryText" format="color" />
<attr name="actionBarSecondaryText" format="color" /> <attr name="actionBarSecondaryText" format="color" />

@ -90,29 +90,28 @@
<color name="task_list_done">#ff777777</color> <color name="task_list_done">#ff777777</color>
<color name="task_edit_deadline_gray">#888888</color> <color name="task_edit_deadline_gray">#888888</color>
<color name="md_dark_background">#303030</color> <color name="background_color">#fafafa</color>
<color name="md_light_background">#fafafa</color> <color name="background_color_dialog">#ffffff</color>
<color name="dialog_dark_background">#424242</color> <color name="icon_tint">#000000</color>
<color name="dialog_light_background">#ffffff</color> <color name="text_primary">#de000000</color> <!-- 87% black -->
<color name="text_secondary">#8a000000</color> <!-- 54% black -->
<color name="drawer_light_background">#f9f9f9</color> <color name="text_tertiary">#61000000</color> <!-- 38% black -->
<color name="drawer_dark_background">#303030</color> <color name="divider">#1f000000</color> <!-- 12% black -->
<color name="drawer_selected_light">#e8e8e8</color>
<color name="drawer_selected_dark">#202020</color> <color name="black_87">#de000000</color> <!-- 87% black -->
<color name="black_54">#8a000000</color> <!-- 54% black -->
<color name="white_text">#fff</color> <color name="black_38">#61000000</color> <!-- 38% black -->
<color name="white_text_hint">#eee</color>
<color name="black_text_hint">#535353</color> <color name="white_100">#ffffffff</color> <!-- 100% white -->
<color name="white_70">#b3ffffff</color> <!-- 70% white -->
<color name="black_87">#de000000</color> <color name="white_50">#80ffffff</color> <!-- 50% white -->
<color name="black_54">#8a000000</color>
<color name="black_38">#61000000</color> <color name="widget_background_light">#fafafa</color>
<color name="black_12">#1f000000</color> <color name="widget_background_black">#000000</color>
<color name="widget_background_dark">#303030</color>
<color name="white_100">#ffffffff</color>
<color name="white_70">#b3ffffff</color> <color name="drawer_color">#f9f9f9</color>
<color name="white_50">#80ffffff</color> <color name="drawer_color_selected">#e8e8e8</color>
<color name="white_12">#1fffffff</color>
<color name="importance_1">@color/red_500</color> <color name="importance_1">@color/red_500</color>
<color name="importance_2">@color/amber_500</color> <color name="importance_2">@color/amber_500</color>

@ -17,11 +17,8 @@
<item name="tag_characters" format="float" type="dimen">12</item> <item name="tag_characters" format="float" type="dimen">12</item>
<item name="alpha_secondary_light" format="float" type="dimen">0.54</item> <item name="alpha_secondary" format="float" type="dimen">0.54</item>
<item name="alpha_disabled_light" format="float" type="dimen">0.38</item> <item name="alpha_disabled" format="float" type="dimen">0.38</item>
<item name="alpha_secondary_dark" format="float" type="dimen">0.70</item>
<item name="alpha_disabled_dark" format="float" type="dimen">0.50</item>
<dimen name="elevation_toolbar">8dp</dimen> <dimen name="elevation_toolbar">8dp</dimen>
<dimen name="elevation_task_list">6dp</dimen> <dimen name="elevation_task_list">6dp</dimen>

@ -883,6 +883,7 @@ File %1$s contained %2$s.\n\n
<string name="theme_light">Light</string> <string name="theme_light">Light</string>
<string name="theme_dark">Dark</string> <string name="theme_dark">Dark</string>
<string name="theme_wallpaper">Wallpaper</string> <string name="theme_wallpaper">Wallpaper</string>
<string name="theme_day_night">Day/Night</string>
<string name="default_value">Default</string> <string name="default_value">Default</string>
<string name="sync_interval_disable">disable</string> <string name="sync_interval_disable">disable</string>

@ -2,6 +2,8 @@
<!-- ========================================================== General --> <!-- ========================================================== General -->
<style name="popup_overlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="SpinnerNoPadding" parent="Widget.AppCompat.TextView.SpinnerItem"> <style name="SpinnerNoPadding" parent="Widget.AppCompat.TextView.SpinnerItem">
<item name="android:paddingLeft">0dp</item> <item name="android:paddingLeft">0dp</item>
<item name="android:paddingRight">0dp</item> <item name="android:paddingRight">0dp</item>

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Tasks" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="android:windowBackground">@color/background_color</item>
<item name="windowActionModeOverlay">true</item>
<item name="asContentBackground">@color/background_color</item>
<item name="asTextColor">@color/text_primary</item>
<item name="asTextColorHint">@color/text_tertiary</item>
<item name="icon_tint">@color/icon_tint</item>
<item name="android:spinnerItemStyle">@style/SpinnerNoPadding</item>
<item name="android:actionModeBackground">?attr/colorPrimary</item>
<item name="alertDialogTheme">@style/TasksDialog</item>
<item name="alpha_secondary">@dimen/alpha_secondary</item>
<item name="alpha_disabled">@dimen/alpha_disabled</item>
<item name="android:textColorPrimary">@color/text_primary</item>
<item name="android:textColorSecondary">@color/text_secondary</item>
<item name="android:textColorTertiary">@color/text_tertiary</item>
<item name="dividerColor">@color/divider</item>
</style>
<style name="TasksOverride" parent="Tasks">
</style>
<style name="TasksDialog" parent="@style/Theme.AppCompat.DayNight.Dialog">
<item name="android:windowMinWidthMinor">@android:dimen/dialog_min_width_minor</item>
<item name="android:windowMinWidthMajor">@android:dimen/dialog_min_width_major</item>
<item name="android:windowBackground">@color/background_color_dialog</item>
<item name="asTextColor">@color/text_primary</item>
<item name="icon_tint">@color/icon_tint</item>
</style>
<style name="ThemeBlack" parent="TasksOverride">
<item name="android:windowBackground">@android:color/black</item>
<item name="asContentBackground">@android:color/black</item>
</style>
<style name="Wallpaper" parent="TasksOverride">
<item name="android:windowBackground">@color/black_38</item>
<item name="asContentBackground">@color/black_38</item>
<item name="android:windowShowWallpaper">true</item>
</style>
</resources>

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="BaseBlack" parent="DarkOverride">
<item name="android:windowBackground">@android:color/black</item>
<item name="asContentBackground">@android:color/black</item>
</style>
</resources>

@ -1,43 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="DarkBase" parent="Theme.AppCompat.NoActionBar">
<item name="popup_theme">@style/ThemeOverlay.AppCompat</item>
<item name="android:windowBackground">@color/md_dark_background</item>
<item name="windowActionModeOverlay">true</item>
<item name="drawer_background">@color/drawer_dark_background</item>
<item name="drawer_background_selected">@color/drawer_selected_dark</item>
<item name="asContentBackground">@color/md_dark_background</item>
<item name="asTextColor">@color/white_100</item>
<item name="asTextColorHint">@color/white_50</item>
<item name="icon_tint">@android:color/white</item>
<item name="android:spinnerItemStyle">@style/SpinnerNoPadding</item>
<item name="android:actionModeBackground">?attr/colorPrimary</item>
<item name="alertDialogTheme">@style/DialogBaseDark</item>
<item name="alpha_secondary">@dimen/alpha_secondary_dark</item>
<item name="alpha_disabled">@dimen/alpha_disabled_dark</item>
<item name="android:textColorPrimary">@color/white_100</item>
<item name="android:textColorSecondary">@color/white_70</item>
<item name="android:textColorTertiary">@color/white_50</item>
<item name="dividerColor">@color/white_12</item>
</style>
<style name="DarkOverride" parent="DarkBase">
</style>
<style name="DialogBaseDark" parent="@style/Theme.AppCompat.Dialog">
<item name="android:windowMinWidthMinor">@android:dimen/dialog_min_width_minor</item>
<item name="android:windowMinWidthMajor">@android:dimen/dialog_min_width_major</item>
<item name="android:windowBackground">@color/dialog_dark_background</item>
<item name="asTextColor">@color/white_100</item>
<item name="icon_tint">@android:color/white</item>
</style>
<style name="Wallpaper" parent="DarkOverride">
<item name="android:windowBackground">@color/black_38</item>
<item name="asContentBackground">@color/black_38</item>
<item name="android:windowShowWallpaper">true</item>
</style>
</resources>

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="LightBase" parent="Theme.AppCompat.Light.NoActionBar">
<item name="popup_theme">@style/ThemeOverlay.AppCompat.Light</item>
<item name="android:windowBackground">@color/md_light_background</item>
<item name="windowActionModeOverlay">true</item>
<item name="drawer_background">@color/drawer_light_background</item>
<item name="drawer_background_selected">@color/drawer_selected_light</item>
<item name="asContentBackground">@color/md_light_background</item>
<item name="asTextColor">@color/black_87</item>
<item name="asTextColorHint">@color/black_38</item>
<item name="icon_tint">@android:color/black</item>
<item name="android:spinnerItemStyle">@style/SpinnerNoPadding</item>
<item name="android:actionModeBackground">?attr/colorPrimary</item>
<item name="alertDialogTheme">@style/LightDialogBase</item>
<item name="alpha_secondary">@dimen/alpha_secondary_light</item>
<item name="alpha_disabled">@dimen/alpha_disabled_light</item>
<item name="android:textColorPrimary">@color/black_87</item>
<item name="android:textColorSecondary">@color/black_54</item>
<item name="android:textColorTertiary">@color/black_38</item>
<item name="dividerColor">@color/black_12</item>
</style>
<style name="LightOverride" parent="LightBase">
</style>
<style name="LightDialogBase" parent="@style/Theme.AppCompat.Light.Dialog">
<item name="android:windowMinWidthMinor">@android:dimen/dialog_min_width_minor</item>
<item name="android:windowMinWidthMajor">@android:dimen/dialog_min_width_major</item>
<item name="android:windowBackground">@color/dialog_light_background</item>
<item name="asTextColor">@color/black_87</item>
<item name="icon_tint">@android:color/black</item>
</style>
</resources>
Loading…
Cancel
Save