|
|
@ -45,13 +45,17 @@ import com.todoroo.andlib.data.TodorooCursor;
|
|
|
|
import com.todoroo.andlib.service.Autowired;
|
|
|
|
import com.todoroo.andlib.service.Autowired;
|
|
|
|
import com.todoroo.andlib.service.DependencyInjectionService;
|
|
|
|
import com.todoroo.andlib.service.DependencyInjectionService;
|
|
|
|
import com.todoroo.andlib.service.ExceptionService;
|
|
|
|
import com.todoroo.andlib.service.ExceptionService;
|
|
|
|
|
|
|
|
import com.todoroo.andlib.sql.Order;
|
|
|
|
|
|
|
|
import com.todoroo.andlib.sql.Query;
|
|
|
|
import com.todoroo.andlib.utility.DialogUtilities;
|
|
|
|
import com.todoroo.andlib.utility.DialogUtilities;
|
|
|
|
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
|
|
|
|
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
|
|
|
|
import com.todoroo.astrid.actfm.sync.ActFmSyncService;
|
|
|
|
import com.todoroo.astrid.actfm.sync.ActFmSyncService;
|
|
|
|
import com.todoroo.astrid.activity.TaskEditFragment;
|
|
|
|
import com.todoroo.astrid.activity.TaskEditFragment;
|
|
|
|
|
|
|
|
import com.todoroo.astrid.dao.UserDao;
|
|
|
|
import com.todoroo.astrid.data.Metadata;
|
|
|
|
import com.todoroo.astrid.data.Metadata;
|
|
|
|
import com.todoroo.astrid.data.TagData;
|
|
|
|
import com.todoroo.astrid.data.TagData;
|
|
|
|
import com.todoroo.astrid.data.Task;
|
|
|
|
import com.todoroo.astrid.data.Task;
|
|
|
|
|
|
|
|
import com.todoroo.astrid.data.User;
|
|
|
|
import com.todoroo.astrid.helper.AsyncImageView;
|
|
|
|
import com.todoroo.astrid.helper.AsyncImageView;
|
|
|
|
import com.todoroo.astrid.service.AstridDependencyInjector;
|
|
|
|
import com.todoroo.astrid.service.AstridDependencyInjector;
|
|
|
|
import com.todoroo.astrid.service.MetadataService;
|
|
|
|
import com.todoroo.astrid.service.MetadataService;
|
|
|
@ -78,6 +82,8 @@ public class EditPeopleControlSet extends PopupControlSet {
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired TaskService taskService;
|
|
|
|
@Autowired TaskService taskService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired UserDao userDao;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired MetadataService metadataService;
|
|
|
|
@Autowired MetadataService metadataService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired ExceptionService exceptionService;
|
|
|
|
@Autowired ExceptionService exceptionService;
|
|
|
@ -352,13 +358,15 @@ public class EditPeopleControlSet extends PopupControlSet {
|
|
|
|
myself.put("id", Task.USER_ID_SELF);
|
|
|
|
myself.put("id", Task.USER_ID_SELF);
|
|
|
|
sharedPeople.add(0, myself);
|
|
|
|
sharedPeople.add(0, myself);
|
|
|
|
|
|
|
|
|
|
|
|
boolean hasTags = t.getTransitory(TaskService.TRANS_TAGS) != null &&
|
|
|
|
boolean hasTags = t.getTransitory("tags") != null &&
|
|
|
|
((HashSet<String>)t.getTransitory(TaskService.TRANS_TAGS)).size() > 0;
|
|
|
|
((HashSet<String>)t.getTransitory("tags")).size() > 0;
|
|
|
|
if (actFmPreferenceService.isLoggedIn() && hasTags) {
|
|
|
|
boolean addUnassigned = actFmPreferenceService.isLoggedIn() && hasTags;
|
|
|
|
|
|
|
|
if (addUnassigned) {
|
|
|
|
JSONObject unassigned = new JSONObject();
|
|
|
|
JSONObject unassigned = new JSONObject();
|
|
|
|
unassigned.put("id", Task.USER_ID_UNASSIGNED);
|
|
|
|
unassigned.put("id", Task.USER_ID_UNASSIGNED);
|
|
|
|
sharedPeople.add(1, unassigned);
|
|
|
|
sharedPeople.add(1, unassigned);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
addAstridFriends(sharedPeople);
|
|
|
|
|
|
|
|
|
|
|
|
// de-duplicate by user id and/or email
|
|
|
|
// de-duplicate by user id and/or email
|
|
|
|
listValues.clear();
|
|
|
|
listValues.clear();
|
|
|
@ -420,7 +428,7 @@ public class EditPeopleControlSet extends PopupControlSet {
|
|
|
|
for (AssignedChangedListener l : listeners) {
|
|
|
|
for (AssignedChangedListener l : listeners) {
|
|
|
|
if (l.shouldShowTaskRabbit()) {
|
|
|
|
if (l.shouldShowTaskRabbit()) {
|
|
|
|
taskRabbitUser = new AssignedToUser(activity.getString(R.string.actfm_EPA_task_rabbit), new JSONObject().put("default_picture", R.drawable.task_rabbit_image));
|
|
|
|
taskRabbitUser = new AssignedToUser(activity.getString(R.string.actfm_EPA_task_rabbit), new JSONObject().put("default_picture", R.drawable.task_rabbit_image));
|
|
|
|
listValues.add(taskRabbitUser);
|
|
|
|
listValues.add(addUnassigned ? 2 : 1, taskRabbitUser);
|
|
|
|
if(l.didPostToTaskRabbit()){
|
|
|
|
if(l.didPostToTaskRabbit()){
|
|
|
|
assignedIndex = listValues.size()-1;
|
|
|
|
assignedIndex = listValues.size()-1;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -443,6 +451,27 @@ public class EditPeopleControlSet extends PopupControlSet {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void addAstridFriends(ArrayList<JSONObject> sharedPeople) {
|
|
|
|
|
|
|
|
TodorooCursor<User> users = userDao.query(Query.select(User.PROPERTIES).orderBy(Order.asc(User.NAME)));
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
User user = new User();
|
|
|
|
|
|
|
|
for (users.moveToFirst(); !users.isAfterLast(); users.moveToNext()) {
|
|
|
|
|
|
|
|
user.readFromCursor(users);
|
|
|
|
|
|
|
|
JSONObject userJson = new JSONObject();
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
ActFmSyncService.JsonHelper.jsonFromUser(userJson, user);
|
|
|
|
|
|
|
|
sharedPeople.add(userJson);
|
|
|
|
|
|
|
|
} catch (JSONException e) {
|
|
|
|
|
|
|
|
// Ignored
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
users.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private class AssignedUserAdapter extends ArrayAdapter<AssignedToUser> {
|
|
|
|
private class AssignedUserAdapter extends ArrayAdapter<AssignedToUser> {
|
|
|
|
|
|
|
|
|
|
|
|
public AssignedUserAdapter(Context context, ArrayList<AssignedToUser> people) {
|
|
|
|
public AssignedUserAdapter(Context context, ArrayList<AssignedToUser> people) {
|
|
|
|