From ebb38d7d753a57eaf7a68844739bffee47c8649c Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 18 Feb 2021 22:16:28 +0100 Subject: [PATCH] consume volume down event --- .../siacs/conversations/services/NotificationService.java | 8 ++++++-- .../eu/siacs/conversations/ui/RtpSessionActivity.java | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java index 64658f492..755895961 100644 --- a/src/main/java/eu/siacs/conversations/services/NotificationService.java +++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java @@ -498,17 +498,21 @@ public class NotificationService { cancel(INCOMING_CALL_NOTIFICATION_ID); } - public void stopSoundAndVibration() { + public boolean stopSoundAndVibration() { + int stopped = 0; if (this.currentlyPlayingRingtone != null) { if (this.currentlyPlayingRingtone.isPlaying()) { Log.d(Config.LOGTAG, "stop playing ring tone"); + ++stopped; } this.currentlyPlayingRingtone.stop(); } if (this.vibrationFuture != null && !this.vibrationFuture.isCancelled()) { - Log.d(Config.LOGTAG, "cancel vibration"); + Log.d(Config.LOGTAG, "stop vibration"); this.vibrationFuture.cancel(true); + ++stopped; } + return stopped > 0; } public static void cancelIncomingCallNotification(final Context context) { diff --git a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java index 36562b176..fdd73f727 100644 --- a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java @@ -151,7 +151,9 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe public boolean onKeyDown(final int keyCode, final KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN){ if (xmppConnectionService != null) { - xmppConnectionService.getNotificationService().stopSoundAndVibration(); + if (xmppConnectionService.getNotificationService().stopSoundAndVibration()) { + return true; + } } } return super.onKeyDown(keyCode, event);