Skip to content

Commit

Permalink
Reduce color usage in list view
Browse files Browse the repository at this point in the history
  • Loading branch information
dmfs committed Mar 2, 2021
1 parent 33a78f4 commit f38d222
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 30 deletions.
8 changes: 8 additions & 0 deletions opentasks-theme/src/main/res/values/theme_light.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
<item name="colorError">@color/material_red_900</item>
<item name="colorWarning">@color/material_deep_orange_900</item>

<item name="android:textColorPrimary">#d0000000</item>
<item name="android:textColorSecondary">#80000000</item>
<item name="android:textColorTertiary">#50000000</item>

<item name="android:textColorPrimaryInverse">#ffffffff</item>
<item name="android:textColorSecondaryInverse">#c0ffffff</item>

Expand Down Expand Up @@ -55,6 +59,10 @@
<item name="colorError">@color/material_red_900</item>
<item name="colorWarning">@color/material_deep_orange_900</item>

<item name="android:textColorPrimary">#d0000000</item>
<item name="android:textColorSecondary">#80000000</item>
<item name="android:textColorTertiary">#50000000</item>

<item name="android:textColorPrimaryInverse">#ffffffff</item>
<item name="android:textColorSecondaryInverse">#c0ffffff</item>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import static android.text.Spanned.SPAN_EXCLUSIVE_EXCLUSIVE;
import static org.dmfs.tasks.contract.TaskContract.TaskColumns.STATUS_CANCELLED;
import static org.dmfs.tasks.model.TaskFieldAdapters.IS_CLOSED;
import static org.dmfs.tasks.model.TaskFieldAdapters.LIST_COLOR_RAW;
import static org.dmfs.tasks.model.TaskFieldAdapters.STATUS;


