Merge remote-tracking branch 'upstream/main'

This commit is contained in:
adbenitez
2024-10-27 03:45:37 +01:00
14 changed files with 131 additions and 33 deletions
@@ -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;
@@ -389,10 +391,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,
@@ -536,8 +544,8 @@ public class NotificationCenter {
.setContentTitle("ArcaneChat") // 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) {
@@ -13,6 +13,7 @@ import androidx.core.content.ContextCompat;
import org.thoughtcrime.securesms.ApplicationContext;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.connect.ForegroundDetector;
import org.thoughtcrime.securesms.notifications.FcmReceiveService;
import org.thoughtcrime.securesms.notifications.NotificationCenter;
import org.thoughtcrime.securesms.util.Util;
@@ -23,6 +24,11 @@ public final class FetchForegroundService extends Service {
private static Intent service;
public static void start(Context context) {
ForegroundDetector foregroundDetector = ForegroundDetector.getInstance();
if (foregroundDetector != null && foregroundDetector.isForeground()) {
return;
}
GenericForegroundService.createFgNotificationChannel(context);
synchronized (SERVICE_LOCK) {
if (service == null) {