Removed block on deleting shared tags so that you can leave them

pull/14/head
Sam Bosley 14 years ago
parent d8cdd97478
commit 7f445f5357

@ -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());
}

@ -68,9 +68,15 @@
<!-- context menu option to delete a tag -->
<string name="tag_cm_delete">Delete List</string>
<!-- context menu option to leave a shared list -->
<string name="tag_cm_leave">Leave List</string>
<!-- Dialog to confirm deletion of a tag -->
<string name="DLG_delete_this_tag_question">Delete this list: %s? (No tasks will be deleted.)</string>
<!-- Dialog to confirm leaving a shared tag -->
<string name="DLG_leave_this_shared_tag_question">Leave this shared list: %s? (No tasks will be deleted.)</string>
<!-- Dialog to rename tag -->
<string name="DLG_rename_this_tag_header">Rename the list %s to:</string>
@ -80,6 +86,9 @@
<!-- Toast notification that a tag has been deleted -->
<string name="TEA_tags_deleted">List %1$s was deleted, affecting %2$d tasks</string>
<!-- Toast notification that a shared tag has been left -->
<string name="TEA_tags_left">You left shared list %1$s, affecting %2$d tasks</string>
<!-- Toast notification that a tag has been renamed -->
<string name="TEA_tags_renamed">Renamed %1$s with %2$s for %3$d tasks</string>

Loading…
Cancel
Save