From 7f445f5357c49e93b44de6604c49502303014706 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Fri, 3 Feb 2012 16:29:02 -0800 Subject: [PATCH] Removed block on deleting shared tags so that you can leave them --- .../todoroo/astrid/tags/TagFilterExposer.java | 34 ++++++++++++------- astrid/res/values/strings-tags.xml | 9 +++++ 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/tags/TagFilterExposer.java b/astrid/plugin-src/com/todoroo/astrid/tags/TagFilterExposer.java index 3c9c872cd..e904709ec 100644 --- a/astrid/plugin-src/com/todoroo/astrid/tags/TagFilterExposer.java +++ b/astrid/plugin-src/com/todoroo/astrid/tags/TagFilterExposer.java @@ -76,9 +76,12 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE filter.color = Color.GRAY; } + TagData tagData = PluginServices.getTagDataService().getTag(tag.tag, TagData.ID, TagData.MEMBER_COUNT); + int deleteIntentLabel = tagData.getValue(TagData.MEMBER_COUNT) > 0 ? R.string.tag_cm_leave : R.string.tag_cm_delete; + filter.contextMenuLabels = new String[] { context.getString(R.string.tag_cm_rename), - context.getString(R.string.tag_cm_delete) + context.getString(deleteIntentLabel) }; filter.contextMenuIntents = new Intent[] { newTagIntent(context, RenameTagActivity.class, tag), @@ -189,11 +192,11 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE TagData tagData = tagDataService.getTag(tag, TagData.MEMBER_COUNT); - if(tagData != null && tagData.getValue(TagData.MEMBER_COUNT) > 0) { - DialogUtilities.okDialog(this, getString(R.string.actfm_tag_operation_disabled), getCancelListener()); - return; - } - showDialog(); +//// if(tagData != null && tagData.getValue(TagData.MEMBER_COUNT) > 0) { +//// DialogUtilities.okDialog(this, getString(R.string.actfm_tag_operation_disabled), getCancelListener()); +//// return; +//// } + showDialog(tagData); } protected DialogInterface.OnClickListener getOkListener() { @@ -234,7 +237,7 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE Toast.LENGTH_SHORT).show(); } - protected abstract void showDialog(); + protected abstract void showDialog(TagData tagData); protected abstract boolean ok(); } @@ -242,19 +245,26 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE public static class DeleteTagActivity extends TagActivity { @Override - protected void showDialog() { - DialogUtilities.okCancelDialog(this, getString(R.string.DLG_delete_this_tag_question, tag), getOkListener(), getCancelListener()); + protected void showDialog(TagData tagData) { + int string; + if (tagData != null && tagData.getValue(TagData.MEMBER_COUNT) > 0) + string = R.string.DLG_leave_this_shared_tag_question; + else + string = R.string.DLG_delete_this_tag_question; + DialogUtilities.okCancelDialog(this, getString(string, tag), getOkListener(), getCancelListener()); } @Override protected boolean ok() { int deleted = tagService.delete(tag); - TagData tagData = PluginServices.getTagDataService().getTag(tag, TagData.ID, TagData.DELETION_DATE); + TagData tagData = PluginServices.getTagDataService().getTag(tag, TagData.ID, TagData.DELETION_DATE, TagData.MEMBER_COUNT); + boolean shared = false; if(tagData != null) { tagData.setValue(TagData.DELETION_DATE, DateUtilities.now()); PluginServices.getTagDataService().save(tagData); + shared = (tagData.getValue(TagData.MEMBER_COUNT) > 0); } - Toast.makeText(this, getString(R.string.TEA_tags_deleted, tag, deleted), + Toast.makeText(this, getString(shared ? R.string.TEA_tags_left : R.string.TEA_tags_deleted, tag, deleted), Toast.LENGTH_SHORT).show(); return true; } @@ -266,7 +276,7 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE private EditText editor; @Override - protected void showDialog() { + protected void showDialog(TagData tagData) { editor = new EditText(this); DialogUtilities.viewDialog(this, getString(R.string.DLG_rename_this_tag_header, tag), editor, getOkListener(), getCancelListener()); } diff --git a/astrid/res/values/strings-tags.xml b/astrid/res/values/strings-tags.xml index 921cabf9d..801cd1246 100644 --- a/astrid/res/values/strings-tags.xml +++ b/astrid/res/values/strings-tags.xml @@ -68,9 +68,15 @@ Delete List + + + Leave List Delete this list: %s? (No tasks will be deleted.) + + + Leave this shared list: %s? (No tasks will be deleted.) Rename the list %s to: @@ -80,6 +86,9 @@ List %1$s was deleted, affecting %2$d tasks + + + You left shared list %1$s, affecting %2$d tasks Renamed %1$s with %2$s for %3$d tasks