From 0d9490e1fb9d73adab7d5dc883e85f00bd55a774 Mon Sep 17 00:00:00 2001 From: Alan Evans Date: Fri, 12 Feb 2021 16:08:36 -0400 Subject: [PATCH] Force disabling of foreground notification vibration. --- .../securesms/notifications/NotificationChannels.java | 11 +++++++++-- .../securesms/service/GenericForegroundService.java | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/notifications/NotificationChannels.java b/app/src/main/java/org/thoughtcrime/securesms/notifications/NotificationChannels.java index 7ca1419c9c..2a9cb66e3c 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/notifications/NotificationChannels.java +++ b/app/src/main/java/org/thoughtcrime/securesms/notifications/NotificationChannels.java @@ -44,9 +44,10 @@ public class NotificationChannels { private static class Version { static final int MESSAGES_CATEGORY = 2; static final int CALLS_PRIORITY_BUMP = 3; + static final int VIBRATE_OFF_OTHER = 4; } - private static final int VERSION = 3; + private static final int VERSION = 4; private static final String CATEGORY_MESSAGES = "messages"; private static final String CONTACT_PREFIX = "contact_"; @@ -57,7 +58,7 @@ public class NotificationChannels { public static final String APP_UPDATES = "app_updates"; public static final String BACKUPS = "backups_v2"; public static final String LOCKED_STATUS = "locked_status_v2"; - public static final String OTHER = "other_v2"; + public static final String OTHER = "other_v3"; public static final String VOICE_NOTES = "voice_notes"; /** @@ -462,6 +463,8 @@ public class NotificationChannels { backups.setShowBadge(false); lockedStatus.setShowBadge(false); other.setShowBadge(false); + other.setVibrationPattern(new long[]{0}); + other.enableVibration(true); voiceNotes.setShowBadge(false); notificationManager.createNotificationChannels(Arrays.asList(messages, calls, failures, backups, lockedStatus, other, voiceNotes)); @@ -489,6 +492,10 @@ public class NotificationChannels { if (oldVersion < Version.CALLS_PRIORITY_BUMP) { notificationManager.deleteNotificationChannel("calls_v2"); } + + if (oldVersion < Version.VIBRATE_OFF_OTHER) { + notificationManager.deleteNotificationChannel("other_v2"); + } } @TargetApi(26) diff --git a/app/src/main/java/org/thoughtcrime/securesms/service/GenericForegroundService.java b/app/src/main/java/org/thoughtcrime/securesms/service/GenericForegroundService.java index 568cd8c06f..08f4d88985 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/service/GenericForegroundService.java +++ b/app/src/main/java/org/thoughtcrime/securesms/service/GenericForegroundService.java @@ -112,6 +112,7 @@ public final class GenericForegroundService extends Service { .setContentTitle(active.title) .setProgress(active.progressMax, active.progress, active.indeterminate) .setContentIntent(PendingIntent.getActivity(this, 0, MainActivity.clearTop(this), 0)) + .setVibrate(new long[]{0}) .build()); }