diff --git a/api/src/com/todoroo/astrid/data/Task.java b/api/src/com/todoroo/astrid/data/Task.java index 9abd49319..18df8e6f4 100644 --- a/api/src/com/todoroo/astrid/data/Task.java +++ b/api/src/com/todoroo/astrid/data/Task.java @@ -165,10 +165,6 @@ public final class Task extends RemoteModel { @Deprecated public static final StringProperty USER = new StringProperty( TABLE, USER_JSON_PROPERTY_NAME); - /** User email (for assigning by email) */ - public static final StringProperty USER_EMAIL = new StringProperty( - TABLE, "userEmail"); - /** Creator user id */ public static final StringProperty CREATOR_ID = new StringProperty( TABLE, "creatorId", Property.PROP_FLAG_USER_ID); @@ -218,6 +214,12 @@ public final class Task extends RemoteModel { Task.USER_ID_IGNORE.equals(userId)); } + public static boolean userIdIsEmail(String userId) { + if (userId == null) + return false; + return userId.indexOf('@') >= 0; + } + // --- notification flags /** whether to send a reminder at deadline */ @@ -301,7 +303,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(USER_EMAIL.name, ""); defaultValues.put(PUSHED_AT.name, 0L); } diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/EditPeopleControlSet.java b/astrid/plugin-src/com/todoroo/astrid/actfm/EditPeopleControlSet.java index 2ad4ae531..e175d03df 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/EditPeopleControlSet.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/EditPeopleControlSet.java @@ -415,7 +415,7 @@ public class EditPeopleControlSet extends PopupControlSet { private int findAssignedIndex(Task t, ArrayList... userLists) { String assignedStr = t.getValue(Task.USER); long assignedId = -2; - String assignedEmail = t.getValue(Task.USER_EMAIL); + String assignedEmail = t.getValue(Task.USER_ID); try { JSONObject assigned = new JSONObject(assignedStr); assignedId = assigned.optLong("id", -2); @@ -668,21 +668,20 @@ public class EditPeopleControlSet extends PopupControlSet { } catch (JSONException e) { // sad times taskUserId = task.getValue(Task.USER_ID); - if (Task.USER_ID_EMAIL.equals(taskUserId)) - taskUserEmail = task.getValue(Task.USER_EMAIL); + if (Task.userIdIsEmail(taskUserId)) + taskUserEmail = taskUserId; } String userId = Long.toString(userJson.optLong("id", -2)); String userEmail = userJson.optString("email"); - boolean match = (userId.equals(taskUserId) && !Task.USER_ID_EMAIL.equals(userId)); + boolean match = userId.equals(taskUserId); match = match || (userEmail.equals(taskUserEmail) && !TextUtils.isEmpty(userEmail)); dirty = match ? dirty : true; - task.setValue(Task.USER_ID, Long.toString(userJson.optLong("id", -2))); + String willAssignToId = Long.toString(userJson.optLong("id", -2)); + task.setValue(Task.USER_ID, willAssignToId); if (Task.USER_ID_EMAIL.equals(task.getValue(Task.USER_ID))) - task.setValue(Task.USER_EMAIL, userEmail); - else - task.setValue(Task.USER_EMAIL, ""); + task.setValue(Task.USER_ID, userEmail); task.setValue(Task.USER, ""); } diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewFragment.java b/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewFragment.java index e45be0921..4f3889416 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewFragment.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewFragment.java @@ -507,8 +507,8 @@ public class TagViewFragment extends TaskListFragment { Criterion assignedCriterion; 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$ // Deprecated field OK for backwards compatibility + else if (Task.userIdIsEmail(currentId) && !TextUtils.isEmpty(email)) + assignedCriterion = Criterion.or(Task.USER_ID.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); diff --git a/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java b/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java index f9d282163..c0cc8a9a0 100755 --- a/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java @@ -927,8 +927,8 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener { String assignedTo = peopleControlSet.getAssignedToString(); String assignedEmail = ""; //$NON-NLS-1$ String assignedId = Task.USER_ID_IGNORE; - if (Task.USER_ID_EMAIL.equals(model.getValue(Task.USER_ID))) { - assignedEmail = model.getValue(Task.USER_EMAIL); + if (Task.userIdIsEmail(model.getValue(Task.USER_ID))) { + assignedEmail = model.getValue(Task.USER_ID); } if (taskEditActivity) { diff --git a/astrid/src/com/todoroo/astrid/service/TaskService.java b/astrid/src/com/todoroo/astrid/service/TaskService.java index 6326783b8..404a1f313 100644 --- a/astrid/src/com/todoroo/astrid/service/TaskService.java +++ b/astrid/src/com/todoroo/astrid/service/TaskService.java @@ -39,8 +39,8 @@ import com.todoroo.astrid.gcal.GCalHelper; import com.todoroo.astrid.gtasks.GtasksMetadata; import com.todoroo.astrid.opencrx.OpencrxCoreUtils; import com.todoroo.astrid.producteev.sync.ProducteevTask; -import com.todoroo.astrid.tags.TaskToTagMetadata; import com.todoroo.astrid.tags.TagService; +import com.todoroo.astrid.tags.TaskToTagMetadata; import com.todoroo.astrid.utility.TitleParser; @@ -216,7 +216,6 @@ 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); diff --git a/astrid/src/com/todoroo/astrid/ui/QuickAddBar.java b/astrid/src/com/todoroo/astrid/ui/QuickAddBar.java index 0ea2de0f9..a29a5187d 100644 --- a/astrid/src/com/todoroo/astrid/ui/QuickAddBar.java +++ b/astrid/src/com/todoroo/astrid/ui/QuickAddBar.java @@ -326,8 +326,8 @@ public class QuickAddBar extends LinearLayout { String assignedTo = peopleControl.getAssignedToString(); String assignedEmail = ""; String assignedId = task.getValue(Task.USER_ID); - if (Task.USER_ID_EMAIL.equals(task.getValue(Task.USER_ID))) { - assignedEmail = task.getValue(Task.USER_EMAIL); + if (Task.userIdIsEmail(task.getValue(Task.USER_ID))) { + assignedEmail = task.getValue(Task.USER_ID); } resetControlSets();