From f9c9f2d2f5e07e966ad6ac165a5a8af3af19cc29 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 25 Aug 2018 13:36:01 +0000 Subject: [PATCH] Made previewing messages in notification a pro feature --- .idea/caches/build_file_checksums.ser | Bin 535 -> 535 bytes .../eu/faircode/email/ServiceSynchronize.java | 25 ++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 6464d45da71ee62d144e4f463be7f64092017616..7da81e0eb63bda3a207eac3696dc3a9a2ca82ad7 100644 GIT binary patch delta 33 pcmbQvGM#0@43jZ&G9IDgf$C4!i&W diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 41901052..1c6e0813 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -281,16 +281,6 @@ public class ServiceSynchronize extends LifecycleService { Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); - DateFormat df = SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.SHORT, SimpleDateFormat.SHORT); - StringBuilder sb = new StringBuilder(); - for (EntityMessage message : messages) { - sb.append(MessageHelper.getFormattedAddresses(message.from, false)); - if (!TextUtils.isEmpty(message.subject)) - sb.append(": ").append(message.subject); - sb.append(" ").append(df.format(new Date(message.sent))); - sb.append("\n"); - } - // Build notification Notification.Builder builder; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) @@ -302,7 +292,6 @@ public class ServiceSynchronize extends LifecycleService { .setSmallIcon(R.drawable.baseline_mail_24) .setContentTitle(getResources().getQuantityString(R.plurals.title_notification_unseen, messages.size(), messages.size())) .setContentIntent(pi) - .setStyle(new Notification.BigTextStyle().bigText(sb.toString())) .setSound(uri) .setShowWhen(false) .setPriority(Notification.PRIORITY_DEFAULT) @@ -310,6 +299,20 @@ public class ServiceSynchronize extends LifecycleService { .setVisibility(Notification.VISIBILITY_PUBLIC) .setDeleteIntent(pid); + if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("pro", false)) { + DateFormat df = SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.SHORT, SimpleDateFormat.SHORT); + StringBuilder sb = new StringBuilder(); + for (EntityMessage message : messages) { + sb.append(MessageHelper.getFormattedAddresses(message.from, false)); + if (!TextUtils.isEmpty(message.subject)) + sb.append(": ").append(message.subject); + sb.append(" ").append(df.format(new Date(message.sent))); + sb.append("\n"); + } + + builder.setStyle(new Notification.BigTextStyle().bigText(sb.toString())); + } + return builder; }