diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java
index 3480008d4c..15a212eb55 100644
--- a/app/src/main/java/eu/faircode/email/Core.java
+++ b/app/src/main/java/eu/faircode/email/Core.java
@@ -3689,29 +3689,30 @@ class Core {
// - on connectivity problems when connecting to store
static NotificationCompat.Builder getNotificationError(Context context, String channel, String title, Throwable ex) {
+ // Build pending intent
Intent intent = new Intent(context, ActivityView.class);
intent.setAction("error");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pi = PendingIntent.getActivity(
context, ActivityView.REQUEST_ERROR, intent, PendingIntent.FLAG_UPDATE_CURRENT);
- return getNotificationError(context, channel, title, ex, pi);
- }
+ // Build notification
+ NotificationCompat.Builder builder =
+ new NotificationCompat.Builder(context, channel)
+ .setSmallIcon(R.drawable.baseline_warning_white_24)
+ .setContentTitle(context.getString(R.string.title_notification_failed, title))
+ .setContentText(Log.formatThrowable(ex, false))
+ .setContentIntent(pi)
+ .setAutoCancel(false)
+ .setShowWhen(true)
+ .setPriority(NotificationCompat.PRIORITY_MAX)
+ .setOnlyAlertOnce(true)
+ .setCategory(NotificationCompat.CATEGORY_ERROR)
+ .setVisibility(NotificationCompat.VISIBILITY_SECRET)
+ .setStyle(new NotificationCompat.BigTextStyle()
+ .bigText(Log.formatThrowable(ex, "\n", false)));
- static NotificationCompat.Builder getNotificationError(Context context, String channel, String title, Throwable ex, PendingIntent pi) {
- return new NotificationCompat.Builder(context, channel)
- .setSmallIcon(R.drawable.baseline_warning_white_24)
- .setContentTitle(context.getString(R.string.title_notification_failed, title))
- .setContentText(Log.formatThrowable(ex, false))
- .setContentIntent(pi)
- .setAutoCancel(false)
- .setShowWhen(true)
- .setPriority(NotificationCompat.PRIORITY_MAX)
- .setOnlyAlertOnce(true)
- .setCategory(NotificationCompat.CATEGORY_ERROR)
- .setVisibility(NotificationCompat.VISIBILITY_SECRET)
- .setStyle(new NotificationCompat.BigTextStyle()
- .bigText(Log.formatThrowable(ex, "\n", false)));
+ return builder;
}
static class State {
diff --git a/app/src/main/java/eu/faircode/email/ServiceSend.java b/app/src/main/java/eu/faircode/email/ServiceSend.java
index 7825e07887..f386e92b5b 100644
--- a/app/src/main/java/eu/faircode/email/ServiceSend.java
+++ b/app/src/main/java/eu/faircode/email/ServiceSend.java
@@ -204,6 +204,22 @@ public class ServiceSend extends ServiceBase {
return builder;
}
+ NotificationCompat.Builder getNotificationError(String recipient, Throwable ex) {
+ return new NotificationCompat.Builder(this, "error")
+ .setSmallIcon(R.drawable.baseline_warning_white_24)
+ .setContentTitle(getString(R.string.title_notification_sending_failed, recipient))
+ .setContentText(Log.formatThrowable(ex, false))
+ .setContentIntent(getPendingIntent(this))
+ .setAutoCancel(false)
+ .setShowWhen(true)
+ .setPriority(NotificationCompat.PRIORITY_MAX)
+ .setOnlyAlertOnce(true)
+ .setCategory(NotificationCompat.CATEGORY_ERROR)
+ .setVisibility(NotificationCompat.VISIBILITY_SECRET)
+ .setStyle(new NotificationCompat.BigTextStyle()
+ .bigText(Log.formatThrowable(ex, "\n", false)));
+ }
+
private static PendingIntent getPendingIntent(Context context) {
Intent intent = new Intent(context, ActivityView.class);
intent.setAction("outbox");
@@ -356,13 +372,10 @@ public class ServiceSend extends ServiceBase {
ops.remove(op);
if (message != null) {
- String title = MessageHelper.formatAddresses(message.to);
- PendingIntent pi = getPendingIntent(this);
-
try {
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
- nm.notify("send:" + message.id, 1,
- Core.getNotificationError(this, "error", title, ex, pi).build());
+ nm.notify("send:" + message.id, 1, getNotificationError(
+ MessageHelper.formatAddressesShort(message.to), ex).build());
} catch (Throwable ex1) {
Log.w(ex1);
}
@@ -535,6 +548,8 @@ public class ServiceSend extends ServiceBase {
// Connect transport
db.identity().setIdentityState(ident.id, "connecting");
iservice.connect(ident);
+ if (BuildConfig.DEBUG)
+ throw new IOException("Test");
db.identity().setIdentityState(ident.id, "connected");
Address[] to = imessage.getAllRecipients();
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 0b6bb5eca1..19f2aad16d 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -98,6 +98,7 @@
Idle
\'%1$s\' failed
\'%1$s\' server alert
+ Sending to %1$s failed
%1$s/%2$s
%1$s (%2$s)