Define constants for transitories in TaskService, fixed a bug where copied tasks would be assigned back to user

pull/14/head
Sam Bosley 13 years ago
parent 91792d38c8
commit 7b4baaede1

@ -344,8 +344,8 @@ public class EditPeopleControlSet extends PopupControlSet {
myself.put("id", Task.USER_ID_SELF); myself.put("id", Task.USER_ID_SELF);
sharedPeople.add(0, myself); sharedPeople.add(0, myself);
boolean hasTags = t.getTransitory("tags") != null && boolean hasTags = t.getTransitory(TaskService.TRANS_TAGS) != null &&
((HashSet<String>)t.getTransitory("tags")).size() > 0; ((HashSet<String>)t.getTransitory(TaskService.TRANS_TAGS)).size() > 0;
if (actFmPreferenceService.isLoggedIn() && hasTags) { if (actFmPreferenceService.isLoggedIn() && hasTags) {
JSONObject unassigned = new JSONObject(); JSONObject unassigned = new JSONObject();
unassigned.put("id", Task.USER_ID_UNASSIGNED); unassigned.put("id", Task.USER_ID_UNASSIGNED);
@ -636,8 +636,8 @@ public class EditPeopleControlSet extends PopupControlSet {
String assignedName = userJson.optString("name", userEmail); String assignedName = userJson.optString("name", userEmail);
if(task.getTransitory("tags") == null || if(task.getTransitory(TaskService.TRANS_TAGS) == null ||
((HashSet<String>)task.getTransitory("tags")).size() == 0) { ((HashSet<String>)task.getTransitory(TaskService.TRANS_TAGS)).size() == 0) {
sharedToast = activity.getString(R.string.actfm_EPA_assigned_toast, assignedName, sharedToast = activity.getString(R.string.actfm_EPA_assigned_toast, assignedName,
assignedName); assignedName);
} }
@ -680,7 +680,7 @@ public class EditPeopleControlSet extends PopupControlSet {
if(!TextUtils.isEmpty(task.getValue(Task.SHARED_WITH)) || sharedWith.length() != 0) if(!TextUtils.isEmpty(task.getValue(Task.SHARED_WITH)) || sharedWith.length() != 0)
task.setValue(Task.SHARED_WITH, sharedWith.toString()); task.setValue(Task.SHARED_WITH, sharedWith.toString());
task.putTransitory("task-assigned", true); task.putTransitory(TaskService.TRANS_ASSIGNED, true);
if(sharedToast != null) if(sharedToast != null)
toast = (toast != null) ? toast + "\n" + sharedToast : sharedToast + "\n"; toast = (toast != null) ? toast + "\n" + sharedToast : sharedToast + "\n";

@ -127,7 +127,7 @@ public final class ActFmSyncService {
public void onModelUpdated(final Task model) { public void onModelUpdated(final Task model) {
if(model.checkAndClearTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC)) if(model.checkAndClearTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC))
return; return;
if (actFmPreferenceService.isOngoing() && model.getTransitory("task-edit-save") == null) if (actFmPreferenceService.isOngoing() && model.getTransitory(TaskService.TRANS_EDIT_SAVE) == null)
return; return;
final ContentValues setValues = model.getSetValues(); final ContentValues setValues = model.getSetValues();
if(setValues == null || !checkForToken() || if(setValues == null || !checkForToken() ||
@ -361,7 +361,7 @@ public final class ActFmSyncService {
if(values.containsKey(Task.DELETION_DATE.name)) { if(values.containsKey(Task.DELETION_DATE.name)) {
params.add("deleted_at"); params.add(task.getValue(Task.DELETION_DATE) / 1000L); params.add("deleted_at"); params.add(task.getValue(Task.DELETION_DATE) / 1000L);
} }
if(task.getTransitory("repeat-complete") != null) { if(task.getTransitory(TaskService.TRANS_REPEAT_COMPLETE) != null) {
params.add("completed"); params.add(DateUtilities.now() / 1000L); params.add("completed"); params.add(DateUtilities.now() / 1000L);
} else if(values.containsKey(Task.COMPLETION_DATE.name)) { } else if(values.containsKey(Task.COMPLETION_DATE.name)) {
params.add("completed"); params.add(task.getValue(Task.COMPLETION_DATE) / 1000L); params.add("completed"); params.add(task.getValue(Task.COMPLETION_DATE) / 1000L);
@ -377,7 +377,7 @@ public final class ActFmSyncService {
params.add("repeat"); params.add(recurrence); params.add("repeat"); params.add(recurrence);
} }
if(values.containsKey(Task.USER_ID.name) && task.getTransitory("task-assigned") != null) { if(values.containsKey(Task.USER_ID.name) && task.getTransitory(TaskService.TRANS_ASSIGNED) != null) {
if(task.getValue(Task.USER_ID) == Task.USER_ID_EMAIL) { if(task.getValue(Task.USER_ID) == Task.USER_ID_EMAIL) {
try { try {
JSONObject user = new JSONObject(task.getValue(Task.USER)); JSONObject user = new JSONObject(task.getValue(Task.USER));

@ -12,8 +12,6 @@ import android.content.BroadcastReceiver;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import com.google.ical.iter.RecurrenceIterator; import com.google.ical.iter.RecurrenceIterator;
import com.google.ical.iter.RecurrenceIteratorFactory; import com.google.ical.iter.RecurrenceIteratorFactory;
@ -34,6 +32,7 @@ import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.gcal.GCalHelper; import com.todoroo.astrid.gcal.GCalHelper;
import com.todoroo.astrid.service.StatisticsConstants; import com.todoroo.astrid.service.StatisticsConstants;
import com.todoroo.astrid.service.StatisticsService; import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.utility.Flags; import com.todoroo.astrid.utility.Flags;
public class RepeatTaskCompleteListener extends BroadcastReceiver { public class RepeatTaskCompleteListener extends BroadcastReceiver {
@ -76,7 +75,7 @@ public class RepeatTaskCompleteListener extends BroadcastReceiver {
task.setValue(Task.COMPLETION_DATE, 0L); task.setValue(Task.COMPLETION_DATE, 0L);
task.setValue(Task.DUE_DATE, newDueDate); task.setValue(Task.DUE_DATE, newDueDate);
task.setValue(Task.HIDE_UNTIL, hideUntil); task.setValue(Task.HIDE_UNTIL, hideUntil);
task.putTransitory("repeat-complete", true); //$NON-NLS-1$ task.putTransitory(TaskService.TRANS_REPEAT_COMPLETE, true);
ContentResolver cr = ContextManager.getContext().getContentResolver(); ContentResolver cr = ContextManager.getContext().getContentResolver();
GCalHelper.rescheduleRepeatingTask(task, cr); GCalHelper.rescheduleRepeatingTask(task, cr);

@ -820,7 +820,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
&& !peopleControlSet.saveSharingSettings(processedToast) && !onPause; && !peopleControlSet.saveSharingSettings(processedToast) && !onPause;
boolean tagsChanged = Flags.check(Flags.TAGS_CHANGED); boolean tagsChanged = Flags.check(Flags.TAGS_CHANGED);
model.putTransitory("task-edit-save", true); //$NON-NLS-1$ model.putTransitory(TaskService.TRANS_EDIT_SAVE, true);
taskService.save(model); taskService.save(model);
if (!onPause && !cancelFinish) { if (!onPause && !cancelFinish) {

@ -17,6 +17,7 @@ import com.todoroo.andlib.sql.Functions;
import com.todoroo.andlib.sql.Query; import com.todoroo.andlib.sql.Query;
import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.api.PermaSql; import com.todoroo.astrid.api.PermaSql;
import com.todoroo.astrid.dao.MetadataDao; import com.todoroo.astrid.dao.MetadataDao;
@ -46,6 +47,13 @@ public class TaskService {
public static final String TRANS_REPEAT_CHANGED = "repeat_changed"; //$NON-NLS-1$ public static final String TRANS_REPEAT_CHANGED = "repeat_changed"; //$NON-NLS-1$
public static final String TRANS_TAGS = "tags"; //$NON-NLS-1$
public static final String TRANS_ASSIGNED = "task-assigned"; //$NON-NLS-1$
public static final String TRANS_EDIT_SAVE = "task-edit-save"; //$NON-NLS-1$
public static final String TRANS_REPEAT_COMPLETE = "repeat-complete"; //$NON-NLS-1$
@Autowired @Autowired
private TaskDao taskDao; private TaskDao taskDao;
@ -384,6 +392,9 @@ public class TaskService {
Task original = new Task(); Task original = new Task();
original.setId(itemId); original.setId(itemId);
Task clone = clone(original); Task clone = clone(original);
long userId = clone.getValue(Task.USER_ID);
if (userId != Task.USER_ID_SELF && userId != ActFmPreferenceService.userId())
clone.putTransitory(TRANS_ASSIGNED, true);
clone.setValue(Task.CREATION_DATE, DateUtilities.now()); clone.setValue(Task.CREATION_DATE, DateUtilities.now());
clone.setValue(Task.COMPLETION_DATE, 0L); clone.setValue(Task.COMPLETION_DATE, 0L);
clone.setValue(Task.DELETION_DATE, 0L); clone.setValue(Task.DELETION_DATE, 0L);

@ -58,8 +58,6 @@ import com.todoroo.astrid.voice.VoiceInputAssistant;
*/ */
public class QuickAddBar extends LinearLayout { public class QuickAddBar extends LinearLayout {
private static final String TRANS_TAGS = "tags"; //$NON-NLS-1$
private ImageButton voiceAddButton; private ImageButton voiceAddButton;
private ImageButton quickAddButton; private ImageButton quickAddButton;
private EditText quickAddBox; private EditText quickAddBox;
@ -214,7 +212,7 @@ public class QuickAddBar extends LinearLayout {
if (tagData != null) { if (tagData != null) {
HashSet<String> tagsTransitory = new HashSet<String>(); HashSet<String> tagsTransitory = new HashSet<String>();
tagsTransitory.add(tagData.getValue(TagData.NAME)); tagsTransitory.add(tagData.getValue(TagData.NAME));
empty.putTransitory(TRANS_TAGS, tagsTransitory); empty.putTransitory(TaskService.TRANS_TAGS, tagsTransitory);
} }
repeatControl.readFromTask(empty); repeatControl.readFromTask(empty);
gcalControl.readFromTask(empty); gcalControl.readFromTask(empty);

Loading…
Cancel
Save