Select the radio ringtone in both Android ringtone playback paths
This commit is contained in:
1 parent
7693db7b4d
commit
aca14bfb70
2 files changed
+7
-6
No files matched your search
@@ -63,9 +63,9 @@ object IncomingCallManager {
|
||||
stopRinging()
|
||||
activeCallId = callId
|
||||
activeRadio = radio; activeChannel = channelId; activePeer = peerNodeId
|
||||
LogManager.addLog("INFO", "InCall", "incoming call id=$callId peer=$peerNodeId ch=$channelId")
|
||||
LogManager.addLog("INFO", "InCall", "incoming call id=$callId peer=$peerNodeId ch=$channelId radio=$radio")
|
||||
acquireWakeLock()
|
||||
ringtone.play()
|
||||
ringtone.play(if (radio) R.raw.radio_incoming else R.raw.ringtone)
|
||||
showNotification(callId, channelId, peerNodeId)
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.os.VibrationEffect
|
||||
import android.os.Vibrator
|
||||
import androidx.annotation.RawRes
|
||||
import com.utun.chat.ChatApplication
|
||||
import com.utun.chat.R
|
||||
|
||||
@@ -49,7 +50,7 @@ class RingtonePlayer {
|
||||
}
|
||||
}
|
||||
|
||||
fun play() {
|
||||
fun play(@RawRes resourceId: Int = R.raw.ringtone) {
|
||||
stop()
|
||||
val ctx = ChatApplication.instance
|
||||
val am = try {
|
||||
@@ -64,11 +65,11 @@ class RingtonePlayer {
|
||||
val playVibrate = ringerMode != AudioManager.RINGER_MODE_SILENT
|
||||
|
||||
LogManager.addLog("INFO", "Ringtone",
|
||||
"ringerMode=%d sound=%b vibrate=%b".format(ringerMode, playSound, playVibrate))
|
||||
"ringerMode=%d sound=%b vibrate=%b resource=%d".format(ringerMode, playSound, playVibrate, resourceId))
|
||||
|
||||
if (playSound) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
val uri = Uri.parse("android.resource://${ctx.packageName}/${R.raw.ringtone}")
|
||||
val uri = Uri.parse("android.resource://${ctx.packageName}/$resourceId")
|
||||
val r = try {
|
||||
RingtoneManager.getRingtone(ctx, uri)
|
||||
} catch (e: Exception) {
|
||||
@@ -86,7 +87,7 @@ class RingtonePlayer {
|
||||
LogManager.addLog("INFO", "Ringtone", "sound started (Ringtone, STREAM_RING)")
|
||||
} else {
|
||||
val mp = try {
|
||||
MediaPlayer.create(ctx, R.raw.ringtone)
|
||||
MediaPlayer.create(ctx, resourceId)
|
||||
} catch (e: Exception) {
|
||||
LogManager.addLog("ERROR", "Ringtone", "MediaPlayer.create failed: ${e.message}")
|
||||
null
|
||||
|
||||
Reference in new issue
Block a user