From 5e873a983ffb4eee2d7a45072b7fee5a91397300 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Thu, 10 Jan 2013 12:24:47 -0800 Subject: [PATCH 01/13] Fixed a filter list color issue --- .../todoroo/astrid/tags/TagFilterExposer.java | 3 --- .../todoroo/astrid/adapter/FilterAdapter.java | 17 +++++++++++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/tags/TagFilterExposer.java b/astrid/plugin-src/com/todoroo/astrid/tags/TagFilterExposer.java index 336835ced..5e60ae8cc 100644 --- a/astrid/plugin-src/com/todoroo/astrid/tags/TagFilterExposer.java +++ b/astrid/plugin-src/com/todoroo/astrid/tags/TagFilterExposer.java @@ -16,7 +16,6 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.res.Resources; -import android.graphics.Color; import android.graphics.drawable.BitmapDrawable; import android.os.Bundle; import android.widget.EditText; @@ -76,8 +75,6 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE contentValues); if(tag.remoteId > 0) { filter.listingTitle += " (" + tag.count + ")"; - if(tag.count == 0) - filter.color = Color.GRAY; } int deleteIntentLabel; diff --git a/astrid/src/com/todoroo/astrid/adapter/FilterAdapter.java b/astrid/src/com/todoroo/astrid/adapter/FilterAdapter.java index 6b13a9b03..39759d255 100644 --- a/astrid/src/com/todoroo/astrid/adapter/FilterAdapter.java +++ b/astrid/src/com/todoroo/astrid/adapter/FilterAdapter.java @@ -52,6 +52,7 @@ import com.todoroo.astrid.api.FilterCategory; import com.todoroo.astrid.api.FilterCategoryWithNewButton; import com.todoroo.astrid.api.FilterListHeader; import com.todoroo.astrid.api.FilterListItem; +import com.todoroo.astrid.api.FilterWithCustomIntent; import com.todoroo.astrid.api.FilterWithUpdate; import com.todoroo.astrid.helper.AsyncImageView; import com.todoroo.astrid.service.MarketStrategy.NookMarketStrategy; @@ -538,14 +539,22 @@ public class FilterAdapter extends ArrayAdapter { } // title / size + int countInt = -1; if(filterCounts.containsKey(filter) || filter.listingTitle.matches(".* \\(\\d+\\)$")) { //$NON-NLS-1$ viewHolder.size.setVisibility(View.VISIBLE); String count; if (filterCounts.containsKey(filter)) { - count = filterCounts.get(filter).toString(); + Integer c = filterCounts.get(filter); + countInt = c; + count = c.toString(); } else { count = filter.listingTitle.substring(filter.listingTitle.lastIndexOf('(') + 1, filter.listingTitle.length() - 1); + try { + countInt = Integer.parseInt(count); + } catch (NumberFormatException e) { + // + } } viewHolder.size.setText(count); @@ -560,8 +569,12 @@ public class FilterAdapter extends ArrayAdapter { } else { viewHolder.name.setText(filter.listingTitle); viewHolder.size.setVisibility(View.GONE); + countInt = -1; } + if(countInt == 0 && filter instanceof FilterWithCustomIntent) + viewHolder.name.setTextColor(Color.GRAY); + viewHolder.name.getLayoutParams().height = (int) (58 * metrics.density); if(!nook && filter instanceof FilterWithUpdate) { viewHolder.urlImage.setVisibility(View.VISIBLE); @@ -574,7 +587,7 @@ public class FilterAdapter extends ArrayAdapter { params.setMargins((int) (8 * metrics.density), 0, 0, 0); } - if(filter.color != 0) + if (filter.color != 0) viewHolder.name.setTextColor(filter.color); // selection From 81eaac69d8e674e369c12efa18f0ce31d65e1bd0 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Fri, 11 Jan 2013 17:35:56 -0800 Subject: [PATCH 02/13] If no tag exists, return empty list ordering --- .../com/todoroo/astrid/subtasks/SubtasksTagUpdater.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/astrid/plugin-src/com/todoroo/astrid/subtasks/SubtasksTagUpdater.java b/astrid/plugin-src/com/todoroo/astrid/subtasks/SubtasksTagUpdater.java index 73e431e66..77341f0d7 100644 --- a/astrid/plugin-src/com/todoroo/astrid/subtasks/SubtasksTagUpdater.java +++ b/astrid/plugin-src/com/todoroo/astrid/subtasks/SubtasksTagUpdater.java @@ -7,6 +7,8 @@ public class SubtasksTagUpdater extends SubtasksUpdater { @Override protected String getSerializedTree(TagData list, Filter filter) { + if (list == null) + return "[]"; //$NON-NLS-1$ String order = list.getValue(TagData.TAG_ORDERING); if (order == null || "null".equals(order)) //$NON-NLS-1$ order = "[]"; //$NON-NLS-1$ From 2e14941b179bf7d60f634923c5c2bfa653e60de8 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Mon, 14 Jan 2013 11:06:42 -0800 Subject: [PATCH 03/13] Hopefully fixed a null pointer exception that would be thrown by the system --- .../astrid/gtasks/auth/ModernAuthManager.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/gtasks/auth/ModernAuthManager.java b/astrid/plugin-src/com/todoroo/astrid/gtasks/auth/ModernAuthManager.java index 81f3f869e..fe8fc6e0d 100644 --- a/astrid/plugin-src/com/todoroo/astrid/gtasks/auth/ModernAuthManager.java +++ b/astrid/plugin-src/com/todoroo/astrid/gtasks/auth/ModernAuthManager.java @@ -16,6 +16,7 @@ package com.todoroo.astrid.gtasks.auth; import java.io.IOException; +import java.util.ArrayList; import android.accounts.Account; import android.accounts.AccountManager; @@ -28,6 +29,8 @@ import android.content.Intent; import android.os.Bundle; import android.util.Log; +import com.google.api.client.googleapis.extensions.android2.auth.GoogleAccountManager; + /** * AuthManager keeps track of the current auth token for a user. The advantage * over just passing around a String is that this class can renew the auth @@ -209,10 +212,12 @@ public class ModernAuthManager implements AuthManager { } public static String[] getAccounts(Activity activity) { - final Account[] accounts = AccountManager.get(activity).getAccountsByType("com.google"); //$NON-NLS-1$ - String[] accountNames = new String[accounts.length]; - for(int i = 0; i < accounts.length; i++) - accountNames[i] = accounts[i].name; - return accountNames; + GoogleAccountManager accountManager = new GoogleAccountManager(activity); + Account[] accounts = accountManager.getAccounts(); + ArrayList accountNames = new ArrayList(); + for (Account a : accounts) { + accountNames.add(a.name); + } + return accountNames.toArray(new String[accountNames.size()]); } } From 6d5a25170c3bd8ede706d2731bc94531e6d156af Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Mon, 14 Jan 2013 11:47:49 -0800 Subject: [PATCH 04/13] 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); From 6f826f1f249645e8d298c0f0e0d7a89b10efcbe4 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Mon, 14 Jan 2013 12:05:08 -0800 Subject: [PATCH 05/13] Bugfixes to task row appearance preference display --- .../src/com/todoroo/astrid/activity/EditPreferences.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/astrid/src/com/todoroo/astrid/activity/EditPreferences.java b/astrid/src/com/todoroo/astrid/activity/EditPreferences.java index 78a3ab4dd..ae5ebbc98 100644 --- a/astrid/src/com/todoroo/astrid/activity/EditPreferences.java +++ b/astrid/src/com/todoroo/astrid/activity/EditPreferences.java @@ -519,8 +519,11 @@ public class EditPreferences extends TodorooPreferenceActivity { StatisticsService.reportEvent(StatisticsConstants.PREF_CHANGED_PREFIX + "row-style", //$NON-NLS-1$ "changed-to", valueString); //$NON-NLS-1$ Preference notes = findPreference(getString(R.string.p_showNotes)); + Preference fullTitle = findPreference(getString(R.string.p_fullTaskTitle)); try { - notes.setEnabled(Integer.parseInt((String) newValue) == 0); + int newValueInt = Integer.parseInt((String) newValue); + fullTitle.setEnabled(newValueInt != 2); + notes.setEnabled(newValueInt == 0); } catch (Exception e) { e.printStackTrace(); } @@ -744,6 +747,7 @@ public class EditPreferences extends TodorooPreferenceActivity { findPreference(getString(R.string.p_showNotes)).setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { + updatePreferences(preference, newValue); StatisticsService.reportEvent(StatisticsConstants.PREF_SHOW_NOTES_IN_ROW, "enabled", newValue.toString()); //$NON-NLS-1$ return true; } @@ -752,6 +756,7 @@ public class EditPreferences extends TodorooPreferenceActivity { findPreference(getString(R.string.p_fullTaskTitle)).setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { + updatePreferences(preference, newValue); StatisticsService.reportEvent(StatisticsConstants.PREF_CHANGED_PREFIX + "full-title", "full-title", newValue.toString()); //$NON-NLS-1$ //$NON-NLS-2$ return true; } From e88eec54a3f2e4ed0ab898b72aa4b200f48e5702 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Mon, 14 Jan 2013 12:20:09 -0800 Subject: [PATCH 06/13] Basic logic and layout for a title-only task adapter row --- .../layout/task_adapter_row_title_only.xml | 50 +++++++++++++++++++ .../astrid/activity/TaskListFragment.java | 1 + .../todoroo/astrid/adapter/TaskAdapter.java | 26 +++++++--- 3 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 astrid/res/layout/task_adapter_row_title_only.xml diff --git a/astrid/res/layout/task_adapter_row_title_only.xml b/astrid/res/layout/task_adapter_row_title_only.xml new file mode 100644 index 000000000..2c7417204 --- /dev/null +++ b/astrid/res/layout/task_adapter_row_title_only.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java b/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java index 6268118e6..f36ea0d0b 100644 --- a/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java @@ -885,6 +885,7 @@ public class TaskListFragment extends ListFragment implements OnScrollListener, case 1: return R.layout.task_adapter_row_simple; case 2: + return R.layout.task_adapter_row_title_only; case 0: default: return R.layout.task_adapter_row; diff --git a/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java b/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java index 488820e80..f27d52cea 100644 --- a/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java +++ b/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java @@ -35,6 +35,7 @@ import android.text.Spannable; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.TextUtils; +import android.text.TextUtils.TruncateAt; import android.util.DisplayMetrics; import android.util.Log; import android.util.TypedValue; @@ -186,6 +187,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable { protected OnCompletedTaskListener onCompletedTaskListener = null; public boolean isFling = false; protected final int resource; + protected final boolean titleOnly; protected final LayoutInflater inflater; private DetailLoaderThread detailLoader; private ActionsLoaderThread actionsLoader; @@ -229,6 +231,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable { this.query = query; this.resource = resource; + this.titleOnly = resource == R.layout.task_adapter_row_title_only; this.fragment = fragment; this.resources = fragment.getResources(); this.onCompletedTaskListener = onCompletedTaskListener; @@ -336,10 +339,14 @@ public class TaskAdapter extends CursorAdapter implements Filterable { boolean showFullTaskTitle = Preferences.getBoolean(R.string.p_fullTaskTitle, false); boolean showNotes = Preferences.getBoolean(R.string.p_showNotes, false); - if (showFullTaskTitle) { + if (showFullTaskTitle && !titleOnly) { viewHolder.nameView.setMaxLines(Integer.MAX_VALUE); viewHolder.nameView.setSingleLine(false); viewHolder.nameView.setEllipsize(null); + } else if (titleOnly) { + viewHolder.nameView.setMaxLines(1); + viewHolder.nameView.setSingleLine(true); + viewHolder.nameView.setEllipsize(TruncateAt.END); } if (showNotes && !simpleLayout) { @@ -355,7 +362,8 @@ public class TaskAdapter extends CursorAdapter implements Filterable { viewHolder.details1.setTag(viewHolder); // add UI component listeners - addListeners(view); + if (!titleOnly) + addListeners(view); return view; } @@ -374,7 +382,8 @@ public class TaskAdapter extends CursorAdapter implements Filterable { task.readFromCursor(cursor); setFieldContentsAndVisibility(view); - setTaskAppearance(viewHolder, task); + if (!titleOnly) + setTaskAppearance(viewHolder, task); } /** @@ -407,12 +416,14 @@ public class TaskAdapter extends CursorAdapter implements Filterable { public synchronized void setFieldContentsAndVisibility(View view) { ViewHolder viewHolder = (ViewHolder)view.getTag(); Task task = viewHolder.task; - if (fontSize < 16) { + if (fontSize < 16 || titleOnly) { viewHolder.rowBody.setMinimumHeight(0); - viewHolder.completeBox.setMinimumHeight(0); + if (viewHolder.completeBox != null) + viewHolder.completeBox.setMinimumHeight(0); } else { viewHolder.rowBody.setMinimumHeight(minRowHeight); - viewHolder.completeBox.setMinimumHeight(minRowHeight); + if (viewHolder.completeBox != null) + viewHolder.completeBox.setMinimumHeight(minRowHeight); } if (task.isEditable()) @@ -432,6 +443,9 @@ public class TaskAdapter extends CursorAdapter implements Filterable { nameView.setText(nameValue); } + if (titleOnly) + return; + float dueDateTextWidth = setupDueDateAndTags(viewHolder, task); String details; From cc2824726f07cd0edd81f3b070c754ab1ae2d4fa Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Mon, 14 Jan 2013 12:32:41 -0800 Subject: [PATCH 07/13] Optimized query with fewer properties when in title only mode --- .../OrderedMetadataListFragmentHelper.java | 6 +++++- .../todoroo/astrid/activity/TaskListFragment.java | 2 ++ .../com/todoroo/astrid/adapter/TaskAdapter.java | 15 +++++++++++++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/subtasks/OrderedMetadataListFragmentHelper.java b/astrid/plugin-src/com/todoroo/astrid/subtasks/OrderedMetadataListFragmentHelper.java index 21d9336a6..4a5adb173 100644 --- a/astrid/plugin-src/com/todoroo/astrid/subtasks/OrderedMetadataListFragmentHelper.java +++ b/astrid/plugin-src/com/todoroo/astrid/subtasks/OrderedMetadataListFragmentHelper.java @@ -123,7 +123,11 @@ public class OrderedMetadataListFragmentHelper implements OrderedListFragm } public Property[] taskProperties() { - ArrayList> properties = new ArrayList>(Arrays.asList(TaskAdapter.PROPERTIES)); + Property[] baseProperties = TaskAdapter.PROPERTIES; + if (Preferences.getIntegerFromString(R.string.p_taskRowStyle_v2, 0) == 2) + baseProperties = TaskAdapter.BASIC_PROPERTIES; + + ArrayList> properties = new ArrayList>(Arrays.asList(baseProperties)); properties.add(updater.indentProperty()); properties.add(updater.orderProperty()); return properties.toArray(new Property[properties.size()]); diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java b/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java index f36ea0d0b..c4d16e013 100644 --- a/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java @@ -934,6 +934,8 @@ public class TaskListFragment extends ListFragment implements OnScrollListener, } public Property[] taskProperties() { + if (Preferences.getIntegerFromString(R.string.p_taskRowStyle_v2, 0) == 2) + return TaskAdapter.BASIC_PROPERTIES; return TaskAdapter.PROPERTIES; } diff --git a/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java b/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java index f27d52cea..91cf54ac5 100644 --- a/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java +++ b/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java @@ -144,6 +144,15 @@ public class TaskAdapter extends CursorAdapter implements Filterable { TAGS // Concatenated list of tags }; + public static final Property[] BASIC_PROPERTIES = new Property[] { + Task.ID, + Task.TITLE, + Task.FLAGS, + Task.COMPLETION_DATE, + Task.HIDE_UNTIL, + Task.DELETION_DATE + }; + public static int[] IMPORTANCE_RESOURCES = new int[] { R.drawable.importance_check_1, R.drawable.importance_check_2, @@ -374,8 +383,10 @@ public class TaskAdapter extends CursorAdapter implements Filterable { TodorooCursor cursor = (TodorooCursor)c; ViewHolder viewHolder = ((ViewHolder)view.getTag()); - viewHolder.isTaskRabbit = (cursor.get(TASK_RABBIT_ID) > 0); - viewHolder.tagsString = cursor.get(TAGS); + if (!titleOnly) { + viewHolder.isTaskRabbit = (cursor.get(TASK_RABBIT_ID) > 0); + viewHolder.tagsString = cursor.get(TAGS); + } Task task = viewHolder.task; task.clear(); From 4b1e22f7164a055ba24d958de8c852d4551e79c4 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Mon, 14 Jan 2013 13:52:03 -0800 Subject: [PATCH 08/13] Title only style enhancements, add checkboxes back --- .../layout/task_adapter_row_title_only.xml | 12 ++- .../todoroo/astrid/adapter/TaskAdapter.java | 100 ++++++++++-------- 2 files changed, 69 insertions(+), 43 deletions(-) diff --git a/astrid/res/layout/task_adapter_row_title_only.xml b/astrid/res/layout/task_adapter_row_title_only.xml index 2c7417204..e2cedaedc 100644 --- a/astrid/res/layout/task_adapter_row_title_only.xml +++ b/astrid/res/layout/task_adapter_row_title_only.xml @@ -18,12 +18,22 @@ android:layout_height="wrap_content" android:layout_marginTop="10dip" android:layout_marginBottom="10dip"> + + cursor = (TodorooCursor)c; ViewHolder viewHolder = ((ViewHolder)view.getTag()); - if (!titleOnly) { + if (!titleOnlyLayout) { viewHolder.isTaskRabbit = (cursor.get(TASK_RABBIT_ID) > 0); viewHolder.tagsString = cursor.get(TAGS); } @@ -393,7 +397,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable { task.readFromCursor(cursor); setFieldContentsAndVisibility(view); - if (!titleOnly) + if (!titleOnlyLayout) setTaskAppearance(viewHolder, task); } @@ -427,14 +431,12 @@ public class TaskAdapter extends CursorAdapter implements Filterable { public synchronized void setFieldContentsAndVisibility(View view) { ViewHolder viewHolder = (ViewHolder)view.getTag(); Task task = viewHolder.task; - if (fontSize < 16 || titleOnly) { + if (fontSize < 16 || titleOnlyLayout) { viewHolder.rowBody.setMinimumHeight(0); - if (viewHolder.completeBox != null) - viewHolder.completeBox.setMinimumHeight(0); + viewHolder.completeBox.setMinimumHeight(0); } else { viewHolder.rowBody.setMinimumHeight(minRowHeight); - if (viewHolder.completeBox != null) - viewHolder.completeBox.setMinimumHeight(minRowHeight); + viewHolder.completeBox.setMinimumHeight(minRowHeight); } if (task.isEditable()) @@ -454,8 +456,10 @@ public class TaskAdapter extends CursorAdapter implements Filterable { nameView.setText(nameValue); } - if (titleOnly) + if (titleOnlyLayout) { + setupCompleteBox(viewHolder); return; + } float dueDateTextWidth = setupDueDateAndTags(viewHolder, task); @@ -568,31 +572,35 @@ public class TaskAdapter extends CursorAdapter implements Filterable { viewHolder.completeBox.setOnTouchListener(otl); viewHolder.completeBox.setOnClickListener(completeBoxListener); - viewHolder.picture.setOnTouchListener(otl); - viewHolder.picture.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - viewHolder.completeBox.performClick(); - } - }); + if (viewHolder.picture != null) { + viewHolder.picture.setOnTouchListener(otl); + viewHolder.picture.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + viewHolder.completeBox.performClick(); + } + }); + } - viewHolder.taskActionContainer.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - TaskAction action = (TaskAction) viewHolder.taskActionIcon.getTag(); - if (action instanceof NotesAction) { - showEditNotesDialog(viewHolder.task); - } else if (action instanceof FilesAction) { - showFilesDialog(viewHolder.task); - } else if (action != null) { - try { - action.intent.send(); - } catch (CanceledException e) { - // Oh well + if (viewHolder.taskActionContainer != null) { + viewHolder.taskActionContainer.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + TaskAction action = (TaskAction) viewHolder.taskActionIcon.getTag(); + if (action instanceof NotesAction) { + showEditNotesDialog(viewHolder.task); + } else if (action instanceof FilesAction) { + showFilesDialog(viewHolder.task); + } else if (action != null) { + try { + action.intent.send(); + } catch (CanceledException e) { + // Oh well + } } } - } - }); + }); + } } private void showEditNotesDialog(final Task task) { @@ -1149,7 +1157,14 @@ public class TaskAdapter extends CursorAdapter implements Filterable { } } - // complete box + setupCompleteBox(viewHolder); + + } + + private void setupCompleteBox(ViewHolder viewHolder) { + // complete box + final Task task = viewHolder.task; + final AsyncImageView pictureView = viewHolder.picture; final CheckableImageView checkBoxView = viewHolder.completeBox; { checkBoxView.setChecked(task.isCompleted()); // disable checkbox if task is readonly @@ -1163,6 +1178,8 @@ public class TaskAdapter extends CursorAdapter implements Filterable { } else { checkBoxView.setImageResource(IMPORTANCE_RESOURCES[value]); } + if (titleOnlyLayout) + return; if (checkBoxView.isChecked()) { if (pictureView != null) @@ -1179,7 +1196,6 @@ public class TaskAdapter extends CursorAdapter implements Filterable { checkBoxView.setVisibility(View.VISIBLE); } } - } // Returns due date text width From 7f3ccbf03c51b22035ec121043b515bc5e1a6f3e Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Mon, 14 Jan 2013 14:05:27 -0800 Subject: [PATCH 09/13] Task row style migration fix --- astrid/src/com/todoroo/astrid/service/UpgradeService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/astrid/src/com/todoroo/astrid/service/UpgradeService.java b/astrid/src/com/todoroo/astrid/service/UpgradeService.java index d24609e0b..325327235 100644 --- a/astrid/src/com/todoroo/astrid/service/UpgradeService.java +++ b/astrid/src/com/todoroo/astrid/service/UpgradeService.java @@ -258,7 +258,7 @@ public final class UpgradeService { if (from < V4_5_1) { String key = context.getString(R.string.p_taskRowStyle); if (Preferences.isSet(key)) { - boolean value = Preferences.getBoolean(key, true); + boolean value = Preferences.getBoolean(key, false); Preferences.clear(key); Preferences.setString(R.string.p_taskRowStyle_v2, value ? "1" : "0"); //$NON-NLS-1$ //$NON-NLS-2$ } From 89188996942b6c12ac1dfad27ed1d2c6456603ee Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Mon, 14 Jan 2013 14:11:00 -0800 Subject: [PATCH 10/13] Removed unused strings to fix translation unit test --- astrid/res/values-de/strings.xml | 4 ---- astrid/res/values-es/strings.xml | 4 ---- astrid/res/values-fr/strings.xml | 4 ---- astrid/res/values-ko/strings.xml | 4 ---- astrid/res/values-pt-rBR/strings.xml | 4 ---- astrid/res/values-ru/strings.xml | 4 ---- astrid/res/values-tr/strings.xml | 2 -- astrid/res/values-zh-rCN/strings.xml | 4 ---- astrid/res/values-zh-rTW/strings.xml | 4 ---- 9 files changed, 34 deletions(-) diff --git a/astrid/res/values-de/strings.xml b/astrid/res/values-de/strings.xml index 0d6084bb9..6b05c934c 100644 --- a/astrid/res/values-de/strings.xml +++ b/astrid/res/values-de/strings.xml @@ -330,10 +330,6 @@ Ideas Tab automatisch laden Internetsuche für Ideas Tab wird ausgeführt, wenn Haken gesetzt ist Internetsuche für Ideas Tab wird nur durchgeführt, wenn vom Nutzer gewünscht - Zeilen-Stil: Einfach - Zeilen-Stil: Original - Titel auf eine Zeile begrenzen, Datum und Listen darunter - Titel auf zwei Zeilen begrenzen mit Datum rechts Farbschema Momentan: %s Einstellungen benötigen mindestens Android 2.0 diff --git a/astrid/res/values-es/strings.xml b/astrid/res/values-es/strings.xml index 3de4285e4..b0ef9a90f 100644 --- a/astrid/res/values-es/strings.xml +++ b/astrid/res/values-es/strings.xml @@ -364,10 +364,6 @@ Auto cargar la pestaña Ideas La búsqueda para la pestaña Ideas se realizará cuando a la pestaña se le de clic La búsqueda para la pestaña Ideas se realizará solo cuando sea pedida manualmente - Tipo de renglón: Simple - Tipo de renglón: Original - Truncar el título a una línea con la fecha y listas debajo - Truncar el título a dos líneas con la fecha a la derecha Combinación de colores Actualmente: %s La configuración requiere Android 2.0+ diff --git a/astrid/res/values-fr/strings.xml b/astrid/res/values-fr/strings.xml index 62c4f0a58..a4ff7d185 100644 --- a/astrid/res/values-fr/strings.xml +++ b/astrid/res/values-fr/strings.xml @@ -339,10 +339,6 @@ Charger automatiquement l\'onglet d\'idées Les recherches web pour l\'onglet d\'idées seront effectuées quand vous cliquerez sur l\'onglet Les recherches web pour l\'onglet d\'idées seront effectuées quand vous le demanderez - Style de ligne : simple - Style de ligne : original - Tronquer le titre en une ligne avec la date et les listes en dessous - Tronquer le titre en deux lignes avec la date sur la droite Thème de couleur Actuellement : %s Ce paramètre requiert Android 2.0+. diff --git a/astrid/res/values-ko/strings.xml b/astrid/res/values-ko/strings.xml index cd746beae..c84affbb1 100644 --- a/astrid/res/values-ko/strings.xml +++ b/astrid/res/values-ko/strings.xml @@ -364,10 +364,6 @@ 아이디어 탭 자동 불러오기 아이디어 탭의 웹 검색은 탭을 클릭했을 때 실행될 것입니다 아이디어 탭의 웹 검색은 수동으로 요청했을 때만 실행될 것입니다 - 가로줄 스타일: 간단히 - 가로줄 스타일: 원래대로 - 제목을 한 줄로 줄이고 날짜와 목록을 그 아래에 출력 - 제목을 두 줄로 줄이고 날짜를 오른쪽에 출력 색상 테마 현재: %s 설정은 안드로이드 2.0 이상이 필요합니다 diff --git a/astrid/res/values-pt-rBR/strings.xml b/astrid/res/values-pt-rBR/strings.xml index a6e4e2fcc..dcef062a6 100644 --- a/astrid/res/values-pt-rBR/strings.xml +++ b/astrid/res/values-pt-rBR/strings.xml @@ -347,10 +347,6 @@ Auto-carregar aba de idéias As pesquisas Web serão feitas quando a aba for tocada As pesquisas Web somente serão feitas quando requisitadas manualmente - Estilo de linha: Simples - Estilo de linha: Original - Truncar título para uma única linha com data e lista abaixo - Truncar título para duas linhas com data à direita Tema Atualmente: %s Esta opção requer Android 2.0+ diff --git a/astrid/res/values-ru/strings.xml b/astrid/res/values-ru/strings.xml index b89cb4b6f..a0c47d3f8 100644 --- a/astrid/res/values-ru/strings.xml +++ b/astrid/res/values-ru/strings.xml @@ -364,10 +364,6 @@ Автозагрузка закладки Идеи Веб-поиск для закладки Идеи будет выполняться при нажатии на закладку Веб-поиск для закладки Идеи будет выполняться только при вызове вручную - Стиль пункта: Простой - Стиль пункта: Оригинальный - Сократить заголовок до одной строки с указанием даты и списков ниже - Сократить заголовок до двух строк с указанием даты справа Цветовая тема Текущая: %s Настройка требует Android 2.0+ diff --git a/astrid/res/values-tr/strings.xml b/astrid/res/values-tr/strings.xml index 5ae99aadb..649d66787 100644 --- a/astrid/res/values-tr/strings.xml +++ b/astrid/res/values-tr/strings.xml @@ -346,8 +346,6 @@ Fikirleri Kendiliğinden-Yükle Sekmesi Fikirler için olan aramalar sekmesi, sekme tıklandığında belirecek Fikirler için olan aramalar sekmesi, yalnızca kullanıcı isteğiyle belirecek - Sıralama biçimi: Basit - Sıralama biçimi: Özgün Renk Teması Geçerli: %s Ayarlar için Android 2.0+ zorunludur. diff --git a/astrid/res/values-zh-rCN/strings.xml b/astrid/res/values-zh-rCN/strings.xml index 87ab23e83..92eca114a 100644 --- a/astrid/res/values-zh-rCN/strings.xml +++ b/astrid/res/values-zh-rCN/strings.xml @@ -328,10 +328,6 @@ 自动加载意见选项标签 点击标签后,网页将会搜索意见选项。 只有手动请求后,网页将会搜索意见选项。 - 列表布局:简单 - 列表布局:原始 - 截取标题为一行,并在下方显示日期和列表 - 截取标题至两行,并在右边显示日期 主题 当前:%s 该设置需要 Android 2.0+ diff --git a/astrid/res/values-zh-rTW/strings.xml b/astrid/res/values-zh-rTW/strings.xml index aa1a8d591..542827ff7 100644 --- a/astrid/res/values-zh-rTW/strings.xml +++ b/astrid/res/values-zh-rTW/strings.xml @@ -328,10 +328,6 @@ 自動加載意見選項標籤 點擊標籤後,網頁將會搜索意見選項。 只有手動請求後,網頁將會搜索意見選項。 - 列表佈局:簡單 - 列表佈局:原始 - 截取標題為一行,並在下方顯示日期和列表 - 截取標題至兩行,並在右邊顯示日期 主題 目前設定: %s 該設置需要 Android 2.0+ From 08f0e65099c4c33ff07d2eff39e72e39a45209b0 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Mon, 14 Jan 2013 14:21:10 -0800 Subject: [PATCH 11/13] AB test row style, use title only as default for astrid lite --- astrid/src/com/todoroo/astrid/service/abtesting/ABTests.java | 5 +++++ .../todoroo/astrid/utility/AstridDefaultPreferenceSpec.java | 3 ++- .../com/todoroo/astrid/utility/AstridLitePreferenceSpec.java | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/astrid/src/com/todoroo/astrid/service/abtesting/ABTests.java b/astrid/src/com/todoroo/astrid/service/abtesting/ABTests.java index 50c7d0a22..6c22ac019 100644 --- a/astrid/src/com/todoroo/astrid/service/abtesting/ABTests.java +++ b/astrid/src/com/todoroo/astrid/service/abtesting/ABTests.java @@ -143,8 +143,13 @@ public class ABTests { public static final String AB_USE_DATE_SHORTCUTS = "android_use_date_shortcuts_v2"; //$NON-NLS-1$ + public static final String AB_TITLE_ONLY = "android_title_only"; //$NON-NLS-1$ + private void initialize() { addTest(AB_USE_DATE_SHORTCUTS, new int[] { 1, 1 }, new int[] { 1, 9 }, new String[] { "date-shortcuts-off", "date-shortcuts-on" }, false); //$NON-NLS-1$ //$NON-NLS-2$ + + addTest(AB_TITLE_ONLY, new int[] { 9, 1 }, + new int[] { 1, 0 }, new String[] { "default-row-style", "title-only-style" }, false); //$NON-NLS-1$//$NON-NLS-2$ } } diff --git a/astrid/src/com/todoroo/astrid/utility/AstridDefaultPreferenceSpec.java b/astrid/src/com/todoroo/astrid/utility/AstridDefaultPreferenceSpec.java index ce1911551..b41a4841e 100644 --- a/astrid/src/com/todoroo/astrid/utility/AstridDefaultPreferenceSpec.java +++ b/astrid/src/com/todoroo/astrid/utility/AstridDefaultPreferenceSpec.java @@ -134,7 +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_taskRowStyle_v2, + ABChooser.readChoiceForTest(ABTests.AB_TITLE_ONLY) == 0 ? "0" : "2", ifUnset); //$NON-NLS-1$ //$NON-NLS-2$ 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 fc3e4cc88..fc0b6d15d 100644 --- a/astrid/src/com/todoroo/astrid/utility/AstridLitePreferenceSpec.java +++ b/astrid/src/com/todoroo/astrid/utility/AstridLitePreferenceSpec.java @@ -120,7 +120,7 @@ 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_taskRowStyle_v2, "2", ifUnset); //$NON-NLS-1$ setPreference(prefs, editor, r, R.string.p_use_date_shortcuts, false, ifUnset); From 6db0a36741ffe2d154332597b20f38606ff81d10 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Mon, 14 Jan 2013 14:25:24 -0800 Subject: [PATCH 12/13] Version bump and upgrade message --- astrid/AndroidManifest.xml | 4 ++-- astrid/src/com/todoroo/astrid/service/UpgradeService.java | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/astrid/AndroidManifest.xml b/astrid/AndroidManifest.xml index 94d5cd719..439348b66 100644 --- a/astrid/AndroidManifest.xml +++ b/astrid/AndroidManifest.xml @@ -6,8 +6,8 @@ --> + android:versionName="4.5.1" + android:versionCode="292"> diff --git a/astrid/src/com/todoroo/astrid/service/UpgradeService.java b/astrid/src/com/todoroo/astrid/service/UpgradeService.java index 325327235..af06f12f0 100644 --- a/astrid/src/com/todoroo/astrid/service/UpgradeService.java +++ b/astrid/src/com/todoroo/astrid/service/UpgradeService.java @@ -283,6 +283,13 @@ public final class UpgradeService { Preferences.clear(AstridPreferences.P_UPGRADE_FROM); StringBuilder changeLog = new StringBuilder(); + if (from >= V4_5_0 && from < V4_5_1) { + newVersionString(changeLog, "4.5.1 (1/15/13)", new String[] { + "New 'Titles only' style option for task lists (Settings -> Appearance -> Task row appearance)", + "Bug and crash fixes" + }); + } + if (from < V4_5_0) { newVersionString(changeLog, "4.5.0 (12/19/12)", new String[] { "Several interface and usability enhancements", From f04ab1b6ba138b374e53d846c9ce5be5b1fe64d0 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Mon, 14 Jan 2013 14:28:03 -0800 Subject: [PATCH 13/13] Typo --- astrid/src/com/todoroo/astrid/service/UpgradeService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/astrid/src/com/todoroo/astrid/service/UpgradeService.java b/astrid/src/com/todoroo/astrid/service/UpgradeService.java index af06f12f0..f855ca04a 100644 --- a/astrid/src/com/todoroo/astrid/service/UpgradeService.java +++ b/astrid/src/com/todoroo/astrid/service/UpgradeService.java @@ -285,7 +285,7 @@ public final class UpgradeService { if (from >= V4_5_0 && from < V4_5_1) { newVersionString(changeLog, "4.5.1 (1/15/13)", new String[] { - "New 'Titles only' style option for task lists (Settings -> Appearance -> Task row appearance)", + "New 'Titles only' style option for task lists (Settings > Appearance > Task row appearance)", "Bug and crash fixes" }); }