control voice call volume when playing audio through earpiece. fixes #3705

This commit is contained in:
Daniel Gultsch 2020-05-25 10:43:56 +02:00
parent 7ca543e42f
commit 8475a28dc5
2 changed files with 8 additions and 2 deletions

View File

@ -75,8 +75,8 @@ import eu.siacs.conversations.utils.MessageUtils;
import eu.siacs.conversations.utils.StylingHelper;
import eu.siacs.conversations.utils.TimeFrameUtils;
import eu.siacs.conversations.utils.UIHelper;
import eu.siacs.conversations.xmpp.mam.MamReference;
import eu.siacs.conversations.xmpp.Jid;
import eu.siacs.conversations.xmpp.mam.MamReference;
public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextView.CopyHandler {
@ -119,6 +119,10 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
public void setVolumeControl(final int stream) {
activity.setVolumeControlStream(stream);
}
public void setOnContactPictureClicked(OnContactPictureClicked listener) {
this.mOnContactPictureClickedListener = listener;
}

View File

@ -363,12 +363,13 @@ public class AudioPlayer implements View.OnClickListener, MediaPlayer.OnCompleti
if (AudioPlayer.player == null || !AudioPlayer.player.isPlaying()) {
return;
}
int streamType;
final int streamType;
if (event.values[0] < 5f && event.values[0] != proximitySensor.getMaximumRange()) {
streamType = AudioManager.STREAM_VOICE_CALL;
} else {
streamType = AudioManager.STREAM_MUSIC;
}
messageAdapter.setVolumeControl(streamType);
double position = AudioPlayer.player.getCurrentPosition();
double duration = AudioPlayer.player.getDuration();
double progress = position / duration;
@ -407,6 +408,7 @@ public class AudioPlayer implements View.OnClickListener, MediaPlayer.OnCompleti
wakeLock.release();
}
}
messageAdapter.setVolumeControl(AudioManager.STREAM_MUSIC);
}
private ViewHolder getCurrentViewHolder() {