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() {
|
internal fun ConferenceCallFragment.navigateToCallsList() {
|
||||||
if (findNavController().currentDestination?.id == R.id.conferenceCallFragment) {
|
if (findNavController().currentDestination?.id == R.id.conferenceCallFragment) {
|
||||||
findNavController().navigate(
|
findNavController().navigate(
|
||||||
|
|
|
@ -134,11 +134,12 @@ class CallActivity : ProximitySensorActivity() {
|
||||||
callsViewModel.currentCallData.observe(
|
callsViewModel.currentCallData.observe(
|
||||||
this
|
this
|
||||||
) { callData ->
|
) { callData ->
|
||||||
if (callData.call.conference == null) {
|
val call = callData.call
|
||||||
Log.i("[Call Activity] Current call isn't linked to a conference, changing fragment")
|
if (call.conference == null) {
|
||||||
|
Log.i("[Call Activity] Current call isn't linked to a conference, switching to SingleCall fragment")
|
||||||
navigateToActiveCall()
|
navigateToActiveCall()
|
||||||
} else {
|
} 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()
|
navigateToConferenceCall()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,10 +157,10 @@ class CallActivity : ProximitySensorActivity() {
|
||||||
this
|
this
|
||||||
) { exists ->
|
) { exists ->
|
||||||
if (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()
|
navigateToConferenceCall()
|
||||||
} else if (coreContext.core.callsNb > 0) {
|
} 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()
|
navigateToActiveCall()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,17 @@ class SingleCallFragment : GenericVideoPreviewFragment<VoipSingleCallFragmentBin
|
||||||
) { callData ->
|
) { callData ->
|
||||||
if (callData != null) {
|
if (callData != null) {
|
||||||
val call = callData.call
|
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)
|
val timer = binding.root.findViewById<Chronometer>(R.id.active_call_timer)
|
||||||
timer.base =
|
timer.base =
|
||||||
SystemClock.elapsedRealtime() - (1000 * call.duration) // Linphone timestamps are in seconds
|
SystemClock.elapsedRealtime() - (1000 * call.duration) // Linphone timestamps are in seconds
|
||||||
|
@ -96,6 +106,8 @@ class SingleCallFragment : GenericVideoPreviewFragment<VoipSingleCallFragmentBin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
controlsViewModel.goToConferenceParticipantsListEvent.observe(
|
controlsViewModel.goToConferenceParticipantsListEvent.observe(
|
||||||
viewLifecycleOwner
|
viewLifecycleOwner
|
||||||
|
|
|
@ -138,8 +138,9 @@ class CallsViewModel : ViewModel() {
|
||||||
init {
|
init {
|
||||||
coreContext.core.addListener(listener)
|
coreContext.core.addListener(listener)
|
||||||
|
|
||||||
val currentCall = coreContext.core.currentCall
|
val currentCall = coreContext.core.currentCall ?: coreContext.core.calls.firstOrNull()
|
||||||
if (currentCall != null) {
|
if (currentCall != null) {
|
||||||
|
Log.i("[Calls] Initializing ViewModel using call [${currentCall.remoteAddress.asStringUriOnly()}] as current")
|
||||||
currentCallData.value?.destroy()
|
currentCallData.value?.destroy()
|
||||||
|
|
||||||
val viewModel = CallData(currentCall)
|
val viewModel = CallData(currentCall)
|
||||||
|
@ -223,14 +224,12 @@ class CallsViewModel : ViewModel() {
|
||||||
Log.i("[Calls] Removing call with ID ${call.callLog.callId} from calls list")
|
Log.i("[Calls] Removing call with ID ${call.callLog.callId} from calls list")
|
||||||
|
|
||||||
val calls = arrayListOf<CallData>()
|
val calls = arrayListOf<CallData>()
|
||||||
calls.addAll(callsData.value.orEmpty())
|
for (data in callsData.value.orEmpty()) {
|
||||||
|
if (data.call == call) {
|
||||||
val data = calls.find { it.call == call }
|
|
||||||
if (data == null) {
|
|
||||||
Log.w("[Calls] Data for call to remove wasn't found")
|
|
||||||
} else {
|
|
||||||
data.destroy()
|
data.destroy()
|
||||||
calls.remove(data)
|
} else {
|
||||||
|
calls.add(data)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
callsData.value = calls
|
callsData.value = calls
|
||||||
|
@ -239,8 +238,6 @@ class CallsViewModel : ViewModel() {
|
||||||
private fun updateCurrentCallData(currentCall: Call?) {
|
private fun updateCurrentCallData(currentCall: Call?) {
|
||||||
var callToUse = currentCall
|
var callToUse = currentCall
|
||||||
if (currentCall == null) {
|
if (currentCall == null) {
|
||||||
Log.i("[Calls] Current call is now null")
|
|
||||||
|
|
||||||
if (coreContext.core.callsNb == 1) {
|
if (coreContext.core.callsNb == 1) {
|
||||||
// Make sure the current call data is matching the only call
|
// Make sure the current call data is matching the only call
|
||||||
val firstData = callsData.value?.firstOrNull()
|
val firstData = callsData.value?.firstOrNull()
|
||||||
|
|
|
@ -248,7 +248,10 @@ class ControlsViewModel : ViewModel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun answer() {
|
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) {
|
if (currentCall != null) {
|
||||||
coreContext.answerCall(currentCall)
|
coreContext.answerCall(currentCall)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue