1
0
mirror of https://github.com/nextcloud/talk-android synced 2025-03-08 15:09:49 +00:00
This commit is contained in:
Mario Danic 2018-11-07 11:12:57 +01:00
parent 5398d17295
commit a90ba05d29
2 changed files with 10 additions and 5 deletions
app/src/main/java/com/nextcloud/talk

View File

@ -78,6 +78,8 @@ import javax.crypto.NoSuchPaddingException;
import javax.inject.Inject;
import androidx.annotation.NonNull;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import androidx.work.Data;
import androidx.work.Worker;
import androidx.work.WorkerParameters;
@ -263,12 +265,12 @@ public class NotificationWorker extends Worker {
PendingIntent pendingIntent = PendingIntent.getActivity(context,
0, intent, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT);
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
CRC32 crc32 = new CRC32();
Notification.Builder notificationBuilder = new Notification.Builder(context)
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, "1")
.setLargeIcon(largeIcon)
.setSmallIcon(smallIcon)
.setCategory(category)
@ -297,7 +299,7 @@ public class NotificationWorker extends Worker {
.getUserId(), signatureVerification.getUserEntity().getBaseUrl());
crc32.update(groupName.getBytes());
NotificationUtils.createNotificationChannelGroup(notificationManager,
NotificationUtils.createNotificationChannelGroup(context,
Long.toString(crc32.getValue()),
groupName);

View File

@ -65,9 +65,12 @@ public class NotificationUtils {
}
@TargetApi(Build.VERSION_CODES.O)
public static void createNotificationChannelGroup(NotificationManager notificationManager,
public static void createNotificationChannelGroup(Context context,
String groupId, CharSequence groupName) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannelGroup notificationChannelGroup = new NotificationChannelGroup(groupId, groupName);
if (!notificationManager.getNotificationChannelGroups().contains(notificationChannelGroup)) {
notificationManager.createNotificationChannelGroup(notificationChannelGroup);