mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
show correct status at the call notification too
This commit is contained in:
@ -54,7 +54,7 @@ class CallActivity : SimpleActivity() {
|
|||||||
callContact = CallManager.getCallContact(applicationContext)
|
callContact = CallManager.getCallContact(applicationContext)
|
||||||
callContactAvatar = getCallContactAvatar()
|
callContactAvatar = getCallContactAvatar()
|
||||||
addLockScreenFlags()
|
addLockScreenFlags()
|
||||||
showNotification()
|
setupNotification()
|
||||||
updateOtherPersonsInfo()
|
updateOtherPersonsInfo()
|
||||||
initProximitySensor()
|
initProximitySensor()
|
||||||
|
|
||||||
@ -134,13 +134,15 @@ class CallActivity : SimpleActivity() {
|
|||||||
|
|
||||||
val statusTextId = when (state) {
|
val statusTextId = when (state) {
|
||||||
Call.STATE_RINGING -> R.string.is_calling
|
Call.STATE_RINGING -> R.string.is_calling
|
||||||
Call.STATE_DIALING -> R.string.is_called
|
Call.STATE_DIALING -> R.string.dialing
|
||||||
else -> 0
|
else -> 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if (statusTextId != 0) {
|
if (statusTextId != 0) {
|
||||||
call_status_label.text = getString(statusTextId)
|
call_status_label.text = getString(statusTextId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setupNotification()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun acceptCall() {
|
private fun acceptCall() {
|
||||||
@ -222,7 +224,7 @@ class CallActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
private fun showNotification() {
|
private fun setupNotification() {
|
||||||
val channelId = "simple_contacts_call"
|
val channelId = "simple_contacts_call"
|
||||||
if (isOreoPlus()) {
|
if (isOreoPlus()) {
|
||||||
val importance = NotificationManager.IMPORTANCE_DEFAULT
|
val importance = NotificationManager.IMPORTANCE_DEFAULT
|
||||||
@ -246,11 +248,17 @@ class CallActivity : SimpleActivity() {
|
|||||||
val declinePendingIntent = PendingIntent.getBroadcast(this, 1, declineCallIntent, PendingIntent.FLAG_CANCEL_CURRENT)
|
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 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 {
|
val collapsedView = RemoteViews(packageName, R.layout.call_notification).apply {
|
||||||
setText(R.id.notification_caller_name, callerName)
|
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_decline_call, declinePendingIntent)
|
||||||
setOnClickPendingIntent(R.id.notification_accept_call, acceptPendingIntent)
|
setOnClickPendingIntent(R.id.notification_accept_call, acceptPendingIntent)
|
||||||
|
@ -106,18 +106,18 @@
|
|||||||
<string name="calling">Calling</string>
|
<string name="calling">Calling</string>
|
||||||
<string name="incoming_call">Incoming call</string>
|
<string name="incoming_call">Incoming call</string>
|
||||||
<string name="incoming_call_from">Incoming call from…</string>
|
<string name="incoming_call_from">Incoming call from…</string>
|
||||||
<string name="ongoing_call">Ongoing call</string>
|
|
||||||
<string name="disconnected">Disconnected</string>
|
<string name="disconnected">Disconnected</string>
|
||||||
<string name="decline_call">Decline</string>
|
<string name="decline_call">Decline</string>
|
||||||
<string name="answer_call">Answer</string>
|
<string name="answer_call">Answer</string>
|
||||||
|
|
||||||
<string name="accept">Accept</string>
|
<string name="accept">Accept</string>
|
||||||
<string name="decline">Decline</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_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_ended">Call Ended</string>
|
||||||
<string name="call_ending">Call Ending</string>
|
<string name="call_ending">Call Ending</string>
|
||||||
|
<string name="ongoing_call">Ongoing Call</string>
|
||||||
|
|
||||||
<!-- Speed dial -->
|
<!-- Speed dial -->
|
||||||
<string name="speed_dial">Speed dial</string>
|
<string name="speed_dial">Speed dial</string>
|
||||||
|
Reference in New Issue
Block a user