From 9d562f37fde6d3a855822b6b7e65f7ecc74e4ee5 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Mon, 6 Feb 2012 11:33:37 -0800 Subject: [PATCH] Compare sql and title when deleting a list --- .../com/todoroo/astrid/tags/TagFilterExposer.java | 11 ++++++++--- .../com/todoroo/astrid/activity/TaskListActivity.java | 9 +++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/tags/TagFilterExposer.java b/astrid/plugin-src/com/todoroo/astrid/tags/TagFilterExposer.java index 376ee260a..c360b1014 100644 --- a/astrid/plugin-src/com/todoroo/astrid/tags/TagFilterExposer.java +++ b/astrid/plugin-src/com/todoroo/astrid/tags/TagFilterExposer.java @@ -54,6 +54,7 @@ import com.todoroo.astrid.tags.TagService.Tag; public class TagFilterExposer extends BroadcastReceiver implements AstridFilterExposer { private static final String TAG = "tag"; //$NON-NLS-1$ + public static final String TAG_SQL = "tagSql"; //$NON-NLS-1$ @Autowired TagDataService tagDataService; @Autowired GtasksPreferenceService gtasksPreferenceService; @@ -88,8 +89,8 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE context.getString(deleteIntentLabel) }; filter.contextMenuIntents = new Intent[] { - newTagIntent(context, RenameTagActivity.class, tag), - newTagIntent(context, DeleteTagActivity.class, tag) + newTagIntent(context, RenameTagActivity.class, tag, tagTemplate.toString()), + newTagIntent(context, DeleteTagActivity.class, tag, tagTemplate.toString()) }; filter.customTaskList = new ComponentName(ContextManager.getContext(), TagViewFragment.class); if(tag.image != null) @@ -113,9 +114,10 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE return filterFromTag(context, tag, TaskCriteria.activeAndVisible()); } - private static Intent newTagIntent(Context context, Class activity, Tag tag) { + private static Intent newTagIntent(Context context, Class activity, Tag tag, String sql) { Intent ret = new Intent(context, activity); ret.putExtra(TAG, tag.tag); + ret.putExtra(TAG_SQL, sql); return ret; } @@ -175,6 +177,7 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE public abstract static class TagActivity extends Activity { protected String tag; + protected String sql; @Autowired public TagService tagService; @Autowired public TagDataService tagDataService; @@ -188,6 +191,7 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE super.onCreate(savedInstanceState); tag = getIntent().getStringExtra(TAG); + sql = getIntent().getStringExtra(TAG_SQL); if(tag == null) { finish(); return; @@ -273,6 +277,7 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE Intent tagDeleted = new Intent(AstridApiConstants.BROADCAST_EVENT_TAG_DELETED); tagDeleted.putExtra(TagViewFragment.EXTRA_TAG_NAME, tag); + tagDeleted.putExtra(TAG_SQL, sql); sendBroadcast(tagDeleted); return true; } diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java index ee6bee60a..92aba3bcf 100644 --- a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java @@ -31,6 +31,7 @@ import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.FilterListItem; import com.todoroo.astrid.reminders.NotificationFragment; import com.todoroo.astrid.service.ThemeService; +import com.todoroo.astrid.tags.TagFilterExposer; import com.todoroo.astrid.ui.FragmentPopover; import com.todoroo.astrid.ui.MainMenuPopover; import com.todoroo.astrid.ui.MainMenuPopover.MainMenuListener; @@ -389,11 +390,15 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener @Override public void onReceive(Context context, Intent intent) { String deletedTag = intent.getStringExtra(TagViewFragment.EXTRA_TAG_NAME); + String deletedTagSql = intent.getStringExtra(TagFilterExposer.TAG_SQL); FilterListFragment fl = getFilterListFragment(); if (fl != null) { Filter currentlyShowing = getIntent().getParcelableExtra(TaskListFragment.TOKEN_FILTER); - if (currentlyShowing != null && currentlyShowing.title != null && currentlyShowing.title.equals(deletedTag)) { - fl.switchToActiveTasks(); + if (currentlyShowing != null) { + boolean titlesMatch = currentlyShowing.title != null && currentlyShowing.title.equals(deletedTag); + boolean sqlMatches = currentlyShowing.sqlQuery != null && currentlyShowing.sqlQuery.equals(deletedTagSql); + if (titlesMatch && sqlMatches) + fl.switchToActiveTasks(); } fl.clear(); // Should auto refresh }