Expand Down Expand Up @@ -230,6 +231,7 @@ protected void setPrio(SharedPreferences prefs, View view, Cursor cursor)
{
// display priority
View prioLabel = getView(view, R.id.priority_label);
prioLabel.setAlpha(IS_CLOSED.get(cursor) ? 0.4f : 1f);
int priority = TaskFieldAdapters.PRIORITY.get(cursor);
if (priority > 0 &&
prefs.getBoolean(prioLabel.getContext().getString(R.string.opentasks_pref_appearance_list_show_priority), true))
Expand Down Expand Up @@ -260,32 +262,40 @@ protected void setColorBar(View view, Cursor cursor)
MaterialCardView cardView = getView(view, R.id.flingContentView);
if (cardView != null)
{
cardView.findViewById(R.id.color_label).setVisibility(View.VISIBLE);
cardView.findViewById(R.id.color_label).setBackgroundColor(LIST_COLOR_RAW.get(cursor));
if (IS_CLOSED.get(cursor))
{
cardView.findViewById(R.id.color_label).setAlpha(0.4f);

if (STATUS.get(cursor) == STATUS_CANCELLED)
{
cardView.setCardBackgroundColor(0xfff0f0f0);
cardView.setStrokeColor(0);
((TextView) cardView.findViewById(android.R.id.title)).setTextColor(0x50000000);
((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));

}
else
{
cardView.setCardBackgroundColor(new AttributeColor(view.getContext(), android.R.attr.windowBackground).argb());
//cardView.setCardElevation(1f);
((TextView) cardView.findViewById(android.R.id.title)).setTextColor(0x80000000);
cardView.setStrokeColor(0xffc0c0c0);
((TextView) cardView.findViewById(android.R.id.title)).setTextColor(
new AttributeColor(view.getContext(), android.R.attr.textColorTertiary).argb());
cardView.setStrokeColor(0xfff0f0f0);
cardView.setStrokeWidth(view.getResources().getDimensionPixelSize(R.dimen.opentasks_cardlist_closed_border_width));
}
cardView.setCardElevation(view.getResources().getDimensionPixelSize(R.dimen.opentasks_cardlist_closed_elevation));
}
else
{
cardView.setCardBackgroundColor(TaskFieldAdapters.LIST_COLOR.get(cursor));
cardView.findViewById(R.id.color_label).setAlpha(1f);
cardView.setCardBackgroundColor(new AttributeColor(view.getContext(), android.R.attr.colorBackground).argb());
cardView.setStrokeColor(0);
((TextView) cardView.findViewById(android.R.id.title)).setTextColor(0xffffffff);
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.textColorPrimary).argb());
cardView.setStrokeWidth(0);
cardView.setCardElevation(view.getResources().getDimensionPixelSize(R.dimen.opentasks_cardlist_open_elevation));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ public final class TaskFieldAdapters
*/
public final static IntegerFieldAdapter LIST_COLOR = new ColorFieldAdapter(TaskContract.Tasks.LIST_COLOR, 0.8f);

/**
* Adapter for the Raw Color Value of the task.
*/
public final static IntegerFieldAdapter LIST_COLOR_RAW = new IntegerFieldAdapter(TaskContract.Tasks.LIST_COLOR);

/**
* Adpater for the ID of the task.
*/
Expand Down
1 change: 1 addition & 0 deletions opentasks/src/main/res/layout/activity_task_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
android:layout_margin="16dp"
android:src="@drawable/ic_action_add"
app:layout_anchor="@id/pager"
app:tint="@android:color/white"
app:layout_anchorGravity="bottom|right|end" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>
38 changes: 17 additions & 21 deletions opentasks/src/main/res/layout/task_list_element.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
android:padding="2dip"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="?android:attr/textColorPrimaryInverse"
android:textColor="?android:attr/textColorPrimary"
android:textIsSelectable="false" />

<LinearLayout
Expand All @@ -106,7 +106,7 @@
android:gravity="right"
android:paddingLeft="0dip"
android:paddingRight="2dip"
android:textColor="?android:attr/textColorSecondaryInverse"
android:textColor="?android:attr/textColorSecondary"
android:textIsSelectable="false"
android:textSize="12sp"
android:visibility="gone" />
Expand All @@ -120,7 +120,7 @@
android:contentDescription="@string/cd_start_date"
android:scaleType="fitStart"
android:src="@drawable/task_start"
android:tint="?android:attr/textColorSecondaryInverse"
android:tint="?android:attr/textColorSecondary"
android:visibility="gone" />
</LinearLayout>

Expand All @@ -138,7 +138,7 @@
android:gravity="right"
android:paddingLeft="0dip"
android:paddingRight="2dip"
android:textColor="?android:attr/textColorSecondaryInverse"
android:textColor="?android:attr/textColorSecondary"
android:textIsSelectable="false"
android:textSize="12sp" />

Expand All @@ -151,11 +151,10 @@
android:contentDescription="@string/cd_due_date"
android:scaleType="fitStart"
android:src="@drawable/task_due"
android:tint="?android:attr/textColorSecondaryInverse"
android:tint="?android:attr/textColorSecondary"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>

</LinearLayout>

<androidx.appcompat.widget.AppCompatTextView
Expand All @@ -167,7 +166,7 @@
android:layout_below="@id/title_layout"
android:padding="2dip"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorSecondaryInverse"
android:textColor="?android:attr/textColorSecondary"
android:textIsSelectable="false"
android:textSize="12sp" />

Expand All @@ -179,26 +178,23 @@
android:layout_alignParentStart="true"
android:padding="2dp"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorSecondaryInverse"
android:textColor="?android:attr/textColorSecondary"
android:textIsSelectable="false"
android:textSize="12sp" />

</RelativeLayout>

<FrameLayout

<View
android:id="@+id/color_label"
android:layout_width="6dip"
android:layout_height="match_parent"
android:layout_gravity="start" />

<View
android:id="@+id/priority_label"
android:layout_width="8dip"
android:layout_width="6dip"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_gravity="right">

<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#ffffffff" />
</FrameLayout>
android:layout_gravity="end" />
</com.google.android.material.card.MaterialCardView>

</RelativeLayout>
Expand Down
6 changes: 3 additions & 3 deletions opentasks/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -280,17 +280,17 @@
</style>

<style name="task_list_overdue_text">
<item name="android:textColor">?android:attr/textColorPrimaryInverse</item>
<item name="android:textColor">?android:attr/textColorPrimary</item>
<item name="android:textStyle">bold</item>
</style>

<style name="task_list_due_text_closed">
<item name="android:textColor">#60000000</item>
<item name="android:textColor">?android:attr/textColorTertiary</item>
<item name="android:textStyle">normal</item>
</style>

<style name="task_list_due_text">
<item name="android:textColor">?android:attr/textColorSecondaryInverse</item>
<item name="android:textColor">?android:attr/textColorSecondary</item>
<item name="android:textStyle">normal</item>
</style>

Expand Down

0 comments on commit f38d222

Please sign in to comment.