Skip to content

Commit

Permalink
Force disabling of foreground notification vibration.
Browse files Browse the repository at this point in the history
  • Loading branch information
alan-signal committed Feb 12, 2021
1 parent 4afb459 commit 0d9490e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Expand Up @@ -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_";
Expand All @@ -57,7 +58,7 @@ private static class Version {
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";

/**
Expand Down Expand Up @@ -462,6 +463,8 @@ private static void onCreate(@NonNull Context context, @NonNull NotificationMana
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));
Expand Down Expand Up @@ -489,6 +492,10 @@ private static void onUpgrade(@NonNull NotificationManager notificationManager,
if (oldVersion < Version.CALLS_PRIORITY_BUMP) {
notificationManager.deleteNotificationChannel("calls_v2");
}

if (oldVersion < Version.VIBRATE_OFF_OTHER) {
notificationManager.deleteNotificationChannel("other_v2");
}
}

@TargetApi(26)
Expand Down
Expand Up @@ -112,6 +112,7 @@ private void postObligatoryForegroundNotification(@NonNull Entry active) {
.setContentTitle(active.title)
.setProgress(active.progressMax, active.progress, active.indeterminate)
.setContentIntent(PendingIntent.getActivity(this, 0, MainActivity.clearTop(this), 0))
.setVibrate(new long[]{0})
.build());
}

Expand Down

0 comments on commit 0d9490e

Please sign in to comment.