From 9aa9e1d05a1a6c651b97d03eccf53a6944133106 Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Sun, 15 Jun 2025 17:24:43 +0300 Subject: [PATCH] Use blue arrow down ico when incoming call was completed elsewhere --- .../main/kotlin/com/tutpro/baresip/BaresipService.kt | 5 +++-- .../kotlin/com/tutpro/baresip/CallDetailsScreen.kt | 2 +- app/src/main/kotlin/com/tutpro/baresip/CallHistory.kt | 3 ++- app/src/main/kotlin/com/tutpro/baresip/CallsScreen.kt | 5 ++++- app/src/main/res/drawable/call_down_blue.xml | 10 ++++++++++ 5 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 app/src/main/res/drawable/call_down_blue.xml diff --git a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt index 301f84ac..42390841 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt @@ -1017,7 +1017,7 @@ class BaresipService: Service() { return } "call closed" -> { - Log.d(TAG, "AoR $aor call $callp is closed") + Log.d(TAG, "AoR $aor call $callp is closed prm: ${ev[1]}") if (call != null) { nm.cancel(CALL_NOTIFICATION_ID) stopRinging() @@ -1055,10 +1055,11 @@ class BaresipService: Service() { !reason.startsWith("480") && !reason.startsWith("Connection reset by") val missed = call.dir == "in" && call.startTime == null && !call.rejected + val completedElsewhere = missed && ev[2].startsWith("SIP;cause=200") if (ua.account.callHistory) { val history = CallHistoryNew(aor, call.peerUri, call.dir) - history.startTime = call.startTime history.stopTime = GregorianCalendar() + history.startTime = if (completedElsewhere) history.stopTime else call.startTime history.rejected = call.rejected if (call.startTime != null && call.dumpfiles[0] != "") history.recording = call.dumpfiles diff --git a/app/src/main/kotlin/com/tutpro/baresip/CallDetailsScreen.kt b/app/src/main/kotlin/com/tutpro/baresip/CallDetailsScreen.kt index 93c8a7af..a30db930 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/CallDetailsScreen.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/CallDetailsScreen.kt @@ -203,7 +203,7 @@ private fun startTime(detail: Details): String { startTimeText = stopText durationText = "?" } else { - if (startTime == null) { + if (startTime == null || detail.direction == R.drawable.call_down_blue) { startTimeText = stopText durationText = "" } else { diff --git a/app/src/main/kotlin/com/tutpro/baresip/CallHistory.kt b/app/src/main/kotlin/com/tutpro/baresip/CallHistory.kt index 4f65ac30..3c9166aa 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/CallHistory.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/CallHistory.kt @@ -11,7 +11,8 @@ import java.util.GregorianCalendar class CallHistoryNew(val aor: String, val peerUri: String, val direction: String) : Serializable { - var startTime: GregorianCalendar? = null // Set to time when call is established (if ever) + // Set to time when call is established (if ever) or stopTime if call was completed elsewhere + var startTime: GregorianCalendar? = null var stopTime = GregorianCalendar() // Set to time when call is closed var rejected = false var recording = arrayOf("", "") // Encoder and decoder recording files diff --git a/app/src/main/kotlin/com/tutpro/baresip/CallsScreen.kt b/app/src/main/kotlin/com/tutpro/baresip/CallsScreen.kt index 54be1239..8586f2c1 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/CallsScreen.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/CallsScreen.kt @@ -439,7 +439,10 @@ private fun loadCallHistory(aor: String): MutableList { if (h.aor == aor) { val direction: Int = if (h.direction == "in") { if (h.startTime != null) { - R.drawable.call_down_green + if (h.startTime != h.stopTime) + R.drawable.call_down_green + else + R.drawable.call_down_blue } else { if (h.rejected) R.drawable.call_down_red diff --git a/app/src/main/res/drawable/call_down_blue.xml b/app/src/main/res/drawable/call_down_blue.xml new file mode 100644 index 00000000..74ee07cf --- /dev/null +++ b/app/src/main/res/drawable/call_down_blue.xml @@ -0,0 +1,10 @@ + + +