Fix speakerphone drawables for selection.

This commit is contained in:
Nicholas Tinsley 2023-11-17 10:04:03 -05:00 committed by Greyson Parrelli
parent 98e3530acd
commit c8f1ebdf4c
3 changed files with 8 additions and 17 deletions

View file

@ -86,21 +86,12 @@ class WebRtcAudioOutputToggleButton @JvmOverloads constructor(context: Context,
val currentOutput = outputState.getCurrentOutput()
val numberOfOutputs = outputState.getOutputs().size
val extra = if (numberOfOutputs < SHOW_PICKER_THRESHOLD) {
when (currentOutput) {
WebRtcAudioOutput.HANDSET -> intArrayOf(R.attr.state_speaker_off)
WebRtcAudioOutput.SPEAKER -> intArrayOf(R.attr.state_speaker_on)
WebRtcAudioOutput.BLUETOOTH_HEADSET -> intArrayOf(R.attr.state_bt_headset_selected) // should never be seen in practice.
WebRtcAudioOutput.WIRED_HEADSET -> intArrayOf(R.attr.state_wired_headset_selected) // should never be seen in practice.
}
} else {
when (currentOutput) {
WebRtcAudioOutput.HANDSET -> intArrayOf(R.attr.state_handset_selected)
WebRtcAudioOutput.SPEAKER -> intArrayOf(R.attr.state_speaker_selected)
WebRtcAudioOutput.BLUETOOTH_HEADSET -> intArrayOf(R.attr.state_bt_headset_selected)
WebRtcAudioOutput.WIRED_HEADSET -> intArrayOf(R.attr.state_wired_headset_selected)
}
val shouldShowDropdownForSpeaker = outputState.getOutputs().size >= SHOW_PICKER_THRESHOLD || !outputState.getOutputs().contains(WebRtcAudioOutput.HANDSET)
val extra = when (currentOutput) {
WebRtcAudioOutput.HANDSET -> intArrayOf(R.attr.state_speaker_off)
WebRtcAudioOutput.SPEAKER -> if (shouldShowDropdownForSpeaker) intArrayOf(R.attr.state_speaker_selected) else intArrayOf(R.attr.state_speaker_on)
WebRtcAudioOutput.BLUETOOTH_HEADSET -> intArrayOf(R.attr.state_bt_headset_selected)
WebRtcAudioOutput.WIRED_HEADSET -> intArrayOf(R.attr.state_wired_headset_selected)
}
Log.i(TAG, "Switching to $currentOutput")

View file

@ -9,7 +9,7 @@
<item app:state_speaker_on="true">
<layer-list>
<item android:drawable="@drawable/webrtc_call_screen_circle_unchecked" />
<item android:bottom="14dp" android:drawable="@drawable/symbol_speaker_fill_white_24" android:left="14dp" android:right="14dp" android:top="14dp" />
<item android:bottom="14dp" android:drawable="@drawable/symbol_speaker_fill_24" android:left="14dp" android:right="14dp" android:top="14dp" />
</layer-list>
</item>
<item app:state_handset_selected="true">

View file

@ -19,7 +19,7 @@
android:left="4dp"
android:right="4dp"
android:drawable="@drawable/webrtc_call_screen_circle_checked" />
<item android:bottom="14dp" android:drawable="@drawable/symbol_speaker_fill_white_24" android:left="14dp" android:right="14dp" android:top="14dp" />
<item android:bottom="14dp" android:drawable="@drawable/symbol_speaker_fill_24" android:left="14dp" android:right="14dp" android:top="14dp" />
</layer-list>
</item>
<item app:state_handset_selected="true">