Refactoring

pull/156/head
M66B 6 years ago
parent ce39566d60
commit 6fb436155a

@ -1885,19 +1885,19 @@ class Core {
R.plurals.title_notification_unseen, messages.size(), messages.size()); R.plurals.title_notification_unseen, messages.size(), messages.size());
// Build notification // Build notification
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, "notification"); NotificationCompat.Builder builder =
builder new NotificationCompat.Builder(context, "notification")
.setSmallIcon(R.drawable.baseline_email_white_24) .setSmallIcon(R.drawable.baseline_email_white_24)
.setContentTitle(title) .setContentTitle(title)
.setContentIntent(piSummary) .setContentIntent(piSummary)
.setNumber(messages.size()) .setNumber(messages.size())
.setShowWhen(false) .setShowWhen(false)
.setDeleteIntent(piClear) .setDeleteIntent(piClear)
.setPriority(NotificationCompat.PRIORITY_DEFAULT) .setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setCategory(NotificationCompat.CATEGORY_STATUS) .setCategory(NotificationCompat.CATEGORY_STATUS)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setGroup(group) .setGroup(group)
.setGroupSummary(true); .setGroupSummary(true);
Notification pub = builder.build(); Notification pub = builder.build();
builder builder
@ -1972,21 +1972,19 @@ class Core {
? Helper.localizeFolderName(context, message.folderName) ? Helper.localizeFolderName(context, message.folderName)
: message.folderDisplay; : message.folderDisplay;
NotificationCompat.Builder mbuilder; NotificationCompat.Builder mbuilder =
mbuilder = new NotificationCompat.Builder(context, channelName); new NotificationCompat.Builder(context, channelName)
.addExtras(args)
mbuilder .setSmallIcon(R.drawable.baseline_email_white_24)
.addExtras(args) .setContentTitle(info.getDisplayName(true))
.setSmallIcon(R.drawable.baseline_email_white_24) .setSubText(message.accountName + " · " + folderName)
.setContentTitle(info.getDisplayName(true)) .setContentIntent(piContent)
.setSubText(message.accountName + " · " + folderName) .setWhen(message.received)
.setContentIntent(piContent) .setDeleteIntent(piIgnore)
.setWhen(message.received) .setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setDeleteIntent(piIgnore) .setCategory(NotificationCompat.CATEGORY_MESSAGE)
.setPriority(NotificationCompat.PRIORITY_DEFAULT) .setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
.setCategory(NotificationCompat.CATEGORY_MESSAGE) .setOnlyAlertOnce(true);
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
.setOnlyAlertOnce(true);
if (notify_group) if (notify_group)
mbuilder.setGroup(group).setGroupSummary(false); mbuilder.setGroup(group).setGroupSummary(false);
@ -2179,19 +2177,18 @@ class Core {
context, ActivityView.REQUEST_ERROR, intent, PendingIntent.FLAG_UPDATE_CURRENT); context, ActivityView.REQUEST_ERROR, intent, PendingIntent.FLAG_UPDATE_CURRENT);
// Build notification // Build notification
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channel); NotificationCompat.Builder builder =
new NotificationCompat.Builder(context, channel)
builder .setSmallIcon(R.drawable.baseline_warning_white_24)
.setSmallIcon(R.drawable.baseline_warning_white_24) .setContentTitle(context.getString(R.string.title_notification_failed, title))
.setContentTitle(context.getString(R.string.title_notification_failed, title)) .setContentText(Helper.formatThrowable(ex))
.setContentText(Helper.formatThrowable(ex)) .setContentIntent(pi)
.setContentIntent(pi) .setAutoCancel(false)
.setAutoCancel(false) .setShowWhen(true)
.setShowWhen(true) .setPriority(NotificationCompat.PRIORITY_MAX)
.setPriority(NotificationCompat.PRIORITY_MAX) .setOnlyAlertOnce(true)
.setOnlyAlertOnce(true) .setCategory(NotificationCompat.CATEGORY_ERROR)
.setCategory(NotificationCompat.CATEGORY_ERROR) .setVisibility(NotificationCompat.VISIBILITY_SECRET);
.setVisibility(NotificationCompat.VISIBILITY_SECRET);
builder.setStyle(new NotificationCompat.BigTextStyle() builder.setStyle(new NotificationCompat.BigTextStyle()
.bigText(Helper.formatThrowable(ex, false, "\n"))); .bigText(Helper.formatThrowable(ex, false, "\n")));

