WebRTC Call : update call banner

This commit is contained in:
ganfra 2021-07-13 13:04:08 +02:00
parent 5c1bf92514
commit 3793df1b36
6 changed files with 35 additions and 29 deletions

View File

@ -17,12 +17,9 @@
package im.vector.app.core.ui.views package im.vector.app.core.ui.views
import android.content.Context import android.content.Context
import android.content.res.ColorStateList
import android.os.Build
import android.util.AttributeSet import android.util.AttributeSet
import android.util.TypedValue import android.util.TypedValue
import android.widget.FrameLayout import android.widget.FrameLayout
import android.widget.RelativeLayout
import androidx.appcompat.content.res.AppCompatResources import androidx.appcompat.content.res.AppCompatResources
import im.vector.app.R import im.vector.app.R
import im.vector.app.databinding.ViewCurrentCallsBinding import im.vector.app.databinding.ViewCurrentCallsBinding
@ -55,21 +52,25 @@ class CurrentCallsView @JvmOverloads constructor(
} }
fun render(calls: List<WebRtcCall>, formattedDuration: String) { fun render(calls: List<WebRtcCall>, formattedDuration: String) {
val connectedCalls = calls.filter { val tapToReturnFormat = if (calls.size == 1) {
it.mxCall.state is CallState.Connected val firstCall = calls.first()
} when (firstCall.mxCall.state) {
val heldCalls = connectedCalls.filter { is CallState.Idle,
it.isLocalOnHold || it.isRemoteOnHold is CallState.CreateOffer,
} is CallState.LocalRinging,
if (connectedCalls.isEmpty()) return is CallState.Dialing -> {
views.currentCallsInfo.text = if (connectedCalls.size == heldCalls.size) { resources.getString(R.string.call_ringing)
resources.getQuantityString(R.plurals.call_only_paused, heldCalls.size, heldCalls.size) }
} else { is CallState.Answering -> {
if (heldCalls.isEmpty()) { resources.getString(R.string.call_connecting)
resources.getString(R.string.call_only_active, formattedDuration) }
} else { else -> {
resources.getQuantityString(R.plurals.call_one_active_and_other_paused, heldCalls.size, formattedDuration, heldCalls.size) resources.getString(R.string.call_one_active, formattedDuration)
}
} }
} else {
resources.getString(R.string.call_multiple_active, calls.size)
} }
views.currentCallsInfo.text = resources.getString(R.string.call_tap_to_return, tapToReturnFormat)
} }
} }

View File

