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