Make people a list is shared with show up in quick add who picker

pull/14/head
Sam Bosley 13 years ago
parent 45ca18cbc7
commit a7cdbd754f

@ -173,7 +173,7 @@ public class EditPeopleControlSet extends PopupControlSet {
@Override
public void readFromTask(Task sourceTask) {
setTask(sourceTask);
setUpData(task);
setUpData(task, null);
}
public void setTask(Task task) {
@ -189,7 +189,7 @@ public class EditPeopleControlSet extends PopupControlSet {
}
@SuppressWarnings("nls")
public void setUpData(final Task task) {
public void setUpData(final Task task, final TagData includeTag) {
try {
JSONObject sharedWith;
if(task.getValue(Task.SHARED_WITH).length() > 0)
@ -223,24 +223,16 @@ public class EditPeopleControlSet extends PopupControlSet {
final String tag = metadata.getValue(TagService.TAG);
TagData tagData = tagDataService.getTag(tag, TagData.MEMBER_COUNT, TagData.MEMBERS, TagData.USER);
if(tagData != null && tagData.getValue(TagData.MEMBER_COUNT) > 0) {
JSONArray members = new JSONArray(tagData.getValue(TagData.MEMBERS));
for(int i = 0; i < members.length(); i++) {
JSONObject user = members.getJSONObject(i);
user.put("tag", tag);
sharedPeople.add(user);
collaborators.add(user);
}
if(!TextUtils.isEmpty(tagData.getValue(TagData.USER))) {
JSONObject user = new JSONObject(tagData.getValue(TagData.USER));
user.put("tag", tag);
sharedPeople.add(user);
collaborators.add(user);
}
addMembersFromTagData(tagData, tag, sharedPeople, collaborators);
} else {
nonSharedTags.add((Metadata) metadata.clone());
}
}
if (includeTag != null && tags.getCount() == 0) {
addMembersFromTagData(includeTag, null, sharedPeople, collaborators);
}
if(collaborators.size() > 0)
buildCollaborators(collaborators);
buildAssignedToSpinner(task, sharedPeople);
@ -257,6 +249,24 @@ public class EditPeopleControlSet extends PopupControlSet {
}
}
private static void addMembersFromTagData(TagData tagData, String tag, ArrayList<JSONObject> sharedPeople, ArrayList<JSONObject> collaborators) throws JSONException {
JSONArray members = new JSONArray(tagData.getValue(TagData.MEMBERS));
if (tag == null)
tag = tagData.getValue(TagData.NAME);
for(int i = 0; i < members.length(); i++) {
JSONObject user = members.getJSONObject(i);
user.put("tag", tag);
sharedPeople.add(user);
collaborators.add(user);
}
if(!TextUtils.isEmpty(tagData.getValue(TagData.USER))) {
JSONObject user = new JSONObject(tagData.getValue(TagData.USER));
user.put("tag", tag);
sharedPeople.add(user);
collaborators.add(user);
}
}
@SuppressWarnings("nls")
private void buildCollaborators(final ArrayList<JSONObject> sharedPeople) throws JSONException {

@ -1,6 +1,7 @@
package com.todoroo.astrid.activity;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map.Entry;
@ -419,6 +420,7 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
setUpTaskList();
((AstridActivity) getActivity()).setupActivityFragment(getTagDataForUpdates());
setUpQuickAddControlSets();
contextMenuExtensionLoader.loadInNewThread(getActivity());
}
@ -534,7 +536,6 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
quickAddControls = (LinearLayout) getView().findViewById(R.id.taskListQuickaddControls);
quickAddControlsContainer = getView().findViewById(R.id.taskListQuickaddControlsContainer);
setUpQuickAddControlSets();
// set listener for pressing enter in quick-add box
quickAddBox = (EditText) getView().findViewById(R.id.quickAddText);
@ -665,10 +666,16 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
private void resetControlSets() {
Task empty = new Task();
TagData tagData = getTagDataForUpdates();
if (tagData != null) {
HashSet<String> tagsTransitory = new HashSet<String>();
tagsTransitory.add(tagData.getValue(TagData.NAME));
empty.putTransitory("tags", tagsTransitory);
}
repeatControl.readFromTask(empty);
gcalControl.readFromTask(empty);
deadlineControl.readFromTask(empty);
peopleControl.setUpData(empty);
peopleControl.setUpData(empty, getTagDataForUpdates());
peopleControl.assignToMe();
peopleControl.setTask(null);
}

Loading…
Cancel
Save