Apply default sync list in task creator

pull/757/head
Alex Baker 6 years ago
parent 1311db836f
commit cb8e0f10f0

@ -1,11 +1,13 @@
package com.todoroo.astrid.service;
import static com.todoroo.andlib.utility.DateUtilities.now;
import static com.todoroo.astrid.helper.UUIDHelper.newUUID;
import android.content.ContentValues;
import android.net.Uri;
import android.text.TextUtils;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.astrid.api.CaldavFilter;
import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.api.GtasksFilter;
import com.todoroo.astrid.api.PermaSql;
@ -13,7 +15,6 @@ import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.Task.Priority;
import com.todoroo.astrid.gcal.GCalHelper;
import com.todoroo.astrid.helper.UUIDHelper;
import com.todoroo.astrid.tags.TagService;
import com.todoroo.astrid.utility.TitleParser;
import java.util.ArrayList;
@ -79,9 +80,17 @@ public class TaskCreator {
}
public Task basicQuickAddTask(String title) {
return createWithValues(null, title);
}
/**
* Create task from the given content values, saving it. This version doesn't need to start with a
* base task model.
*/
public Task createWithValues(Map<String, Object> values, String title) {
title = title.trim();
Task task = createWithValues(null, title);
Task task = create(values, title);
taskDao.createNew(task);
boolean gcalCreateEventEnabled =
@ -98,13 +107,15 @@ public class TaskCreator {
if (task.hasTransitory(GoogleTask.KEY)) {
googleTaskDao.insert(new GoogleTask(task.getId(), task.getTransitory(GoogleTask.KEY)));
} else if (task.hasTransitory(CaldavTask.KEY)) {
caldavDao.insert(
new CaldavTask(task.getId(), task.getTransitory(CaldavTask.KEY), UUIDHelper.newUUID()));
caldavDao.insert(new CaldavTask(task.getId(), task.getTransitory(CaldavTask.KEY), newUUID()));
} else {
Filter remoteList = defaultFilterProvider.getDefaultRemoteList();
if (remoteList != null && remoteList instanceof GtasksFilter) {
if (remoteList instanceof GtasksFilter) {
googleTaskDao.insert(
new GoogleTask(task.getId(), ((GtasksFilter) remoteList).getRemoteId()));
} else if (remoteList instanceof CaldavFilter) {
caldavDao.insert(
new CaldavTask(task.getId(), ((CaldavFilter) remoteList).getUuid(), newUUID()));
}
}
@ -112,11 +123,7 @@ public class TaskCreator {
return task;
}
/**
* Create task from the given content values, saving it. This version doesn't need to start with a
* base task model.
*/
public Task createWithValues(Map<String, Object> values, String title) {
private Task create(Map<String, Object> values, String title) {
Task task = new Task();
task.setCreationDate(now());
task.setModificationDate(now());
@ -124,7 +131,7 @@ public class TaskCreator {
task.setTitle(title.trim());
}
task.setUuid(UUIDHelper.newUUID());
task.setUuid(newUUID());
task.setPriority(
preferences.getIntegerFromString(R.string.p_default_importance_key, Priority.LOW));

Loading…
Cancel
Save