Fixed UI issue when hanging up an active call when an incoming call is ringing
This commit is contained in:
parent
182d80a630
commit
b1b426389d
5 changed files with 59 additions and 26 deletions
|
@ -965,6 +965,26 @@ internal fun SingleCallFragment.navigateToConferenceLayout() {
|
|||
}
|
||||
}
|
||||
|
||||
internal fun SingleCallFragment.navigateToIncomingCall() {
|
||||
if (findNavController().currentDestination?.id == R.id.singleCallFragment) {
|
||||
findNavController().navigate(
|
||||
R.id.action_global_incomingCallFragment,
|
||||
null,
|
||||
popupTo(R.id.singleCallFragment, true)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun SingleCallFragment.navigateToOutgoingCall() {
|
||||
if (findNavController().currentDestination?.id == R.id.singleCallFragment) {
|
||||
findNavController().navigate(
|
||||
R.id.action_global_outgoingCallFragment,
|
||||
null,
|
||||
popupTo(R.id.singleCallFragment, true)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun ConferenceCallFragment.navigateToCallsList() {
|
||||
if (findNavController().currentDestination?.id == R.id.conferenceCallFragment) {
|
||||
findNavController().navigate(
|
||||
|
|
|
@ -134,11 +134,12 @@ class CallActivity : ProximitySensorActivity() {
|
|||
callsViewModel.currentCallData.observe(
|
||||
this
|
||||
) { callData ->
|
||||
if (callData.call.conference == null) {
|
||||
Log.i("[Call Activity] Current call isn't linked to a conference, changing fragment")
|
||||
val call = callData.call
|
||||
if (call.conference == null) {
|
||||
Log.i("[Call Activity] Current call isn't linked to a conference, switching to SingleCall fragment")
|
||||
navigateToActiveCall()
|
||||
} else {
|
||||
Log.i("[Call Activity] Current call is linked to a conference, changing fragment")
|
||||
Log.i("[Call Activity] Current call is linked to a conference, switching to ConferenceCall fragment")
|
||||
navigateToConferenceCall()
|
||||
}
|
||||
}
|
||||
|
@ -156,10 +157,10 @@ class CallActivity : ProximitySensorActivity() {
|
|||
this
|
||||
) { exists ->
|
||||
if (exists) {
|
||||
Log.i("[Call Activity] Found active conference, changing fragment")
|
||||
Log.i("[Call Activity] Found active conference, changing switching to ConferenceCall fragment")
|
||||
navigateToConferenceCall()
|
||||
} else if (coreContext.core.callsNb > 0) {
|
||||
Log.i("[Call Activity] Conference no longer exists, changing fragment")
|
||||
Log.i("[Call Activity] Conference no longer exists, switching to SingleCall fragment")
|
||||
navigateToActiveCall()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,16 +82,28 @@ class SingleCallFragment : GenericVideoPreviewFragment<VoipSingleCallFragmentBin
|
|||
) { callData ->
|
||||
if (callData != null) {
|
||||
val call = callData.call
|
||||
when (val callState = call.state) {
|
||||
Call.State.IncomingReceived, Call.State.IncomingEarlyMedia -> {
|
||||
Log.i("[Single Call] New current call is in [$callState] state, switching to IncomingCall fragment")
|
||||
navigateToIncomingCall()
|
||||
}
|
||||
Call.State.OutgoingInit, Call.State.OutgoingProgress, Call.State.OutgoingRinging, Call.State.OutgoingEarlyMedia -> {
|
||||
Log.i("[Single Call] New current call is in [$callState] state, switching to OutgoingCall fragment")
|
||||
navigateToOutgoingCall()
|
||||
}
|
||||
else -> {
|
||||
Log.i("[Single Call] New current call is in [$callState] state, updating call UI")
|
||||
val timer = binding.root.findViewById<Chronometer>(R.id.active_call_timer)
|
||||
timer.base =
|
||||
SystemClock.elapsedRealtime() - (1000 * call.duration) // Linphone timestamps are in seconds
|
||||
timer.start()
|
||||
|
||||
val timer = binding.root.findViewById<Chronometer>(R.id.active_call_timer)
|
||||
timer.base =
|
||||
SystemClock.elapsedRealtime() - (1000 * call.duration) // Linphone timestamps are in seconds
|
||||
timer.start()
|
||||
|
||||
if (corePreferences.enableFullScreenWhenJoiningVideoCall) {
|
||||
if (call.currentParams.isVideoEnabled) {
|
||||
Log.i("[Single Call] Call params have video enabled, enabling full screen mode")
|
||||
controlsViewModel.fullScreenMode.value = true
|
||||
if (corePreferences.enableFullScreenWhenJoiningVideoCall) {
|
||||
if (call.currentParams.isVideoEnabled) {
|
||||
Log.i("[Single Call] Call params have video enabled, enabling full screen mode")
|
||||
controlsViewModel.fullScreenMode.value = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -138,8 +138,9 @@ class CallsViewModel : ViewModel() {
|
|||
init {
|
||||
coreContext.core.addListener(listener)
|
||||
|
||||
val currentCall = coreContext.core.currentCall
|
||||
val currentCall = coreContext.core.currentCall ?: coreContext.core.calls.firstOrNull()
|
||||
if (currentCall != null) {
|
||||
Log.i("[Calls] Initializing ViewModel using call [${currentCall.remoteAddress.asStringUriOnly()}] as current")
|
||||
currentCallData.value?.destroy()
|
||||
|
||||
val viewModel = CallData(currentCall)
|
||||
|
@ -223,14 +224,12 @@ class CallsViewModel : ViewModel() {
|
|||
Log.i("[Calls] Removing call with ID ${call.callLog.callId} from calls list")
|
||||
|
||||
val calls = arrayListOf<CallData>()
|
||||
calls.addAll(callsData.value.orEmpty())
|
||||
|
||||
val data = calls.find { it.call == call }
|
||||
if (data == null) {
|
||||
Log.w("[Calls] Data for call to remove wasn't found")
|
||||
} else {
|
||||
data.destroy()
|
||||
calls.remove(data)
|
||||
for (data in callsData.value.orEmpty()) {
|
||||
if (data.call == call) {
|
||||
data.destroy()
|
||||
} else {
|
||||
calls.add(data)
|
||||
}
|
||||
}
|
||||
|
||||
callsData.value = calls
|
||||
|
@ -239,8 +238,6 @@ class CallsViewModel : ViewModel() {
|
|||
private fun updateCurrentCallData(currentCall: Call?) {
|
||||
var callToUse = currentCall
|
||||
if (currentCall == null) {
|
||||
Log.i("[Calls] Current call is now null")
|
||||
|
||||
if (coreContext.core.callsNb == 1) {
|
||||
// Make sure the current call data is matching the only call
|
||||
val firstData = callsData.value?.firstOrNull()
|
||||
|
|
|
@ -248,7 +248,10 @@ class ControlsViewModel : ViewModel() {
|
|||
}
|
||||
|
||||
fun answer() {
|
||||
val currentCall = coreContext.core.currentCall
|
||||
val currentCall = coreContext.core.currentCall ?: coreContext.core.calls.find {
|
||||
call ->
|
||||
call.state == Call.State.IncomingReceived || call.state == Call.State.IncomingEarlyMedia
|
||||
}
|
||||
if (currentCall != null) {
|
||||
coreContext.answerCall(currentCall)
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue