Add Small Group Ringing support.

This commit is contained in:
Cody Henthorne
2021-08-24 10:18:39 -04:00
committed by Alex Hart
parent 5787a5f68a
commit db7272730e
39 changed files with 1597 additions and 609 deletions

View File

@@ -1,6 +1,7 @@
package org.thoughtcrime.securesms.notifications;
import android.Manifest;
import android.annotation.SuppressLint;
import android.app.NotificationManager;
import android.content.Context;
import android.database.Cursor;
@@ -28,6 +29,23 @@ public final class DoNotDisturbUtil {
}
@WorkerThread
@SuppressLint("SwitchIntDef")
public static boolean shouldDisturbUserWithCall(@NonNull Context context) {
if (Build.VERSION.SDK_INT <= 23) return true;
NotificationManager notificationManager = ServiceUtil.getNotificationManager(context);
switch (notificationManager.getCurrentInterruptionFilter()) {
case NotificationManager.INTERRUPTION_FILTER_ALL:
case NotificationManager.INTERRUPTION_FILTER_UNKNOWN:
return true;
default:
return false;
}
}
@WorkerThread
@SuppressLint("SwitchIntDef")
public static boolean shouldDisturbUserWithCall(@NonNull Context context, @NonNull Recipient recipient) {
if (Build.VERSION.SDK_INT <= 23) return true;
@@ -91,6 +109,7 @@ public final class DoNotDisturbUtil {
return false;
}
//noinspection ConstantConditions
try (Cursor cursor = context.getContentResolver().query(recipient.resolve().getContactUri(), new String[]{ContactsContract.Contacts.STARRED}, null, null, null)) {
if (cursor == null || !cursor.moveToFirst()) return false;
return CursorUtil.requireInt(cursor, ContactsContract.Contacts.STARRED) == 1;