Support for notification channel per folder

This commit is contained in:
M66B
2019-05-16 10:04:20 +02:00
parent aba421c470
commit 84a27c7d7a
6 changed files with 91 additions and 7 deletions

View File

@@ -19,6 +19,9 @@ package eu.faircode.email;
Copyright 2018-2019 by Marcel Bokhorst (M66B)
*/
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import java.io.Serializable;
@@ -55,6 +58,24 @@ public class TupleFolderEx extends EntityFolder implements Serializable {
return false;
}
void createNotificationChannel(Context context) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel channel = new NotificationChannel(
getNotificationChannelId(id), accountName + "/" + getDisplayName(context),
NotificationManager.IMPORTANCE_HIGH);
channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
nm.createNotificationChannel(channel);
}
}
void deleteNotificationChannel(Context context) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.deleteNotificationChannel(getNotificationChannelId(id));
}
}
@Override
Comparator getComparator(final Context context) {
final Collator collator = Collator.getInstance(Locale.getDefault());