Removed Task.USER_EMAIL column--just send emails in the user_id column

pull/14/head
Sam Bosley 12 years ago
parent 9853d90948
commit 4a03d185e5

@ -165,10 +165,6 @@ public final class Task extends RemoteModel {
@Deprecated public static final StringProperty USER = new StringProperty( @Deprecated public static final StringProperty USER = new StringProperty(
TABLE, USER_JSON_PROPERTY_NAME); TABLE, USER_JSON_PROPERTY_NAME);
/** User email (for assigning by email) */
public static final StringProperty USER_EMAIL = new StringProperty(
TABLE, "userEmail");
/** Creator user id */ /** Creator user id */
public static final StringProperty CREATOR_ID = new StringProperty( public static final StringProperty CREATOR_ID = new StringProperty(
TABLE, "creatorId", Property.PROP_FLAG_USER_ID); TABLE, "creatorId", Property.PROP_FLAG_USER_ID);
@ -218,6 +214,12 @@ public final class Task extends RemoteModel {
Task.USER_ID_IGNORE.equals(userId)); Task.USER_ID_IGNORE.equals(userId));
} }
public static boolean userIdIsEmail(String userId) {
if (userId == null)
return false;
return userId.indexOf('@') >= 0;
}
// --- notification flags // --- notification flags
/** whether to send a reminder at deadline */ /** 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(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(USER_EMAIL.name, ""); // defaultValues.put(USER_EMAIL.name, "");
defaultValues.put(PUSHED_AT.name, 0L); defaultValues.put(PUSHED_AT.name, 0L);
} }

@ -415,7 +415,7 @@ public class EditPeopleControlSet extends PopupControlSet {
private int findAssignedIndex(Task t, ArrayList<AssignedToUser>... userLists) { private int findAssignedIndex(Task t, ArrayList<AssignedToUser>... userLists) {
String assignedStr = t.getValue(Task.USER); String assignedStr = t.getValue(Task.USER);
long assignedId = -2; long assignedId = -2;
String assignedEmail = t.getValue(Task.USER_EMAIL); String assignedEmail = t.getValue(Task.USER_ID);
try { try {
JSONObject assigned = new JSONObject(assignedStr); JSONObject assigned = new JSONObject(assignedStr);
assignedId = assigned.optLong("id", -2); assignedId = assigned.optLong("id", -2);
@ -668,21 +668,20 @@ public class EditPeopleControlSet extends PopupControlSet {
} catch (JSONException e) { } catch (JSONException e) {
// sad times // sad times
taskUserId = task.getValue(Task.USER_ID); taskUserId = task.getValue(Task.USER_ID);
if (Task.USER_ID_EMAIL.equals(taskUserId)) if (Task.userIdIsEmail(taskUserId))
taskUserEmail = task.getValue(Task.USER_EMAIL); taskUserEmail = taskUserId;
} }
String userId = Long.toString(userJson.optLong("id", -2)); String userId = Long.toString(userJson.optLong("id", -2));
String userEmail = userJson.optString("email"); 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)); match = match || (userEmail.equals(taskUserEmail) && !TextUtils.isEmpty(userEmail));
dirty = match ? dirty : true; 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))) if (Task.USER_ID_EMAIL.equals(task.getValue(Task.USER_ID)))
task.setValue(Task.USER_EMAIL, userEmail); task.setValue(Task.USER_ID, userEmail);
else
task.setValue(Task.USER_EMAIL, "");
task.setValue(Task.USER, ""); task.setValue(Task.USER, "");
} }

@ -507,8 +507,8 @@ public class TagViewFragment extends TaskListFragment {
Criterion assignedCriterion; Criterion assignedCriterion;
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.userIdIsEmail(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 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 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);

@ -927,8 +927,8 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
String assignedTo = peopleControlSet.getAssignedToString(); String assignedTo = peopleControlSet.getAssignedToString();
String assignedEmail = ""; //$NON-NLS-1$ String assignedEmail = ""; //$NON-NLS-1$
String assignedId = Task.USER_ID_IGNORE; String assignedId = Task.USER_ID_IGNORE;
if (Task.USER_ID_EMAIL.equals(model.getValue(Task.USER_ID))) { if (Task.userIdIsEmail(model.getValue(Task.USER_ID))) {
assignedEmail = model.getValue(Task.USER_EMAIL); assignedEmail = model.getValue(Task.USER_ID);
} }
if (taskEditActivity) { if (taskEditActivity) {

@ -39,8 +39,8 @@ 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.TaskToTagMetadata;
import com.todoroo.astrid.tags.TagService; import com.todoroo.astrid.tags.TagService;
import com.todoroo.astrid.tags.TaskToTagMetadata;
import com.todoroo.astrid.utility.TitleParser; import com.todoroo.astrid.utility.TitleParser;
@ -216,7 +216,6 @@ 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);

@ -326,8 +326,8 @@ public class QuickAddBar extends LinearLayout {
String assignedTo = peopleControl.getAssignedToString(); String assignedTo = peopleControl.getAssignedToString();
String assignedEmail = ""; String assignedEmail = "";
String assignedId = task.getValue(Task.USER_ID); String assignedId = task.getValue(Task.USER_ID);
if (Task.USER_ID_EMAIL.equals(task.getValue(Task.USER_ID))) { if (Task.userIdIsEmail(task.getValue(Task.USER_ID))) {
assignedEmail = task.getValue(Task.USER_EMAIL); assignedEmail = task.getValue(Task.USER_ID);
} }
resetControlSets(); resetControlSets();

Loading…
Cancel
Save