Fixed widget due date display bug

pull/14/head
Sam Bosley 13 years ago
parent 74dc90b8ef
commit 9fba7953aa

@ -454,6 +454,13 @@ public final class Task extends RemoteModel {
return hasDueTime(getValue(Task.DUE_DATE)); return hasDueTime(getValue(Task.DUE_DATE));
} }
public boolean isOverdue() {
long dueDate = getValue(Task.DUE_DATE);
long compareTo = hasDueTime() ? DateUtilities.now() : DateUtilities.getStartOfDay(DateUtilities.now());
return dueDate < compareTo;
}
public boolean isEditable() { public boolean isEditable() {
return !getFlag(Task.FLAGS, Task.FLAG_IS_READONLY) && return !getFlag(Task.FLAGS, Task.FLAG_IS_READONLY) &&
!(getFlag(Task.FLAGS, Task.FLAG_PUBLIC) && getValue(Task.USER_ID) != Task.USER_ID_SELF); !(getFlag(Task.FLAGS, Task.FLAG_PUBLIC) && getValue(Task.USER_ID) != Task.USER_ID_SELF);

@ -383,12 +383,10 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
if (activity != null) { if (activity != null) {
if(!task.isCompleted() && task.hasDueDate()) { if(!task.isCompleted() && task.hasDueDate()) {
long dueDate = task.getValue(Task.DUE_DATE); long dueDate = task.getValue(Task.DUE_DATE);
long compareTo = task.hasDueTime() ? DateUtilities.now() : DateUtilities.getStartOfDay(DateUtilities.now()); if(task.isOverdue())
if(dueDate > compareTo)
dueDateView.setTextAppearance(fragment.getActivity(), R.style.TextAppearance_TAd_ItemDueDate);
else
dueDateView.setTextAppearance(fragment.getActivity(), R.style.TextAppearance_TAd_ItemDueDate_Overdue); dueDateView.setTextAppearance(fragment.getActivity(), R.style.TextAppearance_TAd_ItemDueDate_Overdue);
else
dueDateView.setTextAppearance(fragment.getActivity(), R.style.TextAppearance_TAd_ItemDueDate);
String dateValue = formatDate(dueDate); String dateValue = formatDate(dueDate);
dueDateView.setText(dateValue); dueDateView.setText(dateValue);
dueDateTextWidth = paint.measureText(dateValue); dueDateTextWidth = paint.measureText(dateValue);

@ -24,7 +24,6 @@ import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.ContextManager; import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService; import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.Preferences; import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.activity.TaskEditActivity; import com.todoroo.astrid.activity.TaskEditActivity;
import com.todoroo.astrid.activity.TaskEditFragment; import com.todoroo.astrid.activity.TaskEditFragment;
@ -181,7 +180,7 @@ public class TasksWidget extends AppWidgetProvider {
if(task.isCompleted()) if(task.isCompleted())
textColor = r.getColor(R.color.task_list_done); textColor = r.getColor(R.color.task_list_done);
else if(task.hasDueDate() && task.getValue(Task.DUE_DATE) < DateUtilities.now()) else if(task.hasDueDate() && task.isOverdue())
textColor = r.getColor(R.color.task_list_overdue); textColor = r.getColor(R.color.task_list_overdue);
RemoteViews row = new RemoteViews(Constants.PACKAGE, R.layout.widget_row); RemoteViews row = new RemoteViews(Constants.PACKAGE, R.layout.widget_row);

Loading…
Cancel
Save