mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-02-17 03:51:03 +01:00
show the other participants name at the calling notification, if available
This commit is contained in:
parent
7c0661983d
commit
75ff0e6101
@ -31,6 +31,7 @@ class DialerCallService : Service() {
|
|||||||
private var callNumber = ""
|
private var callNumber = ""
|
||||||
private var callStatus = Call.STATE_NEW
|
private var callStatus = Call.STATE_NEW
|
||||||
private var isIncomingCall = false
|
private var isIncomingCall = false
|
||||||
|
private var otherParticipantName: String? = null
|
||||||
private var reminderRefreshHandler = Handler()
|
private var reminderRefreshHandler = Handler()
|
||||||
|
|
||||||
override fun onBind(intent: Intent?) = null
|
override fun onBind(intent: Intent?) = null
|
||||||
@ -47,11 +48,12 @@ class DialerCallService : Service() {
|
|||||||
callNumber = intent.getStringExtra(CALL_NUMBER)
|
callNumber = intent.getStringExtra(CALL_NUMBER)
|
||||||
callStatus = intent.getIntExtra(CALL_STATUS, Call.STATE_NEW)
|
callStatus = intent.getIntExtra(CALL_STATUS, Call.STATE_NEW)
|
||||||
isIncomingCall = intent.getBooleanExtra(IS_INCOMING_CALL, false)
|
isIncomingCall = intent.getBooleanExtra(IS_INCOMING_CALL, false)
|
||||||
setupNotification()
|
getOtherParticipantsName()
|
||||||
}
|
}
|
||||||
intent.extras?.containsKey(CALL_STATUS) == true -> {
|
intent.extras?.containsKey(CALL_STATUS) == true -> {
|
||||||
callStatus = intent.getIntExtra(CALL_STATUS, Call.STATE_NEW)
|
callStatus = intent.getIntExtra(CALL_STATUS, Call.STATE_NEW)
|
||||||
setupNotification()
|
callNumber = intent.getStringExtra(CALL_NUMBER)
|
||||||
|
getOtherParticipantsName()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return START_STICKY
|
return START_STICKY
|
||||||
@ -63,6 +65,13 @@ class DialerCallService : Service() {
|
|||||||
reminderRefreshHandler.removeCallbacksAndMessages(null)
|
reminderRefreshHandler.removeCallbacksAndMessages(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getOtherParticipantsName() {
|
||||||
|
ContactsHelper(this).getContactWithNumber(callNumber) {
|
||||||
|
otherParticipantName = it?.getNameToDisplay() ?: callNumber
|
||||||
|
setupNotification()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.O)
|
@TargetApi(Build.VERSION_CODES.O)
|
||||||
private fun setupNotification() {
|
private fun setupNotification() {
|
||||||
val channelId = "call_channel"
|
val channelId = "call_channel"
|
||||||
@ -79,7 +88,7 @@ class DialerCallService : Service() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val notificationLayout = RemoteViews(packageName, R.layout.incoming_call_notification).apply {
|
val notificationLayout = RemoteViews(packageName, R.layout.incoming_call_notification).apply {
|
||||||
setText(R.id.incoming_call_caller, callNumber)
|
setText(R.id.incoming_call_caller, otherParticipantName!!)
|
||||||
setText(R.id.incoming_call_status, getCallStatusString())
|
setText(R.id.incoming_call_status, getCallStatusString())
|
||||||
|
|
||||||
val resources = applicationContext.resources
|
val resources = applicationContext.resources
|
||||||
|
Loading…
x
Reference in New Issue
Block a user