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(UUID.name, NO_UUID);
defaultValues.put(USER_ID.name, "0"); defaultValues.put(USER_ID.name, "0");
defaultValues.put(CREATOR_ID.name, 0); defaultValues.put(CREATOR_ID.name, 0);
defaultValues.put(USER.name, "{}"); defaultValues.put(USER.name, "");
defaultValues.put(PUSHED_AT.name, 0L); 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)))) { 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; 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_ID, Task.USER_ID_SELF);
task.setValue(Task.USER, "{}"); task.setValue(Task.USER, "");
assignedToMe = true; assignedToMe = true;
} else if(Task.USER_ID_UNASSIGNED.equals(Long.toString(userJson.optLong("id")))) { } else if(Task.USER_ID_UNASSIGNED.equals(Long.toString(userJson.optLong("id")))) {
dirty = task.getValue(Task.USER_ID) == Task.USER_ID_UNASSIGNED ? dirty : true; 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_ID, Task.USER_ID_UNASSIGNED);
task.setValue(Task.USER, "{}"); task.setValue(Task.USER, "");
} else { } else {
String user = userJson.toString(); String user = userJson.toString();
String taskUserId = Task.USER_ID_EMAIL; String taskUserId = Task.USER_ID_EMAIL;
String taskUserEmail = ""; String taskUserEmail = "";
try { try {
@SuppressWarnings("deprecation") // For backwards compatibility
JSONObject taskUser = new JSONObject(task.getValue(Task.USER)); JSONObject taskUser = new JSONObject(task.getValue(Task.USER));
taskUserId = Long.toString(taskUser.optLong("id", -2)); taskUserId = Long.toString(taskUser.optLong("id", -2));
taskUserEmail = taskUser.optString("email"); taskUserEmail = taskUser.optString("email");
@ -687,7 +688,7 @@ public class EditPeopleControlSet extends PopupControlSet {
task.setValue(Task.USER_EMAIL, userEmail); task.setValue(Task.USER_EMAIL, userEmail);
else else
task.setValue(Task.USER_EMAIL, ""); task.setValue(Task.USER_EMAIL, "");
task.setValue(Task.USER, "{}"); task.setValue(Task.USER, "");
} }
if(dirty && !actFmPreferenceService.isLoggedIn()) { 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) { private OnClickListener listenerForImage(final JSONObject member, final String id, final String displayName) {
return new OnClickListener() { return new OnClickListener() {
final String email = member.optString("email"); //$NON-NLS-1$ final String email = member.optString("email"); //$NON-NLS-1$
@SuppressWarnings("deprecation")
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (currentId.equals(id)) { if (currentId.equals(id)) {
@ -434,7 +435,7 @@ public class TagViewFragment extends TaskListFragment {
if (ActFmPreferenceService.userId().equals(currentId)) if (ActFmPreferenceService.userId().equals(currentId))
assignedCriterion = Criterion.or(Task.USER_ID.eq(0), Task.USER_ID.eq(id)); assignedCriterion = Criterion.or(Task.USER_ID.eq(0), Task.USER_ID.eq(id));
else if (Task.USER_ID_EMAIL.equals(currentId) && !TextUtils.isEmpty(email)) 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 else
assignedCriterion = Task.USER_ID.eq(id); assignedCriterion = Task.USER_ID.eq(id);
Criterion assigned = Criterion.and(TaskCriteria.activeAndVisible(), assignedCriterion); 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)) else if (property.checkFlag(Property.PROP_FLAG_USER_ID) && ActFmPreferenceService.userId().equals(value))
value = Task.USER_ID_SELF; value = Task.USER_ID_SELF;
if (property.equals(Task.USER_ID)) 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); model.setValue((StringProperty) property, value);
} catch (JSONException e) { } catch (JSONException e) {

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

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

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

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

Loading…
Cancel
Save