Improved operation warnings

pull/217/head
M66B 6 months ago
parent 2a712a3ee3
commit ad8c96d9ce

@ -758,7 +758,7 @@ class Core {
String title = (resid == 0 ? null : context.getString(resid)); String title = (resid == 0 ? null : context.getString(resid));
if (title != null) { if (title != null) {
NotificationCompat.Builder builder = NotificationCompat.Builder builder =
getNotificationError(context, "warning", account, message.id, new Throwable(title, ex)); getNotificationError(context, "warning", account, folder, message, new Throwable(title, ex));
if (NotificationHelper.areNotificationsEnabled(nm)) if (NotificationHelper.areNotificationsEnabled(nm))
nm.notify(op.name + ":" + op.message, nm.notify(op.name + ":" + op.message,
NotificationHelper.NOTIFICATION_TAGGED, NotificationHelper.NOTIFICATION_TAGGED,
@ -5705,25 +5705,39 @@ class Core {
// MailConnectException // MailConnectException
// - on connectivity problems when connecting to store // - on connectivity problems when connecting to store
static NotificationCompat.Builder getNotificationError(Context context, String channel, EntityAccount account, long id, Throwable ex) { static NotificationCompat.Builder getNotificationError(
Context context, String channel, EntityAccount account, EntityFolder folder, EntityMessage message, Throwable ex) {
String title = context.getString(R.string.title_notification_failed, account.name); String title = context.getString(R.string.title_notification_failed, account.name);
String message = Log.formatThrowable(ex, "\n", false); String msg = Log.formatThrowable(ex, "\n", false);
// Build pending intent // Build pending intent
Intent intent = new Intent(context, ActivityError.class); PendingIntent pi;
intent.setAction(channel + ":" + account.id + ":" + id); if (message == null) {
intent.putExtra("title", title); Intent intent = new Intent(context, ActivityError.class);
intent.putExtra("message", message); intent.setAction(channel + ":" + account.id);
intent.putExtra("provider", account.provider); intent.putExtra("title", title);
intent.putExtra("account", account.id); intent.putExtra("message", msg);
intent.putExtra("protocol", account.protocol); intent.putExtra("provider", account.provider);
intent.putExtra("auth_type", account.auth_type); intent.putExtra("account", account.id);
intent.putExtra("host", account.host); intent.putExtra("protocol", account.protocol);
intent.putExtra("address", account.user); intent.putExtra("auth_type", account.auth_type);
intent.putExtra("faq", 22); intent.putExtra("host", account.host);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra("address", account.user);
PendingIntent pi = PendingIntentCompat.getActivity( intent.putExtra("faq", 22);
context, ActivityError.PI_ERROR, intent, PendingIntent.FLAG_UPDATE_CURRENT); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
pi = PendingIntentCompat.getActivity(
context, ActivityError.PI_ERROR, intent, PendingIntent.FLAG_UPDATE_CURRENT);
} else {
Intent thread = new Intent(context, ActivityView.class);
thread.setAction("thread:" + message.id);
thread.putExtra("account", message.account);
thread.putExtra("folder", message.folder);
thread.putExtra("type", folder.type);
thread.putExtra("thread", message.thread);
thread.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
pi = PendingIntentCompat.getActivity(
context, ActivityView.PI_THREAD, thread, PendingIntent.FLAG_UPDATE_CURRENT);
}
// Build notification // Build notification
NotificationCompat.Builder builder = NotificationCompat.Builder builder =
@ -5738,7 +5752,7 @@ class Core {
.setOnlyAlertOnce(true) .setOnlyAlertOnce(true)
.setCategory(NotificationCompat.CATEGORY_ERROR) .setCategory(NotificationCompat.CATEGORY_ERROR)
.setVisibility(NotificationCompat.VISIBILITY_SECRET) .setVisibility(NotificationCompat.VISIBILITY_SECRET)
.setStyle(new NotificationCompat.BigTextStyle().bigText(message)); .setStyle(new NotificationCompat.BigTextStyle().bigText(msg));
return builder; return builder;
} }

@ -1798,7 +1798,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
if (NotificationHelper.areNotificationsEnabled(nm)) if (NotificationHelper.areNotificationsEnabled(nm))
nm.notify("receive:" + account.id, nm.notify("receive:" + account.id,
NotificationHelper.NOTIFICATION_TAGGED, NotificationHelper.NOTIFICATION_TAGGED,
Core.getNotificationError(this, "error", account, 0, ex) Core.getNotificationError(this, "error", account, null, null, ex)
.build()); .build());
} catch (Throwable ex1) { } catch (Throwable ex1) {
Log.w(ex1); Log.w(ex1);
@ -2693,7 +2693,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
if (NotificationHelper.areNotificationsEnabled(nm)) if (NotificationHelper.areNotificationsEnabled(nm))
nm.notify("receive:" + account.id, nm.notify("receive:" + account.id,
NotificationHelper.NOTIFICATION_TAGGED, NotificationHelper.NOTIFICATION_TAGGED,
Core.getNotificationError(this, "warning", account, 0, warning) Core.getNotificationError(this, "warning", account, null, null, warning)
.build()); .build());
} catch (Throwable ex1) { } catch (Throwable ex1) {
Log.w(ex1); Log.w(ex1);

Loading…
Cancel
Save