Stop muted threads from triggering full notification updates.
This commit is contained in:
parent
1f1fc94d22
commit
72b94127fb
1 changed files with 20 additions and 7 deletions
|
@ -34,6 +34,7 @@ import android.text.SpannableStringBuilder;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
import androidx.core.app.NotificationCompat;
|
import androidx.core.app.NotificationCompat;
|
||||||
import androidx.core.app.NotificationManagerCompat;
|
import androidx.core.app.NotificationManagerCompat;
|
||||||
|
@ -245,19 +246,31 @@ public class DefaultMessageNotifier implements MessageNotifier {
|
||||||
long threadId,
|
long threadId,
|
||||||
boolean signal)
|
boolean signal)
|
||||||
{
|
{
|
||||||
boolean isVisible = visibleThread == threadId;
|
boolean isVisible = visibleThread == threadId;
|
||||||
|
Recipient recipient = DatabaseFactory.getThreadDatabase(context).getRecipientForThreadId(threadId);
|
||||||
|
|
||||||
ThreadDatabase threads = DatabaseFactory.getThreadDatabase(context);
|
if (shouldNotify(context, recipient, threadId)) {
|
||||||
|
if (isVisible) {
|
||||||
|
sendInThreadNotification(context, recipient);
|
||||||
|
} else {
|
||||||
|
updateNotification(context, threadId, signal, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean shouldNotify(@NonNull Context context, @Nullable Recipient recipient, long threadId) {
|
||||||
if (!TextSecurePreferences.isNotificationsEnabled(context)) {
|
if (!TextSecurePreferences.isNotificationsEnabled(context)) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isVisible) {
|
if (recipient == null || !recipient.isMuted()) {
|
||||||
sendInThreadNotification(context, threads.getRecipientForThreadId(threadId));
|
return true;
|
||||||
} else {
|
|
||||||
updateNotification(context, threadId, signal, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return FeatureFlags.mentions() &&
|
||||||
|
recipient.isPushV2Group() &&
|
||||||
|
recipient.getMentionSetting() == RecipientDatabase.MentionSetting.ALWAYS_NOTIFY &&
|
||||||
|
DatabaseFactory.getMmsDatabase(context).getUnreadMentionCount(threadId) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Reference in a new issue