diff --git a/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksFilterExposer.java b/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksFilterExposer.java index b32541cd0..56296a729 100644 --- a/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksFilterExposer.java +++ b/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksFilterExposer.java @@ -8,7 +8,6 @@ import android.content.ComponentName; import android.content.ContentValues; import android.content.Context; import android.content.Intent; -import android.os.Bundle; import com.timsu.astrid.R; import com.todoroo.andlib.data.AbstractModel; @@ -60,8 +59,6 @@ public class GtasksFilterExposer extends BroadcastReceiver { Order.asc(Functions.cast(GtasksMetadata.ORDER, "INTEGER"))), //$NON-NLS-1$ values); filter.customTaskList = new ComponentName(ContextManager.getContext(), GtasksListActivity.class); - filter.customExtras = new Bundle(); - filter.customExtras.putString(GtasksListActivity.TOKEN_LIST_ID, list.getValue(GtasksList.REMOTE_ID)); return filter; } diff --git a/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksIndentAction.java b/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksIndentAction.java deleted file mode 100644 index e5dd12840..000000000 --- a/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksIndentAction.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.todoroo.astrid.gtasks; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; - -import com.todoroo.andlib.service.Autowired; -import com.todoroo.andlib.service.ContextManager; -import com.todoroo.andlib.service.DependencyInjectionService; -import com.todoroo.astrid.api.AstridApiConstants; -import com.todoroo.astrid.data.Metadata; -import com.todoroo.astrid.utility.Flags; - -/** - * Context Menu actions for changing indent level of a task - * @author Tim Su - * - */ -abstract public class GtasksIndentAction extends BroadcastReceiver { - - @Autowired private GtasksMetadataService gtasksMetadataService; - @Autowired private GtasksTaskListUpdater gtasksTaskListUpdater; - - abstract int getDelta(); - - @Override - public void onReceive(Context context, Intent intent) { - ContextManager.setContext(context); - DependencyInjectionService.getInstance().inject(this); - - long taskId = intent.getLongExtra(AstridApiConstants.EXTRAS_TASK_ID, -1); - if(taskId == -1) - return; - - Metadata metadata = gtasksMetadataService.getTaskMetadata(taskId); - if(metadata == null) { - metadata = GtasksMetadata.createEmptyMetadata(taskId); - } - - if(metadata.getValue(GtasksMetadata.INDENT) + getDelta() < 0) - return; - - String listId = metadata.getValue(GtasksMetadata.LIST_ID); - gtasksTaskListUpdater.indent(listId, taskId, getDelta()); - gtasksTaskListUpdater.correctMetadataForList(listId); - - Flags.set(Flags.REFRESH); - } - - public static class GtasksIncreaseIndentAction extends GtasksIndentAction { - @Override - public int getDelta() { - return 1; - } - } - - public static class GtasksDecreaseIndentAction extends GtasksIndentAction { - @Override - public int getDelta() { - return -1; - } - } - -} diff --git a/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksListActivity.java b/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksListActivity.java index de9eaadaf..5b52f4b42 100644 --- a/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksListActivity.java +++ b/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksListActivity.java @@ -13,10 +13,6 @@ public class GtasksListActivity extends DraggableTaskListActivity { @Autowired private GtasksTaskListUpdater gtasksTaskListUpdater; - public static final String TOKEN_LIST_ID = "listId"; //$NON-NLS-1$ - - private String listId; - @Override protected IntegerProperty getIndentProperty() { return GtasksMetadata.INDENT; @@ -26,8 +22,6 @@ public class GtasksListActivity extends DraggableTaskListActivity { public void onCreate(Bundle icicle) { super.onCreate(icicle); - listId = getIntent().getStringExtra(TOKEN_LIST_ID); - getTouchListView().setDropListener(dropListener); getTouchListView().setSwipeListener(swipeListener); } @@ -37,7 +31,7 @@ public class GtasksListActivity extends DraggableTaskListActivity { public void drop(int from, int to) { long targetTaskId = taskAdapter.getItemId(from); long destinationTaskId = taskAdapter.getItemId(to); - gtasksTaskListUpdater.moveTo(listId, targetTaskId, destinationTaskId); + gtasksTaskListUpdater.moveTo(targetTaskId, destinationTaskId); loadTaskListContent(true); } }; @@ -46,14 +40,14 @@ public class GtasksListActivity extends DraggableTaskListActivity { @Override public void swipeRight(int which) { long targetTaskId = taskAdapter.getItemId(which); - gtasksTaskListUpdater.indent(listId, targetTaskId, 1); + gtasksTaskListUpdater.indent(targetTaskId, 1); loadTaskListContent(true); } @Override public void swipeLeft(int which) { long targetTaskId = taskAdapter.getItemId(which); - gtasksTaskListUpdater.indent(listId, targetTaskId, -1); + gtasksTaskListUpdater.indent(targetTaskId, -1); loadTaskListContent(true); } }; diff --git a/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksTaskListUpdater.java b/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksTaskListUpdater.java index 69679cd7e..1f8dbbe2a 100644 --- a/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksTaskListUpdater.java +++ b/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksTaskListUpdater.java @@ -42,8 +42,11 @@ public class GtasksTaskListUpdater { /** * Indent a task and all its children */ - public void indent(String listId, final long targetTaskId, final int delta) { - StoreObject list = gtasksListService.getList(listId); + public void indent(final long targetTaskId, final int delta) { + Metadata targetMetadata = gtasksMetadataService.getTaskMetadata(targetTaskId); + if(targetMetadata == null) + return; + StoreObject list = gtasksListService.getList(targetMetadata.getValue(GtasksMetadata.LIST_ID)); if(list == GtasksListService.LIST_NOT_FOUND_OBJECT) return; @@ -108,8 +111,11 @@ public class GtasksTaskListUpdater { * * @param newTaskId task we will move above. if -1, moves to end of list */ - public void moveTo(String listId, final long targetTaskId, final long moveBeforeTaskId) { - StoreObject list = gtasksListService.getList(listId); + public void moveTo(final long targetTaskId, final long moveBeforeTaskId) { + Metadata targetMetadata = gtasksMetadataService.getTaskMetadata(targetTaskId); + if(targetMetadata == null) + return; + StoreObject list = gtasksListService.getList(targetMetadata.getValue(GtasksMetadata.LIST_ID)); if(list == GtasksListService.LIST_NOT_FOUND_OBJECT) return;