diff --git a/FAQ.md b/FAQ.md index e556fe85c2..3e7e7d3f60 100644 --- a/FAQ.md +++ b/FAQ.md @@ -1128,7 +1128,6 @@ but even Google's Chrome cannot handle this. * Did you know that you can retry sending messages by using pull-down-to-refresh in the outbox? * Did you know that you can swipe a conversation left or right to go to the next or previous conversation? * Did you know that you can tap on an image to see where it will be downloaded from? -* Did you know that you can long press the bell icon to delete the notification channel for the email address? * Did you know that you can long press the folder icon in the action bar to select an account?
diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 4bd0709ee2..47885bdfa3 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -176,7 +176,7 @@ public class AdapterMessage extends RecyclerView.Adapter 0) { - NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); + default: + return false; + } + } - InternetAddress from = (InternetAddress) message.from[0]; - String channelName = "notification." + from.getAddress().toLowerCase(); - nm.deleteNotificationChannel(channelName); - } + @TargetApi(Build.VERSION_CODES.O) + private void onActionCreateChannel() { + NotificationChannel channel = new NotificationChannel( + channelId, from.getAddress(), + NotificationManager.IMPORTANCE_HIGH); + channel.setGroup("contacts"); + channel.setDescription(from.getPersonal()); + channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE); + nm.createNotificationChannel(channel); + onActionEditChannel(); + } + + private void onActionEditChannel() { + Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS) + .putExtra(Settings.EXTRA_APP_PACKAGE, context.getPackageName()) + .putExtra(Settings.EXTRA_CHANNEL_ID, channelId); + context.startActivity(intent); + } + + private void onActionDeleteChannel() { + NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); + nm.deleteNotificationChannel(channelId); + } + }); + + popupMenu.show(); } private void onAddContact(TupleMessageEx message) {