Skip to content

Commit

Permalink
Initial Dark Theme, implements #1003
Browse files Browse the repository at this point in the history
This commit provides an initial dark theme for the list view.
  • Loading branch information
dmfs committed Mar 2, 2021
1 parent f38d222 commit 5f2acc5
Show file tree
Hide file tree
Showing 17 changed files with 119 additions and 21 deletions.
13 changes: 13 additions & 0 deletions opentasks-theme/src/main/res/values-v23/theme_dark.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>

<resources>

<style name="OpenTasks_BaseTheme.Dark.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowLightStatusBar">false</item>
<item name="android:statusBarColor">#ff303030</item>
</style>

</resources>
6 changes: 6 additions & 0 deletions opentasks-theme/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@
<attr name="colorWarning"
format="color" />

<attr name="cancelledCardBackground"
format="color|reference" />

<attr name="flatCardBorderColor"
format="color" />

</resources>
4 changes: 2 additions & 2 deletions opentasks-theme/src/main/res/values/theme.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<!-- This sets the default theme to light -->

<style name="OpenTasks_Theme.Default"
parent="OpenTasks_Theme.Light" />
parent="OpenTasks_Theme.Dark" />


<style name="OpenTasks_Theme.Default.Dialog"
parent="OpenTasks_BaseTheme.Light.Dialog" />
parent="OpenTasks_BaseTheme.Dark.Dialog" />

</resources>
74 changes: 74 additions & 0 deletions opentasks-theme/src/main/res/values/theme_dark.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>

<resources>

<!-- The default Light theme. Use this as the parent of your theme to customize it. -->
<style name="OpenTasks_Theme.Dark"
parent="OpenTasks_BaseTheme.Dark.NoActionBar" />

<style name="OpenTasks_BaseTheme.Dark.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#ff303030</item>
</style>

<style name="OpenTasks_BaseTheme.Dark"
parent="Theme.MaterialComponents">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">?attr/colorSecondary</item>
<item name="colorSecondary">@color/secondary</item>
<item name="colorSecondaryVariant">@color/secondary_variant</item>

<item name="colorHighPriority">@color/material_red_700</item>
<item name="colorMediumPriority">@color/material_amber_500</item>
<item name="colorLowPriority">@color/material_green_500</item>

<item name="colorError">@color/material_red_900</item>
<item name="colorWarning">@color/material_deep_orange_900</item>

<item name="android:textColorPrimary">#ffe0e0e0</item>
<item name="android:textColorSecondary">#ff808080</item>
<item name="android:textColorTertiary">#ff505050</item>
<item name="flatCardBorderColor">#ff505050</item>
<item name="cancelledCardBackground">#ff202020</item>

<item name="tabIconTint">?attr/colorPrimary</item>
<item name="tabIndicatorColor">?attr/colorPrimary</item>

<item name="android:scrollbarTrackVertical">@null</item>
<item name="android:scrollbarSize">12dp</item>

</style>

<!-- TODO: what's the correct way of sharing the details of the themes? -->
<style name="OpenTasks_BaseTheme.Dark.Dialog"
parent="Theme.MaterialComponents.Dialog">
<item name="colorPrimary">@color/material_teal_500</item>
<item name="colorPrimaryDark">@color/material_teal_700</item>
<item name="colorAccent">?attr/colorSecondary</item>
<item name="colorSecondary">@color/material_deep_orange_500</item>
<item name="colorSecondaryVariant">@color/material_deep_orange_500</item>

<item name="colorHighPriority">@color/material_red_700</item>
<item name="colorMediumPriority">@color/material_amber_500</item>
<item name="colorLowPriority">@color/material_green_500</item>

<item name="colorError">@color/material_red_900</item>
<item name="colorWarning">@color/material_deep_orange_900</item>

<item name="android:textColorPrimary">#ffe0e0e0</item>
<item name="android:textColorSecondary">#ff808080</item>
<item name="android:textColorTertiary">#ff505050</item>
<item name="flatCardBorderColor">#ff505050</item>
<item name="cancelledCardBackground">#ff202020</item>

<item name="tabIconTint">?attr/colorPrimary</item>
<item name="tabIndicatorColor">?attr/colorPrimary</item>

<item name="android:scrollbarTrackVertical">@null</item>
<item name="android:scrollbarSize">12dp</item>
</style>

</resources>
4 changes: 4 additions & 0 deletions opentasks-theme/src/main/res/values/theme_light.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
<item name="android:textColorPrimary">#d0000000</item>
<item name="android:textColorSecondary">#80000000</item>
<item name="android:textColorTertiary">#50000000</item>
<item name="flatCardBorderColor">#ffd0d0d0</item>
<item name="cancelledCardBackground">#fff0f0f0</item>

