From 2e9227a97a829d15e9b1e077523c1560fa087f79 Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Fri, 15 Jul 2016 20:04:28 -0500 Subject: [PATCH] Add AppCompat Day/Night theme --- src/main/AndroidManifest.xml | 28 +++++----- .../todoroo/astrid/adapter/FilterAdapter.java | 6 +-- .../astrid/repeats/RepeatControlSet.java | 4 +- .../astrid/timers/TimerControlSet.java | 4 +- .../astrid/ui/HideUntilControlSet.java | 4 +- src/main/java/org/tasks/Tasks.java | 4 ++ .../org/tasks/dialogs/ThemePickerDialog.java | 2 +- .../org/tasks/files/MyFilePickerActivity.java | 1 - .../AppCompatPreferenceActivity.java | 3 +- .../preferences/BaseBasicPreferences.java | 6 +++ src/main/java/org/tasks/themes/Theme.java | 3 +- src/main/java/org/tasks/themes/ThemeBase.java | 51 ++++++------------- .../java/org/tasks/themes/ThemeCache.java | 36 +++++++------ ...WidgetBackground.java => WidgetTheme.java} | 16 ++++-- .../java/org/tasks/ui/CalendarControlSet.java | 6 +-- .../java/org/tasks/ui/DeadlineControlSet.java | 8 +-- .../widget/ScrollableWidgetUpdateService.java | 6 +-- .../java/org/tasks/widget/TasksWidget.java | 4 +- .../org/tasks/widget/WidgetConfigDialog.java | 2 +- .../res/layout/fragment_navigation_drawer.xml | 2 +- src/main/res/layout/toolbar.xml | 2 +- src/main/res/values-night/colors.xml | 12 +++++ src/main/res/values-night/dimens.xml | 5 ++ src/main/res/values-night/styles.xml | 3 ++ .../{theme_base_dark.xml => theme.xml} | 2 +- src/main/res/values-v21/theme_base_light.xml | 7 --- src/main/res/values/arrays.xml | 1 + src/main/res/values/attrs.xml | 3 -- src/main/res/values/colors.xml | 45 ++++++++-------- src/main/res/values/dimens.xml | 7 +-- src/main/res/values/strings.xml | 1 + src/main/res/values/styles.xml | 2 + src/main/res/values/theme.xml | 44 ++++++++++++++++ src/main/res/values/theme_base_black.xml | 7 --- src/main/res/values/theme_base_dark.xml | 43 ---------------- src/main/res/values/theme_base_light.xml | 36 ------------- 36 files changed, 189 insertions(+), 227 deletions(-) rename src/main/java/org/tasks/themes/{WidgetBackground.java => WidgetTheme.java} (57%) create mode 100644 src/main/res/values-night/colors.xml create mode 100644 src/main/res/values-night/dimens.xml create mode 100644 src/main/res/values-night/styles.xml rename src/main/res/values-v21/{theme_base_dark.xml => theme.xml} (77%) delete mode 100644 src/main/res/values-v21/theme_base_light.xml create mode 100644 src/main/res/values/theme.xml delete mode 100644 src/main/res/values/theme_base_black.xml delete mode 100644 src/main/res/values/theme_base_dark.xml delete mode 100644 src/main/res/values/theme_base_light.xml diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index dd5c0b80e..e2a6ea4df 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -91,7 +91,7 @@ + android:theme="@style/Tasks" /> + android:theme="@style/Tasks" /> + android:theme="@style/Tasks" /> + android:theme="@style/Tasks" /> + android:theme="@style/Tasks" /> + android:theme="@style/Tasks" /> + android:theme="@style/Tasks"/> + android:theme="@style/Tasks"/> + android:theme="@style/Tasks"/> @@ -360,7 +360,7 @@ + android:theme="@style/TasksDialog"/> @@ -368,7 +368,7 @@ + android:theme="@style/Tasks"/> + android:theme="@style/TasksDialog" /> + android:theme="@style/Tasks"/> { Filter selected = ((TaskListActivity) activity).getCurrentFilter(); 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; @@ -324,7 +324,7 @@ public class FilterAdapter extends ArrayAdapter { viewHolder.icon.setImageResource(filter.icon); viewHolder.icon.setColorFilter(filter.tint >= 0 ? themeCache.getThemeColor(filter.tint).getPrimaryColor() - : theme.getThemeBase().getTextColor()); + : getContext().getResources().getColor(R.color.text_primary)); String title = filter.listingTitle; if(!title.equals(viewHolder.name.getText())) { @@ -339,7 +339,7 @@ public class FilterAdapter extends ArrayAdapter { viewHolder.size.setVisibility(countInt > 0 ? View.VISIBLE : View.INVISIBLE); 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)); } } diff --git a/src/main/java/com/todoroo/astrid/repeats/RepeatControlSet.java b/src/main/java/com/todoroo/astrid/repeats/RepeatControlSet.java index b72ca5751..fae1ce926 100644 --- a/src/main/java/com/todoroo/astrid/repeats/RepeatControlSet.java +++ b/src/main/java/com/todoroo/astrid/repeats/RepeatControlSet.java @@ -470,11 +470,11 @@ public class RepeatControlSet extends TaskEditControlFragment { protected void refreshDisplayView() { if (doRepeat) { displayView.setText(getRepeatString()); - displayView.setTextColor(theme.getThemeBase().getTextColorPrimary()); + displayView.setTextColor(getResources().getColor(R.color.text_primary)); clear.setVisibility(View.VISIBLE); } else { displayView.setText(R.string.repeat_never); - displayView.setTextColor(theme.getThemeBase().getTextColorTertiary()); + displayView.setTextColor(getResources().getColor(R.color.text_tertiary)); clear.setVisibility(View.GONE); } } diff --git a/src/main/java/com/todoroo/astrid/timers/TimerControlSet.java b/src/main/java/com/todoroo/astrid/timers/TimerControlSet.java index 1c85aa49a..8948013d3 100644 --- a/src/main/java/com/todoroo/astrid/timers/TimerControlSet.java +++ b/src/main/java/com/todoroo/astrid/timers/TimerControlSet.java @@ -221,10 +221,10 @@ public class TimerControlSet extends TaskEditControlFragment { if (!TextUtils.isEmpty(toDisplay)) { displayEdit.setText(toDisplay); - displayEdit.setTextColor(theme.getThemeBase().getTextColorPrimary()); + displayEdit.setTextColor(getResources().getColor(R.color.text_primary)); } else { displayEdit.setText(R.string.TEA_timer_controls); - displayEdit.setTextColor(theme.getThemeBase().getTextColorTertiary()); + displayEdit.setTextColor(getResources().getColor(R.color.text_tertiary)); } } diff --git a/src/main/java/com/todoroo/astrid/ui/HideUntilControlSet.java b/src/main/java/com/todoroo/astrid/ui/HideUntilControlSet.java index acc0e45e1..1e4766f7c 100644 --- a/src/main/java/com/todoroo/astrid/ui/HideUntilControlSet.java +++ b/src/main/java/com/todoroo/astrid/ui/HideUntilControlSet.java @@ -102,14 +102,14 @@ public class HideUntilControlSet extends TaskEditControlFragment implements OnIt if (value.setting == Task.HIDE_UNTIL_NONE) { clearButton.setVisibility(View.GONE); tv.setText(value.label); - tv.setTextColor(themeBase.getTextColorTertiary()); + tv.setTextColor(getContext().getColor(R.color.text_tertiary)); } else { String display = value.label; if (value.setting != Task.HIDE_UNTIL_SPECIFIC_DAY && value.setting != Task.HIDE_UNTIL_SPECIFIC_DAY_TIME) { display = display.toLowerCase(); } tv.setText(getString(R.string.TEA_hideUntil_display, display)); - tv.setTextColor(themeBase.getTextColorPrimary()); + tv.setTextColor(getContext().getColor(R.color.text_primary)); } return tv; } diff --git a/src/main/java/org/tasks/Tasks.java b/src/main/java/org/tasks/Tasks.java index f0f7a0dd0..eaec5b4cb 100644 --- a/src/main/java/org/tasks/Tasks.java +++ b/src/main/java/org/tasks/Tasks.java @@ -15,6 +15,7 @@ import org.tasks.analytics.Tracker; import org.tasks.injection.ApplicationComponent; import org.tasks.injection.InjectingApplication; import org.tasks.preferences.Preferences; +import org.tasks.themes.ThemeCache; import javax.inject.Inject; @@ -36,6 +37,7 @@ public class Tasks extends InjectingApplication { @Inject Tracker tracker; @Inject FlavorSetup flavorSetup; @Inject BuildSetup buildSetup; + @Inject ThemeCache themeCache; @Override public void onCreate() { @@ -45,6 +47,8 @@ public class Tasks extends InjectingApplication { flavorSetup.setup(); tracker.setTrackingEnabled(preferences.isTrackingEnabled()); + + themeCache.getThemeBase(preferences.getInt(R.string.p_theme, 0)).applyDayNightMode(); } @Override diff --git a/src/main/java/org/tasks/dialogs/ThemePickerDialog.java b/src/main/java/org/tasks/dialogs/ThemePickerDialog.java index f27514691..8b4f07379 100644 --- a/src/main/java/org/tasks/dialogs/ThemePickerDialog.java +++ b/src/main/java/org/tasks/dialogs/ThemePickerDialog.java @@ -130,7 +130,7 @@ public class ThemePickerDialog extends InjectingDialogFragment { case ACCENTS: return themeCache.getThemeAccent(index).getAccentColor(); case WIDGET_BACKGROUND: - return themeCache.getWidgetBackground(index).getBackgroundColor(); + return themeCache.getWidgetTheme(index).getBackgroundColor(); default: return themeCache.getThemeBase(index).getContentBackground(); } diff --git a/src/main/java/org/tasks/files/MyFilePickerActivity.java b/src/main/java/org/tasks/files/MyFilePickerActivity.java index 6138f89cc..427472339 100644 --- a/src/main/java/org/tasks/files/MyFilePickerActivity.java +++ b/src/main/java/org/tasks/files/MyFilePickerActivity.java @@ -5,7 +5,6 @@ import android.os.Bundle; import com.nononsenseapps.filepicker.FilePickerActivity; import org.tasks.analytics.Tracker; -import org.tasks.injection.ActivityComponent; import org.tasks.injection.ActivityModule; import org.tasks.injection.InjectingApplication; import org.tasks.themes.Theme; diff --git a/src/main/java/org/tasks/preferences/AppCompatPreferenceActivity.java b/src/main/java/org/tasks/preferences/AppCompatPreferenceActivity.java index 0ed808237..20864c968 100644 --- a/src/main/java/org/tasks/preferences/AppCompatPreferenceActivity.java +++ b/src/main/java/org/tasks/preferences/AppCompatPreferenceActivity.java @@ -42,6 +42,7 @@ public abstract class AppCompatPreferenceActivity extends PreferenceActivity { protected void onCreate(Bundle savedInstanceState) { getDelegate().installViewFactory(); getDelegate().onCreate(savedInstanceState); + getDelegate().applyDayNight(); super.onCreate(savedInstanceState); } @@ -118,7 +119,7 @@ public abstract class AppCompatPreferenceActivity extends PreferenceActivity { getDelegate().invalidateOptionsMenu(); } - private AppCompatDelegate getDelegate() { + protected AppCompatDelegate getDelegate() { if (mDelegate == null) { mDelegate = AppCompatDelegate.create(this, null); } diff --git a/src/main/java/org/tasks/preferences/BaseBasicPreferences.java b/src/main/java/org/tasks/preferences/BaseBasicPreferences.java index d24da37e7..e3a1e3d9e 100644 --- a/src/main/java/org/tasks/preferences/BaseBasicPreferences.java +++ b/src/main/java/org/tasks/preferences/BaseBasicPreferences.java @@ -4,6 +4,7 @@ import android.app.Activity; import android.app.FragmentManager; import android.content.DialogInterface; import android.content.Intent; +import android.content.res.Configuration; import android.os.Bundle; import android.preference.Preference; @@ -24,6 +25,7 @@ import org.tasks.locale.Locale; import org.tasks.locale.LocalePickerDialog; import org.tasks.themes.ThemeAccent; import org.tasks.themes.ThemeBase; +import org.tasks.themes.ThemeCache; import org.tasks.themes.ThemeColor; import javax.inject.Inject; @@ -50,6 +52,8 @@ public abstract class BaseBasicPreferences extends InjectingPreferenceActivity i @Inject ThemeAccent themeAccent; @Inject DialogBuilder dialogBuilder; @Inject Locale locale; + @Inject ThemeCache themeCache; + private Bundle result; @Override @@ -172,6 +176,8 @@ public abstract class BaseBasicPreferences extends InjectingPreferenceActivity i switch (palette) { case THEMES: preferences.setInt(R.string.p_theme, index); + themeBase = themeCache.getThemeBase(index); + themeBase.applyDayNightMode(getDelegate()); tracker.reportEvent(Tracking.Events.SET_THEME, Integer.toString(index)); break; case COLORS: diff --git a/src/main/java/org/tasks/themes/Theme.java b/src/main/java/org/tasks/themes/Theme.java index 605d6d1e8..3ad1d5f63 100644 --- a/src/main/java/org/tasks/themes/Theme.java +++ b/src/main/java/org/tasks/themes/Theme.java @@ -36,7 +36,7 @@ public class Theme { } public int getDialogStyle() { - return themeBase.getDialogStyle(); + return R.style.TasksDialog; } public LayoutInflater getLayoutInflater(Context context) { @@ -59,7 +59,6 @@ public class Theme { activity.getWindow().setFormat(PixelFormat.RGBA_8888); } - public void applyToContext(Context context) { Resources.Theme theme = context.getTheme(); themeColor.applyStyle(theme); diff --git a/src/main/java/org/tasks/themes/ThemeBase.java b/src/main/java/org/tasks/themes/ThemeBase.java index d9b3d1d08..4fceffabb 100644 --- a/src/main/java/org/tasks/themes/ThemeBase.java +++ b/src/main/java/org/tasks/themes/ThemeBase.java @@ -2,41 +2,33 @@ package org.tasks.themes; import android.app.Activity; import android.content.Context; +import android.support.v7.app.AppCompatDelegate; import android.view.ContextThemeWrapper; import org.tasks.R; public class ThemeBase { - public static final int[] THEMES = new int[] { - R.style.LightOverride, - R.style.BaseBlack, - R.style.DarkOverride, - R.style.Wallpaper + public static final int[] THEMES = new int[]{ + R.style.TasksOverride, + R.style.ThemeBlack, + R.style.TasksOverride, + R.style.Wallpaper, + R.style.TasksOverride }; private final String name; private final int index; - private final int textColorPrimary; - private final int textColorSecondary; - private final int textColorTertiary; private final int style; - private final int dialogStyle; private final int contentBackground; - private final int textColor; + private final int dayNightMode; - public ThemeBase(String name, int index, int dialogStyle, int contentBackground, - int textColor, int textColorPrimary, int textColorSecondary, - int textColorTertiary) { + public ThemeBase(String name, int index, int dayNightMode) { this.name = name; this.index = index; - this.textColorPrimary = textColorPrimary; - this.textColorSecondary = textColorSecondary; - this.textColorTertiary = textColorTertiary; + this.dayNightMode = dayNightMode; this.style = THEMES[index]; - this.dialogStyle = dialogStyle; - this.contentBackground = contentBackground; - this.textColor = textColor; + this.contentBackground = 0; } public String getName() { @@ -47,18 +39,10 @@ public class ThemeBase { return index; } - public int getDialogStyle() { - return dialogStyle; - } - public int getContentBackground() { return contentBackground; } - public int getTextColor() { - return textColor; - } - public boolean isDarkTheme() { return index > 0; } @@ -71,15 +55,12 @@ public class ThemeBase { activity.setTheme(style); } - public int getTextColorPrimary() { - return textColorPrimary; - } - - public int getTextColorSecondary() { - return textColorSecondary; + public void applyDayNightMode() { + AppCompatDelegate.setDefaultNightMode(dayNightMode); } - public int getTextColorTertiary() { - return textColorTertiary; + public void applyDayNightMode(AppCompatDelegate delegate) { + applyDayNightMode(); + delegate.setLocalNightMode(dayNightMode); } } diff --git a/src/main/java/org/tasks/themes/ThemeCache.java b/src/main/java/org/tasks/themes/ThemeCache.java index 4a62e7b55..0f9bbae98 100644 --- a/src/main/java/org/tasks/themes/ThemeCache.java +++ b/src/main/java/org/tasks/themes/ThemeCache.java @@ -2,6 +2,7 @@ package org.tasks.themes; import android.content.Context; import android.content.res.Resources; +import android.support.v7.app.AppCompatDelegate; import android.util.TypedValue; import android.view.ContextThemeWrapper; @@ -15,24 +16,18 @@ public class ThemeCache { private final List themes = new ArrayList<>(); private final List colors = new ArrayList<>(); private final List accents = new ArrayList<>(); - private final List widgetBackgrounds = new ArrayList<>(); + private final List widgetThemes = new ArrayList<>(); private final ThemeColor untaggedColor; public ThemeCache(Context context) { Resources resources = context.getResources(); - String[] themeNames = resources.getStringArray(R.array.themes); - for (int i = 0 ; i < ThemeBase.THEMES.length ; i++) { - Resources.Theme theme = new ContextThemeWrapper(context, ThemeBase.THEMES[i]).getTheme(); - themes.add(new ThemeBase( - themeNames[i], - i, - 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))); - } + + themes.add(new ThemeBase(context.getString(R.string.theme_light), 0, AppCompatDelegate.MODE_NIGHT_NO)); + themes.add(new ThemeBase(context.getString(R.string.theme_black), 1, AppCompatDelegate.MODE_NIGHT_YES)); + themes.add(new ThemeBase(context.getString(R.string.theme_dark), 2, AppCompatDelegate.MODE_NIGHT_YES)); + themes.add(new ThemeBase(context.getString(R.string.theme_wallpaper), 3, AppCompatDelegate.MODE_NIGHT_YES)); + themes.add(new ThemeBase(context.getString(R.string.theme_day_night), 4, AppCompatDelegate.MODE_NIGHT_AUTO)); + String[] colorNames = resources.getStringArray(R.array.colors); for (int i = 0 ; i < ThemeColor.COLORS.length ; i++) { Resources.Theme theme = new ContextThemeWrapper(context, ThemeColor.COLORS[i]).getTheme(); @@ -53,15 +48,18 @@ public class ThemeCache { resolveAttribute(theme, R.attr.colorAccent))); } String[] widgetBackgroundNames = resources.getStringArray(R.array.widget_background); - for (int i = 0 ; i < WidgetBackground.BACKGROUNDS.length ; i++) { - widgetBackgrounds.add(new WidgetBackground( - widgetBackgroundNames[i], i, resources.getColor(WidgetBackground.BACKGROUNDS[i]))); + for (int i = 0; i < WidgetTheme.BACKGROUNDS.length ; i++) { + widgetThemes.add(new WidgetTheme( + 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); } - public WidgetBackground getWidgetBackground(int index) { - return widgetBackgrounds.get(index); + public WidgetTheme getWidgetTheme(int index) { + return widgetThemes.get(index); } public ThemeBase getThemeBase(int index) { diff --git a/src/main/java/org/tasks/themes/WidgetBackground.java b/src/main/java/org/tasks/themes/WidgetTheme.java similarity index 57% rename from src/main/java/org/tasks/themes/WidgetBackground.java rename to src/main/java/org/tasks/themes/WidgetTheme.java index 541ad6496..ee6b99d58 100644 --- a/src/main/java/org/tasks/themes/WidgetBackground.java +++ b/src/main/java/org/tasks/themes/WidgetTheme.java @@ -2,26 +2,32 @@ package org.tasks.themes; import org.tasks.R; -public class WidgetBackground { +public class WidgetTheme { public static final int[] BACKGROUNDS = new int[] { - R.color.md_light_background, - android.R.color.black, - R.color.md_dark_background + R.color.widget_background_light, + R.color.widget_background_black, + R.color.widget_background_dark }; private final String name; private final int index; 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.index = index; this.backgroundColor = backgroundColor; + this.textColor = textColor; } public int getBackgroundColor() { return backgroundColor; } + public int getTextColor() { + return textColor; + } + public String getName() { return name; } diff --git a/src/main/java/org/tasks/ui/CalendarControlSet.java b/src/main/java/org/tasks/ui/CalendarControlSet.java index 0ab378506..59cd08eb0 100644 --- a/src/main/java/org/tasks/ui/CalendarControlSet.java +++ b/src/main/java/org/tasks/ui/CalendarControlSet.java @@ -304,15 +304,15 @@ public class CalendarControlSet extends TaskEditControlFragment { private void refreshDisplayView() { if (!Strings.isNullOrEmpty(eventUri)) { calendar.setText(R.string.gcal_TEA_showCalendar_label); - calendar.setTextColor(themeBase.getTextColorPrimary()); + calendar.setTextColor(getResources().getColor(R.color.text_primary)); cancelButton.setVisibility(View.VISIBLE); } else if (calendarName != null) { calendar.setText(calendarName); - calendar.setTextColor(themeBase.getTextColorPrimary()); + calendar.setTextColor(getResources().getColor(R.color.text_primary)); cancelButton.setVisibility(View.VISIBLE); } else { calendar.setText(R.string.gcal_TEA_addToCalendar_label); - calendar.setTextColor(themeBase.getTextColorTertiary()); + calendar.setTextColor(getResources().getColor(R.color.text_tertiary)); cancelButton.setVisibility(View.GONE); } } diff --git a/src/main/java/org/tasks/ui/DeadlineControlSet.java b/src/main/java/org/tasks/ui/DeadlineControlSet.java index f2109e6c3..28adb5542 100644 --- a/src/main/java/org/tasks/ui/DeadlineControlSet.java +++ b/src/main/java/org/tasks/ui/DeadlineControlSet.java @@ -141,11 +141,11 @@ public class DeadlineControlSet extends TaskEditControlFragment { tv.setText(dueDateOptions.get(selectedItemPosition)); int textColor; if (date == 0) { - textColor = themeBase.getTextColorTertiary(); + textColor = getResources().getColor(R.color.text_tertiary); } else if (date < newDateTime().startOfDay().getMillis()) { textColor = overdueColor; } else { - textColor = themeBase.getTextColorPrimary(); + textColor = getResources().getColor(R.color.text_primary); } dueDateSpinner.setBackgroundDrawable(getUnderline(textColor)); tv.setTextColor(textColor); @@ -166,11 +166,11 @@ public class DeadlineControlSet extends TaskEditControlFragment { tv.setText(dueTimeOptions.get(selectedItemPosition)); int textColor; if (time == -1) { - textColor = themeBase.getTextColorTertiary(); + textColor = getResources().getColor(R.color.text_tertiary); } else if (newDateTime(date).withMillisOfDay(time).isBeforeNow()) { textColor = overdueColor; } else { - textColor = themeBase.getTextColorPrimary(); + textColor = getResources().getColor(R.color.text_primary); } tv.setTextColor(textColor); dueTimeSpinner.setBackgroundDrawable(getUnderline(textColor)); diff --git a/src/main/java/org/tasks/widget/ScrollableWidgetUpdateService.java b/src/main/java/org/tasks/widget/ScrollableWidgetUpdateService.java index c8002c24f..cfcf14a60 100644 --- a/src/main/java/org/tasks/widget/ScrollableWidgetUpdateService.java +++ b/src/main/java/org/tasks/widget/ScrollableWidgetUpdateService.java @@ -13,8 +13,8 @@ import org.tasks.injection.ServiceComponent; import org.tasks.locale.Locale; import org.tasks.preferences.DefaultFilterProvider; import org.tasks.preferences.Preferences; -import org.tasks.themes.ThemeBase; import org.tasks.themes.ThemeCache; +import org.tasks.themes.WidgetTheme; import org.tasks.ui.WidgetCheckBoxes; import javax.inject.Inject; @@ -52,9 +52,9 @@ public class ScrollableWidgetUpdateService extends InjectingRemoteViewsService { String filterId = (String) extras.get(FILTER_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, - themeBase.getTextColor(), widgetId, database, taskService, defaultFilterProvider, widgetCheckBoxes); + widgetTheme.getTextColor(), widgetId, database, taskService, defaultFilterProvider, widgetCheckBoxes); } @Override diff --git a/src/main/java/org/tasks/widget/TasksWidget.java b/src/main/java/org/tasks/widget/TasksWidget.java index 19398cb21..a0c4b6444 100644 --- a/src/main/java/org/tasks/widget/TasksWidget.java +++ b/src/main/java/org/tasks/widget/TasksWidget.java @@ -23,7 +23,7 @@ import org.tasks.preferences.DefaultFilterProvider; import org.tasks.preferences.Preferences; import org.tasks.themes.ThemeCache; import org.tasks.themes.ThemeColor; -import org.tasks.themes.WidgetBackground; +import org.tasks.themes.WidgetTheme; import javax.inject.Inject; @@ -100,7 +100,7 @@ public class TasksWidget extends InjectingAppWidgetProvider { rvIntent.putExtra(ScrollableWidgetUpdateService.FILTER_ID, filterId); rvIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, id); 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)); RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.scrollable_widget); if (atLeastJellybeanMR1()) { diff --git a/src/main/java/org/tasks/widget/WidgetConfigDialog.java b/src/main/java/org/tasks/widget/WidgetConfigDialog.java index 7b6ea960f..15ff7a348 100644 --- a/src/main/java/org/tasks/widget/WidgetConfigDialog.java +++ b/src/main/java/org/tasks/widget/WidgetConfigDialog.java @@ -174,7 +174,7 @@ public class WidgetConfigDialog extends InjectingDialogFragment implements SeekB } private void updateTheme() { - selectedTheme.setText(themeCache.getWidgetBackground(themeIndex).getName()); + selectedTheme.setText(themeCache.getWidgetTheme(themeIndex).getName()); } private void updateColor() { diff --git a/src/main/res/layout/fragment_navigation_drawer.xml b/src/main/res/layout/fragment_navigation_drawer.xml index f02325a43..f09ceab34 100644 --- a/src/main/res/layout/fragment_navigation_drawer.xml +++ b/src/main/res/layout/fragment_navigation_drawer.xml @@ -5,7 +5,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" - android:background="?attr/drawer_background" + android:background="@color/drawer_color" app:insetForeground="#4000"> diff --git a/src/main/res/values-night/colors.xml b/src/main/res/values-night/colors.xml new file mode 100644 index 000000000..1c93690a1 --- /dev/null +++ b/src/main/res/values-night/colors.xml @@ -0,0 +1,12 @@ + + + #303030 + #424242 + #ffffff + #303030 + #202020 + #ffffffff + #b3ffffff + #80ffffff + #1fffffff + \ No newline at end of file diff --git a/src/main/res/values-night/dimens.xml b/src/main/res/values-night/dimens.xml new file mode 100644 index 000000000..3764c3112 --- /dev/null +++ b/src/main/res/values-night/dimens.xml @@ -0,0 +1,5 @@ + + + 0.70 + 0.50 + \ No newline at end of file diff --git a/src/main/res/values-night/styles.xml b/src/main/res/values-night/styles.xml new file mode 100644 index 000000000..e9bf5d871 --- /dev/null +++ b/src/main/res/values-night/styles.xml @@ -0,0 +1,3 @@ + + diff --git a/src/main/res/values-v21/theme_base_light.xml b/src/main/res/values-v21/theme_base_light.xml deleted file mode 100644 index 0a576eb6c..000000000 --- a/src/main/res/values-v21/theme_base_light.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/main/res/values/arrays.xml b/src/main/res/values/arrays.xml index f25fbdbd2..925b85a29 100644 --- a/src/main/res/values/arrays.xml +++ b/src/main/res/values/arrays.xml @@ -85,6 +85,7 @@ @string/theme_black @string/theme_dark @string/theme_wallpaper + @string/theme_day_night diff --git a/src/main/res/values/attrs.xml b/src/main/res/values/attrs.xml index c4673b6e1..16a99d6d0 100644 --- a/src/main/res/values/attrs.xml +++ b/src/main/res/values/attrs.xml @@ -6,13 +6,10 @@ - - - diff --git a/src/main/res/values/colors.xml b/src/main/res/values/colors.xml index db11c3ccb..494bee9d1 100644 --- a/src/main/res/values/colors.xml +++ b/src/main/res/values/colors.xml @@ -90,29 +90,28 @@ #ff777777 #888888 - #303030 - #fafafa - #424242 - #ffffff - - #f9f9f9 - #303030 - #e8e8e8 - #202020 - - #fff - #eee - #535353 - - #de000000 - #8a000000 - #61000000 - #1f000000 - - #ffffffff - #b3ffffff - #80ffffff - #1fffffff + #fafafa + #ffffff + #000000 + #de000000 + #8a000000 + #61000000 + #1f000000 + + #de000000 + #8a000000 + #61000000 + + #ffffffff + #b3ffffff + #80ffffff + + #fafafa + #000000 + #303030 + + #f9f9f9 + #e8e8e8 @color/red_500 @color/amber_500 diff --git a/src/main/res/values/dimens.xml b/src/main/res/values/dimens.xml index 336a4778d..25ec78790 100644 --- a/src/main/res/values/dimens.xml +++ b/src/main/res/values/dimens.xml @@ -17,11 +17,8 @@ 12 - 0.54 - 0.38 - - 0.70 - 0.50 + 0.54 + 0.38 8dp 6dp diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 560fff8f4..6c5f6e7d5 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -883,6 +883,7 @@ File %1$s contained %2$s.\n\n Light Dark Wallpaper + Day/Night Default disable diff --git a/src/main/res/values/styles.xml b/src/main/res/values/styles.xml index 7fa6f3efa..3dddf9991 100644 --- a/src/main/res/values/styles.xml +++ b/src/main/res/values/styles.xml @@ -2,6 +2,8 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/res/values/theme_base_black.xml b/src/main/res/values/theme_base_black.xml deleted file mode 100644 index 276dd242c..000000000 --- a/src/main/res/values/theme_base_black.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/main/res/values/theme_base_dark.xml b/src/main/res/values/theme_base_dark.xml deleted file mode 100644 index e9ede870d..000000000 --- a/src/main/res/values/theme_base_dark.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/res/values/theme_base_light.xml b/src/main/res/values/theme_base_light.xml deleted file mode 100644 index e4b90cc88..000000000 --- a/src/main/res/values/theme_base_light.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - \ No newline at end of file