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

@@ -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;