From 7ad4dc5420127b467ad6c54661a9389f690380ff Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 4 Jul 2020 18:21:49 +0200 Subject: [PATCH] Added received time to automation intent --- app/src/main/java/eu/faircode/email/EntityRule.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/EntityRule.java b/app/src/main/java/eu/faircode/email/EntityRule.java index 77661266dc..0143ba91d1 100644 --- a/app/src/main/java/eu/faircode/email/EntityRule.java +++ b/app/src/main/java/eu/faircode/email/EntityRule.java @@ -39,6 +39,8 @@ import org.json.JSONObject; import java.io.File; import java.io.IOException; +import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; @@ -107,6 +109,7 @@ public class EntityRule { static final String EXTRA_RULE = "rule"; static final String EXTRA_SENDER = "sender"; static final String EXTRA_SUBJECT = "subject"; + static final String EXTRA_RECEIVED = "received"; private static final long SEND_DELAY = 5000L; // milliseconds @@ -475,12 +478,18 @@ public class EntityRule { String sender = (message.from == null || message.from.length == 0 ? null : ((InternetAddress) message.from[0]).getAddress()); + // ISO 8601 + DateFormat DTF = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); + DTF.setTimeZone(java.util.TimeZone.getTimeZone("Zulu")); + Intent automation = new Intent(ACTION_AUTOMATION); automation.putExtra(EXTRA_RULE, name); automation.putExtra(EXTRA_SENDER, sender); automation.putExtra(EXTRA_SUBJECT, message.subject); + automation.putExtra(EXTRA_RECEIVED, DTF.format(message.received)); - EntityLog.log(context, "Sending " + automation); + List extras = Log.getExtras(automation.getExtras()); + EntityLog.log(context, "Sending " + automation + " " + TextUtils.join(" ", extras)); context.sendBroadcast(automation); return true;