Fixed several bugs with assigning tasks

pull/14/head
Sam Bosley 12 years ago
parent b8476ca5b8
commit c88d8f455b

@ -306,6 +306,7 @@ public final class Task extends RemoteModel {
defaultValues.put(USER_ID.name, "0");
defaultValues.put(CREATOR_ID.name, 0);
defaultValues.put(USER.name, "");
defaultValues.put(USER_EMAIL.name, "");
defaultValues.put(PUSHED_AT.name, 0L);
}

@ -136,7 +136,18 @@ public final class User extends RemoteModel {
String name = getValue(NAME);
if (!(TextUtils.isEmpty(name) || "null".equals(name)))
return name;
return getValue(EMAIL);
String firstName = getValue(FIRST_NAME);
boolean firstNameEmpty = TextUtils.isEmpty(firstName) || "null".equals(firstName);
String lastName = getValue(LAST_NAME);
boolean lastNameEmpty = TextUtils.isEmpty(lastName) || "null".equals(lastName);
if (firstNameEmpty && lastNameEmpty)
return getValue(EMAIL);
StringBuilder nameBuilder = new StringBuilder();
if (!firstNameEmpty)
nameBuilder.append(firstName).append(" ");
if (!lastNameEmpty)
nameBuilder.append(lastName);
return nameBuilder.toString().trim();
}
@Override

@ -188,7 +188,7 @@ public class ActFmInvoker {
public JSONObject postSync(JSONArray data, String token) throws IOException,
ActFmServiceException {
try {
String request = createFetchUrl("api2/" + API_VERSION, "synchronize");
String request = createFetchUrl("api/" + API_VERSION, "synchronize");
if (SYNC_DEBUG)
Log.e("act-fm-post", request);
List<BasicNameValuePair> pairs = new ArrayList<BasicNameValuePair>();

@ -59,7 +59,10 @@ public class ActFmPreferenceService extends SyncProviderUtilities {
*/
public static String userId() {
try {
return Preferences.getStringValue(PREF_USER_ID);
String value = Preferences.getStringValue(PREF_USER_ID);
if (value == null)
return Long.toString(Preferences.getLong(PREF_USER_ID, -2L));
return value;
} catch (Exception e) {
return Long.toString(Preferences.getLong(PREF_USER_ID, -2L));
}

@ -76,8 +76,8 @@ import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.service.abtesting.ABTestEventReportingService;
import com.todoroo.astrid.subtasks.SubtasksHelper;
import com.todoroo.astrid.sync.SyncV2Provider.SyncExceptionHandler;
import com.todoroo.astrid.tags.TaskToTagMetadata;
import com.todoroo.astrid.tags.TagService;
import com.todoroo.astrid.tags.TaskToTagMetadata;
import com.todoroo.astrid.tags.reusable.FeaturedListFilterExposer;
import com.todoroo.astrid.utility.Flags;
@ -1703,8 +1703,8 @@ public final class ActFmSyncService {
}
public static void jsonFromUser(JSONObject json, User model) throws JSONException {
json.put("id", model.getValue(User.REMOTE_ID));
json.put("name", model.getValue(User.NAME));
json.put("id", model.getValue(User.UUID));
json.put("name", model.getDisplayName());
json.put("email", model.getValue(User.EMAIL));
json.put("picture", model.getValue(User.PICTURE));
}

@ -163,9 +163,7 @@ public class ChangesHappened<TYPE extends RemoteModel, OE extends OutstandingEnt
public Object visitLong(Property<Long> property, OE data) {
Long l = data.getMergedValues().getAsLong(OutstandingEntry.VALUE_STRING_PROPERTY.name);
if (l != null) {
if (l == 0 && property.checkFlag(Property.PROP_FLAG_USER_ID))
return ActFmPreferenceService.userId();
else if (property.checkFlag(Property.PROP_FLAG_DATE)) {
if (property.checkFlag(Property.PROP_FLAG_DATE)) {
boolean includeTime = true;
if (Task.DUE_DATE.equals(property) && !Task.hasDueTime(l))
includeTime = false;
@ -189,7 +187,10 @@ public class ChangesHappened<TYPE extends RemoteModel, OE extends OutstandingEnt
@Override
public Object visitString(Property<String> property, OE data) {
return getAsString(data);
String value = getAsString(data);
if (RemoteModel.NO_UUID.equals(value) && property.checkFlag(Property.PROP_FLAG_USER_ID))
return ActFmPreferenceService.userId();
return value;
}
}

Loading…
Cancel
Save