From f8e031ac86c9af78a2f52ecc285b1acc877500bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferdinand=20P=C3=B6ll?= Date: Sat, 24 Jun 2017 15:38:16 +0200 Subject: [PATCH] Added preference to control Heads-up Notifications (turned off by default) --- .../siacs/conversations/services/NotificationService.java | 3 ++- src/main/res/values/defaults.xml | 3 ++- src/main/res/values/strings.xml | 2 ++ src/main/res/xml/preferences.xml | 6 ++++++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java index 5305ae5a4..d73f5d98b 100644 --- a/src/main/java/eu/siacs/conversations/services/NotificationService.java +++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java @@ -283,6 +283,7 @@ public class NotificationService { final String ringtone = preferences.getString("notification_ringtone", null); final boolean vibrate = preferences.getBoolean("vibrate_on_notification", true); final boolean led = preferences.getBoolean("led", true); + final boolean headsup = preferences.getBoolean("notification_headsup", mXmppConnectionService.getResources().getBoolean(R.bool.headsup_notifications)); if (notify && !isQuietHours()) { if (vibrate) { final int dat = 70; @@ -303,7 +304,7 @@ public class NotificationService { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mBuilder.setCategory(Notification.CATEGORY_MESSAGE); } - mBuilder.setPriority(notify ? NotificationCompat.PRIORITY_DEFAULT : NotificationCompat.PRIORITY_LOW); + mBuilder.setPriority(notify ? (headsup ? NotificationCompat.PRIORITY_HIGH : NotificationCompat.PRIORITY_DEFAULT) : NotificationCompat.PRIORITY_LOW); setNotificationColor(mBuilder); mBuilder.setDefaults(0); if (led) { diff --git a/src/main/res/values/defaults.xml b/src/main/res/values/defaults.xml index 66dfdf347..66601cfee 100644 --- a/src/main/res/values/defaults.xml +++ b/src/main/res/values/defaults.xml @@ -4,4 +4,5 @@ true false false - \ No newline at end of file + false + diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index ccd556b2c..f27ad0d3d 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -752,4 +752,6 @@ Server requires registration on website Open website No application found to open website + Heads-up Notifications + Show Heads-up Notifications diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml index 684b98136..6c6d592f8 100644 --- a/src/main/res/xml/preferences.xml +++ b/src/main/res/xml/preferences.xml @@ -66,6 +66,12 @@ android:ringtoneType="notification" android:summary="@string/pref_sound_summary" android:title="@string/pref_sound"/> +