Added missed call notification
This commit is contained in:
@@ -281,6 +281,15 @@ class BaresipService: Service() {
|
|||||||
startActivity(newIntent)
|
startActivity(newIntent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"Call Missed" -> {
|
||||||
|
val newIntent = Intent(this, MainActivity::class.java)
|
||||||
|
newIntent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP or
|
||||||
|
Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
|
newIntent.putExtra("action", action.toLowerCase(Locale.ROOT))
|
||||||
|
newIntent.putExtra("uap", intent!!.getStringExtra("uap"))
|
||||||
|
startActivity(newIntent)
|
||||||
|
}
|
||||||
|
|
||||||
"Call Reject" -> {
|
"Call Reject" -> {
|
||||||
val callp = intent!!.getStringExtra("callp")!!
|
val callp = intent!!.getStringExtra("callp")!!
|
||||||
val call = Call.ofCallp(callp)
|
val call = Call.ofCallp(callp)
|
||||||
@@ -695,7 +704,31 @@ class BaresipService: Service() {
|
|||||||
CallHistory.save()
|
CallHistory.save()
|
||||||
if (call.dir == "in") ua.account.missedCalls = true
|
if (call.dir == "in") ua.account.missedCalls = true
|
||||||
}
|
}
|
||||||
if (!Utils.isVisible()) return
|
if (!Utils.isVisible() && !call.hasHistory && call.dir == "in") {
|
||||||
|
val caller = Utils.friendlyUri(ContactsActivity.contactName(call.peerURI),
|
||||||
|
Utils.aorDomain(aor))
|
||||||
|
val intent = Intent(this, BaresipService::class.java)
|
||||||
|
intent.action = "Call Missed"
|
||||||
|
intent.putExtra("uap", uap)
|
||||||
|
val pi = PendingIntent.getService(this, CALL_REQ_CODE, intent,
|
||||||
|
PendingIntent.FLAG_UPDATE_CURRENT)
|
||||||
|
val nb = NotificationCompat.Builder(this, HIGH_CHANNEL_ID)
|
||||||
|
nb.setSmallIcon(R.drawable.ic_stat)
|
||||||
|
.setColor(ContextCompat.getColor(this,
|
||||||
|
R.color.colorBaresip))
|
||||||
|
.setContentIntent(pi)
|
||||||
|
.setCategory(Notification.CATEGORY_CALL)
|
||||||
|
.setAutoCancel(true)
|
||||||
|
.setContentTitle(getString(R.string.missed_call_from))
|
||||||
|
.setContentText(caller)
|
||||||
|
if (Build.VERSION.SDK_INT < 26) {
|
||||||
|
nb.setVibrate(LongArray(0))
|
||||||
|
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
|
||||||
|
.priority = Notification.PRIORITY_HIGH
|
||||||
|
}
|
||||||
|
nm.notify(CALL_NOTIFICATION_ID, nb.build())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
"refer failed" -> {
|
"refer failed" -> {
|
||||||
Log.d(LOG_TAG, "AoR $aor hanging up call $callp with ${ev[1]}")
|
Log.d(LOG_TAG, "AoR $aor hanging up call $callp with ${ev[1]}")
|
||||||
|
|||||||
@@ -518,6 +518,17 @@ class MainActivity : AppCompatActivity() {
|
|||||||
resumeAction = action
|
resumeAction = action
|
||||||
resumeCall = call
|
resumeCall = call
|
||||||
}
|
}
|
||||||
|
"call missed" -> {
|
||||||
|
val uap = intent.getStringExtra("uap")!!
|
||||||
|
val ua = UserAgent.ofUap(uap)
|
||||||
|
if (ua == null) {
|
||||||
|
Log.w("Baresip", "onNewIntent did not find ua $uap")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (ua.account.aor != aorSpinner.tag)
|
||||||
|
spinToAor(ua.account.aor)
|
||||||
|
resumeAction = action
|
||||||
|
}
|
||||||
"transfer show", "transfer accept" -> {
|
"transfer show", "transfer accept" -> {
|
||||||
val callp = intent.getStringExtra("callp")!!
|
val callp = intent.getStringExtra("callp")!!
|
||||||
val call = Call.ofCallp(callp)
|
val call = Call.ofCallp(callp)
|
||||||
@@ -558,6 +569,9 @@ class MainActivity : AppCompatActivity() {
|
|||||||
answerButton.performClick()
|
answerButton.performClick()
|
||||||
showCall(resumeCall!!.ua)
|
showCall(resumeCall!!.ua)
|
||||||
}
|
}
|
||||||
|
"call missed" -> {
|
||||||
|
callsButton.performClick()
|
||||||
|
}
|
||||||
"call reject" ->
|
"call reject" ->
|
||||||
rejectButton.performClick()
|
rejectButton.performClick()
|
||||||
"call" -> {
|
"call" -> {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical" >
|
android:orientation="vertical" >
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout
|
||||||
android:id="@+id/mainRow"
|
android:id="@+id/mainRow"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|||||||
@@ -209,6 +209,7 @@
|
|||||||
<string name="answer">Vastaa</string>
|
<string name="answer">Vastaa</string>
|
||||||
<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="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 -->
|
||||||
|
|||||||
@@ -187,6 +187,7 @@
|
|||||||
<string name="answer">Answer</string>
|
<string name="answer">Answer</string>
|
||||||
<string name="reject">Reject</string>
|
<string name="reject">Reject</string>
|
||||||
<string name="incoming_call_from">Call from</string>
|
<string name="incoming_call_from">Call from</string>
|
||||||
|
<string name="missed_call_from">Missed call from</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