Removed all references to Task.SHARED_WITH

pull/14/head
Sam Bosley 13 years ago
parent f20cfe1360
commit b1ae98aec4

@ -169,9 +169,6 @@ public final class Task extends RemoteModel {
public static final LongProperty CREATOR_ID = new LongProperty(
TABLE, "creatorId", Property.PROP_FLAG_USER_ID);
public static final StringProperty SHARED_WITH = new StringProperty(
TABLE, "sharedWith");
/** Last Sync date */
public static final LongProperty LAST_SYNC = new LongProperty(
TABLE, "lastSync", Property.PROP_FLAG_DATE);
@ -296,7 +293,6 @@ public final class Task extends RemoteModel {
defaultValues.put(USER_ID.name, "0");
defaultValues.put(CREATOR_ID.name, 0);
defaultValues.put(USER.name, "{}");
defaultValues.put(SHARED_WITH.name, "{}");
defaultValues.put(PUSHED_AT.name, 0L);
}

@ -104,8 +104,6 @@ public class EditPeopleControlSet extends PopupControlSet {
private final Fragment fragment;
private final PeopleContainer sharedWithContainer;
private final CheckBox cbFacebook;
private final CheckBox cbTwitter;
@ -224,67 +222,42 @@ public class EditPeopleControlSet extends PopupControlSet {
@SuppressWarnings("nls")
public void setUpData(final Task task, final TagData includeTag) {
try {
JSONObject sharedWith;
if(task.getValue(Task.SHARED_WITH).length() > 0)
sharedWith = new JSONObject(task.getValue(Task.SHARED_WITH));
else
sharedWith = new JSONObject();
cbFacebook.setChecked(sharedWith.optBoolean("fb", false));
cbTwitter.setChecked(sharedWith.optBoolean("tw", false));
final ArrayList<JSONObject> sharedPeople = new ArrayList<JSONObject>();
JSONArray people = sharedWith.optJSONArray("p");
if(people != null) {
for(int i = 0; i < people.length(); i++) {
String person = people.getString(i);
TextView textView = sharedWithContainer.addPerson(person, "");
textView.setEnabled(false);
sharedPeople.add(PeopleContainer.createUserJson(textView));
}
}
new Thread(new Runnable() {
@Override
public void run() {
ArrayList<JSONObject> collaborators = new ArrayList<JSONObject>();
TodorooCursor<TagData> tags = TagService.getInstance().getTagDataForTask(task.getId(), true, TagData.NAME, TagData.MEMBER_COUNT, TagData.MEMBERS, TagData.USER);
try {
TagData tagData = new TagData();
for(tags.moveToFirst(); !tags.isAfterLast(); tags.moveToNext()) {
tagData.readFromCursor(tags);
final String tag = tagData.getValue(TagData.NAME);
if(tagData.getValue(TagData.MEMBER_COUNT) > 0) {
try {
addMembersFromTagData(tagData, tag, sharedPeople, collaborators);
} catch (JSONException e) {
exceptionService.reportError("json-reading-data", e);
}
}
}
if (includeTag != null && tags.getCount() == 0) {
new Thread(new Runnable() {
@Override
public void run() {
ArrayList<JSONObject> collaborators = new ArrayList<JSONObject>();
TodorooCursor<TagData> tags = TagService.getInstance().getTagDataForTask(task.getId(), true, TagData.NAME, TagData.MEMBER_COUNT, TagData.MEMBERS, TagData.USER);
try {
TagData tagData = new TagData();
for(tags.moveToFirst(); !tags.isAfterLast(); tags.moveToNext()) {
tagData.readFromCursor(tags);
final String tag = tagData.getValue(TagData.NAME);
if(tagData.getValue(TagData.MEMBER_COUNT) > 0) {
try {
addMembersFromTagData(includeTag, null, sharedPeople, collaborators);
addMembersFromTagData(tagData, tag, sharedPeople, collaborators);
} catch (JSONException e) {
exceptionService.reportError("json-reading-data", e);
}
}
}
if(collaborators.size() > 0)
buildCollaborators(collaborators);
buildAssignedToSpinner(task, sharedPeople);
} finally {
tags.close();
loadedUI = true;
if (includeTag != null && tags.getCount() == 0) {
try {
addMembersFromTagData(includeTag, null, sharedPeople, collaborators);
} catch (JSONException e) {
exceptionService.reportError("json-reading-data", e);
}
}
}
}).start();
} catch (JSONException e) {
exceptionService.reportError("json-reading-data", e);
}
if(collaborators.size() > 0)
buildCollaborators(collaborators);
buildAssignedToSpinner(task, sharedPeople);
} finally {
tags.close();
loadedUI = true;
}
}
}).start();
}
@SuppressWarnings("nls")
@ -356,7 +329,7 @@ public class EditPeopleControlSet extends PopupControlSet {
}
@SuppressWarnings("nls")
private void buildAssignedToSpinner(Task t, ArrayList<JSONObject> sharedPeople) {
private void buildAssignedToSpinner(Task t) {
HashSet<Long> userIds = new HashSet<Long>();
HashSet<String> emails = new HashSet<String>();
HashMap<String, AssignedToUser> names = new HashMap<String, AssignedToUser>();
@ -392,7 +365,6 @@ public class EditPeopleControlSet extends PopupControlSet {
// de-duplicate by user id and/or email
coreUsers = convertJsonUsersToAssignedUsers(coreUsersJson, userIds, emails, names);
listUsers = convertJsonUsersToAssignedUsers(sharedPeople, userIds, emails, names);
astridUsers = convertJsonUsersToAssignedUsers(astridFriends, userIds, emails, names);
contactPickerUser = new AssignedToUser(activity.getString(R.string.actfm_EPA_choose_contact),
@ -761,17 +733,8 @@ public class EditPeopleControlSet extends PopupControlSet {
}
JSONObject sharedWith = sharedWithContainer.parseSharedWithAndTags(activity, false);
EditText message = (EditText) getSharedWithView().findViewById(R.id.message);
if (!TextUtils.isEmpty(message.getText()) && sharedWith.has("p"))
sharedWith.put("message", message.getText().toString());
if(cbFacebook.isChecked())
sharedWith.put("fb", true);
if(cbTwitter.isChecked())
sharedWith.put("tw", true);
dirty = dirty || sharedWith.has("p");
if(dirty && !actFmPreferenceService.isLoggedIn()) {
DialogInterface.OnClickListener okListener = new DialogInterface.OnClickListener() {
@Override
@ -798,9 +761,6 @@ public class EditPeopleControlSet extends PopupControlSet {
return false;
}
if(!TextUtils.isEmpty(task.getValue(Task.SHARED_WITH)) || sharedWith.length() != 0)
task.setValue(Task.SHARED_WITH, sharedWith.toString());
task.putTransitory(TaskService.TRANS_ASSIGNED, true);
if (assignedView == assignedCustom)

@ -461,25 +461,25 @@ public final class ActFmSyncService {
}
}
if (values.containsKey(Task.SHARED_WITH.name)) {
try {
JSONObject sharedWith = new JSONObject(task.getValue(Task.SHARED_WITH));
if (sharedWith.has("p")) {
JSONArray people = sharedWith.getJSONArray("p");
for (int i = 0; i < people.length(); i++) {
params.add("share_with[]"); params.add(people.getString(i));
}
if (sharedWith.has("message")) {
String message = sharedWith.getString("message");
if (!TextUtils.isEmpty(message))
params.add("message"); params.add(message);
}
}
} catch (JSONException e) {
Log.e("Error parsing shared_with", task.getValue(Task.SHARED_WITH), e);
}
sharing = true;
}
// if (values.containsKey(Task.SHARED_WITH.name)) {
// try {
// JSONObject sharedWith = new JSONObject(task.getValue(Task.SHARED_WITH));
// if (sharedWith.has("p")) {
// JSONArray people = sharedWith.getJSONArray("p");
// for (int i = 0; i < people.length(); i++) {
// params.add("share_with[]"); params.add(people.getString(i));
// }
// if (sharedWith.has("message")) {
// String message = sharedWith.getString("message");
// if (!TextUtils.isEmpty(message))
// params.add("message"); params.add(message);
// }
// }
// } catch (JSONException e) {
// Log.e("Error parsing shared_with", task.getValue(Task.SHARED_WITH), e);
// }
// sharing = true;
// }
if (sharing) {
addAbTestEventInfo(params);

@ -150,7 +150,8 @@ public class ReminderDialog extends Dialog {
Notifications.getRandomReminder(activity.getResources().getStringArray(R.array.reminder_responses)));
if (Preferences.getBoolean(R.string.p_rmd_social, true)) {
Task task = taskService.fetchById(taskId, Task.ID, Task.SHARED_WITH);
Task task = new Task();
task.setId(taskId);
addFacesToReminder(activity, task);
}
}
@ -161,8 +162,6 @@ public class ReminderDialog extends Dialog {
LinkedHashSet<String> pictureUrls = new LinkedHashSet<String>();
AtomicBoolean isSharedTask = new AtomicBoolean(false);
addSharedWithFaces(task, pictureUrls, isSharedTask);
if (pictureUrls.size() < MAX_FACES) {
addTagFaces(task.getId(), pictureUrls, isSharedTask);
}
@ -221,18 +220,6 @@ public class ReminderDialog extends Dialog {
}
}
private void addSharedWithFaces(Task t, LinkedHashSet<String> pictureUrls, AtomicBoolean isSharedTask) {
try {
JSONObject sharedWith = new JSONObject(t.getValue(Task.SHARED_WITH));
if (sharedWith.has("p")) { //$NON-NLS-1$
JSONArray people = sharedWith.getJSONArray("p"); //$NON-NLS-1$
addPicturesFromJSONArray(people, pictureUrls, isSharedTask);
}
} catch (JSONException e) {
//
}
}
private void addTagFaces(long taskId, LinkedHashSet<String> pictureUrls, AtomicBoolean isSharedTask) {
TodorooCursor<TagData> tags = tagService.getTagDataForTask(taskId, TagData.MEMBER_COUNT.gt(0), TagData.MEMBERS);
try {

@ -219,8 +219,7 @@ public class Database extends AbstractDatabase {
Log.e("astrid", "db-upgrade-" + oldVersion + "-" + newVersion, e);
}
case 10: try {
database.execSQL("ALTER TABLE " + Task.TABLE.name + " ADD " +
Task.SHARED_WITH.accept(visitor, null));
//
} catch (SQLiteException e) {
Log.e("astrid", "db-upgrade-" + oldVersion + "-" + newVersion, e);
}

Loading…
Cancel
Save