Update status notification when new call is added
Improved status notification content text
This commit is contained in:
@@ -894,7 +894,7 @@ class BaresipService: Service() {
|
|||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
val connection = ConnectionService.connections[callp]
|
val connection = ConnectionService.connections[callp]
|
||||||
if (call!!.held && !newHeldState) {
|
if (call.held && !newHeldState) {
|
||||||
Log.d(TAG, "Call ${call.callp} un-held by peer.")
|
Log.d(TAG, "Call ${call.callp} un-held by peer.")
|
||||||
call.onhold = false
|
call.onhold = false
|
||||||
// Use a Coroutine with a small delay to let the SIP
|
// Use a Coroutine with a small delay to let the SIP
|
||||||
@@ -1346,6 +1346,7 @@ class BaresipService: Service() {
|
|||||||
call.onHoldCall = onHoldCall
|
call.onHoldCall = onHoldCall
|
||||||
call.conferenceCall = conferenceCall
|
call.conferenceCall = conferenceCall
|
||||||
call.add()
|
call.add()
|
||||||
|
updateStatusNotification()
|
||||||
if (onHoldCall != null)
|
if (onHoldCall != null)
|
||||||
onHoldCall.newCall = call
|
onHoldCall.newCall = call
|
||||||
if (!call.connect(uri)) {
|
if (!call.connect(uri)) {
|
||||||
@@ -1353,6 +1354,7 @@ class BaresipService: Service() {
|
|||||||
ConnectionService.onCallClosed(callp)
|
ConnectionService.onCallClosed(callp)
|
||||||
call.remove()
|
call.remove()
|
||||||
call.destroy()
|
call.destroy()
|
||||||
|
updateStatusNotification()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1464,6 +1466,7 @@ class BaresipService: Service() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun updateStatusNotification() {
|
fun updateStatusNotification() {
|
||||||
|
|
||||||
val activeCall = Call.calls().find {
|
val activeCall = Call.calls().find {
|
||||||
it.status.value == "connected" || it.status.value == "outgoing" || it.status.value == "answered"
|
it.status.value == "connected" || it.status.value == "outgoing" || it.status.value == "answered"
|
||||||
}
|
}
|
||||||
@@ -1499,9 +1502,17 @@ class BaresipService: Service() {
|
|||||||
.setPriority(NotificationCompat.PRIORITY_LOW)
|
.setPriority(NotificationCompat.PRIORITY_LOW)
|
||||||
.setWhen(activeCall.startTime?.timeInMillis ?: System.currentTimeMillis())
|
.setWhen(activeCall.startTime?.timeInMillis ?: System.currentTimeMillis())
|
||||||
.setUsesChronometer(true)
|
.setUsesChronometer(true)
|
||||||
.setContentText(if (activeCall.onhold) getString(R.string.call_is_on_hold) else getString(R.string.call_is_connected))
|
.setContentText(
|
||||||
|
if (activeCall.onhold)
|
||||||
|
getString(R.string.call_is_on_hold)
|
||||||
|
else
|
||||||
|
when (activeCall.status.value) {
|
||||||
|
"outgoing", "incoming" -> getString(R.string.call_is_ringing)
|
||||||
|
"connected", "answered" -> getString(R.string.call_is_connected)
|
||||||
|
else -> getString(R.string.call)
|
||||||
|
}
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
// IMPORTANT: Explicitly clear the style first to ensure CallStyle is removed
|
|
||||||
builder.setStyle(null)
|
builder.setStyle(null)
|
||||||
builder.setStyle(NotificationCompat.DecoratedCustomViewStyle())
|
builder.setStyle(NotificationCompat.DecoratedCustomViewStyle())
|
||||||
.setCategory(Notification.CATEGORY_SERVICE)
|
.setCategory(Notification.CATEGORY_SERVICE)
|
||||||
|
|||||||
@@ -504,6 +504,7 @@
|
|||||||
<string name="allow_video">Accept sending and receiving video with \'%1$s\'\?</string>
|
<string name="allow_video">Accept sending and receiving video with \'%1$s\'\?</string>
|
||||||
<string name="allow_video_send">Accept sending of video to \'%1$s\'\?</string>
|
<string name="allow_video_send">Accept sending of video to \'%1$s\'\?</string>
|
||||||
<string name="allow_video_recv">Accept receiving video from \'%1$s\'\?</string>
|
<string name="allow_video_recv">Accept receiving video from \'%1$s\'\?</string>
|
||||||
|
<string name="call_is_ringing">Call is ringing</string>
|
||||||
<string name="call_is_on_hold">Call is on hold</string>
|
<string name="call_is_on_hold">Call is on hold</string>
|
||||||
<string name="call_is_connected">Call is connected</string>
|
<string name="call_is_connected">Call is connected</string>
|
||||||
<string name="rec_in_call">Recording can be turned on or off only when call is not
|
<string name="rec_in_call">Recording can be turned on or off only when call is not
|
||||||
|
|||||||
Reference in New Issue
Block a user