@ -80,16 +80,15 @@ public class ServiceExternal extends Service {
} }
private NotificationCompat.Builder getNotification() { private NotificationCompat.Builder getNotification() {
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "service"); NotificationCompat.Builder builder =
new NotificationCompat.Builder(this, "service")
builder .setSmallIcon(R.drawable.baseline_compare_arrows_white_24)
.setSmallIcon(R.drawable.baseline_compare_arrows_white_24) .setContentTitle(getString(R.string.tile_synchronize))
.setContentTitle(getString(R.string.tile_synchronize)) .setAutoCancel(false)
.setAutoCancel(false) .setShowWhen(false)
.setShowWhen(false) .setPriority(NotificationCompat.PRIORITY_MIN)
.setPriority(NotificationCompat.PRIORITY_MIN) .setCategory(NotificationCompat.CATEGORY_STATUS)
.setCategory(NotificationCompat.CATEGORY_STATUS) .setVisibility(NotificationCompat.VISIBILITY_SECRET);
.setVisibility(NotificationCompat.VISIBILITY_SECRET);
return builder; return builder;
} }

@ -123,17 +123,16 @@ public class ServiceSend extends LifecycleService {
PendingIntent pi = PendingIntent.getActivity( PendingIntent pi = PendingIntent.getActivity(
this, ActivityView.REQUEST_OUTBOX, intent, PendingIntent.FLAG_UPDATE_CURRENT); this, ActivityView.REQUEST_OUTBOX, intent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "send"); NotificationCompat.Builder builder =
new NotificationCompat.Builder(this, "send")
builder .setSmallIcon(R.drawable.baseline_send_24)
.setSmallIcon(R.drawable.baseline_send_24) .setContentTitle(getString(R.string.title_notification_sending))
.setContentTitle(getString(R.string.title_notification_sending)) .setContentIntent(pi)
.setContentIntent(pi) .setAutoCancel(false)
.setAutoCancel(false) .setShowWhen(true)
.setShowWhen(true) .setPriority(NotificationCompat.PRIORITY_MIN)
.setPriority(NotificationCompat.PRIORITY_MIN) .setCategory(NotificationCompat.CATEGORY_STATUS)
.setCategory(NotificationCompat.CATEGORY_STATUS) .setVisibility(NotificationCompat.VISIBILITY_SECRET);
.setVisibility(NotificationCompat.VISIBILITY_SECRET);
if (lastUnsent > 0) if (lastUnsent > 0)
builder.setContentText(getResources().getQuantityString( builder.setContentText(getResources().getQuantityString(

@ -266,18 +266,17 @@ public class ServiceSynchronize extends LifecycleService {
PendingIntent piWhy = PendingIntent.getActivity(this, ActivityView.REQUEST_WHY, why, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent piWhy = PendingIntent.getActivity(this, ActivityView.REQUEST_WHY, why, PendingIntent.FLAG_UPDATE_CURRENT);
// Build notification // Build notification
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "service"); NotificationCompat.Builder builder =
new NotificationCompat.Builder(this, "service")
builder .setSmallIcon(R.drawable.baseline_compare_arrows_white_24)
.setSmallIcon(R.drawable.baseline_compare_arrows_white_24) .setContentTitle(getResources().getQuantityString(
.setContentTitle(getResources().getQuantityString( R.plurals.title_notification_synchronizing, lastStats.accounts, lastStats.accounts))
R.plurals.title_notification_synchronizing, lastStats.accounts, lastStats.accounts)) .setContentIntent(piWhy)
.setContentIntent(piWhy) .setAutoCancel(false)
.setAutoCancel(false) .setShowWhen(false)
.setShowWhen(false) .setPriority(NotificationCompat.PRIORITY_MIN)
.setPriority(NotificationCompat.PRIORITY_MIN) .setCategory(NotificationCompat.CATEGORY_STATUS)
.setCategory(NotificationCompat.CATEGORY_STATUS) .setVisibility(NotificationCompat.VISIBILITY_SECRET);
.setVisibility(NotificationCompat.VISIBILITY_SECRET);
if (lastStats.operations > 0) if (lastStats.operations > 0)
builder.setContentText(getResources().getQuantityString( builder.setContentText(getResources().getQuantityString(

Loading…
Cancel
Save