Use account id as group id

This commit is contained in:
M66B 2019-06-08 09:51:00 +02:00
parent 183bb1b7a9
commit 9a9ebeb79c
4 changed files with 14 additions and 10 deletions

View File

@ -844,11 +844,12 @@ public class ActivitySetup extends ActivityBilling implements FragmentManager.On
account.deleteNotificationChannel(context);
if (account.notify)
if (jaccount.has("channel")) {
NotificationChannelGroup group = new NotificationChannelGroup(account.name, account.name);
NotificationChannelGroup group = new NotificationChannelGroup("group." + account.id, account.name);
nm.createNotificationChannelGroup(group);
JSONObject jchannel = (JSONObject) jaccount.get("channel");
jchannel.put("id", EntityAccount.getNotificationChannelId(account.id));
jchannel.put("group", group.getId());
nm.createNotificationChannel(channelFromJSON(context, jchannel));
Log.i("Imported account channel=" + jchannel);
@ -892,11 +893,12 @@ public class ActivitySetup extends ActivityBilling implements FragmentManager.On
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (jfolder.has("channel")) {
NotificationChannelGroup group = new NotificationChannelGroup(account.name, account.name);
NotificationChannelGroup group = new NotificationChannelGroup("group." + account.id, account.name);
nm.createNotificationChannelGroup(group);
JSONObject jchannel = (JSONObject) jfolder.get("channel");
jchannel.put("id", EntityFolder.getNotificationChannelId(folder.id));
jchannel.put("group", group.getId());
nm.createNotificationChannel(channelFromJSON(context, jchannel));
Log.i("Imported folder channel=" + jchannel);

View File

@ -32,7 +32,7 @@ public interface DaoFolder {
List<EntityFolder> getFolders(long account);
@Query("SELECT folder.*" +
", account.`order` AS accountOrder, account.name AS accountName, account.color AS accountColor, account.state AS accountState" +
", account.id AS accountId, account.`order` AS accountOrder, account.name AS accountName, account.color AS accountColor, account.state AS accountState" +
", COUNT(message.id) AS messages" +
", SUM(CASE WHEN message.content = 1 THEN 1 ELSE 0 END) AS content" +
", SUM(CASE WHEN message.ui_seen = 0 THEN 1 ELSE 0 END) AS unseen" +
@ -64,7 +64,7 @@ public interface DaoFolder {
List<TupleFolderSort> getSortedFolders();
@Query("SELECT folder.*" +
", account.`order` AS accountOrder, account.name AS accountName, account.color AS accountColor, account.state AS accountState" +
", account.id AS accountId, account.`order` AS accountOrder, account.name AS accountName, account.color AS accountColor, account.state AS accountState" +
", COUNT(message.id) AS messages" +
", SUM(CASE WHEN message.content = 1 THEN 1 ELSE 0 END) AS content" +
", SUM(CASE WHEN message.ui_seen = 0 THEN 1 ELSE 0 END) AS unseen" +
@ -80,7 +80,7 @@ public interface DaoFolder {
LiveData<List<TupleFolderEx>> liveFolders(Long account);
@Query("SELECT folder.*" +
", account.`order` AS accountOrder, account.name AS accountName, account.color AS accountColor, account.state AS accountState" +
", account.id AS accountId, account.`order` AS accountOrder, account.name AS accountName, account.color AS accountColor, account.state AS accountState" +
", COUNT(message.id) AS messages" +
", SUM(CASE WHEN message.content = 1 THEN 1 ELSE 0 END) AS content" +
", SUM(CASE WHEN message.ui_seen = 0 THEN 1 ELSE 0 END) AS unseen" +
@ -119,7 +119,7 @@ public interface DaoFolder {
LiveData<Integer> liveSynchronizing();
@Query("SELECT folder.*" +
", account.`order` AS accountOrder, account.name AS accountName, account.color AS accountColor, account.state AS accountState" +
", account.id AS accountId, account.`order` AS accountOrder, account.name AS accountName, account.color AS accountColor, account.state AS accountState" +
", COUNT(message.id) AS messages" +
", SUM(CASE WHEN message.content = 1 THEN 1 ELSE 0 END) AS content" +
", SUM(CASE WHEN message.ui_seen = 0 THEN 1 ELSE 0 END) AS unseen" +

View File

@ -110,13 +110,13 @@ public class EntityAccount extends EntityOrder implements Serializable {
void createNotificationChannel(Context context) {
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannelGroup group = new NotificationChannelGroup(name, name);
NotificationChannelGroup group = new NotificationChannelGroup("group." + id, name);
nm.createNotificationChannelGroup(group);
NotificationChannel channel = new NotificationChannel(
getNotificationChannelId(id), name,
NotificationManager.IMPORTANCE_HIGH);
channel.setGroup(name);
channel.setGroup(group.getId());
channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
channel.enableLights(true);
nm.createNotificationChannel(channel);

View File

@ -37,6 +37,7 @@ import java.util.Locale;
import java.util.Objects;
public class TupleFolderEx extends EntityFolder implements Serializable {
public Long accountId;
public Integer accountOrder;
public String accountName;
public Integer accountColor;
@ -63,6 +64,7 @@ public class TupleFolderEx extends EntityFolder implements Serializable {
if (obj instanceof TupleFolderEx) {
TupleFolderEx other = (TupleFolderEx) obj;
return (super.equals(obj) &&
Objects.equals(this.accountId, other.accountId) &&
Objects.equals(this.accountName, other.accountName) &&
Objects.equals(this.accountColor, other.accountColor) &&
Objects.equals(this.accountState, other.accountState) &&
@ -78,13 +80,13 @@ public class TupleFolderEx extends EntityFolder implements Serializable {
void createNotificationChannel(Context context) {
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannelGroup group = new NotificationChannelGroup(accountName, accountName);
NotificationChannelGroup group = new NotificationChannelGroup("group." + accountId, accountName);
nm.createNotificationChannelGroup(group);
NotificationChannel channel = new NotificationChannel(
getNotificationChannelId(id), getDisplayName(context),
NotificationManager.IMPORTANCE_HIGH);
channel.setGroup(accountName);
channel.setGroup(group.getId());
channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
channel.enableLights(true);
nm.createNotificationChannel(channel);