Merge branch 'master' into fix_108
This commit is contained in:
commit
88213f1c39
79 changed files with 1317 additions and 238 deletions
|
|
@ -488,7 +488,6 @@ fun Context.getNameAndPhotoFromPhoneNumber(number: String): NamePhoto {
|
|||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
showErrorToast(e)
|
||||
}
|
||||
|
||||
return NamePhoto(number, null)
|
||||
|
|
@ -507,8 +506,12 @@ fun Context.insertNewSMS(address: String, subject: String, body: String, date: L
|
|||
put(Sms.SUBSCRIPTION_ID, subscriptionId)
|
||||
}
|
||||
|
||||
val newUri = contentResolver.insert(uri, contentValues)
|
||||
return newUri?.lastPathSegment?.toLong() ?: 0L
|
||||
return try {
|
||||
val newUri = contentResolver.insert(uri, contentValues)
|
||||
newUri?.lastPathSegment?.toLong() ?: 0L
|
||||
} catch (e: Exception) {
|
||||
0L
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.deleteConversation(threadId: Long) {
|
||||
|
|
@ -633,7 +636,7 @@ fun Context.getThreadId(addresses: Set<String>): Long {
|
|||
}
|
||||
|
||||
fun Context.showReceivedMessageNotification(address: String, body: String, threadId: Long, bitmap: Bitmap?) {
|
||||
val privateCursor = getMyContactsCursor()?.loadInBackground()
|
||||
val privateCursor = getMyContactsCursor(false, true)?.loadInBackground()
|
||||
ensureBackgroundThread {
|
||||
val senderName = getNameFromAddress(address, privateCursor)
|
||||
|
||||
|
|
@ -709,37 +712,41 @@ fun Context.showMessageNotification(address: String, body: String, threadId: Lon
|
|||
val builder = NotificationCompat.Builder(this, NOTIFICATION_CHANNEL).apply {
|
||||
when (config.notificationSetting) {
|
||||
CONFIGURE_NAME_AND_MESSAGE -> {
|
||||
this.setContentTitle(sender)
|
||||
this.setLargeIcon(largeIcon)
|
||||
this.setContentText(body)
|
||||
setContentTitle(sender)
|
||||
setLargeIcon(largeIcon)
|
||||
setContentText(body)
|
||||
}
|
||||
CONFIGURE_NAME -> {
|
||||
this.setContentTitle(sender)
|
||||
this.setLargeIcon(largeIcon)
|
||||
setContentTitle(sender)
|
||||
setLargeIcon(largeIcon)
|
||||
}
|
||||
}
|
||||
this.color = config.primaryColor
|
||||
this.setSmallIcon(R.drawable.ic_messenger)
|
||||
this.setStyle(NotificationCompat.BigTextStyle().setSummaryText(summaryText).bigText(body))
|
||||
this.setContentIntent(pendingIntent)
|
||||
this.priority = NotificationCompat.PRIORITY_MAX
|
||||
this.setDefaults(Notification.DEFAULT_LIGHTS)
|
||||
this.setCategory(Notification.CATEGORY_MESSAGE)
|
||||
this.setAutoCancel(true)
|
||||
this.setSound(soundUri, AudioManager.STREAM_NOTIFICATION)
|
||||
|
||||
color = getAdjustedPrimaryColor()
|
||||
setSmallIcon(R.drawable.ic_messenger)
|
||||
setStyle(NotificationCompat.BigTextStyle().setSummaryText(summaryText).bigText(body))
|
||||
setContentIntent(pendingIntent)
|
||||
priority = NotificationCompat.PRIORITY_MAX
|
||||
setDefaults(Notification.DEFAULT_LIGHTS)
|
||||
setCategory(Notification.CATEGORY_MESSAGE)
|
||||
setAutoCancel(true)
|
||||
setSound(soundUri, AudioManager.STREAM_NOTIFICATION)
|
||||
}
|
||||
|
||||
if (replyAction != null && config.notificationSetting == CONFIGURE_NAME_AND_MESSAGE) {
|
||||
builder.addAction(replyAction)
|
||||
}
|
||||
|
||||
builder.addAction(R.drawable.ic_check_vector, getString(R.string.mark_as_read), markAsReadPendingIntent)
|
||||
.setChannelId(NOTIFICATION_CHANNEL)
|
||||
|
||||
notificationManager.notify(threadId.hashCode(), builder.build())
|
||||
}
|
||||
|
||||
fun Context.getConfigurationText(type: Int) = getString(when (type) {
|
||||
CONFIGURE_NAME_AND_MESSAGE -> R.string.configure_name_and_message
|
||||
CONFIGURE_NAME -> R.string.configure_name
|
||||
else -> R.string.configure_no_details
|
||||
})
|
||||
fun Context.getConfigurationText(type: Int) = getString(
|
||||
when (type) {
|
||||
CONFIGURE_NAME_AND_MESSAGE -> R.string.sender_and_message
|
||||
CONFIGURE_NAME -> R.string.sender_only
|
||||
else -> R.string.nothing
|
||||
}
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue