mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-04 08:08:16 +02:00
Experiment: rule to set notifications local only
This commit is contained in:
@@ -119,6 +119,7 @@ public class EntityRule {
|
||||
static final int TYPE_TTS = 14;
|
||||
static final int TYPE_DELETE = 15;
|
||||
static final int TYPE_SOUND = 16;
|
||||
static final int TYPE_LOCAL_ONLY = 17;
|
||||
|
||||
static final String ACTION_AUTOMATION = BuildConfig.APPLICATION_ID + ".AUTOMATION";
|
||||
static final String EXTRA_RULE = "rule";
|
||||
@@ -510,6 +511,8 @@ public class EntityRule {
|
||||
return onActionDelete(context, message, jaction);
|
||||
case TYPE_SOUND:
|
||||
return onActionSound(context, message, jaction);
|
||||
case TYPE_LOCAL_ONLY:
|
||||
return onActionLocalOnly(context, message, jaction);
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown rule type=" + type + " name=" + name);
|
||||
}
|
||||
@@ -589,6 +592,8 @@ public class EntityRule {
|
||||
if (TextUtils.isEmpty(uri))
|
||||
throw new IllegalArgumentException(context.getString(R.string.title_rule_select_sound));
|
||||
return;
|
||||
case TYPE_LOCAL_ONLY:
|
||||
return;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown rule type=" + type);
|
||||
}
|
||||
@@ -1127,6 +1132,18 @@ public class EntityRule {
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean onActionLocalOnly(Context context, EntityMessage message, JSONObject jargs) throws JSONException {
|
||||
if (message.ui_seen)
|
||||
return false;
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
|
||||
message.ui_local_only = true;
|
||||
db.message().setMessageUiLocalOnly(message.id, message.ui_local_only);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static Calendar getRelativeCalendar(int minutes, long reference) {
|
||||
int d = minutes / (24 * 60);
|
||||
int h = minutes / 60 % 24;
|
||||
|
||||
Reference in New Issue
Block a user