Prevent crash if person name wasn't found when creating a call notification on Android 31+
This commit is contained in:
parent
f24f3f2c85
commit
b4fd0ec5f4
1 changed files with 18 additions and 16 deletions
|
@ -164,22 +164,24 @@ class Api31Compatibility {
|
||||||
|
|
||||||
val builder = Notification.Builder(
|
val builder = Notification.Builder(
|
||||||
context, channel
|
context, channel
|
||||||
)
|
).apply {
|
||||||
.setStyle(
|
try {
|
||||||
Notification.CallStyle.forOngoingCall(caller, declineIntent).setIsVideo(isVideo)
|
style = Notification.CallStyle.forOngoingCall(caller, declineIntent)
|
||||||
)
|
.setIsVideo(isVideo)
|
||||||
.setSmallIcon(iconResourceId)
|
} catch (ise: IllegalStateException) {
|
||||||
.setAutoCancel(false)
|
Log.e("[Api31 Compatibility] Can't use notification call style: $ise")
|
||||||
.setCategory(Notification.CATEGORY_CALL)
|
}
|
||||||
.setVisibility(Notification.VISIBILITY_PUBLIC)
|
setSmallIcon(iconResourceId)
|
||||||
.setWhen(System.currentTimeMillis())
|
setAutoCancel(false)
|
||||||
.setShowWhen(true)
|
setCategory(Notification.CATEGORY_CALL)
|
||||||
.setOngoing(true)
|
setVisibility(Notification.VISIBILITY_PUBLIC)
|
||||||
.setColor(ContextCompat.getColor(context, R.color.notification_led_color))
|
setWhen(System.currentTimeMillis())
|
||||||
.setFullScreenIntent(
|
setShowWhen(true)
|
||||||
pendingIntent,
|
setOngoing(true)
|
||||||
true
|
setColor(ContextCompat.getColor(context, R.color.notification_led_color))
|
||||||
) // This is required for CallStyle notification
|
// This is required for CallStyle notification
|
||||||
|
setFullScreenIntent(pendingIntent, true)
|
||||||
|
}
|
||||||
|
|
||||||
if (!corePreferences.preventInterfaceFromShowingUp) {
|
if (!corePreferences.preventInterfaceFromShowingUp) {
|
||||||
builder.setContentIntent(pendingIntent)
|
builder.setContentIntent(pendingIntent)
|
||||||
|
|
Loading…
Reference in a new issue