From 6d5a25170c3bd8ede706d2731bc94531e6d156af Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Mon, 14 Jan 2013 11:47:49 -0800 Subject: [PATCH] Lots of refactoring to support more than two task row styles in preparation for a 'titles only' style --- .../AstridOrderedListFragmentHelper.java | 4 +-- .../OrderedMetadataListFragmentHelper.java | 4 +-- astrid/res/values/keys.xml | 8 +++++- astrid/res/values/strings-core.xml | 18 ++++++++++--- astrid/res/xml/preferences.xml | 7 ++--- .../astrid/activity/EditPreferences.java | 26 ++++++++++++------- .../astrid/activity/TaskListFragment.java | 16 +++++++++--- .../astrid/service/UpgradeService.java | 14 ++++++++++ .../utility/AstridDefaultPreferenceSpec.java | 4 +-- .../utility/AstridLitePreferenceSpec.java | 4 +-- 10 files changed, 75 insertions(+), 30 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/subtasks/AstridOrderedListFragmentHelper.java b/astrid/plugin-src/com/todoroo/astrid/subtasks/AstridOrderedListFragmentHelper.java index 38555f00c..85185c8f9 100644 --- a/astrid/plugin-src/com/todoroo/astrid/subtasks/AstridOrderedListFragmentHelper.java +++ b/astrid/plugin-src/com/todoroo/astrid/subtasks/AstridOrderedListFragmentHelper.java @@ -181,10 +181,8 @@ public class AstridOrderedListFragmentHelper implements OrderedListFragmen public TaskAdapter createTaskAdapter(TodorooCursor cursor, AtomicReference sqlQueryTemplate) { - int resource = Preferences.getBoolean(R.string.p_taskRowStyle, false) ? - R.layout.task_adapter_row_simple : R.layout.task_adapter_row; - taskAdapter = new DraggableTaskAdapter(fragment, resource, + taskAdapter = new DraggableTaskAdapter(fragment, TaskListFragment.getTaskRowResource(), cursor, sqlQueryTemplate, false, null); getTouchListView().setItemHightNormal(taskAdapter.computeFullRowHeight()); diff --git a/astrid/plugin-src/com/todoroo/astrid/subtasks/OrderedMetadataListFragmentHelper.java b/astrid/plugin-src/com/todoroo/astrid/subtasks/OrderedMetadataListFragmentHelper.java index 90f34caf0..21d9336a6 100644 --- a/astrid/plugin-src/com/todoroo/astrid/subtasks/OrderedMetadataListFragmentHelper.java +++ b/astrid/plugin-src/com/todoroo/astrid/subtasks/OrderedMetadataListFragmentHelper.java @@ -194,10 +194,8 @@ public class OrderedMetadataListFragmentHelper implements OrderedListFragm public TaskAdapter createTaskAdapter(TodorooCursor cursor, AtomicReference sqlQueryTemplate) { - int resource = Preferences.getBoolean(R.string.p_taskRowStyle, false) ? - R.layout.task_adapter_row_simple : R.layout.task_adapter_row; - taskAdapter = new DraggableTaskAdapter(fragment, resource, + taskAdapter = new DraggableTaskAdapter(fragment, TaskListFragment.getTaskRowResource(), cursor, sqlQueryTemplate, false, null); taskAdapter.addOnCompletedTaskListener(new OnCompletedTaskListener() { diff --git a/astrid/res/values/keys.xml b/astrid/res/values/keys.xml index 47db84ca6..a078517f0 100644 --- a/astrid/res/values/keys.xml +++ b/astrid/res/values/keys.xml @@ -217,7 +217,13 @@ font_size - p_taskRowStyle + p_taskRowStyle + p_taskRowStyle_v2 + + 0 + 1 + 2 + notesVisible beastMode transparent diff --git a/astrid/res/values/strings-core.xml b/astrid/res/values/strings-core.xml index 5671ca987..3979b5799 100644 --- a/astrid/res/values/strings-core.xml +++ b/astrid/res/values/strings-core.xml @@ -707,10 +707,20 @@ Web searches for ideas tab will be performed only when manually requested - Row style: Simple - Row style: Original - Truncate title to one line with date and lists below - Truncate title to two lines with date on right + + Original + Simple + Title only + + + + Truncate title to two lines with date on right + Truncate title to one line with date and lists below + Single line title only + + + + Row style: %s Use filters diff --git a/astrid/res/xml/preferences.xml b/astrid/res/xml/preferences.xml index 4d402a24c..ea85f9947 100644 --- a/astrid/res/xml/preferences.xml +++ b/astrid/res/xml/preferences.xml @@ -49,9 +49,10 @@ android:title="@string/EPr_fontSize_title" android:summary="@string/EPr_fontSize_desc" /> - + cursor) { - int resource = Preferences.getBoolean(R.string.p_taskRowStyle, false) ? - R.layout.task_adapter_row_simple : R.layout.task_adapter_row; - return new TaskAdapter(this, resource, + return new TaskAdapter(this, getTaskRowResource(), cursor, sqlQueryTemplate, false, new OnCompletedTaskListener() { @Override diff --git a/astrid/src/com/todoroo/astrid/service/UpgradeService.java b/astrid/src/com/todoroo/astrid/service/UpgradeService.java index 977a5fcb6..d24609e0b 100644 --- a/astrid/src/com/todoroo/astrid/service/UpgradeService.java +++ b/astrid/src/com/todoroo/astrid/service/UpgradeService.java @@ -50,6 +50,7 @@ import com.todoroo.astrid.utility.Constants; public final class UpgradeService { + public static final int V4_5_1 = 292; public static final int V4_5_0 = 291; public static final int V4_4_4_1 = 290; public static final int V4_4_4 = 289; @@ -182,6 +183,8 @@ public final class UpgradeService { Preferences.setInt(AstridPreferences.P_UPGRADE_FROM, from); + inlineUpgrades(context, from); // Migrations that are short or don't require launching a separate activity + if(from < maxWithUpgrade) { Intent upgrade = new Intent(context, UpgradeActivity.class); upgrade.putExtra(UpgradeActivity.TOKEN_FROM_VERSION, from); @@ -251,6 +254,17 @@ public final class UpgradeService { } } + private void inlineUpgrades(Context context, int from) { + if (from < V4_5_1) { + String key = context.getString(R.string.p_taskRowStyle); + if (Preferences.isSet(key)) { + boolean value = Preferences.getBoolean(key, true); + Preferences.clear(key); + Preferences.setString(R.string.p_taskRowStyle_v2, value ? "1" : "0"); //$NON-NLS-1$ //$NON-NLS-2$ + } + } + } + /** * Return a change log string. Releases occur often enough that we don't * expect change sets to be localized. diff --git a/astrid/src/com/todoroo/astrid/utility/AstridDefaultPreferenceSpec.java b/astrid/src/com/todoroo/astrid/utility/AstridDefaultPreferenceSpec.java index 58970d92f..ce1911551 100644 --- a/astrid/src/com/todoroo/astrid/utility/AstridDefaultPreferenceSpec.java +++ b/astrid/src/com/todoroo/astrid/utility/AstridDefaultPreferenceSpec.java @@ -117,8 +117,6 @@ public class AstridDefaultPreferenceSpec extends AstridPreferenceSpec { setPreference(prefs, editor, r, R.string.p_show_menu_sort, true, ifUnset); setPreference(prefs, editor, r, R.string.p_show_menu_addons, true, ifUnset); - setPreference(prefs, editor, r, R.string.p_taskRowStyle, false, ifUnset); - setPreference(prefs, editor, r, R.string.p_calendar_reminders, true, ifUnset); setPreference(prefs, editor, r, R.string.p_use_filters, true, ifUnset); @@ -136,6 +134,8 @@ public class AstridDefaultPreferenceSpec extends AstridPreferenceSpec { setPreference(prefs, editor, r, R.string.p_show_task_edit_comments, true, ifUnset); + setPreference(prefs, editor, r, R.string.p_taskRowStyle_v2, "0", ifUnset); //$NON-NLS-1$ + setPreference(prefs, editor, r, R.string.p_use_date_shortcuts, ABChooser.readChoiceForTest(ABTests.AB_USE_DATE_SHORTCUTS) != 0, ifUnset); diff --git a/astrid/src/com/todoroo/astrid/utility/AstridLitePreferenceSpec.java b/astrid/src/com/todoroo/astrid/utility/AstridLitePreferenceSpec.java index df9830b0d..fc3e4cc88 100644 --- a/astrid/src/com/todoroo/astrid/utility/AstridLitePreferenceSpec.java +++ b/astrid/src/com/todoroo/astrid/utility/AstridLitePreferenceSpec.java @@ -91,8 +91,6 @@ public class AstridLitePreferenceSpec extends AstridPreferenceSpec { setPreference(prefs, editor, r, R.string.p_ideas_tab_enabled, false, ifUnset); setPreference(prefs, editor, r, R.string.p_autoIdea, false, ifUnset); - setPreference(prefs, editor, r, R.string.p_taskRowStyle, true, ifUnset); - setPreference(prefs, editor, r, R.string.p_calendar_reminders, true, ifUnset); setPreference(prefs, editor, r, R.string.p_use_filters, false, ifUnset); @@ -122,6 +120,8 @@ public class AstridLitePreferenceSpec extends AstridPreferenceSpec { setPreference(prefs, editor, r, R.string.p_show_task_edit_comments, false, ifUnset); + setPreference(prefs, editor, r, R.string.p_taskRowStyle_v2, "0", ifUnset); //$NON-NLS-1$ + setPreference(prefs, editor, r, R.string.p_use_date_shortcuts, false, ifUnset); extras.setExtras(context, prefs, editor, r, ifUnset);