During call, volume keys now control media volume
This commit is contained in:
@ -520,7 +520,7 @@ class BaresipService: Service() {
|
|||||||
}
|
}
|
||||||
"call outgoing" -> {
|
"call outgoing" -> {
|
||||||
stopMediaPlayer()
|
stopMediaPlayer()
|
||||||
am.mode = AudioManager.MODE_IN_CALL
|
am.mode = AudioManager.MODE_IN_COMMUNICATION
|
||||||
requestAudioFocus(AudioAttributes.USAGE_VOICE_COMMUNICATION,
|
requestAudioFocus(AudioAttributes.USAGE_VOICE_COMMUNICATION,
|
||||||
AudioAttributes.CONTENT_TYPE_SPEECH)
|
AudioAttributes.CONTENT_TYPE_SPEECH)
|
||||||
setCallVolume()
|
setCallVolume()
|
||||||
@ -529,12 +529,14 @@ class BaresipService: Service() {
|
|||||||
}
|
}
|
||||||
"call ringing" -> {
|
"call ringing" -> {
|
||||||
playRingBack()
|
playRingBack()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
"call progress" -> {
|
"call progress" -> {
|
||||||
if (ev[1] != "0")
|
if (ev[1] != "0")
|
||||||
stopMediaPlayer()
|
stopMediaPlayer()
|
||||||
else
|
else
|
||||||
playRingBack()
|
playRingBack()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
"call incoming" -> {
|
"call incoming" -> {
|
||||||
val peerUri = Api.call_peeruri(callp)
|
val peerUri = Api.call_peeruri(callp)
|
||||||
@ -636,8 +638,8 @@ class BaresipService: Service() {
|
|||||||
"call answered" -> {
|
"call answered" -> {
|
||||||
stopRinging()
|
stopRinging()
|
||||||
stopMediaPlayer()
|
stopMediaPlayer()
|
||||||
if (am.mode != AudioManager.MODE_IN_CALL)
|
if (am.mode != AudioManager.MODE_IN_COMMUNICATION)
|
||||||
am.mode = AudioManager.MODE_IN_CALL
|
am.mode = AudioManager.MODE_IN_COMMUNICATION
|
||||||
requestAudioFocus(AudioAttributes.USAGE_VOICE_COMMUNICATION,
|
requestAudioFocus(AudioAttributes.USAGE_VOICE_COMMUNICATION,
|
||||||
AudioAttributes.CONTENT_TYPE_SPEECH)
|
AudioAttributes.CONTENT_TYPE_SPEECH)
|
||||||
setCallVolume()
|
setCallVolume()
|
||||||
|
|||||||
@ -649,11 +649,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
delegate.applyDayNight()
|
delegate.applyDayNight()
|
||||||
}
|
}
|
||||||
|
|
||||||
volumeControlStream = if (am.mode == AudioManager.MODE_RINGTONE)
|
|
||||||
AudioManager.STREAM_RING
|
|
||||||
else
|
|
||||||
AudioManager.STREAM_VOICE_CALL
|
|
||||||
|
|
||||||
window.decorView.post {
|
window.decorView.post {
|
||||||
if (firstRun) {
|
if (firstRun) {
|
||||||
if (!Utils.checkPermission(this, Manifest.permission.RECORD_AUDIO))
|
if (!Utils.checkPermission(this, Manifest.permission.RECORD_AUDIO))
|
||||||
@ -867,10 +862,14 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
|
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
|
||||||
|
val stream = if (am.mode == AudioManager.MODE_RINGTONE)
|
||||||
|
AudioManager.STREAM_RING
|
||||||
|
else
|
||||||
|
AudioManager.STREAM_MUSIC
|
||||||
when (keyCode) {
|
when (keyCode) {
|
||||||
KeyEvent.KEYCODE_VOLUME_DOWN, KeyEvent.KEYCODE_VOLUME_UP -> {
|
KeyEvent.KEYCODE_VOLUME_DOWN, KeyEvent.KEYCODE_VOLUME_UP -> {
|
||||||
Log.d(TAG, "Adjusting volume $keyCode of stream $volumeControlStream")
|
Log.d(TAG, "Adjusting volume $keyCode of stream $stream")
|
||||||
am.adjustStreamVolume(volumeControlStream,
|
am.adjustStreamVolume(stream,
|
||||||
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)
|
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)
|
||||||
AudioManager.ADJUST_LOWER else
|
AudioManager.ADJUST_LOWER else
|
||||||
AudioManager.ADJUST_RAISE,
|
AudioManager.ADJUST_RAISE,
|
||||||
@ -958,9 +957,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
": ${ev[1]}",
|
": ${ev[1]}",
|
||||||
Toast.LENGTH_LONG).show()
|
Toast.LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
"call ringing", "call progress" -> {
|
|
||||||
volumeControlStream = AudioManager.STREAM_VOICE_CALL
|
|
||||||
}
|
|
||||||
"call rejected" -> {
|
"call rejected" -> {
|
||||||
if (aor == aorSpinner.tag) {
|
if (aor == aorSpinner.tag) {
|
||||||
callsButton.setImageResource(R.drawable.calls_missed)
|
callsButton.setImageResource(R.drawable.calls_missed)
|
||||||
@ -986,7 +982,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
"call established" -> {
|
"call established" -> {
|
||||||
volumeControlStream = AudioManager.STREAM_VOICE_CALL
|
|
||||||
if (aor == aorSpinner.tag) {
|
if (aor == aorSpinner.tag) {
|
||||||
dtmf.setText("")
|
dtmf.setText("")
|
||||||
dtmf.hint = getString(R.string.dtmf)
|
dtmf.hint = getString(R.string.dtmf)
|
||||||
@ -1110,7 +1105,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
callsButton.setImageResource(R.drawable.calls_missed)
|
callsButton.setImageResource(R.drawable.calls_missed)
|
||||||
}
|
}
|
||||||
if (speakerIcon != null) speakerIcon!!.setIcon(R.drawable.speaker_off)
|
if (speakerIcon != null) speakerIcon!!.setIcon(R.drawable.speaker_off)
|
||||||
volumeControlStream = AudioManager.STREAM_VOICE_CALL
|
|
||||||
val param = ev[1].trim()
|
val param = ev[1].trim()
|
||||||
if ((param != "") && (Call.uaCalls(ua, "").size == 0)) {
|
if ((param != "") && (Call.uaCalls(ua, "").size == 0)) {
|
||||||
if (param[0].isDigit())
|
if (param[0].isDigit())
|
||||||
@ -1643,7 +1637,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
rejectButton.visibility = View.INVISIBLE
|
rejectButton.visibility = View.INVISIBLE
|
||||||
callControl.visibility = View.INVISIBLE
|
callControl.visibility = View.INVISIBLE
|
||||||
dialpadButton.isEnabled = true
|
dialpadButton.isEnabled = true
|
||||||
volumeControlStream = AudioManager.STREAM_VOICE_CALL
|
|
||||||
} else {
|
} else {
|
||||||
swipeRefresh.isEnabled = false
|
swipeRefresh.isEnabled = false
|
||||||
val call = Call.uaCalls(ua, "")[0]
|
val call = Call.uaCalls(ua, "")[0]
|
||||||
@ -1662,7 +1655,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
rejectButton.visibility = View.INVISIBLE
|
rejectButton.visibility = View.INVISIBLE
|
||||||
callControl.visibility = View.INVISIBLE
|
callControl.visibility = View.INVISIBLE
|
||||||
dialpadButton.isEnabled = false
|
dialpadButton.isEnabled = false
|
||||||
volumeControlStream = AudioManager.STREAM_VOICE_CALL
|
|
||||||
}
|
}
|
||||||
"incoming" -> {
|
"incoming" -> {
|
||||||
callTitle.text = getString(R.string.incoming_call_from_dots)
|
callTitle.text = getString(R.string.incoming_call_from_dots)
|
||||||
@ -1678,7 +1670,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
rejectButton.isEnabled = true
|
rejectButton.isEnabled = true
|
||||||
callControl.visibility = View.INVISIBLE
|
callControl.visibility = View.INVISIBLE
|
||||||
dialpadButton.isEnabled = false
|
dialpadButton.isEnabled = false
|
||||||
volumeControlStream = AudioManager.STREAM_RING
|
|
||||||
}
|
}
|
||||||
"connected" -> {
|
"connected" -> {
|
||||||
callControl.post {
|
callControl.post {
|
||||||
@ -1728,7 +1719,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
dialpadButton.isEnabled = false
|
dialpadButton.isEnabled = false
|
||||||
infoButton.isEnabled = true
|
infoButton.isEnabled = true
|
||||||
callControl.visibility = View.VISIBLE
|
callControl.visibility = View.VISIBLE
|
||||||
volumeControlStream = AudioManager.STREAM_VOICE_CALL
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user