Added rule action permanent delete

This commit is contained in:
M66B
2021-12-28 08:59:08 +01:00
parent 9b4e36fa00
commit e670335429
9 changed files with 57 additions and 4 deletions

View File

@@ -183,6 +183,9 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
case EntityRule.TYPE_AUTOMATION:
tvAction.setText(R.string.title_rule_automation);
break;
case EntityRule.TYPE_DELETE:
tvAction.setText(R.string.title_rule_delete);
break;
default:
throw new IllegalArgumentException("Unknown action type=" + type);
}

View File

@@ -113,6 +113,7 @@ public class EntityRule {
static final int TYPE_HIDE = 12;
static final int TYPE_IMPORTANCE = 13;
static final int TYPE_TTS = 14;
static final int TYPE_DELETE = 15;
static final String ACTION_AUTOMATION = BuildConfig.APPLICATION_ID + ".AUTOMATION";
static final String EXTRA_RULE = "rule";
@@ -464,6 +465,8 @@ public class EntityRule {
return onActionTts(context, message, jaction);
case TYPE_AUTOMATION:
return onActionAutomation(context, message, jaction);
case TYPE_DELETE:
return onActionDelete(context, message, jaction);
default:
throw new IllegalArgumentException("Unknown rule type=" + type + " name=" + name);
}
@@ -528,6 +531,8 @@ public class EntityRule {
return;
case TYPE_AUTOMATION:
return;
case TYPE_DELETE:
return;
default:
throw new IllegalArgumentException("Unknown rule type=" + type);
}
@@ -928,6 +933,14 @@ public class EntityRule {
return true;
}
private boolean onActionDelete(Context context, EntityMessage message, JSONObject jargs) {
EntityOperation.queue(context, message, EntityOperation.DELETE);
message.ui_hide = true;
return true;
}
private static Calendar getRelativeCalendar(int minutes, long reference) {
int d = minutes / (24 * 60);
int h = minutes / 60 % 24;

View File

@@ -161,6 +161,7 @@ public class FragmentRule extends FragmentBase {
private Group grpAnswer;
private Group grpTts;
private Group grpAutomation;
private Group grpDelete;
private ArrayAdapter<String> adapterDay;
private ArrayAdapter<Action> adapterAction;
@@ -299,6 +300,7 @@ public class FragmentRule extends FragmentBase {
grpAnswer = view.findViewById(R.id.grpAnswer);
grpTts = view.findViewById(R.id.grpTts);
grpAutomation = view.findViewById(R.id.grpAutomation);
grpDelete = view.findViewById(R.id.grpDelete);
ibSender.setOnClickListener(new View.OnClickListener() {
@Override
@@ -456,6 +458,7 @@ public class FragmentRule extends FragmentBase {
actions.add(new Action(EntityRule.TYPE_MOVE, getString(R.string.title_rule_move)));
actions.add(new Action(EntityRule.TYPE_COPY, getString(R.string.title_rule_copy)));
}
actions.add(new Action(EntityRule.TYPE_DELETE, getString(R.string.title_rule_delete)));
actions.add(new Action(EntityRule.TYPE_ANSWER, getString(R.string.title_rule_answer)));
actions.add(new Action(EntityRule.TYPE_TTS, getString(R.string.title_rule_tts)));
actions.add(new Action(EntityRule.TYPE_AUTOMATION, getString(R.string.title_rule_automation)));
@@ -587,6 +590,7 @@ public class FragmentRule extends FragmentBase {
grpAnswer.setVisibility(View.GONE);
grpTts.setVisibility(View.GONE);
grpAutomation.setVisibility(View.GONE);
grpDelete.setVisibility(View.GONE);
pbWait.setVisibility(View.VISIBLE);
@@ -1050,6 +1054,7 @@ public class FragmentRule extends FragmentBase {
grpAnswer.setVisibility(type == EntityRule.TYPE_ANSWER ? View.VISIBLE : View.GONE);
grpTts.setVisibility(type == EntityRule.TYPE_TTS ? View.VISIBLE : View.GONE);
grpAutomation.setVisibility(type == EntityRule.TYPE_AUTOMATION ? View.VISIBLE : View.GONE);
grpDelete.setVisibility(type == EntityRule.TYPE_DELETE ? View.VISIBLE : View.GONE);
}
private void onActionDelete() {