From c70c83f988fd8634a5997e1449cf89a12a03b99b Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Fri, 18 Jan 2013 16:15:56 -0800 Subject: [PATCH] Don't show tags with null titles, fixed pushed_at dates for tables --- .../todoroo/astrid/actfm/sync/ActFmInvoker.java | 2 +- .../astrid/actfm/sync/ActFmSyncThread.java | 6 ++---- .../astrid/actfm/sync/messages/MakeChanges.java | 13 ++++++++++--- .../com/todoroo/astrid/tags/TagFilterExposer.java | 15 +++++++++------ 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmInvoker.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmInvoker.java index 337c9a51b..3934ce25c 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmInvoker.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmInvoker.java @@ -50,7 +50,7 @@ public class ActFmInvoker { private static final int API_VERSION = 7; - private static final boolean SYNC_DEBUG = Constants.DEBUG || true; + public static final boolean SYNC_DEBUG = Constants.DEBUG || true; @Autowired private RestClient restClient; diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncThread.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncThread.java index d7a9abfe7..a16401eb4 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncThread.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncThread.java @@ -31,7 +31,6 @@ import com.todoroo.astrid.data.TagData; import com.todoroo.astrid.data.TagOutstanding; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.TaskOutstanding; -import com.todoroo.astrid.utility.Constants; import com.todoroo.astrid.utility.Flags; public class ActFmSyncThread { @@ -158,10 +157,9 @@ public class ActFmSyncThread { JSONObject serialized = message.serializeToJSON(); if (serialized != null) { payload.put(serialized); - if (true || Constants.DEBUG) - Log.w("actfm-sync-message", serialized.toString()); + if (ActFmInvoker.SYNC_DEBUG) + Log.e("actfm-send-message", serialized.toString()); } - } try { diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/MakeChanges.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/MakeChanges.java index e9a167135..efadd2c8a 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/MakeChanges.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/MakeChanges.java @@ -1,5 +1,6 @@ package com.todoroo.astrid.actfm.sync.messages; +import java.text.ParseException; import java.util.Iterator; import org.json.JSONObject; @@ -10,6 +11,7 @@ import android.util.Log; import com.todoroo.andlib.data.Property; import com.todoroo.andlib.data.Property.LongProperty; import com.todoroo.andlib.data.Property.StringProperty; +import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.andlib.utility.Preferences; import com.todoroo.astrid.dao.RemoteModelDao; import com.todoroo.astrid.data.RemoteModel; @@ -72,8 +74,13 @@ public class MakeChanges extends ServerToClientMessage Log.e(ERROR_TAG, "Error instantiating model for MakeChanges", e); } } else if (NameMaps.TABLE_ID_PUSHED_AT.equals(table)) { - long pushedAt = changes.optLong(NameMaps.TABLE_ID_PUSHED_AT); - if (pushedAt > 0) { + long tablePushedAt = 0; + try { + tablePushedAt = DateUtilities.parseIso8601(changes.optString(NameMaps.TABLE_ID_PUSHED_AT)); + } catch (ParseException e) { + // + } + if (tablePushedAt > 0) { String pushedAtKey = null; if (NameMaps.TABLE_ID_TASKS.equals(uuid)) pushedAtKey = NameMaps.PUSHED_AT_TASKS; @@ -81,7 +88,7 @@ public class MakeChanges extends ServerToClientMessage pushedAtKey = NameMaps.PUSHED_AT_TAGS; if (pushedAtKey != null) - Preferences.setLong(pushedAtKey, pushedAt); + Preferences.setLong(pushedAtKey, tablePushedAt); } } diff --git a/astrid/plugin-src/com/todoroo/astrid/tags/TagFilterExposer.java b/astrid/plugin-src/com/todoroo/astrid/tags/TagFilterExposer.java index d41dafca1..458e13d19 100644 --- a/astrid/plugin-src/com/todoroo/astrid/tags/TagFilterExposer.java +++ b/astrid/plugin-src/com/todoroo/astrid/tags/TagFilterExposer.java @@ -18,6 +18,7 @@ import android.content.Intent; import android.content.res.Resources; import android.graphics.drawable.BitmapDrawable; import android.os.Bundle; +import android.text.TextUtils; import android.widget.EditText; import android.widget.Toast; @@ -66,6 +67,8 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE @SuppressWarnings("nls") public static FilterWithCustomIntent filterFromTag(Context context, Tag tag, Criterion criterion) { String title = tag.tag; + if (TextUtils.isEmpty(title)) + return null; QueryTemplate tagTemplate = tag.queryTemplate(criterion); ContentValues contentValues = new ContentValues(); contentValues.put(Metadata.KEY.name, TagMetadata.KEY); @@ -155,8 +158,7 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE boolean shouldAddUntagged = addUntaggedFilter && Preferences.getBoolean(R.string.p_show_not_in_list_filter, true); - int length = shouldAddUntagged ? tags.length + 1 : tags.length; - Filter[] filters = new Filter[length]; + ArrayList filters = new ArrayList(tags.length); Context context = ContextManager.getContext(); Resources r = context.getResources(); @@ -173,14 +175,15 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE null); untagged.listingIcon = ((BitmapDrawable)r.getDrawable( ThemeService.getDrawable(R.drawable.gl_lists, themeFlags))).getBitmap(); - filters[0] = untagged; + filters.add(untagged); } for(int i = 0; i < tags.length; i++) { - int index = shouldAddUntagged ? i + 1 : i; - filters[index] = constructFilter(context, tags[i]); + Filter f = constructFilter(context, tags[i]); + if (f != null) + filters.add(f); } - FilterCategory filter = new FilterCategory(context.getString(name), filters); + FilterCategory filter = new FilterCategory(context.getString(name), filters.toArray(new Filter[filters.size()])); return filter; }