mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-20 08:39:22 +01:00
Play sound for raised hand.
This commit is contained in:
committed by
Clark Chen
parent
b4f2208bae
commit
1b9cf631be
@@ -115,6 +115,13 @@ sealed class AudioManagerCommand : Parcelable {
|
||||
}
|
||||
}
|
||||
|
||||
class PlayStateChangeUp : AudioManagerCommand() {
|
||||
companion object {
|
||||
@JvmField
|
||||
val CREATOR: Parcelable.Creator<PlayStateChangeUp> = ParcelCheat { PlayStateChangeUp() }
|
||||
}
|
||||
}
|
||||
|
||||
class ParcelCheat<T>(private val createFrom: (Parcel) -> T) : Parcelable.Creator<T> {
|
||||
override fun createFromParcel(parcel: Parcel): T = createFrom(parcel)
|
||||
override fun newArray(size: Int): Array<T?> = throw UnsupportedOperationException()
|
||||
|
||||
@@ -191,6 +191,10 @@ public abstract class AudioManagerCompat {
|
||||
return (float) (1 - (Math.log(maxVolume + 1 - volume) / Math.log(maxVolume + 1)));
|
||||
}
|
||||
|
||||
public float getVoiceCallVolume() {
|
||||
return audioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL);
|
||||
}
|
||||
|
||||
abstract public SoundPool createSoundPool();
|
||||
|
||||
abstract public boolean requestCallAudioFocus();
|
||||
|
||||
@@ -44,6 +44,10 @@ sealed class SignalAudioManager(protected val context: Context, protected val ev
|
||||
protected val incomingRinger = IncomingRinger(context)
|
||||
protected val outgoingRinger = OutgoingRinger(context)
|
||||
|
||||
private val stateChangeUpSoundId = context.assets.openFd("sounds/state-change_confirm-up.ogg").use {
|
||||
soundPool.load(it, 1)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun create(context: Context, eventListener: EventListener?): SignalAudioManager {
|
||||
@@ -66,6 +70,7 @@ sealed class SignalAudioManager(protected val context: Context, protected val ev
|
||||
is AudioManagerCommand.StartIncomingRinger -> startIncomingRinger(command.ringtoneUri, command.vibrate)
|
||||
is AudioManagerCommand.SilenceIncomingRinger -> silenceIncomingRinger()
|
||||
is AudioManagerCommand.StartOutgoingRinger -> startOutgoingRinger()
|
||||
is AudioManagerCommand.PlayStateChangeUp -> playStateChangeUp()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -81,6 +86,11 @@ sealed class SignalAudioManager(protected val context: Context, protected val ev
|
||||
}
|
||||
}
|
||||
|
||||
private fun playStateChangeUp() {
|
||||
val volume: Float = androidAudioManager.voiceCallVolume
|
||||
soundPool.play(stateChangeUpSoundId, volume, volume, 0, 0, 1f)
|
||||
}
|
||||
|
||||
protected abstract fun initialize()
|
||||
protected abstract fun start()
|
||||
protected abstract fun stop(playDisconnect: Boolean)
|
||||
|
||||
Reference in New Issue
Block a user