diff options
author | Christian Schneppe <christian@pix-art.de> | 2016-06-29 10:48:29 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-06-29 10:48:29 +0200 |
commit | e20199d74c2a48eebab924a1de217b722ca7cf4d (patch) | |
tree | 0120cce4cf83209e6c1764f8170a86dc959c6fdc | |
parent | bbc9ba78933cde7bd51508ba1ae4850504cdd637 (diff) |
vibrate on new messages when app is open
-rw-r--r-- | src/main/java/eu/siacs/conversations/services/NotificationService.java | 4 | ||||
-rw-r--r-- | src/main/java/eu/siacs/conversations/services/XmppConnectionService.java | 7 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java index d6787301a..47cdc4f3b 100644 --- a/src/main/java/eu/siacs/conversations/services/NotificationService.java +++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java @@ -143,8 +143,12 @@ public class NotificationService { final boolean isScreenOn = mXmppConnectionService.isInteractive(); if (this.mIsInForeground && isScreenOn && this.mOpenConversation == message.getConversation()) { Log.d(Config.LOGTAG,message.getConversation().getAccount().getJid().toBareJid()+": suppressing notification because conversation is open"); + mXmppConnectionService.vibrate(); return; } + if (this.mIsInForeground && isScreenOn) { + mXmppConnectionService.vibrate(); + } synchronized (notifications) { pushToStack(message); final Account account = message.getConversation().getAccount(); diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 1d80c066f..df52a3b27 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -23,6 +23,7 @@ import android.os.IBinder; import android.os.PowerManager; import android.os.PowerManager.WakeLock; import android.os.SystemClock; +import android.os.Vibrator; import android.preference.PreferenceManager; import android.provider.ContactsContract; import android.security.KeyChain; @@ -2859,6 +2860,12 @@ public class XmppConnectionService extends Service { return count; } + public void vibrate() { + Log.d(Config.LOGTAG,"Notification: short vibrate"); + Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE); + vibrator.vibrate(100); + } + public void showErrorToastInUi(int resId) { if (mOnShowErrorToast != null) { |