diff --git a/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java b/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java index 5d9552b64..5e616da78 100755 --- a/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java @@ -833,16 +833,27 @@ public final class TaskEditFragment extends Fragment implements taskService.save(model); if (!onPause && !cancelFinish) { + boolean setActivityResult = (getActivity() instanceof TaskEditActivity); + if (!peopleControlSet.isAssignedToMe()) { - Intent data = new Intent(); - data.putExtra(TOKEN_TASK_WAS_ASSIGNED, true); - data.putExtra(TOKEN_ASSIGNED_TO, - peopleControlSet.getAssignedToString()); - getActivity().setResult(Activity.RESULT_OK, data); + String assignedTo = peopleControlSet.getAssignedToString(); + if (setActivityResult) { + Intent data = new Intent(); + data.putExtra(TOKEN_TASK_WAS_ASSIGNED, true); + data.putExtra(TOKEN_ASSIGNED_TO, + assignedTo); + getActivity().setResult(Activity.RESULT_OK, data); + } else { + // Notify task list fragment in multi-column case + // since the activity isn't actually finishing + TaskListActivity tla = (TaskListActivity) getActivity(); + tla.switchToAssignedFilter(assignedTo); + } } shouldSaveState = false; getActivity().onBackPressed(); + } } diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java index 301e97dc0..9e29a0544 100644 --- a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java @@ -3,6 +3,7 @@ package com.todoroo.astrid.activity; import android.app.Activity; import android.content.BroadcastReceiver; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; @@ -22,6 +23,7 @@ import android.widget.TextView; import com.timsu.astrid.R; import com.todoroo.andlib.utility.AndroidUtilities; +import com.todoroo.andlib.utility.DialogUtilities; import com.todoroo.astrid.actfm.ActFmLoginActivity; import com.todoroo.astrid.actfm.TagSettingsActivity; import com.todoroo.astrid.actfm.TagUpdatesFragment; @@ -29,6 +31,7 @@ import com.todoroo.astrid.actfm.TagViewFragment; 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.reminders.NotificationFragment; import com.todoroo.astrid.service.ThemeService; import com.todoroo.astrid.tags.TagFilterExposer; @@ -361,11 +364,44 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener if (fla != null) fla.clear(); } + } else if (requestCode == TaskListFragment.ACTIVITY_EDIT_TASK && resultCode != Activity.RESULT_CANCELED) { + // Handle switch to assigned filter when it comes from TaskEditActivity finishing + // For cases when we're in a multi-frame layout, the TaskEditFragment will notify us here directly + TaskListFragment tlf = getTaskListFragment(); + if (tlf != null) { + if (data != null + && data.hasExtra(TaskEditFragment.TOKEN_TASK_WAS_ASSIGNED) + && data.getBooleanExtra( + TaskEditFragment.TOKEN_TASK_WAS_ASSIGNED, false)) { + String assignedTo = data.getStringExtra(TaskEditFragment.TOKEN_ASSIGNED_TO); + switchToAssignedFilter(assignedTo); + } else { + tlf.refresh(); + } + } } super.onActivityResult(requestCode, resultCode, data); } + protected void switchToAssignedFilter(final String assignedEmail) { + TaskListFragment tlf = getTaskListFragment(); + if (tlf != null && !tlf.isFilter()) { + DialogInterface.OnClickListener okListener = new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + Filter assignedFilter = CustomFilterExposer.getAssignedByMeFilter(getResources()); + onFilterItemClicked(assignedFilter); + } + }; + DialogUtilities.okCancelCustomDialog(this, + getString(R.string.actfm_view_task_title), + getString(R.string.actfm_view_task_text, assignedEmail), + R.string.actfm_view_task_ok, R.string.actfm_view_task_cancel, + 0, okListener, null); + } + } + @Override public void mainMenuItemSelected(int item) { TaskListFragment tla = getTaskListFragment(); diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java b/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java index 08e8f475d..e32b41f21 100644 --- a/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java @@ -72,7 +72,6 @@ import com.todoroo.andlib.sql.Functions; import com.todoroo.andlib.sql.QueryTemplate; import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.andlib.utility.DateUtilities; -import com.todoroo.andlib.utility.DialogUtilities; import com.todoroo.andlib.utility.Preferences; import com.todoroo.andlib.widget.GestureService; import com.todoroo.andlib.widget.GestureService.GestureInterface; @@ -91,7 +90,6 @@ import com.todoroo.astrid.api.TaskAction; import com.todoroo.astrid.api.TaskContextActionExposer; import com.todoroo.astrid.api.TaskDecoration; import com.todoroo.astrid.core.CoreFilterExposer; -import com.todoroo.astrid.core.CustomFilterExposer; import com.todoroo.astrid.core.SortHelper; import com.todoroo.astrid.dao.Database; import com.todoroo.astrid.dao.TaskDao.TaskCriteria; @@ -746,6 +744,7 @@ public class TaskListFragment extends ListFragment implements OnScrollListener, protected void refresh() { taskAdapter.flushCaches(); loadTaskListContent(true); + taskService.cleanup(); } /** @@ -853,42 +852,6 @@ public class TaskListFragment extends ListFragment implements OnScrollListener, } }, 1000); } - - if (resultCode != Activity.RESULT_CANCELED) { - if (data != null - && data.hasExtra(TaskEditFragment.TOKEN_TASK_WAS_ASSIGNED) - && data.getBooleanExtra( - TaskEditFragment.TOKEN_TASK_WAS_ASSIGNED, false) - && !isFilter) { - String assignedTo = data.getStringExtra(TaskEditFragment.TOKEN_ASSIGNED_TO); - switchToAssignedFilter(assignedTo); - } else { - taskAdapter.flushCaches(); - loadTaskListContent(true); - taskService.cleanup(); - } - } - } - - private void switchToAssignedFilter(final String assignedEmail) { - DialogInterface.OnClickListener okListener = new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - Filter assignedFilter = CustomFilterExposer.getAssignedByMeFilter(getResources()); - - Intent intent = new Intent(getActivity(), - TaskListActivity.class); - intent.putExtra(TaskListFragment.TOKEN_FILTER, assignedFilter); - intent.putExtra(TaskListFragment.TOKEN_OVERRIDE_ANIM, true); - startActivityForResult(intent, 0); - transitionForTaskEdit(); - } - }; - DialogUtilities.okCancelCustomDialog(getActivity(), - getString(R.string.actfm_view_task_title), - getString(R.string.actfm_view_task_text, assignedEmail), - R.string.actfm_view_task_ok, R.string.actfm_view_task_cancel, - 0, okListener, null); } public void onScroll(AbsListView view, int firstVisibleItem, @@ -1262,6 +1225,10 @@ public class TaskListFragment extends ListFragment implements OnScrollListener, } } + public boolean isFilter() { + return isFilter; + } + /** Show a dialog box and delete the task specified */ private void deleteTask(final Task task) { new AlertDialog.Builder(getActivity()).setTitle(