|
|
|
@ -1,5 +1,6 @@
|
|
|
|
package com.todoroo.astrid.subtasks;
|
|
|
|
package com.todoroo.astrid.subtasks;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
|
|
|
|
|
|
|
import com.todoroo.andlib.data.Property;
|
|
|
|
import com.todoroo.andlib.data.Property;
|
|
|
|
@ -7,7 +8,7 @@ import com.todoroo.andlib.data.TodorooCursor;
|
|
|
|
import com.todoroo.andlib.sql.Criterion;
|
|
|
|
import com.todoroo.andlib.sql.Criterion;
|
|
|
|
import com.todoroo.andlib.sql.Query;
|
|
|
|
import com.todoroo.andlib.sql.Query;
|
|
|
|
import com.todoroo.astrid.api.Filter;
|
|
|
|
import com.todoroo.astrid.api.Filter;
|
|
|
|
import com.todoroo.astrid.core.BuiltInFilters;
|
|
|
|
import com.todoroo.astrid.core.BuiltInFilterExposer;
|
|
|
|
import com.todoroo.astrid.dao.TagDataDao;
|
|
|
|
import com.todoroo.astrid.dao.TagDataDao;
|
|
|
|
import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
|
|
|
|
import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
|
|
|
|
import com.todoroo.astrid.dao.TaskListMetadataDao;
|
|
|
|
import com.todoroo.astrid.dao.TaskListMetadataDao;
|
|
|
|
@ -19,6 +20,7 @@ import com.todoroo.astrid.service.TaskService;
|
|
|
|
import com.todoroo.astrid.subtasks.AstridOrderedListUpdater.Node;
|
|
|
|
import com.todoroo.astrid.subtasks.AstridOrderedListUpdater.Node;
|
|
|
|
|
|
|
|
|
|
|
|
import org.tasks.R;
|
|
|
|
import org.tasks.R;
|
|
|
|
|
|
|
|
import org.tasks.injection.ForApplication;
|
|
|
|
import org.tasks.preferences.Preferences;
|
|
|
|
import org.tasks.preferences.Preferences;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
@ -31,24 +33,23 @@ import timber.log.Timber;
|
|
|
|
|
|
|
|
|
|
|
|
public class SubtasksHelper {
|
|
|
|
public class SubtasksHelper {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final Context context;
|
|
|
|
private final Preferences preferences;
|
|
|
|
private final Preferences preferences;
|
|
|
|
private final TaskService taskService;
|
|
|
|
private final TaskService taskService;
|
|
|
|
private final TagDataDao tagDataDao;
|
|
|
|
private final TagDataDao tagDataDao;
|
|
|
|
private final TaskListMetadataDao taskListMetadataDao;
|
|
|
|
private final TaskListMetadataDao taskListMetadataDao;
|
|
|
|
private BuiltInFilters builtInFilters;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Inject
|
|
|
|
@Inject
|
|
|
|
public SubtasksHelper(Preferences preferences, TaskService taskService, TagDataDao tagDataDao,
|
|
|
|
public SubtasksHelper(@ForApplication Context context, Preferences preferences, TaskService taskService, TagDataDao tagDataDao, TaskListMetadataDao taskListMetadataDao) {
|
|
|
|
TaskListMetadataDao taskListMetadataDao, BuiltInFilters builtInFilters) {
|
|
|
|
this.context = context;
|
|
|
|
this.preferences = preferences;
|
|
|
|
this.preferences = preferences;
|
|
|
|
this.taskService = taskService;
|
|
|
|
this.taskService = taskService;
|
|
|
|
this.tagDataDao = tagDataDao;
|
|
|
|
this.tagDataDao = tagDataDao;
|
|
|
|
this.taskListMetadataDao = taskListMetadataDao;
|
|
|
|
this.taskListMetadataDao = taskListMetadataDao;
|
|
|
|
this.builtInFilters = builtInFilters;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public boolean shouldUseSubtasksFragmentForFilter(Filter filter) {
|
|
|
|
public boolean shouldUseSubtasksFragmentForFilter(Filter filter) {
|
|
|
|
if(filter == null || builtInFilters.isMyTasksFilter(filter) || builtInFilters.isTodayFilter(filter) || filter.isTagFilter()) {
|
|
|
|
if(filter == null || BuiltInFilterExposer.isInbox(context, filter) || BuiltInFilterExposer.isTodayFilter(context, filter) || filter.isTagFilter()) {
|
|
|
|
if(preferences.getBoolean(R.string.p_manual_sort, false)) {
|
|
|
|
if(preferences.getBoolean(R.string.p_manual_sort, false)) {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -70,9 +71,9 @@ public class SubtasksHelper {
|
|
|
|
TaskListMetadata tlm = null;
|
|
|
|
TaskListMetadata tlm = null;
|
|
|
|
if (tagData != null) {
|
|
|
|
if (tagData != null) {
|
|
|
|
tlm = taskListMetadataDao.fetchByTagId(tagData.getUuid(), TaskListMetadata.TASK_IDS);
|
|
|
|
tlm = taskListMetadataDao.fetchByTagId(tagData.getUuid(), TaskListMetadata.TASK_IDS);
|
|
|
|
} else if (builtInFilters.isMyTasksFilter(filter)) {
|
|
|
|
} else if (BuiltInFilterExposer.isInbox(context, filter)) {
|
|
|
|
tlm = taskListMetadataDao.fetchByTagId(TaskListMetadata.FILTER_ID_ALL, TaskListMetadata.TASK_IDS);
|
|
|
|
tlm = taskListMetadataDao.fetchByTagId(TaskListMetadata.FILTER_ID_ALL, TaskListMetadata.TASK_IDS);
|
|
|
|
} else if (builtInFilters.isTodayFilter(filter)) {
|
|
|
|
} else if (BuiltInFilterExposer.isTodayFilter(context, filter)) {
|
|
|
|
tlm = taskListMetadataDao.fetchByTagId(TaskListMetadata.FILTER_ID_TODAY, TaskListMetadata.TASK_IDS);
|
|
|
|
tlm = taskListMetadataDao.fetchByTagId(TaskListMetadata.FILTER_ID_TODAY, TaskListMetadata.TASK_IDS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|