diff --git a/astrid/plugin-src/com/todoroo/astrid/taskrabbit/TaskRabbitActivity.java b/astrid/plugin-src/com/todoroo/astrid/taskrabbit/TaskRabbitActivity.java index d9da661d8..eaaf7108c 100644 --- a/astrid/plugin-src/com/todoroo/astrid/taskrabbit/TaskRabbitActivity.java +++ b/astrid/plugin-src/com/todoroo/astrid/taskrabbit/TaskRabbitActivity.java @@ -59,7 +59,6 @@ import com.todoroo.astrid.dao.Database; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.helper.TaskEditControlSet; import com.todoroo.astrid.reminders.Notifications; -import com.todoroo.astrid.service.MetadataService; import com.todoroo.astrid.service.StatisticsConstants; import com.todoroo.astrid.service.StatisticsService; import com.todoroo.astrid.service.TaskService; @@ -93,9 +92,6 @@ public class TaskRabbitActivity extends FragmentActivity { @Autowired private TaskService taskService; - @Autowired - private MetadataService metadataService; - @Autowired private ExceptionService exceptionService; @@ -291,8 +287,7 @@ public class TaskRabbitActivity extends FragmentActivity { } catch (Exception e) { // oops, can't serialize } - model = TaskService.createWithValues(values, null, - taskService, metadataService); + model = TaskService.createWithValues(values, null); } if (model == null) { diff --git a/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java b/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java index 15beb7f29..e4d9f0069 100755 --- a/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java @@ -754,8 +754,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener { } catch (Exception e) { // oops, can't serialize } - model = TaskService.createWithValues(values, null, - taskService, metadataService); + model = TaskService.createWithValues(values, null); getActivity().getIntent().putExtra(TOKEN_ID, model.getId()); } diff --git a/astrid/src/com/todoroo/astrid/service/TaskService.java b/astrid/src/com/todoroo/astrid/service/TaskService.java index bff5fb4f3..7d746ee82 100644 --- a/astrid/src/com/todoroo/astrid/service/TaskService.java +++ b/astrid/src/com/todoroo/astrid/service/TaskService.java @@ -1,6 +1,7 @@ package com.todoroo.astrid.service; import java.util.ArrayList; +import java.util.List; import java.util.Map.Entry; import org.weloveastrid.rmilk.data.MilkTaskFields; @@ -11,7 +12,6 @@ import com.todoroo.andlib.data.Property; import com.todoroo.andlib.data.TodorooCursor; import com.todoroo.andlib.service.Autowired; import com.todoroo.andlib.service.DependencyInjectionService; -import com.todoroo.andlib.service.ExceptionService; import com.todoroo.andlib.sql.Criterion; import com.todoroo.andlib.sql.Functions; import com.todoroo.andlib.sql.Query; @@ -21,6 +21,7 @@ import com.todoroo.andlib.utility.Preferences; import com.todoroo.astrid.actfm.sync.ActFmPreferenceService; import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.PermaSql; +import com.todoroo.astrid.core.PluginServices; import com.todoroo.astrid.dao.MetadataDao; import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria; import com.todoroo.astrid.dao.TaskDao; @@ -65,9 +66,6 @@ public class TaskService { @Autowired private MetadataDao metadataDao; - @Autowired - private ExceptionService exceptionService; - public TaskService() { DependencyInjectionService.getInstance().inject(this); } @@ -401,14 +399,7 @@ public class TaskService { *
  • @context - add the tag "@context" *
  • !4 - set priority to !!!! */ - public boolean quickAdd(Task task) { - ArrayList tags = new ArrayList(); - boolean quickAddMarkup = false; - try { - quickAddMarkup = parseQuickAddMarkup(task, tags); - } catch (Throwable e) { - exceptionService.reportError("parse-quick-add", e); //$NON-NLS-1$ - } + private void quickAdd(Task task, List tags) { save(task); Metadata metadata = new Metadata(); @@ -418,7 +409,6 @@ public class TaskService { metadata.setValue(TagService.TAG, tag); metadataDao.createNew(metadata); } - return quickAddMarkup; } /** @@ -463,10 +453,9 @@ public class TaskService { * @param metadataService * @return */ - public static Task createWithValues(ContentValues values, String title, - TaskService taskService, MetadataService metadataService) { + public static Task createWithValues(ContentValues values, String title) { Task task = new Task(); - return createWithValues(task, values, title, taskService, metadataService); + return createWithValues(task, values, title); } /** @@ -479,11 +468,18 @@ public class TaskService { * @param metadataService * @return */ - public static Task createWithValues(Task task, ContentValues values, String title, - TaskService taskService, MetadataService metadataService) { + public static Task createWithValues(Task task, ContentValues values, String title) { if (title != null) task.setValue(Task.TITLE, title); + ArrayList tags = new ArrayList(); + boolean quickAddMarkup = false; + try { + quickAddMarkup = parseQuickAddMarkup(task, tags); + } catch (Throwable e) { + PluginServices.getExceptionService().reportError("parse-quick-add", e); //$NON-NLS-1$ + } + ContentValues forMetadata = null; if (values != null && values.size() > 0) { ContentValues forTask = new ContentValues(); @@ -508,15 +504,15 @@ public class TaskService { if (task.getValue(Task.USER_ID) != Task.USER_ID_SELF) task.putTransitory(TRANS_ASSIGNED, true); - boolean markup = taskService.quickAdd(task); - if (markup) + PluginServices.getTaskService().quickAdd(task, tags); + if (quickAddMarkup) task.putTransitory(TRANS_QUICK_ADD_MARKUP, true); if (forMetadata != null && forMetadata.size() > 0) { Metadata metadata = new Metadata(); metadata.setValue(Metadata.TASK, task.getId()); metadata.mergeWith(forMetadata); - metadataService.save(metadata); + PluginServices.getMetadataService().save(metadata); } return task; diff --git a/astrid/src/com/todoroo/astrid/ui/QuickAddBar.java b/astrid/src/com/todoroo/astrid/ui/QuickAddBar.java index 90c1392a5..7d2177a17 100644 --- a/astrid/src/com/todoroo/astrid/ui/QuickAddBar.java +++ b/astrid/src/com/todoroo/astrid/ui/QuickAddBar.java @@ -84,7 +84,6 @@ public class QuickAddBar extends LinearLayout implements RecognizerApiListener { @Autowired AddOnService addOnService; @Autowired ExceptionService exceptionService; - @Autowired TaskService taskService; @Autowired MetadataService metadataService; @Autowired ActFmPreferenceService actFmPreferenceService; @@ -305,14 +304,13 @@ public class QuickAddBar extends LinearLayout implements RecognizerApiListener { peopleControl.saveSharingSettings(null); } - TaskService.createWithValues(task, fragment.getFilter().valuesForNewTasks, title, - taskService, metadataService); + TaskService.createWithValues(task, fragment.getFilter().valuesForNewTasks, title); String assignedTo = peopleControl.getAssignedToString(); resetControlSets(); - addToCalendar(task, title, taskService); + addToCalendar(task, title); if(!TextUtils.isEmpty(title)) fragment.showTaskEditHelpPopover(); @@ -356,7 +354,7 @@ public class QuickAddBar extends LinearLayout implements RecognizerApiListener { } } - private static void addToCalendar(Task task, String title, TaskService taskService) { + private static void addToCalendar(Task task, String title) { boolean gcalCreateEventEnabled = Preferences.getStringValue(R.string.gcal_p_default) != null && !Preferences.getStringValue(R.string.gcal_p_default).equals("-1"); //$NON-NLS-1$ @@ -366,7 +364,7 @@ public class QuickAddBar extends LinearLayout implements RecognizerApiListener { task.setValue(Task.CALENDAR_URI, calendarUri.toString()); task.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true); task.putTransitory(SyncFlags.GTASKS_SUPPRESS_SYNC, true); - taskService.save(task); + PluginServices.getTaskService().save(task); } } @@ -380,12 +378,10 @@ public class QuickAddBar extends LinearLayout implements RecognizerApiListener { if (TextUtils.isEmpty(title)) return null; - TaskService taskService = PluginServices.getTaskService(); - MetadataService metadataService = PluginServices.getMetadataService(); title = title.trim(); - Task task = TaskService.createWithValues(null, title, taskService, metadataService); - addToCalendar(task, title, taskService); + Task task = TaskService.createWithValues(null, title); + addToCalendar(task, title); return task; }