diff --git a/app/src/main/java/eu/faircode/email/EntityRule.java b/app/src/main/java/eu/faircode/email/EntityRule.java
index bd537d5d2d..c348b7561a 100644
--- a/app/src/main/java/eu/faircode/email/EntityRule.java
+++ b/app/src/main/java/eu/faircode/email/EntityRule.java
@@ -1313,6 +1313,8 @@ public class EntityRule {
}
private boolean onActionAutomation(Context context, EntityMessage message, JSONObject jargs, String html) {
+ Intent automation;
+
InternetAddress iaddr =
(message.from == null || message.from.length == 0
? null : ((InternetAddress) message.from[0]));
@@ -1321,16 +1323,36 @@ public class EntityRule {
DateFormat DTF = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
DTF.setTimeZone(java.util.TimeZone.getTimeZone("Zulu"));
+ if (html == null && message.content) {
+ File file = message.getFile(context);
+ try {
+ html = Helper.readText(file);
+ } catch (IOException ex) {
+ Log.e(ex);
+ }
+ }
+
String text = HtmlHelper.getFullText(context, html);
String preview = HtmlHelper.getPreview(text);
- Intent automation = new Intent(ACTION_AUTOMATION);
- automation.putExtra(EXTRA_RULE, name);
- automation.putExtra(EXTRA_RECEIVED, DTF.format(message.received));
- automation.putExtra(EXTRA_SENDER, iaddr == null ? null : iaddr.getAddress());
- automation.putExtra(EXTRA_NAME, iaddr == null ? null : iaddr.getPersonal());
- automation.putExtra(EXTRA_SUBJECT, message.subject);
- automation.putExtra(EXTRA_PREVIEW, preview);
+ boolean gb = jargs.optBoolean("gadgetbridge");
+ if (gb) {
+ // https://gadgetbridge.org/internals/automations/intents/#send-a-custom-notification
+ automation = new Intent("nodomain.freeyourgadget.gadgetbridge.command.DEBUG_SEND_NOTIFICATION");
+ automation.putExtra("type", "GENERIC_EMAIL");
+ automation.putExtra("sender", iaddr == null ? null : MessageHelper.formatAddresses(new InternetAddress[]{iaddr}));
+ automation.putExtra("subject", message.subject);
+ automation.putExtra("body", TextUtils.isEmpty(preview) ? "-" : preview);
+ //automation.setPackage("nodomain.freeyourgadget.gadgetbridge");
+ } else {
+ automation = new Intent(ACTION_AUTOMATION);
+ automation.putExtra(EXTRA_RULE, name);
+ automation.putExtra(EXTRA_RECEIVED, DTF.format(message.received));
+ automation.putExtra(EXTRA_SENDER, iaddr == null ? null : iaddr.getAddress());
+ automation.putExtra(EXTRA_NAME, iaddr == null ? null : iaddr.getPersonal());
+ automation.putExtra(EXTRA_SUBJECT, message.subject);
+ automation.putExtra(EXTRA_PREVIEW, preview);
+ }
List extras = Log.getExtras(automation.getExtras());
EntityLog.log(context, EntityLog.Type.Rules, message,
diff --git a/app/src/main/java/eu/faircode/email/FragmentRule.java b/app/src/main/java/eu/faircode/email/FragmentRule.java
index 197e267434..3389a27231 100644
--- a/app/src/main/java/eu/faircode/email/FragmentRule.java
+++ b/app/src/main/java/eu/faircode/email/FragmentRule.java
@@ -180,6 +180,8 @@ public class FragmentRule extends FragmentBase {
private TextView tvAutomation;
+ private CheckBox cbGadgetBridge;
+
private EditText etNotes;
private ViewButtonColor btnColorNotes;
@@ -394,6 +396,8 @@ public class FragmentRule extends FragmentBase {
tvAutomation = view.findViewById(R.id.tvAutomation);
+ cbGadgetBridge = view.findViewById(R.id.cbGadgetBridge);
+
etNotes = view.findViewById(R.id.etNotes);
btnColorNotes = view.findViewById(R.id.btnColorNotes);
@@ -972,6 +976,7 @@ public class FragmentRule extends FragmentBase {
grpTts.setVisibility(View.GONE);
grpSound.setVisibility(View.GONE);
grpAutomation.setVisibility(View.GONE);
+ cbGadgetBridge.setVisibility(View.GONE);
grpDelete.setVisibility(View.GONE);
grpLocalOnly.setVisibility(View.GONE);
grpNotes.setVisibility(View.GONE);
@@ -1518,6 +1523,10 @@ public class FragmentRule extends FragmentBase {
etAlarmDuration.setText(duration == 0 ? null : Integer.toString(duration));
break;
+ case EntityRule.TYPE_AUTOMATION:
+ cbGadgetBridge.setChecked(jaction.optBoolean("gadgetbridge"));
+ break;
+
case EntityRule.TYPE_NOTES:
etNotes.setText(jaction.getString("notes"));
btnColorNotes.setColor(
@@ -1591,6 +1600,7 @@ public class FragmentRule extends FragmentBase {
grpTts.setVisibility(type == EntityRule.TYPE_TTS ? View.VISIBLE : View.GONE);
grpSound.setVisibility(type == EntityRule.TYPE_SOUND ? View.VISIBLE : View.GONE);
grpAutomation.setVisibility(type == EntityRule.TYPE_AUTOMATION ? View.VISIBLE : View.GONE);
+ cbGadgetBridge.setVisibility(type == EntityRule.TYPE_AUTOMATION && BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
grpDelete.setVisibility(type == EntityRule.TYPE_DELETE ? View.VISIBLE : View.GONE);
grpLocalOnly.setVisibility(type == EntityRule.TYPE_LOCAL_ONLY ? View.VISIBLE : View.GONE);
grpNotes.setVisibility(type == EntityRule.TYPE_NOTES ? View.VISIBLE : View.GONE);
@@ -1964,6 +1974,10 @@ public class FragmentRule extends FragmentBase {
}
break;
+ case EntityRule.TYPE_AUTOMATION:
+ jaction.put("gadgetbridge", cbGadgetBridge.isChecked());
+ break;
+
case EntityRule.TYPE_NOTES:
jaction.put("notes", etNotes.getText().toString());
int ncolor = btnColorNotes.getColor();
diff --git a/app/src/main/res/layout/fragment_rule.xml b/app/src/main/res/layout/fragment_rule.xml
index 25a322bc08..74cc7b7279 100644
--- a/app/src/main/res/layout/fragment_rule.xml
+++ b/app/src/main/res/layout/fragment_rule.xml
@@ -1373,6 +1373,15 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/etAlarmDuration" />
+
+
+ app:layout_constraintTop_toBottomOf="@+id/cbGadgetBridge" />
Template missing
Keyword missing
This will send the intent \'%1$s\' with the extras \'%2$s\'
+ GadgetBridge
Local notes missing
URL missing or invalid
Permanent deletion is irreversible, so make sure the rule conditions are correct!