Added message importance/rule

This commit is contained in:
M66B
2020-02-01 13:51:32 +01:00
parent cb741da678
commit 80a76c4663
10 changed files with 2220 additions and 26 deletions

View File

@@ -100,6 +100,7 @@ public class EntityRule {
static final int TYPE_NOOP = 10;
static final int TYPE_KEYWORD = 11;
static final int TYPE_HIDE = 12;
static final int TYPE_IMPORTANCE = 13;
static final String ACTION_AUTOMATION = BuildConfig.APPLICATION_ID + ".AUTOMATION";
static final String EXTRA_RULE = "rule";
@@ -306,6 +307,8 @@ public class EntityRule {
return onActionSnooze(context, message, jaction);
case TYPE_FLAG:
return onActionFlag(context, message, jaction);
case TYPE_IMPORTANCE:
return onActionImportance(context, message, jaction);
case TYPE_KEYWORD:
return onActionKeyword(context, message, jaction);
case TYPE_MOVE:
@@ -495,6 +498,19 @@ public class EntityRule {
return true;
}
private boolean onActionImportance(Context context, EntityMessage message, JSONObject jargs) throws JSONException {
Integer importance = jargs.getInt("value");
if (importance == EntityMessage.PRIORITIY_NORMAL)
importance = null;
DB db = DB.getInstance(context);
db.message().setMessageImportance(message.id, importance);
message.importance = importance;
return true;
}
private boolean onActionKeyword(Context context, EntityMessage message, JSONObject jargs) throws JSONException {
String keyword = jargs.getString("keyword");
if (TextUtils.isEmpty(keyword)) {