|
|
|
@ -5,6 +5,10 @@
|
|
|
|
|
*/
|
|
|
|
|
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;
|
|
|
|
@ -17,6 +21,7 @@ import android.os.Bundle;
|
|
|
|
|
import android.support.v4.app.ActionBar;
|
|
|
|
|
import android.support.v4.app.Fragment;
|
|
|
|
|
import android.support.v4.view.ViewPager.OnPageChangeListener;
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
import android.util.TypedValue;
|
|
|
|
|
import android.view.KeyEvent;
|
|
|
|
|
import android.view.View;
|
|
|
|
@ -46,6 +51,7 @@ 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;
|
|
|
|
@ -616,8 +622,10 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
|
|
|
|
|
if (tlf != null) {
|
|
|
|
|
if (data != null) {
|
|
|
|
|
if (data.getBooleanExtra(TaskEditFragment.TOKEN_TASK_WAS_ASSIGNED, false)) {
|
|
|
|
|
String assignedTo = data.getStringExtra(TaskEditFragment.TOKEN_ASSIGNED_TO);
|
|
|
|
|
switchToAssignedFilter(assignedTo);
|
|
|
|
|
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);
|
|
|
|
|
taskAssignedTo(assignedTo, assignedEmail, assignedId);
|
|
|
|
|
} else if (data.getParcelableExtra(TaskEditFragment.TOKEN_NEW_REPEATING_TASK) != null) {
|
|
|
|
|
Task repeating = data.getParcelableExtra(TaskEditFragment.TOKEN_NEW_REPEATING_TASK);
|
|
|
|
|
DateChangedAlerts.showRepeatChangedDialog(this, repeating);
|
|
|
|
@ -652,8 +660,8 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
|
|
|
|
|
tlf.refresh();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void switchToAssignedFilter(final String assignedEmail) {
|
|
|
|
|
TaskListFragment tlf = getTaskListFragment();
|
|
|
|
|
public void taskAssignedTo(final String assignedDisplay, String assignedEmail, final long assignedId) {
|
|
|
|
|
final TaskListFragment tlf = getTaskListFragment();
|
|
|
|
|
if (tlf != null && tlf.isInbox()) {
|
|
|
|
|
DialogInterface.OnClickListener okListener = new DialogInterface.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
@ -664,9 +672,67 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
|
|
|
|
|
};
|
|
|
|
|
DialogUtilities.okCancelCustomDialog(this,
|
|
|
|
|
getString(R.string.actfm_view_task_title),
|
|
|
|
|
getString(R.string.actfm_view_task_text, assignedEmail),
|
|
|
|
|
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)) {
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} 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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|