Fixed several references to non-string userids

pull/14/head
Sam Bosley 12 years ago
parent 51bf8445e6
commit c7d7167763

@ -165,6 +165,10 @@ 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);
@ -209,6 +213,15 @@ public final class Task extends RemoteModel {
/** user id = myself */
public static final String USER_ID_SELF = "0";
public static boolean isRealUserId(String userId) {
if (userId == null)
return false;
return !(Task.USER_ID_SELF.equals(userId) ||
Task.USER_ID_UNASSIGNED.equals(userId) ||
Task.USER_ID_EMAIL.equals(userId) ||
Task.USER_ID_IGNORE.equals(userId));
}
// --- notification flags
/** whether to send a reminder at deadline */

@ -200,21 +200,10 @@ public class GCMIntentService extends GCMBaseIntentService {
Intent notifyIntent = null;
int notifId;
long user_idTemp = -2;
final String user_idString = intent.getStringExtra("oid");
if (user_idString != null) {
try {
user_idTemp = Long.parseLong(user_idString);
} catch(NumberFormatException e) {
// We tried
Log.e("c2dm-receive", "oid-parse", e);
}
}
final long user_id = user_idTemp;
final String user_id = intent.getStringExtra("oid");
final String token_id = intent.getStringExtra("tid");
// unregister
if (!actFmPreferenceService.isLoggedIn() || user_id != ActFmPreferenceService.userId()) {
if (!actFmPreferenceService.isLoggedIn() || !ActFmPreferenceService.userId().equals(user_id)) {
new Thread() {
@Override
public void run() {
@ -372,11 +361,10 @@ public class GCMIntentService extends GCMBaseIntentService {
try {
Update update = new Update();
update.setValue(Update.UUID, intent.getStringExtra("activity_id"));
update.setValue(Update.USER_ID, Long.parseLong(intent.getStringExtra("user_id")));
update.setValue(Update.USER_ID, intent.getStringExtra("user_id"));
JSONObject user = new JSONObject();
user.put("id", update.getValue(Update.USER_ID));
user.put("name", intent.getStringExtra("user_name"));
update.setValue(Update.USER, user.toString());
update.setValue(Update.ACTION, "commented");
update.setValue(Update.ACTION_CODE, "tag_comment");
update.setValue(Update.TARGET_NAME, intent.getStringExtra("title"));

@ -8,9 +8,7 @@ package com.todoroo.astrid.actfm.sync;
import org.json.JSONException;
import org.json.JSONObject;
import android.content.ContentValues;
import android.content.Context;
import android.text.TextUtils;
import com.todoroo.andlib.data.Property;
import com.todoroo.andlib.data.TodorooCursor;
@ -27,7 +25,6 @@ import com.todoroo.astrid.dao.UserDao;
import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.User;
import com.todoroo.astrid.service.MetadataService;
import com.todoroo.astrid.service.TagDataService;
import com.todoroo.astrid.tags.TagService;
@ -142,43 +139,4 @@ public final class ActFmDataService {
cursor.close();
}
}
/**
* Save / Merge JSON user
* @param userObject
* @throws JSONException
*/
@SuppressWarnings("nls")
public void saveUserData(JSONObject userObject) throws JSONException {
Criterion criterion = User.REMOTE_ID.eq(userObject.getLong("id"));
if (!TextUtils.isEmpty(userObject.optString("email")))
criterion = Criterion.or(criterion, Criterion.and(User.EMAIL.isNotNull(), User.EMAIL.eq(userObject.optString("email"))));
TodorooCursor<User> cursor = userDao.query(Query.select(User.PROPERTIES).where(criterion));
try {
cursor.moveToFirst();
User user = new User();
if (!cursor.isAfterLast()) {
user.readFromCursor(cursor);
}
ActFmSyncService.JsonHelper.userFromJson(userObject, user);
userDao.persist(user);
} finally {
cursor.close();
}
}
public void addUserByEmail(String email) {
TodorooCursor<User> cursor = userDao.query(Query.select(User.ID).where(User.EMAIL.eq(email)));
try {
if (cursor.getCount() == 0) {
User user = new User();
user.setValue(User.REMOTE_ID, Task.USER_ID_IGNORE);
user.setValue(User.EMAIL, email);
userDao.persist(user);
}
} finally {
cursor.close();
}
}
}

@ -71,8 +71,6 @@ import com.todoroo.astrid.gtasks.GtasksMetadata;
import com.todoroo.astrid.gtasks.GtasksPreferenceService;
import com.todoroo.astrid.helper.ImageDiskCache;
import com.todoroo.astrid.service.MetadataService;
import com.todoroo.astrid.service.StatisticsConstants;
import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.service.TagDataService;
import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.service.abtesting.ABTestEventReportingService;
@ -437,29 +435,29 @@ public final class ActFmSyncService {
boolean sharing = false;
if(values.containsKey(Task.USER_ID.name) && task.getTransitory(TaskService.TRANS_ASSIGNED) != null) {
if(task.getValue(Task.USER_ID) == Task.USER_ID_EMAIL) {
try {
JSONObject user = new JSONObject(task.getValue(Task.USER));
String userEmail = user.optString("email");
if (!TextUtils.isEmpty(userEmail)) {
params.add("user_email");
params.add(userEmail);
actFmDataService.addUserByEmail(userEmail);
sharing = true;
}
} catch (JSONException e) {
Log.e("Error parsing user", task.getValue(Task.USER), e);
}
} else {
params.add("user_id");
if(task.getValue(Task.USER_ID) == Task.USER_ID_SELF)
params.add(ActFmPreferenceService.userId());
else
params.add(task.getValue(Task.USER_ID));
}
}
// if(values.containsKey(Task.USER_ID.name) && task.getTransitory(TaskService.TRANS_ASSIGNED) != null) {
// if(task.getValue(Task.USER_ID) == Task.USER_ID_EMAIL) {
// try {
// JSONObject user = new JSONObject(task.getValue(Task.USER));
// String userEmail = user.optString("email");
// if (!TextUtils.isEmpty(userEmail)) {
// params.add("user_email");
// params.add(userEmail);
//
// actFmDataService.addUserByEmail(userEmail);
// sharing = true;
// }
// } catch (JSONException e) {
// Log.e("Error parsing user", task.getValue(Task.USER), e);
// }
// } else {
// params.add("user_id");
// if(task.getValue(Task.USER_ID) == Task.USER_ID_SELF)
// params.add(ActFmPreferenceService.userId());
// else
// params.add(task.getValue(Task.USER_ID));
// }
// }
// if (values.containsKey(Task.SHARED_WITH.name)) {
// try {
@ -1067,11 +1065,11 @@ public final class ActFmSyncService {
}
private void saveUsers(JSONArray users, HashSet<Long> ids) throws JSONException {
for (int i = 0; i < users.length(); i++) {
JSONObject userObject = users.getJSONObject(i);
ids.add(userObject.optLong("id"));
actFmDataService.saveUserData(userObject);
}
// for (int i = 0; i < users.length(); i++) {
// JSONObject userObject = users.getJSONObject(i);
// ids.add(userObject.optLong("id"));
// actFmDataService.saveUserData(userObject);
// }
}
public int fetchUsers() throws JSONException, IOException {
@ -1498,12 +1496,12 @@ public final class ActFmSyncService {
JsonHelper.taskFromJson(item, remote, metadata);
if(remote.getValue(Task.USER_ID) == 0) {
if(!remote.isSaved())
StatisticsService.reportEvent(StatisticsConstants.ACTFM_TASK_CREATED);
else if(remote.isCompleted())
StatisticsService.reportEvent(StatisticsConstants.ACTFM_TASK_COMPLETED);
}
// if(remote.getValue(Task.USER_ID) == 0) {
// if(!remote.isSaved())
// StatisticsService.reportEvent(StatisticsConstants.ACTFM_TASK_CREATED);
// else if(remote.isCompleted())
// StatisticsService.reportEvent(StatisticsConstants.ACTFM_TASK_COMPLETED);
// }
if(!remote.isSaved() && remote.hasDueDate() &&
remote.getValue(Task.DUE_DATE) < DateUtilities.now())
@ -1713,10 +1711,10 @@ public final class ActFmSyncService {
public static void updateFromJson(JSONObject json, Update model) throws JSONException {
model.setValue(Update.REMOTE_ID, json.getLong("id"));
readUser(json.getJSONObject("user"), model, Update.USER_ID, Update.USER);
if (!json.isNull("other_user")) {
readUser(json.getJSONObject("other_user"), model, Update.OTHER_USER_ID, Update.OTHER_USER);
}
// readUser(json.getJSONObject("user"), model, Update.USER_ID, Update.USER);
// if (!json.isNull("other_user")) {
// readUser(json.getJSONObject("other_user"), model, Update.OTHER_USER_ID, Update.OTHER_USER);
// }
model.setValue(Update.ACTION, json.getString("action"));
model.setValue(Update.ACTION_CODE, json.getString("action_code"));
model.setValue(Update.TARGET_NAME, json.getString("target_name"));
@ -1733,23 +1731,23 @@ public final class ActFmSyncService {
public static void readUser(JSONObject user, AbstractModel model, LongProperty idProperty,
StringProperty userProperty) throws JSONException {
long id = user.optLong("id", -2);
if(id == -2) {
model.setValue(idProperty, -1L);
if(userProperty != null) {
JSONObject unassigned = new JSONObject();
unassigned.put("id", -1L);
model.setValue(userProperty, unassigned.toString());
}
} else if (id == ActFmPreferenceService.userId()) {
model.setValue(idProperty, 0L);
if (userProperty != null)
model.setValue(userProperty, ActFmPreferenceService.thisUser().toString());
} else {
model.setValue(idProperty, id);
if(userProperty != null)
model.setValue(userProperty, user.toString());
}
// long id = user.optLong("id", -2);
// if(id == -2) {
// model.setValue(idProperty, -1L);
// if(userProperty != null) {
// JSONObject unassigned = new JSONObject();
// unassigned.put("id", -1L);
// model.setValue(userProperty, unassigned.toString());
// }
// } else if (id == ActFmPreferenceService.userId()) {
// model.setValue(idProperty, 0L);
// if (userProperty != null)
// model.setValue(userProperty, ActFmPreferenceService.thisUser().toString());
// } else {
// model.setValue(idProperty, id);
// if(userProperty != null)
// model.setValue(userProperty, user.toString());
// }
}
/**
@ -1771,8 +1769,8 @@ public final class ActFmSyncService {
model.setValue(TagData.REMOTE_ID, json.getLong("id"));
model.setValue(TagData.NAME, json.getString("name"));
if (!featuredList)
readUser(json.getJSONObject("user"), model, TagData.USER_ID, TagData.USER);
// if (!featuredList)
// readUser(json.getJSONObject("user"), model, TagData.USER_ID, TagData.USER);
if (featuredList)
model.setFlag(TagData.FLAGS, TagData.FLAG_FEATURED, true);
@ -1819,8 +1817,8 @@ public final class ActFmSyncService {
model.setValue(Task.UUID, null);
else
model.setValue(Task.UUID, remoteId);
readUser(json.getJSONObject("user"), model, Task.USER_ID, Task.USER);
readUser(json.getJSONObject("creator"), model, Task.CREATOR_ID, null);
// readUser(json.getJSONObject("user"), model, Task.USER_ID, Task.USER);
// readUser(json.getJSONObject("creator"), model, Task.CREATOR_ID, null);
model.setValue(Task.TITLE, json.getString("title"));
model.setValue(Task.IMPORTANCE, json.getInt("importance"));
int urgency = json.getBoolean("has_due_time") ? Task.URGENCY_SPECIFIC_DAY_TIME : Task.URGENCY_SPECIFIC_DAY;

@ -76,10 +76,10 @@ public class ActFmSyncV2Provider extends SyncV2Provider {
@Override
public void pushRemoteModel(Task model) {
long userId = model.getValue(Task.USER_ID);
if (userId != Task.USER_ID_SELF && userId != ActFmPreferenceService.userId())
model.putTransitory(TaskService.TRANS_ASSIGNED, true);
actFmSyncService.pushTaskOnSave(model, model.getMergedValues());
// long userId = model.getValue(Task.USER_ID);
// if (userId != Task.USER_ID_SELF && userId != ActFmPreferenceService.userId())
// model.putTransitory(TaskService.TRANS_ASSIGNED, true);
// actFmSyncService.pushTaskOnSave(model, model.getMergedValues());
}
};

@ -199,7 +199,7 @@ public final class GtasksSyncService {
com.google.api.services.tasks.model.Task remoteModel = null;
boolean newlyCreated = false;
if (values.containsKey(Task.USER_ID.name) && values.getAsLong(Task.USER_ID.name) != Task.USER_ID_SELF) {
if (values.containsKey(Task.USER_ID.name) && !Task.USER_ID_SELF.equals(values.getAsString(Task.USER_ID.name))) {
if (gtasksMetadata != null && !TextUtils.isEmpty(gtasksMetadata.getValue(GtasksMetadata.ID))) {
try {
invoker.deleteGtask(gtasksMetadata.getValue(GtasksMetadata.LIST_ID), gtasksMetadata.getValue(GtasksMetadata.ID));

@ -440,7 +440,7 @@ public class EditNoteActivity extends LinearLayout implements TimerActionListene
Update update = new Update();
update.setValue(Update.MESSAGE, message);
update.setValue(Update.ACTION_CODE, actionCode);
update.setValue(Update.USER_ID, 0L);
update.setValue(Update.USER_ID, Task.USER_ID_SELF);
if(task.containsNonNullValue(Task.UUID) && !RemoteModel.NO_UUID.equals(task.getValue(Task.UUID)))
update.setValue(Update.TASK_UUID, task.getValue(Task.UUID));
update.setValue(Update.TASK_LOCAL, task.getId());

@ -68,7 +68,7 @@ public class PeopleFilterExposer extends BroadcastReceiver {
User user = new User();
for (users.moveToFirst(); !users.isAfterLast(); users.moveToNext()) {
user.readFromCursor(users);
if (user.getValue(User.REMOTE_ID) == ActFmPreferenceService.userId())
if (ActFmPreferenceService.userId().equals(user.getValue(User.UUID)))
continue;
Filter currFilter = filterFromUserData(user);
if (currFilter != null)

@ -160,7 +160,7 @@ public class Notifications extends BroadcastReceiver {
if (!Preferences.getBoolean(R.string.p_rmd_enabled, true))
return false;
// you're done, or not yours - don't sound, do delete
if(task.isCompleted() || task.isDeleted() || task.getValue(Task.USER_ID) != 0)
if(task.isCompleted() || task.isDeleted() || !Task.USER_ID_SELF.equals(task.getValue(Task.USER_ID)))
return false;
// new task edit in progress

@ -192,7 +192,7 @@ public final class ReminderService {
// Make sure no alarms are scheduled other than the next one. When that one is shown, it
// will schedule the next one after it, and so on and so forth.
clearAllAlarms(task);
if(task.isCompleted() || task.isDeleted() || task.getValue(Task.USER_ID) != 0) {
if(task.isCompleted() || task.isDeleted() || !Task.USER_ID_SELF.equals(task.getValue(Task.USER_ID))) {
return;
}

@ -42,6 +42,7 @@ import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.RemoteModel;
import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.gtasks.GtasksPreferenceService;
import com.todoroo.astrid.service.AstridDependencyInjector;
import com.todoroo.astrid.service.TagDataService;
@ -83,7 +84,7 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE
}
int deleteIntentLabel;
if (tag.memberCount > 0 && tag.userId != 0)
if (tag.memberCount > 0 && !Task.USER_ID_SELF.equals(tag.userId))
deleteIntentLabel = R.string.tag_cm_leave;
else
deleteIntentLabel = R.string.tag_cm_delete;
@ -219,7 +220,7 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE
TagData tagData = tagDataService.getTag(tag, TagData.MEMBER_COUNT, TagData.USER_ID);
if(tagData != null && tagData.getValue(TagData.MEMBER_COUNT) > 0 && tagData.getValue(TagData.USER_ID) == 0) {
if(tagData != null && tagData.getValue(TagData.MEMBER_COUNT) > 0 && Task.USER_ID_SELF.equals(tagData.getValue(TagData.USER_ID))) {
DialogUtilities.okCancelDialog(this, getString(R.string.actfm_tag_operation_owner_delete), getOkListener(), getCancelListener());
return;
}

@ -108,7 +108,7 @@ public final class TagService {
public long id;
public String uuid;
public String image;
public long userId;
public String userId;
public long memberCount;
@Deprecated public long remoteId;
@ -416,7 +416,7 @@ public final class TagService {
if(tagData != null) {
tagData.setValue(TagData.DELETION_DATE, DateUtilities.now());
PluginServices.getTagDataService().save(tagData);
shared = tagData.getValue(TagData.MEMBER_COUNT) > 0 && tagData.getValue(TagData.USER_ID) != 0; // Was I a list member and NOT owner?
shared = tagData.getValue(TagData.MEMBER_COUNT) > 0 && !Task.USER_ID_SELF.equals(tagData.getValue(TagData.USER_ID)); // Was I a list member and NOT owner?
}
Toast.makeText(context, context.getString(shared ? R.string.TEA_tags_left : R.string.TEA_tags_deleted, tag, deleted),
Toast.LENGTH_SHORT).show();

@ -14,9 +14,6 @@ import java.util.List;
import java.util.Locale;
import java.util.concurrent.atomic.AtomicReference;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
@ -932,13 +929,9 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
&& !TextUtils.isEmpty(model.getValue(Task.RECURRENCE));
String assignedTo = peopleControlSet.getAssignedToString();
String assignedEmail = ""; //$NON-NLS-1$
long assignedId = Task.USER_ID_IGNORE;
try {
JSONObject assignedUser = new JSONObject(model.getValue(Task.USER));
assignedEmail = assignedUser.optString("email", ""); //$NON-NLS-1$ //$NON-NLS-2$
assignedId = assignedUser.optLong("id", Task.USER_ID_IGNORE); //$NON-NLS-1$
} catch (JSONException e) {
//
String assignedId = Task.USER_ID_IGNORE;
if (Task.USER_ID_EMAIL.equals(model.getValue(Task.USER_ID))) {
assignedEmail = model.getValue(Task.USER_EMAIL);
}
if (taskEditActivity) {
@ -948,7 +941,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
data.putExtra(TOKEN_ASSIGNED_TO_DISPLAY, assignedTo);
if (!TextUtils.isEmpty(assignedEmail))
data.putExtra(TOKEN_ASSIGNED_TO_EMAIL, assignedEmail);
if (assignedId > 0)
if (Task.isRealUserId(assignedId));
data.putExtra(TOKEN_ASSIGNED_TO_ID, assignedId);
}
if (showRepeatAlert) {

@ -5,10 +5,6 @@
*/
package com.todoroo.astrid.activity;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.animation.LayoutTransition;
import android.app.Activity;
import android.app.SearchManager;
@ -51,7 +47,6 @@ import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.api.FilterListItem;
import com.todoroo.astrid.core.CustomFilterExposer;
import com.todoroo.astrid.core.PluginServices;
import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.people.PeopleFilterMode;
@ -628,7 +623,7 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
if (data.getBooleanExtra(TaskEditFragment.TOKEN_TASK_WAS_ASSIGNED, false)) {
String assignedTo = data.getStringExtra(TaskEditFragment.TOKEN_ASSIGNED_TO_DISPLAY);
String assignedEmail = data.getStringExtra(TaskEditFragment.TOKEN_ASSIGNED_TO_EMAIL);
long assignedId = data.getLongExtra(TaskEditFragment.TOKEN_ASSIGNED_TO_ID, Task.USER_ID_IGNORE);
String assignedId = data.getStringExtra(TaskEditFragment.TOKEN_ASSIGNED_TO_ID);
taskAssignedTo(assignedTo, assignedEmail, assignedId);
} else if (data.getParcelableExtra(TaskEditFragment.TOKEN_NEW_REPEATING_TASK) != null) {
Task repeating = data.getParcelableExtra(TaskEditFragment.TOKEN_NEW_REPEATING_TASK);
@ -664,7 +659,7 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
tlf.refresh();
}
public void taskAssignedTo(final String assignedDisplay, String assignedEmail, final long assignedId) {
public void taskAssignedTo(final String assignedDisplay, String assignedEmail, final String assignedId) {
final TaskListFragment tlf = getTaskListFragment();
if (tlf != null && tlf.isInbox()) {
DialogInterface.OnClickListener okListener = new DialogInterface.OnClickListener() {
@ -679,72 +674,73 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
getString(R.string.actfm_view_task_text, assignedDisplay),
R.string.actfm_view_task_ok, R.string.actfm_view_task_cancel,
0, okListener, null);
} else if (tlf != null && (!TextUtils.isEmpty(assignedEmail) || assignedId > 0)) {
} else if (tlf != null && (!TextUtils.isEmpty(assignedEmail) || Task.isRealUserId(assignedId))) {
checkAddTagMember(tlf, assignedDisplay, assignedEmail, assignedId);
}
}
private void checkAddTagMember(final TaskListFragment tlf, final String assignedDisplay, String assignedEmail, long assignedId) {
final TagData td = tlf.getActiveTagData();
if (td != null) {
String members = td.getValue(TagData.MEMBERS);
if (members == null)
members = ""; //$NON-NLS-1$
if (TextUtils.isEmpty(members) || TextUtils.isEmpty(assignedEmail) || !members.contains(assignedEmail)) {
// show dialog to ask if user should be added to the tag-members
JSONObject user = new JSONObject();
JSONArray membersArray = null;
boolean memberFound = false;
try {
if (!TextUtils.isEmpty(assignedEmail))
user.put("email", assignedEmail); //$NON-NLS-1$
if (assignedId > 0)
user.put("id", assignedId); //$NON-NLS-1$
membersArray = new JSONArray(members);
for (int i = 0; i < membersArray.length(); i++) {
JSONObject member = membersArray.getJSONObject(i);
long memberId = member.optLong("id", Task.USER_ID_IGNORE); //$NON-NLS-1$
if (memberId > 0 && memberId == assignedId) {
memberFound = true;
break;
}
}
if (!memberFound) {
String ownerString = td.getValue(TagData.USER);
JSONObject owner = new JSONObject(ownerString);
long ownerId = owner.optLong("id", Task.USER_ID_IGNORE); //$NON-NLS-1$
if (ownerId > 0 && assignedId == ownerId)
memberFound = true;
}
} catch (JSONException e) {
return;
}
if (memberFound)
return;
membersArray.put(user);
final JSONArray finalArray = membersArray;
DialogInterface.OnClickListener okListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface d, int which) {
td.setValue(TagData.MEMBERS, finalArray.toString());
td.setValue(TagData.MEMBER_COUNT, finalArray.length());
PluginServices.getTagDataService().save(td);
tlf.refresh();
}
};
DialogUtilities.okCancelCustomDialog(this,
getString(R.string.actfm_EPA_add_person_to_list_title),
getString(R.string.actfm_EPA_add_person_to_list, assignedDisplay, assignedDisplay),
R.string.actfm_EPA_add_person_to_list_ok,
R.string.actfm_EPA_add_person_to_list_cancel,
android.R.drawable.ic_dialog_alert,
okListener, null);
}
}
private void checkAddTagMember(final TaskListFragment tlf, final String assignedDisplay, String assignedEmail, String assignedId) {
throw new RuntimeException("Hey Sam! You should reimplement this");
// final TagData td = tlf.getActiveTagData();
// if (td != null) {
// String members = td.getValue(TagData.MEMBERS);
// if (members == null)
// members = ""; //$NON-NLS-1$
// if (TextUtils.isEmpty(members) || TextUtils.isEmpty(assignedEmail) || !members.contains(assignedEmail)) {
// // show dialog to ask if user should be added to the tag-members
// JSONObject user = new JSONObject();
// JSONArray membersArray = null;
// boolean memberFound = false;
// try {
// if (!TextUtils.isEmpty(assignedEmail))
// user.put("email", assignedEmail); //$NON-NLS-1$
// if (assignedId > 0)
// user.put("id", assignedId); //$NON-NLS-1$
// membersArray = new JSONArray(members);
//
// for (int i = 0; i < membersArray.length(); i++) {
// JSONObject member = membersArray.getJSONObject(i);
// long memberId = member.optLong("id", Task.USER_ID_IGNORE); //$NON-NLS-1$
// if (memberId > 0 && memberId == assignedId) {
// memberFound = true;
// break;
// }
// }
// if (!memberFound) {
// String ownerString = td.getValue(TagData.USER);
// JSONObject owner = new JSONObject(ownerString);
// long ownerId = owner.optLong("id", Task.USER_ID_IGNORE); //$NON-NLS-1$
// if (ownerId > 0 && assignedId == ownerId)
// memberFound = true;
// }
// } catch (JSONException e) {
// return;
// }
//
// if (memberFound)
// return;
//
// membersArray.put(user);
//
// final JSONArray finalArray = membersArray;
// DialogInterface.OnClickListener okListener = new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface d, int which) {
// td.setValue(TagData.MEMBERS, finalArray.toString());
// td.setValue(TagData.MEMBER_COUNT, finalArray.length());
// PluginServices.getTagDataService().save(td);
// tlf.refresh();
// }
// };
// DialogUtilities.okCancelCustomDialog(this,
// getString(R.string.actfm_EPA_add_person_to_list_title),
// getString(R.string.actfm_EPA_add_person_to_list, assignedDisplay, assignedDisplay),
// R.string.actfm_EPA_add_person_to_list_ok,
// R.string.actfm_EPA_add_person_to_list_cancel,
// android.R.drawable.ic_dialog_alert,
// okListener, null);
// }
// }
}
public void incrementFilterCount(Filter filter) {

@ -467,8 +467,8 @@ public class TaskService {
Task original = new Task();
original.setId(itemId);
Task clone = clone(original);
long userId = clone.getValue(Task.USER_ID);
if (userId != Task.USER_ID_SELF && userId != ActFmPreferenceService.userId())
String userId = clone.getValue(Task.USER_ID);
if (!Task.USER_ID_SELF.equals(userId) && !ActFmPreferenceService.userId().equals(userId))
clone.putTransitory(TRANS_ASSIGNED, true);
clone.setValue(Task.CREATION_DATE, DateUtilities.now());
clone.setValue(Task.COMPLETION_DATE, 0L);

@ -8,9 +8,6 @@ package com.todoroo.astrid.ui;
import java.util.HashSet;
import java.util.concurrent.atomic.AtomicReference;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.content.ContentValues;
import android.content.Context;
@ -328,13 +325,9 @@ public class QuickAddBar extends LinearLayout {
String assignedTo = peopleControl.getAssignedToString();
String assignedEmail = "";
long assignedId = Task.USER_ID_IGNORE;
try {
JSONObject assignedUser = new JSONObject(task.getValue(Task.USER));
assignedEmail = assignedUser.optString("email", ""); //$NON-NLS-1$ //$NON-NLS-2$
assignedId = assignedUser.optLong("id", Task.USER_ID_IGNORE);
} catch (JSONException e) {
//
String assignedId = task.getValue(Task.USER_ID);
if (Task.USER_ID_EMAIL.equals(task.getValue(Task.USER_ID))) {
assignedEmail = task.getValue(Task.USER_EMAIL);
}
resetControlSets();

Loading…
Cancel
Save