From a7986cd029f580838d8fec7d774148ae32c183d8 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Thu, 13 Sep 2012 11:44:39 -0700 Subject: [PATCH] Don't show emergent tags in row, fixed not in any list filter to not count emergent tags --- .../com/todoroo/astrid/tags/TagFilterExposer.java | 2 +- .../plugin-src/com/todoroo/astrid/tags/TagService.java | 8 +++++--- .../com/todoroo/astrid/activity/TaskListFragment.java | 10 ++++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/tags/TagFilterExposer.java b/astrid/plugin-src/com/todoroo/astrid/tags/TagFilterExposer.java index a8f5d50df..bcbd4db6e 100644 --- a/astrid/plugin-src/com/todoroo/astrid/tags/TagFilterExposer.java +++ b/astrid/plugin-src/com/todoroo/astrid/tags/TagFilterExposer.java @@ -175,7 +175,7 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE R.string.tag_FEx_untagged_w_astrid : R.string.tag_FEx_untagged; Filter untagged = new Filter(r.getString(untaggedLabel), r.getString(R.string.tag_FEx_untagged), - TagService.untaggedTemplate(), + TagService.getInstance().untaggedTemplate(), null); untagged.listingIcon = ((BitmapDrawable)r.getDrawable( ThemeService.getDrawable(R.drawable.gl_lists, themeFlags))).getBitmap(); diff --git a/astrid/plugin-src/com/todoroo/astrid/tags/TagService.java b/astrid/plugin-src/com/todoroo/astrid/tags/TagService.java index 94f06c4aa..c573aaf79 100644 --- a/astrid/plugin-src/com/todoroo/astrid/tags/TagService.java +++ b/astrid/plugin-src/com/todoroo/astrid/tags/TagService.java @@ -184,9 +184,11 @@ public final class TagService { additionalCriterion); } - public static QueryTemplate untaggedTemplate() { + public QueryTemplate untaggedTemplate() { + String[] emergentTags = getEmergentTags(); + return new QueryTemplate().where(Criterion.and( - Criterion.not(Task.ID.in(Query.select(Metadata.TASK).from(Metadata.TABLE).where(MetadataCriteria.withKey(KEY)))), + Criterion.not(Task.ID.in(Query.select(Metadata.TASK).from(Metadata.TABLE).where(Criterion.and(MetadataCriteria.withKey(KEY), Criterion.not(TAG.in(emergentTags)))))), TaskCriteria.isActive(), TaskApiDao.TaskCriteria.ownedByMe(), TaskCriteria.isVisible())); @@ -222,7 +224,7 @@ public final class TagService { } } - private String[] getEmergentTags() { + public String[] getEmergentTags() { TodorooCursor emergent = tagDataService.query(Query.select(TagData.NAME) .where(Functions.bitwiseAnd(TagData.FLAGS, TagData.FLAG_EMERGENT).gt(0))); try { diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java b/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java index 8cd24b03d..0ad979457 100644 --- a/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java @@ -54,6 +54,7 @@ import android.widget.TextView; import com.timsu.astrid.R; import com.todoroo.andlib.data.Property; +import com.todoroo.andlib.data.Property.StringProperty; import com.todoroo.andlib.data.TodorooCursor; import com.todoroo.andlib.service.Autowired; import com.todoroo.andlib.service.ContextManager; @@ -906,8 +907,13 @@ public class TaskListFragment extends ListFragment implements OnScrollListener, if (getActiveTagData() != null) tagName = getActiveTagData().getValue(TagData.NAME); - Criterion tagsJoinCriterion = Criterion.and(Field.field(TAGS_METADATA_JOIN + "." + Metadata.KEY.name).eq(TagService.KEY), //$NON-NLS-1$ - Task.ID.eq(Field.field(TAGS_METADATA_JOIN + "." + Metadata.TASK.name))); + String[] emergentTags = TagService.getInstance().getEmergentTags(); + StringProperty tagProperty = new StringProperty(null, TAGS_METADATA_JOIN + "." + TagService.TAG.name); + + Criterion tagsJoinCriterion = Criterion.and( + Field.field(TAGS_METADATA_JOIN + "." + Metadata.KEY.name).eq(TagService.KEY), //$NON-NLS-1$ + Task.ID.eq(Field.field(TAGS_METADATA_JOIN + "." + Metadata.TASK.name)), + Criterion.not(tagProperty.in(emergentTags))); if (tagName != null) tagsJoinCriterion = Criterion.and(tagsJoinCriterion, Field.field(TAGS_METADATA_JOIN + "." + TagService.TAG.name).neq(tagName));