mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 03:18:06 +00:00
Added vu meter for playback volume + setting to enable vu meters (disabled by default)
This commit is contained in:
parent
32060f6830
commit
85679dcc43
4 changed files with 39 additions and 10 deletions
|
|
@ -407,6 +407,10 @@ class CorePreferences
|
|||
val showLettersOnDialpad: Boolean
|
||||
get() = config.getBool("ui", "show_letters_on_dialpad", true)
|
||||
|
||||
@get:WorkerThread
|
||||
val showMicrophoneAndSpeakerVuMeters: Boolean
|
||||
get() = config.getBool("ui", "show_mic_speaker_vu_meter", false)
|
||||
|
||||
// Paths
|
||||
|
||||
@get:AnyThread
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ class VuMeterView : View {
|
|||
vuMeterPaint = Paint()
|
||||
vuMeterPaint.strokeWidth = 2f
|
||||
vuMeterPaint.isAntiAlias = true
|
||||
vuMeterPaint.setColor(color)
|
||||
vuMeterPaint.color = color
|
||||
}
|
||||
|
||||
fun setVuMeterPercentage(percentage: Float) {
|
||||
|
|
@ -93,7 +93,7 @@ class VuMeterView : View {
|
|||
}
|
||||
|
||||
override fun onDraw(canvas: Canvas) {
|
||||
paint.setShader(createShader())
|
||||
paint.shader = createShader()
|
||||
canvas.drawCircle(width / 2f, height / 2f, width / 2f, paint)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,6 +116,8 @@ class CurrentCallViewModel
|
|||
|
||||
val microphoneRecordingVolume = MutableLiveData<Float>()
|
||||
|
||||
val playbackVolume = MutableLiveData<Float>()
|
||||
|
||||
val isSpeakerEnabled = MutableLiveData<Boolean>()
|
||||
|
||||
val isHeadsetEnabled = MutableLiveData<Boolean>()
|
||||
|
|
@ -537,6 +539,7 @@ class CurrentCallViewModel
|
|||
proximitySensorEnabled.value = false
|
||||
videoUpdateInProgress.value = false
|
||||
microphoneRecordingVolume.value = 0f
|
||||
playbackVolume.value = 0f
|
||||
|
||||
refreshKeyguardLockedStatus()
|
||||
answerAlpha.value = 1f
|
||||
|
|
@ -1254,12 +1257,14 @@ class CurrentCallViewModel
|
|||
Log.i("$TAG Failed to find an existing 1-1 conversation for current call")
|
||||
}
|
||||
|
||||
microphoneVolumeVuMeterTickerFlow().onEach {
|
||||
coreContext.postOnCoreThread {
|
||||
val volumeDbm0 = currentCall.recordVolume
|
||||
microphoneRecordingVolume.postValue(computeVuMeterValue(volumeDbm0))
|
||||
}
|
||||
}.launchIn(viewModelScope)
|
||||
if (corePreferences.showMicrophoneAndSpeakerVuMeters) {
|
||||
volumeVuMeterTickerFlow().onEach {
|
||||
coreContext.postOnCoreThread {
|
||||
microphoneRecordingVolume.postValue(computeVuMeterValue(currentCall.recordVolume))
|
||||
playbackVolume.postValue(computeVuMeterValue(currentCall.playVolume))
|
||||
}
|
||||
}.launchIn(viewModelScope)
|
||||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
|
|
@ -1530,7 +1535,7 @@ class CurrentCallViewModel
|
|||
showGreenToast(R.string.call_is_being_recorded, R.drawable.record_fill)
|
||||
}
|
||||
|
||||
private fun microphoneVolumeVuMeterTickerFlow() = flow {
|
||||
private fun volumeVuMeterTickerFlow() = flow {
|
||||
while (::currentCall.isInitialized) {
|
||||
emit(Unit)
|
||||
delay(50)
|
||||
|
|
|
|||
|
|
@ -114,6 +114,27 @@
|
|||
app:layout_constraintStart_toEndOf="@id/toggle_video"
|
||||
app:layout_constraintEnd_toStartOf="@id/change_audio_output" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/change_audio_output_background"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:background="@drawable/in_call_button_background_red"
|
||||
android:contentDescription="@null"
|
||||
app:layout_constraintTop_toTopOf="@id/change_audio_output"
|
||||
app:layout_constraintBottom_toBottomOf="@id/change_audio_output"
|
||||
app:layout_constraintStart_toStartOf="@id/change_audio_output"
|
||||
app:layout_constraintEnd_toEndOf="@id/change_audio_output" />
|
||||
|
||||
<org.linphone.ui.call.view.VuMeterView
|
||||
android:id="@+id/playback_volume_vu_meter"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
vuMeterPercentage="@{viewModel.playbackVolume}"
|
||||
app:layout_constraintTop_toTopOf="@id/change_audio_output_background"
|
||||
app:layout_constraintBottom_toBottomOf="@id/change_audio_output_background"
|
||||
app:layout_constraintStart_toStartOf="@id/change_audio_output_background"
|
||||
app:layout_constraintEnd_toEndOf="@id/change_audio_output_background" />
|
||||
|
||||
<ImageView
|
||||
android:onClick="@{() -> viewModel.changeAudioOutputDevice()}"
|
||||
android:id="@+id/change_audio_output"
|
||||
|
|
@ -122,7 +143,6 @@
|
|||
android:layout_marginEnd="16dp"
|
||||
android:padding="@dimen/call_button_icon_padding"
|
||||
android:src="@{viewModel.isHearingAidEnabled ? @drawable/ear : viewModel.isHeadsetEnabled ? @drawable/headset : viewModel.isBluetoothEnabled ? @drawable/bluetooth : viewModel.isSpeakerEnabled ? @drawable/speaker_high : @drawable/speaker_slash, default=@drawable/speaker_slash}"
|
||||
android:background="@drawable/in_call_button_background_red"
|
||||
android:contentDescription="@string/content_description_change_output_audio_device"
|
||||
app:tint="@color/in_call_button_tint_color"
|
||||
app:layout_constraintTop_toBottomOf="@id/call_actions_handle"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue