Removed or fixed most references to Task.USER

pull/14/head
Sam Bosley 12 years ago
parent 8c8300524e
commit 16abc83b12

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

@ -655,17 +655,18 @@ public class EditPeopleControlSet extends PopupControlSet {
if(userJson == null || Task.USER_ID_SELF.equals(Long.toString(userJson.optLong("id", -2)))) {
dirty = task.getValue(Task.USER_ID) == Task.USER_ID_SELF ? dirty : true;
task.setValue(Task.USER_ID, Task.USER_ID_SELF);
task.setValue(Task.USER, "{}");
task.setValue(Task.USER, "");
assignedToMe = true;
} else if(Task.USER_ID_UNASSIGNED.equals(Long.toString(userJson.optLong("id")))) {
dirty = task.getValue(Task.USER_ID) == Task.USER_ID_UNASSIGNED ? dirty : true;
task.setValue(Task.USER_ID, Task.USER_ID_UNASSIGNED);
task.setValue(Task.USER, "{}");
task.setValue(Task.USER, "");
} else {
String user = userJson.toString();
String taskUserId = Task.USER_ID_EMAIL;
String taskUserEmail = "";
try {
@SuppressWarnings("deprecation") // For backwards compatibility
JSONObject taskUser = new JSONObject(task.getValue(Task.USER));
taskUserId = Long.toString(taskUser.optLong("id", -2));
taskUserEmail = taskUser.optString("email");
@ -687,7 +688,7 @@ public class EditPeopleControlSet extends PopupControlSet {
task.setValue(Task.USER_EMAIL, userEmail);
else
task.setValue(Task.USER_EMAIL, "");
task.setValue(Task.USER, "{}");
task.setValue(Task.USER, "");
}
if(dirty && !actFmPreferenceService.isLoggedIn()) {

@ -422,6 +422,7 @@ public class TagViewFragment extends TaskListFragment {
private OnClickListener listenerForImage(final JSONObject member, final String id, final String displayName) {
return new OnClickListener() {
final String email = member.optString("email"); //$NON-NLS-1$
@SuppressWarnings("deprecation")
@Override
public void onClick(View v) {
if (currentId.equals(id)) {
@ -434,7 +435,7 @@ public class TagViewFragment extends TaskListFragment {
if (ActFmPreferenceService.userId().equals(currentId))
assignedCriterion = Criterion.or(Task.USER_ID.eq(0), Task.USER_ID.eq(id));
else if (Task.USER_ID_EMAIL.equals(currentId) && !TextUtils.isEmpty(email))
assignedCriterion = Criterion.or(Task.USER_EMAIL.eq(email), Task.USER.like("%" + email + "%")); //$NON-NLS-1$ //$NON-NLS-2$
assignedCriterion = Criterion.or(Task.USER_EMAIL.eq(email), Task.USER.like("%" + email + "%")); //$NON-NLS-1$ //$NON-NLS-2$ // Deprecated field OK for backwards compatibility
else
assignedCriterion = Task.USER_ID.eq(id);
Criterion assigned = Criterion.and(TaskCriteria.activeAndVisible(), assignedCriterion);

@ -92,7 +92,7 @@ public class JSONChangeToPropertyVisitor implements PropertyVisitor<Void, String
else if (property.checkFlag(Property.PROP_FLAG_USER_ID) && ActFmPreferenceService.userId().equals(value))
value = Task.USER_ID_SELF;
if (property.equals(Task.USER_ID))
model.setValue(Task.USER, "{}"); // Clear this value for migration purposes
model.setValue(Task.USER, ""); // Clear this value for migration purposes
model.setValue((StringProperty) property, value);
} catch (JSONException e) {

@ -93,7 +93,6 @@ public class NameMaps {
putTaskPropertyToServerName(Task.NOTES, "notes", false);
putTaskPropertyToServerName(Task.RECURRENCE, "repeat", false);
putTaskPropertyToServerName(Task.USER_ID, "user_id", false);
putTaskPropertyToServerName(Task.USER, "user", true);
putTaskPropertyToServerName(Task.CREATOR_ID, "creator_id", true);
putTaskPropertyToServerName(Task.UUID, "uuid", true);
putTaskPropertyToServerName(Task.PUSHED_AT, "pushed_at", true);

@ -8,9 +8,6 @@ package com.todoroo.astrid.people;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONException;
import org.json.JSONObject;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentValues;
@ -30,7 +27,6 @@ import com.todoroo.andlib.sql.Order;
import com.todoroo.andlib.sql.Query;
import com.todoroo.andlib.sql.QueryTemplate;
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
import com.todoroo.astrid.actfm.sync.ActFmSyncService;
import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.api.FilterListItem;
@ -80,7 +76,7 @@ public class PeopleFilterExposer extends BroadcastReceiver {
}
}
@SuppressWarnings("nls")
@SuppressWarnings({ "nls", "deprecation" })
private static FilterWithCustomIntent filterFromUserData(User user) {
String title = user.getDisplayName();
if (TextUtils.isEmpty(title) || "null".equals(title))
@ -91,8 +87,8 @@ public class PeopleFilterExposer extends BroadcastReceiver {
if (TextUtils.isEmpty(email) || "null".equals(email))
criterion = Task.USER_ID.eq(user.getValue(User.REMOTE_ID));
else
criterion = Criterion.or(Task.USER.like("%" + email + "%"),
Task.USER_ID.eq(user.getValue(User.REMOTE_ID)));
criterion = Criterion.or(Task.USER_ID.eq(user.getValue(User.UUID)),
Task.USER.like("%" + email + "%")); // Deprecated field OK for backwards compatibility
criterion = Criterion.and(TaskCriteria.activeAndVisible(), criterion);
@ -103,14 +99,7 @@ public class PeopleFilterExposer extends BroadcastReceiver {
filter.customTaskList = new ComponentName(ContextManager.getContext(), PersonViewFragment.class);
ContentValues values = new ContentValues();
values.put(Task.USER_ID.name, user.getValue(User.REMOTE_ID));
try {
JSONObject userJson = new JSONObject();
ActFmSyncService.JsonHelper.jsonFromUser(userJson, user);
values.put(Task.USER.name, userJson.toString());
} catch (JSONException e) {
// Ignored
}
values.put(Task.USER_ID.name, user.getValue(User.UUID));
filter.valuesForNewTasks = values;
String imageUrl = user.getValue(User.PICTURE);

@ -1146,6 +1146,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
pictureView.setDefaultImageResource(R.drawable.icn_anyone_transparent);
else {
pictureView.setDefaultImageResource(R.drawable.icn_default_person_image);
// TODO: Implement a join here
try {
JSONObject user = new JSONObject(task.getValue(Task.USER));
pictureView.setUrl(user.optString("picture")); //$NON-NLS-1$

@ -216,6 +216,7 @@ public class TaskService {
newTask.clearValue(Task.ID);
newTask.clearValue(Task.UUID);
newTask.clearValue(Task.USER);
newTask.clearValue(Task.USER_EMAIL);
newTask.clearValue(Task.USER_ID);
taskDao.save(newTask);

Loading…
Cancel
Save