consume volume down event

This commit is contained in:
Daniel Gultsch 2021-02-18 22:16:28 +01:00
parent 484f633180
commit ebb38d7d75
2 changed files with 9 additions and 3 deletions

View file

@ -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) {

View file

@ -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);