If more than one missed call, show number of missed calls in notify
Moved baresip service constants to constants class
This commit is contained in:
@@ -770,20 +770,35 @@ class BaresipService: Service() {
|
|||||||
PendingIntent.FLAG_UPDATE_CURRENT)
|
PendingIntent.FLAG_UPDATE_CURRENT)
|
||||||
val nb = NotificationCompat.Builder(this, HIGH_CHANNEL_ID)
|
val nb = NotificationCompat.Builder(this, HIGH_CHANNEL_ID)
|
||||||
nb.setSmallIcon(R.drawable.ic_stat)
|
nb.setSmallIcon(R.drawable.ic_stat)
|
||||||
.setColor(ContextCompat.getColor(this,
|
.setColor(ContextCompat.getColor(this, R.color.colorBaresip))
|
||||||
R.color.colorBaresip))
|
.setContentIntent(pi)
|
||||||
.setContentIntent(pi)
|
.setCategory(Notification.CATEGORY_CALL)
|
||||||
.setCategory(Notification.CATEGORY_CALL)
|
.setAutoCancel(true)
|
||||||
.setAutoCancel(true)
|
if (VERSION.SDK_INT < 23) {
|
||||||
.setContentTitle(getString(R.string.missed_call_from))
|
nb.setContentTitle(getString(R.string.missed_call_from))
|
||||||
.setContentText(caller)
|
nb.setContentText(caller)
|
||||||
|
} else {
|
||||||
|
var missedCalls = 0
|
||||||
|
for (notification in nm.activeNotifications)
|
||||||
|
if (notification.id == CALL_MISSED_NOTIFICATION_ID)
|
||||||
|
missedCalls++
|
||||||
|
if (missedCalls == 0) {
|
||||||
|
nb.setContentTitle(getString(R.string.missed_call_from))
|
||||||
|
nb.setContentText(caller)
|
||||||
|
} else {
|
||||||
|
nb.setContentTitle(getString(R.string.missed_calls))
|
||||||
|
nb.setContentText(
|
||||||
|
String.format(getString(R.string.missed_calls_count),
|
||||||
|
missedCalls + 1))
|
||||||
|
}
|
||||||
|
}
|
||||||
if (VERSION.SDK_INT < 26) {
|
if (VERSION.SDK_INT < 26) {
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
nb.setVibrate(LongArray(0))
|
nb.setVibrate(LongArray(0))
|
||||||
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
|
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
|
||||||
.priority = Notification.PRIORITY_HIGH
|
.priority = Notification.PRIORITY_HIGH
|
||||||
}
|
}
|
||||||
nm.notify(CALL_NOTIFICATION_ID, nb.build())
|
nm.notify(CALL_MISSED_NOTIFICATION_ID, nb.build())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1306,26 +1321,6 @@ class BaresipService: Service() {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
const val STATUS_NOTIFICATION_ID = 101
|
|
||||||
const val CALL_NOTIFICATION_ID = 102
|
|
||||||
const val TRANSFER_NOTIFICATION_ID = 103
|
|
||||||
const val MESSAGE_NOTIFICATION_ID = 104
|
|
||||||
|
|
||||||
const val STATUS_REQ_CODE = 1
|
|
||||||
const val CALL_REQ_CODE = 2
|
|
||||||
const val ANSWER_REQ_CODE = 3
|
|
||||||
const val REJECT_REQ_CODE = 4
|
|
||||||
const val TRANSFER_REQ_CODE = 5
|
|
||||||
const val ACCEPT_REQ_CODE = 6
|
|
||||||
const val DENY_REQ_CODE = 7
|
|
||||||
const val MESSAGE_REQ_CODE = 8
|
|
||||||
const val REPLY_REQ_CODE = 9
|
|
||||||
const val SAVE_REQ_CODE = 10
|
|
||||||
const val DELETE_REQ_CODE = 11
|
|
||||||
|
|
||||||
const val DEFAULT_CHANNEL_ID = "com.tutpro.baresip.default"
|
|
||||||
const val HIGH_CHANNEL_ID = "com.tutpro.baresip.high"
|
|
||||||
|
|
||||||
var isServiceRunning = false
|
var isServiceRunning = false
|
||||||
var isConfigInitialized = false
|
var isConfigInitialized = false
|
||||||
var libraryLoaded = false
|
var libraryLoaded = false
|
||||||
|
|||||||
@@ -2,9 +2,30 @@ package com.tutpro.baresip
|
|||||||
|
|
||||||
const val TAG = "Baresip"
|
const val TAG = "Baresip"
|
||||||
|
|
||||||
|
const val DEFAULT_CHANNEL_ID = "com.tutpro.baresip.default"
|
||||||
|
const val HIGH_CHANNEL_ID = "com.tutpro.baresip.high"
|
||||||
|
|
||||||
const val BACKUP_PERMISSION_REQUEST_CODE = 1
|
const val BACKUP_PERMISSION_REQUEST_CODE = 1
|
||||||
const val RESTORE_PERMISSION_REQUEST_CODE = 2
|
const val RESTORE_PERMISSION_REQUEST_CODE = 2
|
||||||
const val RECORD_PERMISSION_REQUEST_CODE = 3
|
const val RECORD_PERMISSION_REQUEST_CODE = 3
|
||||||
const val CONTACTS_PERMISSION_REQUEST_CODE = 4
|
const val CONTACTS_PERMISSION_REQUEST_CODE = 4
|
||||||
const val READ_CERT_PERMISSION_CODE = 5
|
const val READ_CERT_PERMISSION_CODE = 5
|
||||||
const val READ_CA_PERMISSION_CODE = 6
|
const val READ_CA_PERMISSION_CODE = 6
|
||||||
|
|
||||||
|
const val STATUS_NOTIFICATION_ID = 101
|
||||||
|
const val CALL_NOTIFICATION_ID = 102
|
||||||
|
const val CALL_MISSED_NOTIFICATION_ID = 103
|
||||||
|
const val TRANSFER_NOTIFICATION_ID = 104
|
||||||
|
const val MESSAGE_NOTIFICATION_ID = 105
|
||||||
|
|
||||||
|
const val STATUS_REQ_CODE = 1
|
||||||
|
const val CALL_REQ_CODE = 2
|
||||||
|
const val ANSWER_REQ_CODE = 3
|
||||||
|
const val REJECT_REQ_CODE = 4
|
||||||
|
const val TRANSFER_REQ_CODE = 5
|
||||||
|
const val ACCEPT_REQ_CODE = 6
|
||||||
|
const val DENY_REQ_CODE = 7
|
||||||
|
const val MESSAGE_REQ_CODE = 8
|
||||||
|
const val REPLY_REQ_CODE = 9
|
||||||
|
const val SAVE_REQ_CODE = 10
|
||||||
|
const val DELETE_REQ_CODE = 11
|
||||||
|
|||||||
@@ -242,6 +242,8 @@
|
|||||||
<string name="reject">Hylkää</string>
|
<string name="reject">Hylkää</string>
|
||||||
<string name="incoming_call_from">Puhelu soittajalta</string>
|
<string name="incoming_call_from">Puhelu soittajalta</string>
|
||||||
<string name="missed_call_from">Vastaamaton puhelu soittajalta</string>
|
<string name="missed_call_from">Vastaamaton puhelu soittajalta</string>
|
||||||
|
<string name="missed_calls">Vastaamattomia puheluita</string>
|
||||||
|
<string name="missed_calls_count">%1$d vastaamatonta puhelua</string>
|
||||||
<string name="transfer_request_to">Puhelun siirtopyyntö kohteeseen</string>
|
<string name="transfer_request_to">Puhelun siirtopyyntö kohteeseen</string>
|
||||||
<string name="message_from">Viesti lähettäjältä</string>
|
<string name="message_from">Viesti lähettäjältä</string>
|
||||||
<!-- Boot Completed Receiver -->
|
<!-- Boot Completed Receiver -->
|
||||||
|
|||||||
@@ -220,6 +220,8 @@
|
|||||||
<string name="reject">Reject</string>
|
<string name="reject">Reject</string>
|
||||||
<string name="incoming_call_from">Incoming call from</string>
|
<string name="incoming_call_from">Incoming call from</string>
|
||||||
<string name="missed_call_from">Missed call from</string>
|
<string name="missed_call_from">Missed call from</string>
|
||||||
|
<string name="missed_calls">Missed calls</string>
|
||||||
|
<string name="missed_calls_count">%1$d missed calls</string>
|
||||||
<string name="transfer_request_to">Call transfer request to</string>
|
<string name="transfer_request_to">Call transfer request to</string>
|
||||||
<string name="message_from">Message from</string>
|
<string name="message_from">Message from</string>
|
||||||
<!-- Boot Completed Receiver -->
|
<!-- Boot Completed Receiver -->
|
||||||
|
|||||||
Reference in New Issue
Block a user