Merge remote-tracking branch 'upstream/4.0' into 120221_sb_swipe_between_lists

pull/14/head
Sam Bosley 13 years ago
commit 36a5821813

@ -365,6 +365,24 @@ public abstract class AbstractModel implements Parcelable, Cloneable {
return transitoryData.get(key); return transitoryData.get(key);
} }
public Object clearTransitory(String key) {
if (transitoryData == null)
return null;
return transitoryData.remove(key);
}
// --- Convenience wrappers for using transitories as flags
public boolean checkTransitory(String flag) {
Object trans = getTransitory(flag);
return trans != null;
}
public boolean checkAndClearTransitory(String flag) {
Object trans = clearTransitory(flag);
return trans != null;
}
// --- property management // --- property management
/** /**

@ -0,0 +1,10 @@
package com.todoroo.astrid.data;
@SuppressWarnings("nls")
public class SyncFlags {
public static final String ACTFM_SUPPRESS_SYNC = "actfm_suppress_sync";
public static final String GTASKS_SUPPRESS_SYNC = "gtasks_suppress_sync";
}

@ -37,6 +37,7 @@ import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.api.FilterWithCustomIntent; import com.todoroo.astrid.api.FilterWithCustomIntent;
import com.todoroo.astrid.dao.UpdateDao; import com.todoroo.astrid.dao.UpdateDao;
import com.todoroo.astrid.data.SyncFlags;
import com.todoroo.astrid.data.TagData; import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.Update; import com.todoroo.astrid.data.Update;
@ -47,7 +48,6 @@ import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.sync.SyncResultCallbackAdapter; import com.todoroo.astrid.sync.SyncResultCallbackAdapter;
import com.todoroo.astrid.tags.TagFilterExposer; import com.todoroo.astrid.tags.TagFilterExposer;
import com.todoroo.astrid.utility.Constants; import com.todoroo.astrid.utility.Constants;
import com.todoroo.astrid.utility.Flags;
@SuppressWarnings("nls") @SuppressWarnings("nls")
public class C2DMReceiver extends BroadcastReceiver { public class C2DMReceiver extends BroadcastReceiver {
@ -133,7 +133,7 @@ public class C2DMReceiver extends BroadcastReceiver {
TagData tagData = new TagData(); TagData tagData = new TagData();
if(cursor.getCount() == 0) { if(cursor.getCount() == 0) {
tagData.setValue(TagData.REMOTE_ID, Long.parseLong(intent.getStringExtra("tag_id"))); tagData.setValue(TagData.REMOTE_ID, Long.parseLong(intent.getStringExtra("tag_id")));
Flags.set(Flags.ACTFM_SUPPRESS_SYNC); tagData.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
tagDataService.save(tagData); tagDataService.save(tagData);
} else { } else {
cursor.moveToNext(); cursor.moveToNext();
@ -152,7 +152,7 @@ public class C2DMReceiver extends BroadcastReceiver {
final Task task = new Task(); final Task task = new Task();
if(cursor.getCount() == 0) { if(cursor.getCount() == 0) {
task.setValue(Task.REMOTE_ID, Long.parseLong(intent.getStringExtra("task_id"))); task.setValue(Task.REMOTE_ID, Long.parseLong(intent.getStringExtra("task_id")));
Flags.set(Flags.ACTFM_SUPPRESS_SYNC); task.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
taskService.save(task); taskService.save(task);
} else { } else {
cursor.moveToNext(); cursor.moveToNext();
@ -298,7 +298,7 @@ public class C2DMReceiver extends BroadcastReceiver {
task.setValue(Task.TITLE, intent.getStringExtra("title")); task.setValue(Task.TITLE, intent.getStringExtra("title"));
task.setValue(Task.REMOTE_ID, Long.parseLong(intent.getStringExtra("task_id"))); task.setValue(Task.REMOTE_ID, Long.parseLong(intent.getStringExtra("task_id")));
task.setValue(Task.USER_ID, Task.USER_ID_UNASSIGNED); task.setValue(Task.USER_ID, Task.USER_ID_UNASSIGNED);
Flags.set(Flags.ACTFM_SUPPRESS_SYNC); task.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
taskService.save(task); taskService.save(task);
new Thread(new Runnable() { new Thread(new Runnable() {
@ -338,7 +338,7 @@ public class C2DMReceiver extends BroadcastReceiver {
if(cursor.getCount() == 0) { if(cursor.getCount() == 0) {
tagData.setValue(TagData.NAME, intent.getStringExtra("title")); tagData.setValue(TagData.NAME, intent.getStringExtra("title"));
tagData.setValue(TagData.REMOTE_ID, Long.parseLong(intent.getStringExtra("tag_id"))); tagData.setValue(TagData.REMOTE_ID, Long.parseLong(intent.getStringExtra("tag_id")));
Flags.set(Flags.ACTFM_SUPPRESS_SYNC); tagData.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
tagDataService.save(tagData); tagDataService.save(tagData);
new Thread(new Runnable() { new Thread(new Runnable() {

@ -44,6 +44,7 @@ import com.todoroo.astrid.activity.ShortcutActivity;
import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.core.PluginServices; import com.todoroo.astrid.core.PluginServices;
import com.todoroo.astrid.data.SyncFlags;
import com.todoroo.astrid.data.TagData; import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.helper.AsyncImageView; import com.todoroo.astrid.helper.AsyncImageView;
import com.todoroo.astrid.helper.ImageDiskCache; import com.todoroo.astrid.helper.ImageDiskCache;
@ -318,7 +319,7 @@ public class TagSettingsActivity extends FragmentActivity {
imm.hideSoftInputFromWindow(tagName.getWindowToken(), 0); imm.hideSoftInputFromWindow(tagName.getWindowToken(), 0);
if (isNewTag) { if (isNewTag) {
Flags.set(Flags.ACTFM_SUPPRESS_SYNC); tagData.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
tagDataService.save(tagData); tagDataService.save(tagData);
final Runnable loadTag = new Runnable() { final Runnable loadTag = new Runnable() {
@ -436,7 +437,7 @@ public class TagSettingsActivity extends FragmentActivity {
imageCache.move(tagData.getValue(TagData.PICTURE), url); imageCache.move(tagData.getValue(TagData.PICTURE), url);
} }
tagData.setValue(TagData.PICTURE, url); tagData.setValue(TagData.PICTURE, url);
Flags.set(Flags.ACTFM_SUPPRESS_SYNC); tagData.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
tagDataService.save(tagData); tagDataService.save(tagData);
} catch (IOException e) { } catch (IOException e) {
DialogUtilities.okDialog(TagSettingsActivity.this, e.toString(), null); DialogUtilities.okDialog(TagSettingsActivity.this, e.toString(), null);

@ -42,6 +42,7 @@ import com.todoroo.astrid.activity.AstridActivity;
import com.todoroo.astrid.activity.TaskListActivity; import com.todoroo.astrid.activity.TaskListActivity;
import com.todoroo.astrid.adapter.UpdateAdapter; import com.todoroo.astrid.adapter.UpdateAdapter;
import com.todoroo.astrid.dao.UpdateDao; import com.todoroo.astrid.dao.UpdateDao;
import com.todoroo.astrid.data.SyncFlags;
import com.todoroo.astrid.data.TagData; import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.Update; import com.todoroo.astrid.data.Update;
import com.todoroo.astrid.helper.AsyncImageView; import com.todoroo.astrid.helper.AsyncImageView;
@ -51,7 +52,6 @@ import com.todoroo.astrid.service.StatisticsConstants;
import com.todoroo.astrid.service.StatisticsService; import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.service.TagDataService; import com.todoroo.astrid.service.TagDataService;
import com.todoroo.astrid.tags.TagService; import com.todoroo.astrid.tags.TagService;
import com.todoroo.astrid.utility.Flags;
public class TagUpdatesFragment extends ListFragment { public class TagUpdatesFragment extends ListFragment {
@ -361,7 +361,7 @@ public class TagUpdatesFragment extends ListFragment {
Log.e("EditNoteActivity", "Failed to put image to disk..."); Log.e("EditNoteActivity", "Failed to put image to disk...");
} }
} }
Flags.set(Flags.ACTFM_SUPPRESS_SYNC); update.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
updateDao.createNew(update); updateDao.createNew(update);
final long updateId = update.getId(); final long updateId = update.getId();

@ -120,7 +120,7 @@ public final class ActFmSyncService {
taskDao.addListener(new ModelUpdateListener<Task>() { taskDao.addListener(new ModelUpdateListener<Task>() {
@Override @Override
public void onModelUpdated(final Task model) { public void onModelUpdated(final Task model) {
if(Flags.checkAndClear(Flags.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("task-edit-save") == null)
return; return;
@ -149,7 +149,7 @@ public final class ActFmSyncService {
updateDao.addListener(new ModelUpdateListener<Update>() { updateDao.addListener(new ModelUpdateListener<Update>() {
@Override @Override
public void onModelUpdated(final Update model) { public void onModelUpdated(final Update model) {
if(Flags.checkAndClear(Flags.ACTFM_SUPPRESS_SYNC)) if(model.checkAndClearTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC))
return; return;
if (actFmPreferenceService.isOngoing()) if (actFmPreferenceService.isOngoing())
return; return;
@ -169,7 +169,7 @@ public final class ActFmSyncService {
tagDataDao.addListener(new ModelUpdateListener<TagData>() { tagDataDao.addListener(new ModelUpdateListener<TagData>() {
@Override @Override
public void onModelUpdated(final TagData model) { public void onModelUpdated(final TagData model) {
if(Flags.checkAndClear(Flags.ACTFM_SUPPRESS_SYNC)) if(model.checkAndClearTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC))
return; return;
if (actFmPreferenceService.isOngoing()) if (actFmPreferenceService.isOngoing())
return; return;
@ -439,7 +439,7 @@ public final class ActFmSyncService {
task.setValue(Task.LAST_SYNC, DateUtilities.now() + 1000L); task.setValue(Task.LAST_SYNC, DateUtilities.now() + 1000L);
} }
Flags.set(Flags.ACTFM_SUPPRESS_SYNC); task.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
taskDao.saveExisting(task); taskDao.saveExisting(task);
} }
@ -558,7 +558,7 @@ public final class ActFmSyncService {
JSONObject result = actFmInvoker.invoke("tag_save", params.toArray(new Object[params.size()])); JSONObject result = actFmInvoker.invoke("tag_save", params.toArray(new Object[params.size()]));
if(newlyCreated) { if(newlyCreated) {
tagData.setValue(TagData.REMOTE_ID, result.optLong("id")); tagData.setValue(TagData.REMOTE_ID, result.optLong("id"));
Flags.set(Flags.ACTFM_SUPPRESS_SYNC); tagData.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
tagDataDao.saveExisting(tagData); tagDataDao.saveExisting(tagData);
} }
} catch (ActFmServiceException e) { } catch (ActFmServiceException e) {
@ -618,7 +618,7 @@ public final class ActFmSyncService {
JSONObject item = list.getJSONObject(i); JSONObject item = list.getJSONObject(i);
readIds(locals, item, remote); readIds(locals, item, remote);
JsonHelper.tagFromJson(item, remote); JsonHelper.tagFromJson(item, remote);
Flags.set(Flags.ACTFM_SUPPRESS_SYNC); remote.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
tagDataService.save(remote); tagDataService.save(remote);
} }
} }
@ -660,7 +660,7 @@ public final class ActFmSyncService {
"token", token); "token", token);
JsonHelper.tagFromJson(result, tagData); JsonHelper.tagFromJson(result, tagData);
Flags.set(Flags.ACTFM_SUPPRESS_SYNC); tagData.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
tagDataService.save(tagData); tagDataService.save(tagData);
} }
@ -682,7 +682,7 @@ public final class ActFmSyncService {
ArrayList<Metadata> metadata = new ArrayList<Metadata>(); ArrayList<Metadata> metadata = new ArrayList<Metadata>();
JsonHelper.taskFromJson(result, task, metadata); JsonHelper.taskFromJson(result, task, metadata);
Flags.set(Flags.ACTFM_SUPPRESS_SYNC); task.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
taskService.save(task); taskService.save(task);
metadataService.synchronizeMetadata(task.getId(), metadata, Metadata.KEY.eq(TagService.KEY)); metadataService.synchronizeMetadata(task.getId(), metadata, Metadata.KEY.eq(TagService.KEY));
} }
@ -743,7 +743,7 @@ public final class ActFmSyncService {
remote.getValue(Task.DUE_DATE) < DateUtilities.now()) remote.getValue(Task.DUE_DATE) < DateUtilities.now())
remote.setFlag(Task.REMINDER_FLAGS, Task.NOTIFY_AFTER_DEADLINE, false); remote.setFlag(Task.REMINDER_FLAGS, Task.NOTIFY_AFTER_DEADLINE, false);
Flags.set(Flags.ACTFM_SUPPRESS_SYNC); remote.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
taskService.save(remote); taskService.save(remote);
ids.add(remote.getId()); ids.add(remote.getId());
metadataService.synchronizeMetadata(remote.getId(), metadata, MetadataCriteria.withKey(TagService.KEY)); metadataService.synchronizeMetadata(remote.getId(), metadata, MetadataCriteria.withKey(TagService.KEY));
@ -800,7 +800,7 @@ public final class ActFmSyncService {
StatisticsService.reportEvent(StatisticsConstants.ACTFM_TASK_COMPLETED); StatisticsService.reportEvent(StatisticsConstants.ACTFM_TASK_COMPLETED);
} }
Flags.set(Flags.ACTFM_SUPPRESS_SYNC); remote.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
taskService.save(remote); taskService.save(remote);
ids.add(remote.getId()); ids.add(remote.getId());
metadataService.synchronizeMetadata(remote.getId(), metadata, MetadataCriteria.withKey(TagService.KEY)); metadataService.synchronizeMetadata(remote.getId(), metadata, MetadataCriteria.withKey(TagService.KEY));
@ -943,7 +943,7 @@ public final class ActFmSyncService {
readIds(locals, item, remote); readIds(locals, item, remote);
JsonHelper.updateFromJson(item, remote); JsonHelper.updateFromJson(item, remote);
Flags.set(Flags.ACTFM_SUPPRESS_SYNC); remote.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
if(remote.getId() == AbstractModel.NO_ID) if(remote.getId() == AbstractModel.NO_ID)
updateDao.createNew(remote); updateDao.createNew(remote);
else else
@ -1127,7 +1127,7 @@ public final class ActFmSyncService {
public static void updateFromJson(JSONObject json, Update model) throws JSONException { public static void updateFromJson(JSONObject json, Update model) throws JSONException {
model.setValue(Update.REMOTE_ID, json.getLong("id")); model.setValue(Update.REMOTE_ID, json.getLong("id"));
readUser(json.getJSONObject("user"), model, Update.USER_ID, Update.USER); readUser(json.getJSONObject("user"), model, Update.USER_ID, Update.USER);
if (json.has("other_user")) { if (!json.isNull("other_user")) {
readUser(json.getJSONObject("other_user"), model, Update.OTHER_USER_ID, Update.OTHER_USER); readUser(json.getJSONObject("other_user"), model, Update.OTHER_USER_ID, Update.OTHER_USER);
} }
model.setValue(Update.ACTION, json.getString("action")); model.setValue(Update.ACTION, json.getString("action"));

@ -16,6 +16,7 @@ import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.dao.MetadataDao; import com.todoroo.astrid.dao.MetadataDao;
import com.todoroo.astrid.dao.TaskDao; import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.SyncFlags;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.gtasks.GtasksMetadata; import com.todoroo.astrid.gtasks.GtasksMetadata;
import com.todoroo.astrid.gtasks.GtasksMetadataService; import com.todoroo.astrid.gtasks.GtasksMetadataService;
@ -26,7 +27,6 @@ import com.todoroo.astrid.gtasks.api.GtasksApiUtilities;
import com.todoroo.astrid.gtasks.api.GtasksInvoker; import com.todoroo.astrid.gtasks.api.GtasksInvoker;
import com.todoroo.astrid.gtasks.api.MoveRequest; import com.todoroo.astrid.gtasks.api.MoveRequest;
import com.todoroo.astrid.service.MetadataService; import com.todoroo.astrid.service.MetadataService;
import com.todoroo.astrid.utility.Flags;
public final class GtasksSyncService { public final class GtasksSyncService {
@ -93,7 +93,7 @@ public final class GtasksSyncService {
taskDao.addListener(new ModelUpdateListener<Task>() { taskDao.addListener(new ModelUpdateListener<Task>() {
public void onModelUpdated(final Task model) { public void onModelUpdated(final Task model) {
if(Flags.checkAndClear(Flags.GTASKS_SUPPRESS_SYNC)) if(model.checkAndClearTransitory(SyncFlags.GTASKS_SUPPRESS_SYNC))
return; return;
if (gtasksPreferenceService.isOngoing()) //Don't try and sync changes that occur during a normal sync if (gtasksPreferenceService.isOngoing()) //Don't try and sync changes that occur during a normal sync
return; return;
@ -131,7 +131,7 @@ public final class GtasksSyncService {
public void triggerMoveForMetadata(final Metadata metadata) { public void triggerMoveForMetadata(final Metadata metadata) {
if (Flags.checkAndClear(Flags.GTASKS_SUPPRESS_SYNC)) if (metadata.checkAndClearTransitory(SyncFlags.GTASKS_SUPPRESS_SYNC))
return; return;
if (!metadata.getValue(Metadata.KEY).equals(GtasksMetadata.METADATA_KEY)) //Don't care about non-gtasks metadata if (!metadata.getValue(Metadata.KEY).equals(GtasksMetadata.METADATA_KEY)) //Don't care about non-gtasks metadata
return; return;
@ -233,7 +233,7 @@ public final class GtasksSyncService {
task.setValue(Task.MODIFICATION_DATE, DateUtilities.now()); task.setValue(Task.MODIFICATION_DATE, DateUtilities.now());
gtasksMetadata.setValue(GtasksMetadata.LAST_SYNC, DateUtilities.now() + 1000L); gtasksMetadata.setValue(GtasksMetadata.LAST_SYNC, DateUtilities.now() + 1000L);
metadataService.save(gtasksMetadata); metadataService.save(gtasksMetadata);
Flags.set(Flags.GTASKS_SUPPRESS_SYNC); task.putTransitory(SyncFlags.GTASKS_SUPPRESS_SYNC, true);
taskDao.saveExisting(task); taskDao.saveExisting(task);
} }
@ -250,7 +250,7 @@ public final class GtasksSyncService {
// Update order metadata from result // Update order metadata from result
if (result != null) { if (result != null) {
model.setValue(GtasksMetadata.GTASKS_ORDER, Long.parseLong(result.getPosition())); model.setValue(GtasksMetadata.GTASKS_ORDER, Long.parseLong(result.getPosition()));
Flags.set(Flags.GTASKS_SUPPRESS_SYNC); model.putTransitory(SyncFlags.GTASKS_SUPPRESS_SYNC, true);
metadataDao.saveExisting(model); metadataDao.saveExisting(model);
} }
} }

@ -27,6 +27,7 @@ import com.todoroo.astrid.dao.StoreObjectDao;
import com.todoroo.astrid.dao.TaskDao; import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.StoreObject; import com.todoroo.astrid.data.StoreObject;
import com.todoroo.astrid.data.SyncFlags;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.gtasks.GtasksList; import com.todoroo.astrid.gtasks.GtasksList;
import com.todoroo.astrid.gtasks.GtasksListService; import com.todoroo.astrid.gtasks.GtasksListService;
@ -44,7 +45,6 @@ import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.service.TaskService; import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.sync.SyncResultCallback; import com.todoroo.astrid.sync.SyncResultCallback;
import com.todoroo.astrid.sync.SyncV2Provider; import com.todoroo.astrid.sync.SyncV2Provider;
import com.todoroo.astrid.utility.Flags;
public class GtasksSyncV2Provider extends SyncV2Provider { public class GtasksSyncV2Provider extends SyncV2Provider {
@ -270,7 +270,7 @@ public class GtasksSyncV2Provider extends SyncV2Provider {
TaskDao.setDefaultReminders(task.task); TaskDao.setDefaultReminders(task.task);
} }
if (!TextUtils.isEmpty(task.task.getValue(Task.TITLE))) { if (!TextUtils.isEmpty(task.task.getValue(Task.TITLE))) {
Flags.set(Flags.GTASKS_SUPPRESS_SYNC); task.task.putTransitory(SyncFlags.GTASKS_SUPPRESS_SYNC, true);
gtasksMetadataService.saveTaskAndMetadata(task); gtasksMetadataService.saveTaskAndMetadata(task);
} }
} }

@ -53,6 +53,7 @@ import com.todoroo.astrid.core.PluginServices;
import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria; import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
import com.todoroo.astrid.dao.UpdateDao; import com.todoroo.astrid.dao.UpdateDao;
import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.SyncFlags;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.Update; import com.todoroo.astrid.data.Update;
import com.todoroo.astrid.helper.AsyncImageView; import com.todoroo.astrid.helper.AsyncImageView;
@ -63,7 +64,6 @@ import com.todoroo.astrid.service.StatisticsConstants;
import com.todoroo.astrid.service.StatisticsService; import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.sync.SyncResultCallback; import com.todoroo.astrid.sync.SyncResultCallback;
import com.todoroo.astrid.timers.TimerActionControlSet.TimerActionListener; import com.todoroo.astrid.timers.TimerActionControlSet.TimerActionListener;
import com.todoroo.astrid.utility.Flags;
public class EditNoteActivity extends LinearLayout implements TimerActionListener { public class EditNoteActivity extends LinearLayout implements TimerActionListener {
@ -436,7 +436,7 @@ public class EditNoteActivity extends LinearLayout implements TimerActionListene
Log.e("EditNoteActivity", "Failed to put image to disk..."); Log.e("EditNoteActivity", "Failed to put image to disk...");
} }
} }
Flags.set(Flags.ACTFM_SUPPRESS_SYNC); update.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
updateDao.createNew(update); updateDao.createNew(update);
final long updateId = update.getId(); final long updateId = update.getId();

@ -24,13 +24,13 @@ import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
import com.todoroo.astrid.dao.TaskDao; import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.dao.TaskDao.TaskCriteria; import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.SyncFlags;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.gcal.GCalHelper; import com.todoroo.astrid.gcal.GCalHelper;
import com.todoroo.astrid.gtasks.GtasksMetadata; import com.todoroo.astrid.gtasks.GtasksMetadata;
import com.todoroo.astrid.opencrx.OpencrxCoreUtils; import com.todoroo.astrid.opencrx.OpencrxCoreUtils;
import com.todoroo.astrid.producteev.sync.ProducteevTask; import com.todoroo.astrid.producteev.sync.ProducteevTask;
import com.todoroo.astrid.tags.TagService; import com.todoroo.astrid.tags.TagService;
import com.todoroo.astrid.utility.Flags;
import com.todoroo.astrid.utility.TitleParser; import com.todoroo.astrid.utility.TitleParser;
@ -122,6 +122,8 @@ public class TaskService {
try { try {
if(cursor.getCount() > 0) { if(cursor.getCount() > 0) {
Metadata metadata = new Metadata(); Metadata metadata = new Metadata();
newTask.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
newTask.putTransitory(SyncFlags.GTASKS_SUPPRESS_SYNC, true);
taskDao.save(newTask); taskDao.save(newTask);
long newId = newTask.getId(); long newId = newTask.getId();
for(cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { for(cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
@ -388,15 +390,13 @@ public class TaskService {
clone.setValue(Task.CALENDAR_URI, ""); //$NON-NLS-1$ clone.setValue(Task.CALENDAR_URI, ""); //$NON-NLS-1$
GCalHelper.createTaskEventIfEnabled(clone); GCalHelper.createTaskEventIfEnabled(clone);
Flags.set(Flags.ACTFM_SUPPRESS_SYNC);
Flags.set(Flags.GTASKS_SUPPRESS_SYNC);
save(clone); save(clone);
return clone.getId(); return clone.getId();
} }
/** /**
* Create task from the given content values, saving it. * Create task from the given content values, saving it. This version
* doesn't need to start with a base task model.
* *
* @param values * @param values
* @param title * @param title
@ -407,6 +407,21 @@ public class TaskService {
public static Task createWithValues(ContentValues values, String title, public static Task createWithValues(ContentValues values, String title,
TaskService taskService, MetadataService metadataService) { TaskService taskService, MetadataService metadataService) {
Task task = new Task(); Task task = new Task();
return createWithValues(task, values, title, taskService, metadataService);
}
/**
* Create task from the given content values, saving it.
*
* @param task base task to start with
* @param values
* @param title
* @param taskService
* @param metadataService
* @return
*/
public static Task createWithValues(Task task, ContentValues values, String title,
TaskService taskService, MetadataService metadataService) {
if (title != null) if (title != null)
task.setValue(Task.TITLE, title); task.setValue(Task.TITLE, title);
@ -430,6 +445,7 @@ public class TaskService {
} }
task.mergeWith(forTask); task.mergeWith(forTask);
} }
boolean markup = taskService.quickAdd(task); boolean markup = taskService.quickAdd(task);
if (markup) if (markup)
task.putTransitory(TRANS_QUICK_ADD_MARKUP, true); task.putTransitory(TRANS_QUICK_ADD_MARKUP, true);

