mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
WebRTC Call : update call banner
This commit is contained in:
parent
5c1bf92514
commit
3793df1b36
@ -17,12 +17,9 @@
|
||||
package im.vector.app.core.ui.views
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.os.Build
|
||||
import android.util.AttributeSet
|
||||
import android.util.TypedValue
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.RelativeLayout
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
import im.vector.app.R
|
||||
import im.vector.app.databinding.ViewCurrentCallsBinding
|
||||
@ -55,21 +52,25 @@ class CurrentCallsView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
fun render(calls: List<WebRtcCall>, formattedDuration: String) {
|
||||
val connectedCalls = calls.filter {
|
||||
it.mxCall.state is CallState.Connected
|
||||
}
|
||||
val heldCalls = connectedCalls.filter {
|
||||
it.isLocalOnHold || it.isRemoteOnHold
|
||||
}
|
||||
if (connectedCalls.isEmpty()) return
|
||||
views.currentCallsInfo.text = if (connectedCalls.size == heldCalls.size) {
|
||||
resources.getQuantityString(R.plurals.call_only_paused, heldCalls.size, heldCalls.size)
|
||||
} else {
|
||||
if (heldCalls.isEmpty()) {
|
||||
resources.getString(R.string.call_only_active, formattedDuration)
|
||||
} else {
|
||||
resources.getQuantityString(R.plurals.call_one_active_and_other_paused, heldCalls.size, formattedDuration, heldCalls.size)
|
||||
val tapToReturnFormat = if (calls.size == 1) {
|
||||
val firstCall = calls.first()
|
||||
when (firstCall.mxCall.state) {
|
||||
is CallState.Idle,
|
||||
is CallState.CreateOffer,
|
||||
is CallState.LocalRinging,
|
||||
is CallState.Dialing -> {
|
||||
resources.getString(R.string.call_ringing)
|
||||
}
|
||||
is CallState.Answering -> {
|
||||
resources.getString(R.string.call_connecting)
|
||||
}
|
||||
else -> {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ package im.vector.app.core.ui.views
|
||||
import androidx.core.view.isVisible
|
||||
import im.vector.app.features.call.webrtc.WebRtcCall
|
||||
import org.matrix.android.sdk.api.session.call.CallState
|
||||
import timber.log.Timber
|
||||
|
||||
class CurrentCallsViewPresenter {
|
||||
|
||||
@ -37,13 +38,9 @@ class CurrentCallsViewPresenter {
|
||||
this.currentCall = currentCall
|
||||
this.currentCall?.addListener(tickListener)
|
||||
this.calls = calls
|
||||
val hasActiveCall = currentCall?.mxCall?.state is CallState.Connected
|
||||
val hasActiveCall = currentCall != null
|
||||
currentCallsView?.isVisible = hasActiveCall
|
||||
if (hasActiveCall) {
|
||||
currentCallsView?.render(calls, currentCall?.formattedDuration() ?: "")
|
||||
} else {
|
||||
currentCallsView?.isVisible = false
|
||||
}
|
||||
currentCallsView?.render(calls, currentCall?.formattedDuration() ?: "")
|
||||
}
|
||||
|
||||
fun bind(activeCallView: CurrentCallsView, interactionListener: CurrentCallsView.Callback) {
|
||||
|
@ -21,6 +21,7 @@ import androidx.lifecycle.ViewModel
|
||||
import im.vector.app.features.call.webrtc.WebRtcCall
|
||||
import im.vector.app.features.call.webrtc.WebRtcCallManager
|
||||
import org.matrix.android.sdk.api.session.call.MxCall
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
class SharedKnownCallsViewModel @Inject constructor(
|
||||
@ -32,14 +33,12 @@ class SharedKnownCallsViewModel @Inject constructor(
|
||||
val callListener = object : WebRtcCall.Listener {
|
||||
|
||||
override fun onStateUpdate(call: MxCall) {
|
||||
// post it-self
|
||||
liveKnownCalls.postValue(liveKnownCalls.value)
|
||||
liveKnownCalls.postValue(callManager.getCalls())
|
||||
}
|
||||
|
||||
override fun onHoldUnhold() {
|
||||
super.onHoldUnhold()
|
||||
// post it-self
|
||||
liveKnownCalls.postValue(liveKnownCalls.value)
|
||||
liveKnownCalls.postValue(callManager.getCalls())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -245,7 +245,7 @@ class VectorCallActivity : VectorBaseActivity<ActivityCallBinding>(), CallContro
|
||||
is CallState.Dialing -> {
|
||||
views.callVideoGroup.isInvisible = true
|
||||
views.callInfoGroup.isVisible = true
|
||||
views.callToolbar.setSubtitle(R.string.call_ring)
|
||||
views.callToolbar.setSubtitle(R.string.call_ringing)
|
||||
configureCallInfo(state)
|
||||
}
|
||||
is CallState.Answering -> {
|
||||
|
@ -359,7 +359,7 @@ class NotificationUtils @Inject constructor(private val context: Context,
|
||||
val builder = NotificationCompat.Builder(context, SILENT_NOTIFICATION_CHANNEL_ID)
|
||||
.setContentTitle(ensureTitleNotEmpty(title))
|
||||
.apply {
|
||||
setContentText(stringProvider.getString(R.string.call_ring))
|
||||
setContentText(stringProvider.getString(R.string.call_ringing))
|
||||
}
|
||||
.setSmallIcon(R.drawable.incoming_call_notification_transparent)
|
||||
.setCategory(NotificationCompat.CATEGORY_CALL)
|
||||
|
@ -721,6 +721,7 @@
|
||||
<string name="call">Call</string>
|
||||
<string name="call_connected">Call connected</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_ring">Calling…</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="other">1 active call (%1$s) · %2$d paused calls</item>
|
||||
</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_connect_action">Connect</string>
|
||||
|
Loading…
Reference in New Issue
Block a user