Update Context.kt

This commit is contained in:
Tibor Kaputa 2021-08-18 12:45:33 +02:00 committed by GitHub
parent b65a78394e
commit f68bc54771
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -710,13 +710,13 @@ fun Context.showMessageNotification(address: String, body: String, threadId: Lon
val largeIcon = bitmap ?: SimpleContactsHelper(this).getContactLetterIcon(sender) val largeIcon = bitmap ?: SimpleContactsHelper(this).getContactLetterIcon(sender)
val builder = NotificationCompat.Builder(this, NOTIFICATION_CHANNEL).apply { val builder = NotificationCompat.Builder(this, NOTIFICATION_CHANNEL).apply {
when (config.notificationSetting) { when (config.lockScreenVisibilitySetting) {
CONFIGURE_NAME_AND_MESSAGE -> { LOCK_SCREEN_SENDER_MESSAGE -> {
setContentTitle(sender) setContentTitle(sender)
setLargeIcon(largeIcon) setLargeIcon(largeIcon)
setContentText(body) setContentText(body)
} }
CONFIGURE_NAME -> { LOCK_SCREEN_SENDER -> {
setContentTitle(sender) setContentTitle(sender)
setLargeIcon(largeIcon) setLargeIcon(largeIcon)
} }
@ -733,7 +733,7 @@ fun Context.showMessageNotification(address: String, body: String, threadId: Lon
setSound(soundUri, AudioManager.STREAM_NOTIFICATION) setSound(soundUri, AudioManager.STREAM_NOTIFICATION)
} }
if (replyAction != null && config.notificationSetting == CONFIGURE_NAME_AND_MESSAGE) { if (replyAction != null && config.lockScreenVisibilitySetting == LOCK_SCREEN_SENDER_MESSAGE) {
builder.addAction(replyAction) builder.addAction(replyAction)
} }
@ -743,10 +743,10 @@ fun Context.showMessageNotification(address: String, body: String, threadId: Lon
notificationManager.notify(threadId.hashCode(), builder.build()) notificationManager.notify(threadId.hashCode(), builder.build())
} }
fun Context.getConfigurationText(type: Int) = getString( fun Context.getLockScreenVisibilityText(type: Int) = getString(
when (type) { when (type) {
CONFIGURE_NAME_AND_MESSAGE -> R.string.sender_and_message LOCK_SCREEN_SENDER_MESSAGE -> R.string.sender_and_message
CONFIGURE_NAME -> R.string.sender_only LOCK_SCREEN_SENDER -> R.string.sender_only
else -> R.string.nothing else -> R.string.nothing
} }
) )