Added rule action to silence notifications

pull/214/head
M66B 11 months ago
parent c127eab2d8
commit 8000ec282a

@ -8,6 +8,7 @@ For support you can use [the contact form](https://contact.faircode.eu/?product=
### Next version
* Added rule action for silent notifications
* Added option to disable Gmail labels button
* Small improvements and minor bug fixes
* Updated [AndroidX](https://developer.android.com/jetpack/androidx/versions/all-channel)

@ -8,6 +8,7 @@ For support you can use [the contact form](https://contact.faircode.eu/?product=
### Next version
* Added rule action for silent notifications
* Added option to disable Gmail labels button
* Small improvements and minor bug fixes
* Updated [AndroidX](https://developer.android.com/jetpack/androidx/versions/all-channel)

@ -585,6 +585,8 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
return R.string.title_rule_notes;
case EntityRule.TYPE_URL:
return R.string.title_rule_url;
case EntityRule.TYPE_SILENT:
return R.string.title_rule_silent;
default:
throw new IllegalArgumentException("Unknown action type=" + type);
}

@ -133,6 +133,7 @@ public class EntityRule {
static final int TYPE_LOCAL_ONLY = 17;
static final int TYPE_NOTES = 18;
static final int TYPE_URL = 19;
static final int TYPE_SILENT = 20;
static final String ACTION_AUTOMATION = BuildConfig.APPLICATION_ID + ".AUTOMATION";
static final String EXTRA_RULE = "rule";
@ -631,6 +632,8 @@ public class EntityRule {
return onActionNotes(context, message, jaction, html);
case TYPE_URL:
return onActionUrl(context, message, jaction, html);
case TYPE_SILENT:
return onActionSilent(context, message, jaction);
default:
throw new IllegalArgumentException("Unknown rule type=" + type + " name=" + name);
}
@ -719,6 +722,8 @@ public class EntityRule {
if (TextUtils.isEmpty(url) || !Patterns.WEB_URL.matcher(url).matches())
throw new IllegalArgumentException(context.getString(R.string.title_rule_url_missing));
return;
case TYPE_SILENT:
return;
default:
throw new IllegalArgumentException("Unknown rule type=" + type);
}
@ -1484,6 +1489,14 @@ public class EntityRule {
return true;
}
private boolean onActionSilent(Context context, EntityMessage message, JSONObject jargs) {
DB db = DB.getInstance(context);
db.message().setMessageUiSilent(message.id, true);
message.ui_silent = true;
return true;
}
private static Calendar getRelativeCalendar(boolean all, int minutes, long reference) {
int d = minutes / (24 * 60);
int h = minutes / 60 % 24;

@ -639,6 +639,7 @@ public class FragmentRule extends FragmentBase {
actions.add(new Action(EntityRule.TYPE_UNSEEN, getString(R.string.title_rule_unseen)));
actions.add(new Action(EntityRule.TYPE_HIDE, getString(R.string.title_rule_hide)));
actions.add(new Action(EntityRule.TYPE_IGNORE, getString(R.string.title_rule_ignore)));
actions.add(new Action(EntityRule.TYPE_SILENT, getString(R.string.title_rule_silent)));
if (BuildConfig.DEBUG)
actions.add(new Action(EntityRule.TYPE_LOCAL_ONLY, getString(R.string.title_rule_local_only)));
actions.add(new Action(EntityRule.TYPE_SNOOZE, getString(R.string.title_rule_snooze)));

@ -1985,6 +1985,7 @@
<string name="title_rule_automation">Automation</string>
<string name="title_rule_delete">Delete permanently</string>
<string name="title_rule_sound">Play sound</string>
<string name="title_rule_silent">Silent notification</string>
<string name="title_rule_caption">Edit rule</string>
<string name="title_rule_title">Rule applies to</string>

@ -8,6 +8,7 @@ Ypupiara
Next version
* Added rule action for silent notifications
* Added option to disable Gmail labels button
* Small improvements and minor bug fixes
* Updated AndroidX

Loading…
Cancel
Save