diff --git a/app/src/main/java/com/todoroo/astrid/activity/TaskListFragment.java b/app/src/main/java/com/todoroo/astrid/activity/TaskListFragment.java index d8785dd15..82e4bff7a 100644 --- a/app/src/main/java/com/todoroo/astrid/activity/TaskListFragment.java +++ b/app/src/main/java/com/todoroo/astrid/activity/TaskListFragment.java @@ -42,9 +42,6 @@ import butterknife.ButterKnife; import butterknife.OnClick; import com.google.android.material.snackbar.Snackbar; import com.google.common.primitives.Longs; -import com.todoroo.andlib.sql.Criterion; -import com.todoroo.andlib.sql.Join; -import com.todoroo.andlib.sql.QueryTemplate; import com.todoroo.astrid.adapter.TaskAdapter; import com.todoroo.astrid.adapter.TaskAdapterProvider; import com.todoroo.astrid.api.CaldavFilter; @@ -76,7 +73,6 @@ import org.tasks.activities.TagSettingsActivity; import org.tasks.analytics.Tracker; import org.tasks.analytics.Tracking; import org.tasks.caldav.CaldavCalendarSettingsActivity; -import org.tasks.data.Tag; import org.tasks.dialogs.DialogBuilder; import org.tasks.dialogs.SortDialog; import org.tasks.injection.ForActivity; @@ -343,18 +339,7 @@ public final class TaskListFragment extends InjectingFragment } private Filter createSearchFilter(String query) { - String title = getString(R.string.FLA_search_filter, query); - return new SearchFilter( - title, - new QueryTemplate() - .join(Join.left(Tag.TABLE, Tag.TASK_UID.eq(Task.UUID))) - .where( - Criterion.and( - Task.DELETION_DATE.eq(0), - Criterion.or( - Task.NOTES.like("%" + query + "%"), - Task.TITLE.like("%" + query + "%"), - Tag.NAME.like("%" + query + "%"))))); + return new SearchFilter(getString(R.string.FLA_search_filter, query), query); } @Override diff --git a/app/src/main/java/com/todoroo/astrid/api/SearchFilter.java b/app/src/main/java/com/todoroo/astrid/api/SearchFilter.java index 816dd86cf..8f2c99c9b 100644 --- a/app/src/main/java/com/todoroo/astrid/api/SearchFilter.java +++ b/app/src/main/java/com/todoroo/astrid/api/SearchFilter.java @@ -2,7 +2,11 @@ package com.todoroo.astrid.api; import android.os.Parcel; import android.os.Parcelable; +import com.todoroo.andlib.sql.Criterion; +import com.todoroo.andlib.sql.Join; import com.todoroo.andlib.sql.QueryTemplate; +import com.todoroo.astrid.data.Task; +import org.tasks.data.Tag; public class SearchFilter extends Filter { @@ -27,7 +31,19 @@ public class SearchFilter extends Filter { private SearchFilter() {} - public SearchFilter(String title, QueryTemplate where) { - super(title, where); + public SearchFilter(String title, String query) { + super(title, getQueryTemplate(query)); + } + + private static QueryTemplate getQueryTemplate(String query) { + return new QueryTemplate() + .join(Join.left(Tag.TABLE, Tag.TASK.eq(Task.ID))) + .where( + Criterion.and( + Task.DELETION_DATE.eq(0), + Criterion.or( + Task.NOTES.like("%" + query + "%"), + Task.TITLE.like("%" + query + "%"), + Tag.NAME.like("%" + query + "%")))); } } diff --git a/app/src/main/java/org/tasks/data/Tag.java b/app/src/main/java/org/tasks/data/Tag.java index 54e2643c8..b8d386a45 100644 --- a/app/src/main/java/org/tasks/data/Tag.java +++ b/app/src/main/java/org/tasks/data/Tag.java @@ -21,7 +21,6 @@ public class Tag { public static final LongProperty TASK = new LongProperty(TABLE, "task"); public static final StringProperty TAG_UID = new StringProperty(TABLE, "tag_uid"); - public static final StringProperty TASK_UID = new StringProperty(TABLE, "task_uid"); public static final StringProperty NAME = new StringProperty(TABLE, "name"); @PrimaryKey(autoGenerate = true)