<item name="android:textColorPrimaryInverse">#ffffffff</item>
<item name="android:textColorSecondaryInverse">#c0ffffff</item>
Expand Down Expand Up @@ -62,6 +64,8 @@
<item name="android:textColorPrimary">#d0000000</item>
<item name="android:textColorSecondary">#80000000</item>
<item name="android:textColorTertiary">#50000000</item>
<item name="flatCardBorderColor">#ffd0d0d0</item>
<item name="cancelledCardBackground">#fff0f0f0</item>

<item name="android:textColorPrimaryInverse">#ffffffff</item>
<item name="android:textColorSecondaryInverse">#c0ffffff</item>
Expand Down
6 changes: 3 additions & 3 deletions opentasks/src/main/java/org/dmfs/tasks/EditTaskFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public void onScroll(int oldScrollY, int newScrollY)
// ensure we're using the latest values
mValues.update(mAppContext, CONTENT_VALUE_MAPPER);
}
mListColor = TaskFieldAdapters.LIST_COLOR.get(mValues);
mListColor = TaskFieldAdapters.LIST_COLOR_DARKENED.get(mValues);
// update the color of the action bar as soon as possible
updateColor(0);
setListUri(TaskLists.getContentUri(mAuthority), LIST_LOADER_VISIBLE_LISTS_FILTER);
Expand Down Expand Up @@ -553,7 +553,7 @@ public void onContentLoaded(ContentSet contentSet)
{
if (contentSet.containsKey(Tasks.ACCOUNT_TYPE))
{
mListColor = TaskFieldAdapters.LIST_COLOR.get(contentSet);
mListColor = TaskFieldAdapters.LIST_COLOR_DARKENED.get(contentSet);
updateColor((float) mRootView.getScrollY() / mTaskListBar.getMeasuredHeight());

if (mAppForEdit)
Expand Down Expand Up @@ -596,7 +596,7 @@ public void onItemSelected(AdapterView<?> arg0, View arg1, int pos, long itemId)
Cursor c = (Cursor) arg0.getItemAtPosition(pos);

String accountType = c.getString(TASK_LIST_PROJECTION_VALUES.account_type);
mListColor = TaskFieldAdapters.LIST_COLOR.get(c);
mListColor = TaskFieldAdapters.LIST_COLOR_DARKENED.get(c);
updateColor((float) mRootView.getScrollY() / mTaskListBar.getMeasuredHeight());

if (mEditor != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ private void setListUri(Uri uri, String filter)
public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
{
Cursor c = (Cursor) parent.getItemAtPosition(position);
mLastColor = TaskFieldAdapters.LIST_COLOR.get(c);
mLastColor = TaskFieldAdapters.LIST_COLOR_DARKENED.get(c);
mColorBackground.setBackgroundColor(mLastColor);
mSelectedListId = id;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ private void selectChildView(ExpandableListView expandLV, int groupPosition, int
}

Uri taskUri = ContentUris.withAppendedId(Instances.getContentUri(mAuthority), (long) TaskFieldAdapters.TASK_ID.get(cursor));
Color taskListColor = new ValueColor(TaskFieldAdapters.LIST_COLOR.get(cursor));
Color taskListColor = new ValueColor(TaskFieldAdapters.LIST_COLOR_DARKENED.get(cursor));
mCallbacks.onItemSelected(taskUri, taskListColor, force, mInstancePosition);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ public void onContentLoaded(ContentSet contentSet)
{
if (contentSet.containsKey(Tasks.ACCOUNT_TYPE))
{
mListColor = TaskFieldAdapters.LIST_COLOR.get(contentSet);
mListColor = TaskFieldAdapters.LIST_COLOR_DARKENED.get(contentSet);
((Callback) getActivity()).onListColorLoaded(new ValueColor(mListColor));

updateColor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,20 +270,20 @@ protected void setColorBar(View view, Cursor cursor)

if (STATUS.get(cursor) == STATUS_CANCELLED)
{
cardView.setCardBackgroundColor(0xfff0f0f0);
cardView.setCardBackgroundColor(new AttributeColor(view.getContext(), R.attr.cancelledCardBackground).argb());
cardView.setStrokeWidth(0);
cardView.setStrokeColor(0);
((TextView) cardView.findViewById(android.R.id.title)).setTextColor(
new AttributeColor(view.getContext(), android.R.attr.textColorTertiary).argb());
cardView.setStrokeWidth(view.getResources().getDimensionPixelSize(R.dimen.opentasks_cardlist_open_border_width));

((TextView) cardView.findViewById(android.R.id.title))
.setTextColor(new AttributeColor(view.getContext(), android.R.attr.textColorTertiary).argb());
}
else
{
cardView.setCardBackgroundColor(new AttributeColor(view.getContext(), android.R.attr.windowBackground).argb());
//cardView.setCardElevation(1f);
((TextView) cardView.findViewById(android.R.id.title)).setTextColor(
new AttributeColor(view.getContext(), android.R.attr.textColorTertiary).argb());
cardView.setStrokeColor(0xfff0f0f0);
// todo: use a dedicated color
cardView.setStrokeColor(new AttributeColor(view.getContext(), R.attr.flatCardBorderColor).argb());
cardView.setStrokeWidth(view.getResources().getDimensionPixelSize(R.dimen.opentasks_cardlist_closed_border_width));
}
cardView.setCardElevation(view.getResources().getDimensionPixelSize(R.dimen.opentasks_cardlist_closed_elevation));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ public static TaskListWidgetItem[] getWidgetItems(Cursor mTasksCursor)
while (mTasksCursor.moveToNext())
{
items[itemIndex] = new TaskListWidgetItem(TaskFieldAdapters.TASK_ID.get(mTasksCursor), TaskFieldAdapters.TITLE.get(mTasksCursor),
TaskFieldAdapters.DUE.get(mTasksCursor), TaskFieldAdapters.LIST_COLOR.get(mTasksCursor),
TaskFieldAdapters.DUE.get(mTasksCursor), TaskFieldAdapters.LIST_COLOR_DARKENED.get(mTasksCursor),
TaskFieldAdapters.IS_CLOSED.get(mTasksCursor));
itemIndex++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void inflate()
* Add a couple of fields to the model.
*/
// task list color
addField(new FieldDescriptor(context, R.id.task_field_list_color, R.string.task_list, null, TaskFieldAdapters.LIST_COLOR)
addField(new FieldDescriptor(context, R.id.task_field_list_color, R.string.task_list, null, TaskFieldAdapters.LIST_COLOR_DARKENED)
.setViewLayout(LIST_COLOR_VIEW).setEditorLayout(LIST_COLOR_VIEW).setNoAutoAdd(true));

// task list name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public final class TaskFieldAdapters
/**
* Adapter for the Color of the task.
*/
public final static IntegerFieldAdapter LIST_COLOR = new ColorFieldAdapter(TaskContract.Tasks.LIST_COLOR, 0.8f);
public final static IntegerFieldAdapter LIST_COLOR_DARKENED = new ColorFieldAdapter(TaskContract.Tasks.LIST_COLOR, 0.8f);

/**
* Adapter for the Raw Color Value of the task.
Expand Down
2 changes: 1 addition & 1 deletion opentasks/src/main/java/org/dmfs/tasks/model/XmlModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public void inflate() throws ModelInflaterException
try
{
// add a field for the list
addField(new FieldDescriptor(context, R.id.task_field_list_color, R.string.task_list, null, TaskFieldAdapters.LIST_COLOR)
addField(new FieldDescriptor(context, R.id.task_field_list_color, R.string.task_list, null, TaskFieldAdapters.LIST_COLOR_DARKENED)
.setViewLayout(DefaultModel.LIST_COLOR_VIEW).setEditorLayout(DefaultModel.LIST_COLOR_VIEW).setNoAutoAdd(true));
addField(new FieldDescriptor(context, R.id.task_field_list_name, R.string.task_list, null, new StringFieldAdapter(Tasks.LIST_NAME)).setViewLayout(
new LayoutDescriptor(R.layout.text_field_view_nodivider_large).setOption(LayoutDescriptor.OPTION_NO_TITLE, true)).setNoAutoAdd(true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public View getDropDownView(int position, View convertView, ViewGroup parent)
TextView accountName = (TextView) convertView.findViewById(R.id.task_list_account_name);
Cursor cursor = (Cursor) getItem(position);

listColor.setBackgroundColor(TaskFieldAdapters.LIST_COLOR.get(cursor));
listColor.setBackgroundColor(TaskFieldAdapters.LIST_COLOR_DARKENED.get(cursor));
listName.setText(cursor.getString(mTaskNameColumn));
accountName.setText(cursor.getString(mAccountNameColumn));
return convertView;
Expand Down
3 changes: 2 additions & 1 deletion opentasks/src/main/res/layout/fragment_quick_add_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@android:color/white"
android:background="?android:attr/windowBackground"
android:orientation="vertical"
android:padding="0dp">

Expand Down Expand Up @@ -75,6 +75,7 @@
android:text="@string/quick_add_task_created"
android:textAppearance="?android:attr/textAppearanceLarge"
android:visibility="invisible"
app:drawableTint="?android:attr/textColorPrimary"
app:drawableStartCompat="@drawable/ic_checkmark_light" />
</FrameLayout>

Expand Down
2 changes: 1 addition & 1 deletion opentasks/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@

<style name="dialog_button_stacked_secondary"
parent="dialog_button_stacked_primary">
<item name="android:textColor">#90000000</item>
<item name="android:textColor">?android:attr/textColorSecondary</item>
</style>

<style name="checklist_checked_item_text">
Expand Down

0 comments on commit 5f2acc5

Please sign in to comment.