diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-10-02 22:17:25 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-10-02 22:17:25 +0200 |
commit | facd15f0373913eaafe8aa3a9a65cd02d8269aba (patch) | |
tree | e3f7117ac1d6f2c70170233fdfc09a90567cc0b6 /src | |
parent | f671938e842ece605f600860107ec9d2b8bfd019 (diff) |
check if display is off for notifications
Diffstat (limited to 'src')
-rw-r--r-- | src/eu/siacs/conversations/services/NotificationService.java | 10 |
1 files 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() { |