mirror of https://github.com/M66B/FairEmail.git
Group channels by account
This commit is contained in:
parent
c596293b61
commit
e50abcbcea
|
@ -382,8 +382,12 @@ public class ApplicationEx extends Application {
|
||||||
jchannel.getString("name"),
|
jchannel.getString("name"),
|
||||||
jchannel.getInt("importance"));
|
jchannel.getInt("importance"));
|
||||||
|
|
||||||
if (jchannel.has("group") && !jchannel.isNull("group"))
|
if (jchannel.has("group") && !jchannel.isNull("group")) {
|
||||||
channel.setGroup(jchannel.getString("group"));
|
String groupName = jchannel.getString("group");
|
||||||
|
NotificationChannelGroup group = new NotificationChannelGroup(groupName, groupName);
|
||||||
|
nm.createNotificationChannelGroup(group);
|
||||||
|
channel.setGroup(groupName);
|
||||||
|
}
|
||||||
|
|
||||||
if (jchannel.has("description") && !jchannel.isNull("description"))
|
if (jchannel.has("description") && !jchannel.isNull("description"))
|
||||||
channel.setDescription(jchannel.getString("description"));
|
channel.setDescription(jchannel.getString("description"));
|
||||||
|
|
|
@ -21,6 +21,7 @@ package eu.faircode.email;
|
||||||
|
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.NotificationChannel;
|
import android.app.NotificationChannel;
|
||||||
|
import android.app.NotificationChannelGroup;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
|
@ -106,9 +107,14 @@ public class EntityAccount extends EntityOrder implements Serializable {
|
||||||
void createNotificationChannel(Context context) {
|
void createNotificationChannel(Context context) {
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
||||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
|
||||||
|
NotificationChannelGroup group = new NotificationChannelGroup(name, name);
|
||||||
|
nm.createNotificationChannelGroup(group);
|
||||||
|
|
||||||
NotificationChannel channel = new NotificationChannel(
|
NotificationChannel channel = new NotificationChannel(
|
||||||
getNotificationChannelId(id), name,
|
getNotificationChannelId(id), name,
|
||||||
NotificationManager.IMPORTANCE_HIGH);
|
NotificationManager.IMPORTANCE_HIGH);
|
||||||
|
channel.setGroup(name);
|
||||||
channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
|
channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
|
||||||
nm.createNotificationChannel(channel);
|
nm.createNotificationChannel(channel);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ package eu.faircode.email;
|
||||||
|
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.NotificationChannel;
|
import android.app.NotificationChannel;
|
||||||
|
import android.app.NotificationChannelGroup;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
|
@ -68,9 +69,14 @@ public class TupleFolderEx extends EntityFolder implements Serializable {
|
||||||
void createNotificationChannel(Context context) {
|
void createNotificationChannel(Context context) {
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
||||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
|
||||||
|
NotificationChannelGroup group = new NotificationChannelGroup(accountName, accountName);
|
||||||
|
nm.createNotificationChannelGroup(group);
|
||||||
|
|
||||||
NotificationChannel channel = new NotificationChannel(
|
NotificationChannel channel = new NotificationChannel(
|
||||||
getNotificationChannelId(id), accountName + "/" + getDisplayName(context),
|
getNotificationChannelId(id), getDisplayName(context),
|
||||||
NotificationManager.IMPORTANCE_HIGH);
|
NotificationManager.IMPORTANCE_HIGH);
|
||||||
|
channel.setGroup(accountName);
|
||||||
channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
|
channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
|
||||||
nm.createNotificationChannel(channel);
|
nm.createNotificationChannel(channel);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue