From ca947aeef29ef236c7a7622c9e3cdd3fe4160251 Mon Sep 17 00:00:00 2001 From: adb Date: Thu, 24 Oct 2024 20:42:39 +0200 Subject: [PATCH] Use tag or display name for notifications instead address (#3380) Use tag or display name for notifications instead address --- jni/deltachat-core-rust | 2 +- .../notifications/NotificationCenter.java | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/jni/deltachat-core-rust b/jni/deltachat-core-rust index acd7a1d17..06955cf5a 160000 --- a/jni/deltachat-core-rust +++ b/jni/deltachat-core-rust @@ -1 +1 @@ -Subproject commit acd7a1d17ee51d19b1aad5373dfa36847e013129 +Subproject commit 06955cf5a9e9366f2f5974438181e47d80cd9788 diff --git a/src/main/java/org/thoughtcrime/securesms/notifications/NotificationCenter.java b/src/main/java/org/thoughtcrime/securesms/notifications/NotificationCenter.java index ccfe9b4cf..112e0a549 100644 --- a/src/main/java/org/thoughtcrime/securesms/notifications/NotificationCenter.java +++ b/src/main/java/org/thoughtcrime/securesms/notifications/NotificationCenter.java @@ -1,5 +1,7 @@ package org.thoughtcrime.securesms.notifications; +import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_PRIVATE_TAG; + import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationChannelGroup; @@ -387,10 +389,16 @@ public class NotificationCenter { builder.setGroup(GRP_MSG + "." + accountId); } - String accountAddr = dcContext.getConfig("addr"); + String accountTag = dcContext.getConfig(CONFIG_PRIVATE_TAG); + if (accountTag.isEmpty() && context.dcAccounts.getAll().length > 1) { + accountTag = dcContext.getName(); + } + if (privacy.isDisplayContact()) { builder.setContentTitle(dcChat.getName()); - builder.setSubText(accountAddr); + if (!TextUtils.isEmpty(accountTag)) { + builder.setSubText(accountTag); + } } // if privacy allows, for better accessibility, @@ -534,8 +542,8 @@ public class NotificationCenter { .setContentTitle("Delta Chat") // content title would only be used on SDK <24 .setContentText("New messages") // content text would only be used on SDK <24 .setContentIntent(getOpenChatlistIntent(accountId)); - if (privacy.isDisplayContact()) { - summary.setSubText(accountAddr); + if (privacy.isDisplayContact() && !TextUtils.isEmpty(accountTag)) { + summary.setSubText(accountTag); } notificationManager.notify(String.valueOf(accountId), ID_MSG_SUMMARY, summary.build()); } catch (Exception e) {