From facd15f0373913eaafe8aa3a9a65cd02d8269aba Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Thu, 2 Oct 2014 22:17:25 +0200 Subject: check if display is off for notifications --- src/eu/siacs/conversations/services/NotificationService.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/eu/siacs/conversations/services/NotificationService.java b/src/eu/siacs/conversations/services/NotificationService.java index 012bac30..eb203909 100644 --- a/src/eu/siacs/conversations/services/NotificationService.java +++ b/src/eu/siacs/conversations/services/NotificationService.java @@ -12,6 +12,7 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.net.Uri; +import android.os.PowerManager; import android.support.v4.app.NotificationCompat; import android.support.v4.app.TaskStackBuilder; import android.text.Html; @@ -39,7 +40,12 @@ public class NotificationService { } public synchronized void push(Message message) { - if (this.mIsInForeground + + PowerManager pm = (PowerManager) mXmppConnectionService + .getSystemService(Context.POWER_SERVICE); + boolean isScreenOn = pm.isScreenOn(); + + if (this.mIsInForeground && isScreenOn && this.mOpenConversation == message.getConversation()) { return; // simply ignore } @@ -51,7 +57,7 @@ public class NotificationService { mList.add(message); notifications.put(conversationUuid, mList); } - updateNotification(!(this.mIsInForeground && this.mOpenConversation == null)); + updateNotification(!(this.mIsInForeground && this.mOpenConversation == null) || !isScreenOn); } public void clear() { -- cgit v1.2.3