From d814380b0b60cc3c32f204e940f691a1c748b2e0 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Mon, 13 Feb 2012 13:53:49 -0800 Subject: [PATCH] Option for legacy style importance indicators and check boxes --- .../res/layout/task_adapter_draggable_row.xml | 6 + astrid/res/layout/task_adapter_row.xml | 200 ++++++++++-------- astrid/res/values/keys.xml | 2 + astrid/res/values/strings-core.xml | 4 + astrid/res/xml/preferences.xml | 7 + .../todoroo/astrid/adapter/TaskAdapter.java | 47 ++-- 6 files changed, 159 insertions(+), 107 deletions(-) diff --git a/astrid/res/layout/task_adapter_draggable_row.xml b/astrid/res/layout/task_adapter_draggable_row.xml index 9e71d46b4..24842aec9 100644 --- a/astrid/res/layout/task_adapter_draggable_row.xml +++ b/astrid/res/layout/task_adapter_draggable_row.xml @@ -9,6 +9,12 @@ android:paddingBottom="2dip" android:gravity="center_vertical" android:orientation="horizontal"> + + - - - - - - - - - - - - - - - - - - - - - - - - - + android:background="@android:drawable/list_selector_background" + android:orientation="horizontal"> - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/astrid/res/values/keys.xml b/astrid/res/values/keys.xml index 214debcf3..fc01cdf5a 100644 --- a/astrid/res/values/keys.xml +++ b/astrid/res/values/keys.xml @@ -201,6 +201,8 @@ showSmartConfirmation allowCompressedTaskRows + + legacyImportanceStyle diff --git a/astrid/res/values/strings-core.xml b/astrid/res/values/strings-core.xml index 408c43b02..94e8bc4d7 100644 --- a/astrid/res/values/strings-core.xml +++ b/astrid/res/values/strings-core.xml @@ -481,6 +481,10 @@ Compact Task Row Compress task rows to fit title + + Use legacy importance style + Use legacy importance style + Color Theme diff --git a/astrid/res/xml/preferences.xml b/astrid/res/xml/preferences.xml index 35acab67e..366e7c796 100644 --- a/astrid/res/xml/preferences.xml +++ b/astrid/res/xml/preferences.xml @@ -27,6 +27,12 @@ android:title="@string/EPr_compressTaskRows_title" android:summary="@string/EPr_compressTaskRows_desc" android:defaultValue="false" /> + + + diff --git a/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java b/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java index 0dc8890c9..47a7442ce 100644 --- a/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java +++ b/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java @@ -126,25 +126,31 @@ public class TaskAdapter extends CursorAdapter implements Filterable { }; public static int[] IMPORTANCE_RESOURCES = new int[] { - R.drawable.importance_check_1, //task_indicator_0, - R.drawable.importance_check_2, //task_indicator_1, - R.drawable.importance_check_3, //task_indicator_2, - R.drawable.importance_check_4, //task_indicator_3, + R.drawable.importance_check_1, + R.drawable.importance_check_2, + R.drawable.importance_check_3, + R.drawable.importance_check_4, }; + public static int[] LEGACY_IMPORTANCE_RESOURCES = new int[] { + R.drawable.importance_1, + R.drawable.importance_2, + R.drawable.importance_3, + R.drawable.importance_4, + }; public static int[] IMPORTANCE_RESOURCES_LARGE = new int[] { - R.drawable.check_box_large_1, //task_indicator_0, - R.drawable.check_box_large_2, //task_indicator_1, - R.drawable.check_box_large_3, //task_indicator_2, - R.drawable.check_box_large_4, //task_indicator_3, + R.drawable.check_box_large_1, + R.drawable.check_box_large_2, + R.drawable.check_box_large_3, + R.drawable.check_box_large_4, }; public static int[] IMPORTANCE_REPEAT_RESOURCES = new int[] { - R.drawable.importance_check_repeat_1, //task_indicator_0, - R.drawable.importance_check_repeat_2, //task_indicator_1, - R.drawable.importance_check_repeat_3, //task_indicator_2, - R.drawable.importance_check_repeat_4, //task_indicator_3, + R.drawable.importance_check_repeat_1, + R.drawable.importance_check_repeat_2, + R.drawable.importance_check_repeat_3, + R.drawable.importance_check_repeat_4, }; // --- instance variables @@ -263,6 +269,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable { viewHolder.task = new Task(); viewHolder.view = view; viewHolder.rowBody = (ViewGroup)view.findViewById(R.id.rowBody); + viewHolder.importance = view.findViewById(R.id.importance_legacy); viewHolder.nameView = (TextView)view.findViewById(R.id.title); viewHolder.picture = (AsyncImageView)view.findViewById(R.id.picture); viewHolder.pictureBorder = (ImageView)view.findViewById(R.id.pictureBorder); @@ -329,6 +336,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable { public ViewGroup view; public ViewGroup rowBody; public TextView nameView; + public View importance; // for legacy importance style public CheckBox completeBox; public AsyncImageView picture; public ImageView pictureBorder; @@ -431,17 +439,28 @@ public class TaskAdapter extends CursorAdapter implements Filterable { // importance bar final CheckBox checkBoxView = viewHolder.completeBox; { + // Logic for legacy style + boolean useLegacyImportance = Preferences.getBoolean(R.string.p_useLegacyImportanceStyle, false); + if (useLegacyImportance) { + viewHolder.importance.setVisibility(View.VISIBLE); + } else { + viewHolder.importance.setVisibility(View.GONE); + } + int value = task.getValue(Task.IMPORTANCE); if (value >= IMPORTANCE_RESOURCES.length) value = IMPORTANCE_RESOURCES.length - 1; - if (!TextUtils.isEmpty(task.getValue(Task.RECURRENCE))) { + if (useLegacyImportance) { + checkBoxView.setButtonDrawable(R.drawable.btn_check); + viewHolder.importance.setBackgroundResource(LEGACY_IMPORTANCE_RESOURCES[value]); + } else if (!TextUtils.isEmpty(task.getValue(Task.RECURRENCE))) { checkBoxView.setButtonDrawable(IMPORTANCE_REPEAT_RESOURCES[value]); } else { checkBoxView.setButtonDrawable(IMPORTANCE_RESOURCES[value]); } if (pictureView != null && pictureView.getVisibility() == View.VISIBLE) { checkBoxView.setVisibility(View.INVISIBLE); - if (viewHolder.pictureBorder != null) + if (viewHolder.pictureBorder != null && !useLegacyImportance) viewHolder.pictureBorder.setBackgroundResource(IMPORTANCE_RESOURCES_LARGE[value]); } else { checkBoxView.setVisibility(View.VISIBLE);