@ -19,6 +19,7 @@ package im.vector.app.core.ui.views
import androidx.core.view.isVisible import androidx.core.view.isVisible
import im.vector.app.features.call.webrtc.WebRtcCall import im.vector.app.features.call.webrtc.WebRtcCall
import org.matrix.android.sdk.api.session.call.CallState import org.matrix.android.sdk.api.session.call.CallState
import timber.log.Timber
class CurrentCallsViewPresenter { class CurrentCallsViewPresenter {
@ -37,13 +38,9 @@ class CurrentCallsViewPresenter {
this.currentCall = currentCall this.currentCall = currentCall
this.currentCall?.addListener(tickListener) this.currentCall?.addListener(tickListener)
this.calls = calls this.calls = calls
val hasActiveCall = currentCall?.mxCall?.state is CallState.Connected val hasActiveCall = currentCall != null
currentCallsView?.isVisible = hasActiveCall currentCallsView?.isVisible = hasActiveCall
if (hasActiveCall) { currentCallsView?.render(calls, currentCall?.formattedDuration() ?: "")
currentCallsView?.render(calls, currentCall?.formattedDuration() ?: "")
} else {
currentCallsView?.isVisible = false
}
} }
fun bind(activeCallView: CurrentCallsView, interactionListener: CurrentCallsView.Callback) { fun bind(activeCallView: CurrentCallsView, interactionListener: CurrentCallsView.Callback) {

View File

@ -21,6 +21,7 @@ import androidx.lifecycle.ViewModel
import im.vector.app.features.call.webrtc.WebRtcCall import im.vector.app.features.call.webrtc.WebRtcCall
import im.vector.app.features.call.webrtc.WebRtcCallManager import im.vector.app.features.call.webrtc.WebRtcCallManager
import org.matrix.android.sdk.api.session.call.MxCall import org.matrix.android.sdk.api.session.call.MxCall
import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
class SharedKnownCallsViewModel @Inject constructor( class SharedKnownCallsViewModel @Inject constructor(
@ -32,14 +33,12 @@ class SharedKnownCallsViewModel @Inject constructor(
val callListener = object : WebRtcCall.Listener { val callListener = object : WebRtcCall.Listener {
override fun onStateUpdate(call: MxCall) { override fun onStateUpdate(call: MxCall) {
// post it-self liveKnownCalls.postValue(callManager.getCalls())
liveKnownCalls.postValue(liveKnownCalls.value)
} }
override fun onHoldUnhold() { override fun onHoldUnhold() {
super.onHoldUnhold() super.onHoldUnhold()
// post it-self liveKnownCalls.postValue(callManager.getCalls())
liveKnownCalls.postValue(liveKnownCalls.value)
} }
} }

View File

@ -245,7 +245,7 @@ class VectorCallActivity : VectorBaseActivity<ActivityCallBinding>(), CallContro
is CallState.Dialing -> { is CallState.Dialing -> {
views.callVideoGroup.isInvisible = true views.callVideoGroup.isInvisible = true
views.callInfoGroup.isVisible = true views.callInfoGroup.isVisible = true
views.callToolbar.setSubtitle(R.string.call_ring) views.callToolbar.setSubtitle(R.string.call_ringing)
configureCallInfo(state) configureCallInfo(state)
} }
is CallState.Answering -> { is CallState.Answering -> {

View File

@ -359,7 +359,7 @@ class NotificationUtils @Inject constructor(private val context: Context,
val builder = NotificationCompat.Builder(context, SILENT_NOTIFICATION_CHANNEL_ID) val builder = NotificationCompat.Builder(context, SILENT_NOTIFICATION_CHANNEL_ID)
.setContentTitle(ensureTitleNotEmpty(title)) .setContentTitle(ensureTitleNotEmpty(title))
.apply { .apply {
setContentText(stringProvider.getString(R.string.call_ring)) setContentText(stringProvider.getString(R.string.call_ringing))
} }
.setSmallIcon(R.drawable.incoming_call_notification_transparent) .setSmallIcon(R.drawable.incoming_call_notification_transparent)
.setCategory(NotificationCompat.CATEGORY_CALL) .setCategory(NotificationCompat.CATEGORY_CALL)

View File

@ -721,6 +721,7 @@
<string name="call">Call</string> <string name="call">Call</string>
<string name="call_connected">Call connected</string> <string name="call_connected">Call connected</string>
<string name="call_connecting">Call connecting…</string> <string name="call_connecting">Call connecting…</string>
<string name="call_ringing">Call ringing…</string>
<string name="call_ended">Call ended</string> <string name="call_ended">Call ended</string>
<string name="call_ring">Calling…</string> <string name="call_ring">Calling…</string>
<string name="incoming_call">Incoming Call</string> <string name="incoming_call">Incoming Call</string>
@ -3239,6 +3240,14 @@
<item quantity="one">1 active call (%1$s) · 1 paused call</item> <item quantity="one">1 active call (%1$s) · 1 paused call</item>
<item quantity="other">1 active call (%1$s) · %2$d paused calls</item> <item quantity="other">1 active call (%1$s) · %2$d paused calls</item>
</plurals> </plurals>
<plurals name="call_active_status">
<item quantity="one">Active call (%1$s)</item>
<item quantity="other">%1$d active calls</item>
</plurals>
<string name="call_one_active">Active call (%1$s) ·</string>
<string name="call_multiple_active">%1$d active calls ·</string>
<string name="call_tap_to_return">%1$s Tap to return</string>
<string name="call_transfer_consult_first">Consult first</string> <string name="call_transfer_consult_first">Consult first</string>
<string name="call_transfer_connect_action">Connect</string> <string name="call_transfer_connect_action">Connect</string>