@ -1,5 +1,6 @@
package com.todoroo.astrid.ui; package com.todoroo.astrid.ui;
import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import android.app.Activity; import android.app.Activity;
@ -36,6 +37,7 @@ import com.todoroo.astrid.activity.TaskListActivity;
import com.todoroo.astrid.activity.TaskListFragment; import com.todoroo.astrid.activity.TaskListFragment;
import com.todoroo.astrid.activity.TaskListFragment.OnTaskListItemClickedListener; import com.todoroo.astrid.activity.TaskListFragment.OnTaskListItemClickedListener;
import com.todoroo.astrid.dao.TaskDao; import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.data.SyncFlags;
import com.todoroo.astrid.data.TagData; import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.gcal.GCalControlSet; import com.todoroo.astrid.gcal.GCalControlSet;
@ -267,18 +269,7 @@ public class QuickAddBar extends LinearLayout {
return null; return null;
} }
boolean quickAddChanges = repeatControl.isRecurrenceSet() || Task task = new Task();
deadlineControl.isDeadlineSet() ||
!assignedToMe; // Will the quickadd save have any effect?
if (quickAddChanges)
Flags.set(Flags.ACTFM_SUPPRESS_SYNC);
if (deadlineControl.isDeadlineSet()) // If deadline is set, second save will trigger push
Flags.set(Flags.GTASKS_SUPPRESS_SYNC);
Task task = TaskService.createWithValues(fragment.getFilter().valuesForNewTasks, title,
taskService, metadataService);
if (repeatControl.isRecurrenceSet()) if (repeatControl.isRecurrenceSet())
repeatControl.writeToModel(task); repeatControl.writeToModel(task);
@ -292,7 +283,9 @@ public class QuickAddBar extends LinearLayout {
peopleControl.setTask(task); peopleControl.setTask(task);
peopleControl.saveSharingSettings(null); peopleControl.saveSharingSettings(null);
} }
taskService.save(task);
TaskService.createWithValues(task, fragment.getFilter().valuesForNewTasks, title,
taskService, metadataService);
String assignedTo = peopleControl.getAssignedToString(); String assignedTo = peopleControl.getAssignedToString();
@ -305,8 +298,8 @@ public class QuickAddBar extends LinearLayout {
Uri calendarUri = GCalHelper.createTaskEvent(task, Uri calendarUri = GCalHelper.createTaskEvent(task,
activity.getContentResolver(), new ContentValues()); activity.getContentResolver(), new ContentValues());
task.setValue(Task.CALENDAR_URI, calendarUri.toString()); task.setValue(Task.CALENDAR_URI, calendarUri.toString());
Flags.set(Flags.ACTFM_SUPPRESS_SYNC); task.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
Flags.set(Flags.GTASKS_SUPPRESS_SYNC); task.putTransitory(SyncFlags.GTASKS_SUPPRESS_SYNC, true);
taskService.save(task); taskService.save(task);
} }

@ -21,16 +21,6 @@ public class Flags {
*/ */
public static final int TOAST_ON_SAVE = 1 << 2; public static final int TOAST_ON_SAVE = 1 << 2;
/**
* If set, indicates to suppress the next act.fm sync attempt
*/
public static final int ACTFM_SUPPRESS_SYNC = 1 << 3;
/**
* If set, indicates to suppress the next gtasks sync attempt
*/
public static final int GTASKS_SUPPRESS_SYNC = 1 << 4;
/** /**
* If set, indicates that the edit popover was dismissed by the edit fragment/back button * If set, indicates that the edit popover was dismissed by the edit fragment/back button
*/ */

Loading…
Cancel
Save