TODOs: Color, Style, and Shuffle XML
Reshuffle these things in order to get much closer to David's mocks
Some missing things: The times still say "20 hours ago" instead of
something shorter like "20 hrs". I think we'll have to do it ourselves.
I also didn't finish the empty screen. I only gave it a nice color.
Change-Id: Ic97a13a97c5f26003db1080dae7969b1a4f6a3e9
diff --git a/app/src/main/java/io/v/todos/TaskViewHolder.java b/app/src/main/java/io/v/todos/TaskViewHolder.java
index 35c90e6..1605ac0 100644
--- a/app/src/main/java/io/v/todos/TaskViewHolder.java
+++ b/app/src/main/java/io/v/todos/TaskViewHolder.java
@@ -4,6 +4,7 @@
package io.v.todos;
+import android.graphics.Paint;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;
@@ -28,17 +29,24 @@
final TextView name=(TextView) itemView.findViewById(R.id.task_text);
name.setText(task.text);
+ if (task.done) {
+ name.setPaintFlags(name.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
+ name.setTextColor(name.getTextColors().withAlpha(UIUtil.ALPHA_HINT));
+ } else {
+ name.setPaintFlags(name.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
+ name.setTextColor(name.getTextColors().withAlpha(UIUtil.ALPHA_PRIMARY));
+ }
final TextView created=(TextView) itemView.findViewById(R.id.task_time);
created.setText(computeCreated(task));
- getCardView().setCardBackgroundColor(task.done ? 0xFFCCCCCC : 0xFFFFFFFF);
+ //getCardView().setCardBackgroundColor(task.done ? 0xFFCCCCCC : 0xFFFFFFFF);
itemView.setTag(task.key);
itemView.setOnClickListener(itemListener);
}
private String computeCreated(Task task) {
- return UIUtil.computeTimeAgo(getCardView().getContext(), "Created", task.addedAt);
+ return UIUtil.computeTimeAgo(getCardView().getContext(), task.addedAt);
}
}
diff --git a/app/src/main/java/io/v/todos/TodoListViewHolder.java b/app/src/main/java/io/v/todos/TodoListViewHolder.java
index a70cb8f..3638a78 100644
--- a/app/src/main/java/io/v/todos/TodoListViewHolder.java
+++ b/app/src/main/java/io/v/todos/TodoListViewHolder.java
@@ -4,6 +4,7 @@
package io.v.todos;
+import android.graphics.Paint;
import android.view.View;
import android.widget.TextView;
@@ -25,28 +26,30 @@
public void bindTodoList(ListMetadata listMetadata, View.OnClickListener listener) {
mName.setText(listMetadata.name);
mCompletedStatus.setText(computeCompleted(listMetadata));
+ if (listMetadata.isDone()) {
+ mName.setPaintFlags(mName.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
+ mName.setTextColor(mName.getTextColors().withAlpha(UIUtil.ALPHA_HINT));
+ } else {
+ mName.setPaintFlags(mName.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
+ mName.setTextColor(mName.getTextColors().withAlpha(UIUtil.ALPHA_PRIMARY));
+ }
mTimeAgo.setText(computeTimeAgo(listMetadata));
- getCardView().setCardBackgroundColor(listMetadata.isDone() ? 0xFFCCCCCC : 0xFFFFFFFF);
+ //getCardView().setCardBackgroundColor(listMetadata.isDone() ? 0xFFCCCCCC : 0xFFFFFFFF);
itemView.setTag(listMetadata.key);
itemView.setOnClickListener(listener);
}
private String computeTimeAgo(ListMetadata listMetadata) {
- return UIUtil.computeTimeAgo(getCardView().getContext(), "Last Updated",
- listMetadata.updatedAt);
+ return UIUtil.computeTimeAgo(getCardView().getContext(), listMetadata.updatedAt);
}
private String computeCompleted(ListMetadata listMetadata) {
- if (listMetadata.isDone()) {
- return "Done!";
- } else if (listMetadata.numTasks == 0) {
- return "Needs Tasks";
- } else if (listMetadata.numCompleted == 0) {
- return "Not Started";
+ if (listMetadata.numTasks == 0) {
+ return "No Tasks";
} else {
- return listMetadata.numCompleted + " of " + listMetadata.numTasks;
+ return listMetadata.numCompleted + "/" + listMetadata.numTasks + " completed";
}
}
diff --git a/app/src/main/java/io/v/todos/UIUtil.java b/app/src/main/java/io/v/todos/UIUtil.java
index 7760ea9..50b83b3 100644
--- a/app/src/main/java/io/v/todos/UIUtil.java
+++ b/app/src/main/java/io/v/todos/UIUtil.java
@@ -31,12 +31,17 @@
private UIUtil() {
}
- private static final long JUST_NOW_DURATION = 60 * 1000 - 1;
- public static String computeTimeAgo(Context context, String prefix, long startTime) {
+ private static final long JUST_NOW_DURATION = 60 * 60 * 1000 - 1;
+ public static final int ALPHA_PRIMARY = (int)(255 * 0.87);
+ public static final int ALPHA_SECONDARY = (int)(255 * 0.54);
+ public static final int ALPHA_HINT = (int)(255 * 0.38);
+
+ public static String computeTimeAgo(Context context, long startTime) {
long now = System.currentTimeMillis();
- return prefix + ": " + (now - startTime > JUST_NOW_DURATION ?
- DateUtils.getRelativeTimeSpanString(startTime, now, DateUtils.MINUTE_IN_MILLIS) :
+ return (now - startTime > JUST_NOW_DURATION ?
+ DateUtils.getRelativeTimeSpanString(startTime, now, DateUtils.HOUR_IN_MILLIS, DateUtils.FORMAT_ABBREV_ALL).
+ toString() :
context.getString(R.string.just_now));
}
diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml
index fd3e0fb..bbd6d53 100644
--- a/app/src/main/res/layout/content_main.xml
+++ b/app/src/main/res/layout/content_main.xml
@@ -25,7 +25,9 @@
android:layout_height="match_parent"
android:gravity="center"
android:alpha="0"
- android:visibility="gone"/>
+ android:visibility="gone"
+ android:textColor="#E0FFFFFF"
+ android:background="@color/colorPrimaryLight"/>
</FrameLayout>
<android.support.design.widget.FloatingActionButton
diff --git a/app/src/main/res/layout/task_row.xml b/app/src/main/res/layout/task_row.xml
index b7f3059..21415bd 100644
--- a/app/src/main/res/layout/task_row.xml
+++ b/app/src/main/res/layout/task_row.xml
@@ -42,50 +42,44 @@
android:layout_height="match_parent"
android:layout_marginBottom="1dp"
card_view:cardElevation="1dp"
- card_view:cardBackgroundColor="#DDDDFF"
card_view:cardCornerRadius="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="horizontal">
+ android:orientation="horizontal"
+ android:layout_marginTop="@dimen/small_margin"
+ android:layout_marginBottom="@dimen/small_margin">
<ImageButton
android:id="@+id/task_done"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
- android:padding="16dp"
+ android:padding="@dimen/fab_margin"
android:background="?attr/selectableItemBackgroundBorderless"
android:layout_weight="0"/>
- <LinearLayout
- android:layout_width="fill_parent"
+ <TextView
+ android:id="@+id/task_text"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_margin="@dimen/small_margin"
android:layout_weight="1"
- android:orientation="vertical">
+ android:layout_gravity="center_vertical"
+ android:textColor="#E0000000"
+ android:textSize="22sp"
+ android:textStyle="bold"/>
- <TextView
- android:id="@+id/task_text"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_margin="5dp"
- android:layout_weight="1"
- android:gravity="center_vertical"
- android:textColor="#000000"
- android:textSize="22sp"
- android:textStyle="bold"/>
-
- <TextView
- android:id="@+id/task_time"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_margin="5dp"
- android:layout_weight="1"
- android:gravity="center_vertical"
- android:textColor="#333333"
- android:textSize="12sp"/>
- </LinearLayout>
+ <TextView
+ android:id="@+id/task_time"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/fab_margin"
+ android:layout_weight="0"
+ android:layout_gravity="center_vertical"
+ android:textColor="#61000000"
+ android:textSize="12sp"/>
</LinearLayout>
</android.support.v7.widget.CardView>
</FrameLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/todo_list_row.xml b/app/src/main/res/layout/todo_list_row.xml
index b1e0879..4dd003b 100644
--- a/app/src/main/res/layout/todo_list_row.xml
+++ b/app/src/main/res/layout/todo_list_row.xml
@@ -38,49 +38,43 @@
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_marginBottom="1dp"
card_view:cardElevation="1dp"
- card_view:cardBackgroundColor="#DDDDFF"
card_view:cardCornerRadius="0dp">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingLeft="10dp">
-
- <TextView android:id="@+id/todo_list_name"
- android:layout_width="fill_parent"
- android:layout_weight = "1"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:textStyle="bold"
- android:textSize="22sp"
- android:textColor="#000000"
- android:layout_margin="5dp" />
+ android:padding="@dimen/fab_margin">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="horizontal"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight = "1">
-
- <TextView android:id="@+id/todo_list_completed"
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:textSize="12sp"
- android:textColor="#333333"
- android:layout_margin="5dp" />
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight = "1">
+ <TextView android:id="@+id/todo_list_name"
+ android:layout_width="wrap_content"
+ android:layout_weight = "1"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:textStyle="bold"
+ android:textSize="22sp"
+ android:textColor="#E0000000" />
<TextView android:id="@+id/todo_list_time"
- android:layout_width="0dp"
- android:layout_weight="2"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:textSize="12sp"
- android:textColor="#333333"
- android:layout_margin="5dp" />
+ android:layout_width="wrap_content"
+ android:layout_weight="0"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:textSize="12sp"
+ android:textColor="#61000000" />
</LinearLayout>
+
+ <TextView android:id="@+id/todo_list_completed"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="0"
+ android:textSize="12sp"
+ android:textColor="#61000000" />
</LinearLayout>
</android.support.v7.widget.CardView>
</FrameLayout>
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index 3ab3e9c..2fe96f5 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -2,5 +2,6 @@
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
+ <color name="colorPrimaryLight">#9FA8DA</color>
<color name="colorAccent">#FF4081</color>
</resources>
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index 812cb7b..3d6dd01 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -3,4 +3,5 @@
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="fab_margin">16dp</dimen>
+ <dimen name="small_margin">5dp</dimen>
</resources>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 9eee6fe..05e3637 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -9,7 +9,7 @@
<string name="init_persistence">Initializing…</string>
<string name="no_lists">No todo lists.\nPress \'+\' to add lists.</string>
<string name="no_tasks">No tasks.\nPress \'+\' to add tasks.</string>
- <string name="just_now">Just now</string>
+ <string name="just_now">Now</string>
<string name="email_debug_subject">Debug the persistence layer</string>
<string name="no_email_client">An app to share emails is not installed, cannot send debug request</string>
<!-- Errors -->