diff --git a/src/main/java/com/todoroo/astrid/widget/TasksWidget.java b/src/main/java/com/todoroo/astrid/widget/TasksWidget.java index ff43146f4..4c3649c25 100644 --- a/src/main/java/com/todoroo/astrid/widget/TasksWidget.java +++ b/src/main/java/com/todoroo/astrid/widget/TasksWidget.java @@ -11,24 +11,26 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.os.Build; +import android.support.v4.app.TaskStackBuilder; import com.todoroo.andlib.utility.DateUtilities; -import com.todoroo.astrid.activity.TaskEditActivity; import com.todoroo.astrid.activity.TaskEditFragment; -import com.todoroo.astrid.activity.TaskListActivity; +import com.todoroo.astrid.activity.TaskListFragment; +import com.todoroo.astrid.api.Filter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.tasks.Broadcaster; import org.tasks.R; import org.tasks.injection.InjectingAppWidgetProvider; -import org.tasks.preferences.ActivityPreferences; +import org.tasks.intents.TaskIntents; import org.tasks.widget.WidgetHelper; import javax.inject.Inject; import static com.todoroo.andlib.utility.AndroidUtilities.preIceCreamSandwich; import static com.todoroo.astrid.api.AstridApiConstants.BROADCAST_EVENT_REFRESH; +import static org.tasks.intents.TaskIntents.getEditTaskStack; public class TasksWidget extends InjectingAppWidgetProvider { @@ -52,15 +54,11 @@ public class TasksWidget extends InjectingAppWidgetProvider { broadcaster.toggleCompletedState(intent.getLongExtra(TaskEditFragment.TOKEN_ID, 0)); break; case EDIT_TASK: - if (context.getResources().getBoolean(R.bool.two_pane_layout)) { - intent.setClass(context, TaskListActivity.class); - } else { - intent.setClass(context, TaskEditActivity.class); - } - intent.setFlags(WidgetHelper.flags); - intent.putExtra(TaskEditFragment.OVERRIDE_FINISH_ANIM, false); - context.startActivity(intent); - + getEditTaskStack( + context, + (Filter) intent.getParcelableExtra(TaskListFragment.TOKEN_FILTER), + intent.getLongExtra(TaskEditFragment.TOKEN_ID, 0)) + .startActivities(); break; case BROADCAST_EVENT_REFRESH: updateWidgets(context); diff --git a/src/main/java/org/tasks/intents/TaskIntents.java b/src/main/java/org/tasks/intents/TaskIntents.java index d1f6ae8ab..7f192d194 100644 --- a/src/main/java/org/tasks/intents/TaskIntents.java +++ b/src/main/java/org/tasks/intents/TaskIntents.java @@ -63,6 +63,9 @@ public class TaskIntents { taskStackBuilder.addNextIntent(new Intent(context, TaskEditActivity.class) {{ putExtra(TaskEditFragment.TOKEN_ID, taskId); }}); + if (filter != null) { + taskStackBuilder.editIntentAt(0).putExtra(TaskListFragment.TOKEN_FILTER, filter); + } } return taskStackBuilder; } diff --git a/src/main/java/org/tasks/widget/ScrollableViewsFactory.java b/src/main/java/org/tasks/widget/ScrollableViewsFactory.java index 0c2f0174f..471288e6f 100644 --- a/src/main/java/org/tasks/widget/ScrollableViewsFactory.java +++ b/src/main/java/org/tasks/widget/ScrollableViewsFactory.java @@ -14,6 +14,7 @@ import android.widget.RemoteViewsService; import com.todoroo.andlib.data.TodorooCursor; import com.todoroo.astrid.activity.TaskEditFragment; import com.todoroo.astrid.activity.TaskListActivity; +import com.todoroo.astrid.activity.TaskListFragment; import com.todoroo.astrid.adapter.TaskAdapter; import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.core.SortHelper; @@ -165,6 +166,7 @@ public class ScrollableViewsFactory implements RemoteViewsService.RemoteViewsFac Intent editIntent = new Intent(); editIntent.setAction(TasksWidget.EDIT_TASK); + editIntent.putExtra(TaskListFragment.TOKEN_FILTER, filter); editIntent.putExtra(TaskEditFragment.TOKEN_ID, task.getId()); editIntent.putExtra(TaskListActivity.OPEN_TASK, task.getId()); row.setOnClickFillInIntent(R.id.text, editIntent);