mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-02-17 03:51:03 +01:00
show correct status at the call notification too
This commit is contained in:
parent
7f1c2471d0
commit
70466bd1a1
@ -54,7 +54,7 @@ class CallActivity : SimpleActivity() {
|
||||
callContact = CallManager.getCallContact(applicationContext)
|
||||
callContactAvatar = getCallContactAvatar()
|
||||
addLockScreenFlags()
|
||||
showNotification()
|
||||
setupNotification()
|
||||
updateOtherPersonsInfo()
|
||||
initProximitySensor()
|
||||
|
||||
@ -134,13 +134,15 @@ class CallActivity : SimpleActivity() {
|
||||
|
||||
val statusTextId = when (state) {
|
||||
Call.STATE_RINGING -> R.string.is_calling
|
||||
Call.STATE_DIALING -> R.string.is_called
|
||||
Call.STATE_DIALING -> R.string.dialing
|
||||
else -> 0
|
||||
}
|
||||
|
||||
if (statusTextId != 0) {
|
||||
call_status_label.text = getString(statusTextId)
|
||||
}
|
||||
|
||||
setupNotification()
|
||||
}
|
||||
|
||||
private fun acceptCall() {
|
||||
@ -222,7 +224,7 @@ class CallActivity : SimpleActivity() {
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private fun showNotification() {
|
||||
private fun setupNotification() {
|
||||
val channelId = "simple_contacts_call"
|
||||
if (isOreoPlus()) {
|
||||
val importance = NotificationManager.IMPORTANCE_DEFAULT
|
||||
@ -246,11 +248,17 @@ class CallActivity : SimpleActivity() {
|
||||
val declinePendingIntent = PendingIntent.getBroadcast(this, 1, declineCallIntent, PendingIntent.FLAG_CANCEL_CURRENT)
|
||||
|
||||
val callerName = if (callContact != null && callContact!!.name.isNotEmpty()) callContact!!.name else getString(R.string.unknown_caller)
|
||||
val contentText = getString(R.string.incoming_call)
|
||||
val contentTextId = when (CallManager.getState()) {
|
||||
Call.STATE_RINGING -> R.string.is_calling
|
||||
Call.STATE_DIALING -> R.string.dialing
|
||||
Call.STATE_DISCONNECTED -> R.string.call_ended
|
||||
Call.STATE_DISCONNECTING -> R.string.call_ending
|
||||
else -> R.string.ongoing_call
|
||||
}
|
||||
|
||||
val collapsedView = RemoteViews(packageName, R.layout.call_notification).apply {
|
||||
setText(R.id.notification_caller_name, callerName)
|
||||
setText(R.id.notification_caller_number, contentText)
|
||||
setText(R.id.notification_caller_number, getString(contentTextId))
|
||||
|
||||
setOnClickPendingIntent(R.id.notification_decline_call, declinePendingIntent)
|
||||
setOnClickPendingIntent(R.id.notification_accept_call, acceptPendingIntent)
|
||||
|
@ -106,18 +106,18 @@
|
||||
<string name="calling">Calling</string>
|
||||
<string name="incoming_call">Incoming call</string>
|
||||
<string name="incoming_call_from">Incoming call from…</string>
|
||||
<string name="ongoing_call">Ongoing call</string>
|
||||
<string name="disconnected">Disconnected</string>
|
||||
<string name="decline_call">Decline</string>
|
||||
<string name="answer_call">Answer</string>
|
||||
|
||||
<string name="accept">Accept</string>
|
||||
<string name="decline">Decline</string>
|
||||
<string name="unknown_caller">Unknown caller</string>
|
||||
<string name="unknown_caller">Unknown Caller</string>
|
||||
<string name="is_calling">Is Calling</string>
|
||||
<string name="is_called">Is Called</string>
|
||||
<string name="dialing">Dialing</string>
|
||||
<string name="call_ended">Call Ended</string>
|
||||
<string name="call_ending">Call Ending</string>
|
||||
<string name="ongoing_call">Ongoing Call</string>
|
||||
|
||||
<!-- Speed dial -->
|
||||
<string name="speed_dial">Speed dial</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user