Commit 8258a3bf by zhangchengbo

fix:解决通讯录回复发送失败问题

parent 57a78b72
...@@ -14,6 +14,7 @@ import android.media.RingtoneManager ...@@ -14,6 +14,7 @@ import android.media.RingtoneManager
import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat
import androidx.core.app.Person import androidx.core.app.Person
import androidx.core.app.RemoteInput import androidx.core.app.RemoteInput
import com.secspace.log.Log
import com.secspace.sms.R import com.secspace.sms.R
import com.secspace.sms.activities.ThreadActivity import com.secspace.sms.activities.ThreadActivity
import com.secspace.sms.extensions.config import com.secspace.sms.extensions.config
...@@ -48,7 +49,7 @@ class NotificationHelper(private val context: Context) { ...@@ -48,7 +49,7 @@ class NotificationHelper(private val context: Context) {
) { ) {
maybeCreateChannel(name = context.getString(R.string.channel_received_sms)) maybeCreateChannel(name = context.getString(R.string.channel_received_sms))
// Log.d("TAG", "showReceivedMessageNotification: messageId = $messageId address = $address body = $body threadId = $threadId sender = $sender normalNumber = $normalNumber") Log.d("TAG", "showReceivedMessageNotification: messageId = $messageId address = $address body = $body threadId = $threadId sender = $sender normalNumber = $normalNumber")
val notificationId = threadId.hashCode() val notificationId = threadId.hashCode()
val contentIntent = Intent(context, ThreadActivity::class.java).apply { val contentIntent = Intent(context, ThreadActivity::class.java).apply {
putExtra(THREAD_ID, threadId) putExtra(THREAD_ID, threadId)
...@@ -71,7 +72,7 @@ class NotificationHelper(private val context: Context) { ...@@ -71,7 +72,7 @@ class NotificationHelper(private val context: Context) {
PendingIntent.getBroadcast(context, notificationId, deleteSmsIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE) PendingIntent.getBroadcast(context, notificationId, deleteSmsIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE)
var replyAction: NotificationCompat.Action? = null var replyAction: NotificationCompat.Action? = null
// val isNoReplySms = isShortCodeWithLetters(address) val isNoReplySms = isShortCodeWithLetters(address)
if (isNougatPlus() /*&& !isNoReplySms*/) { if (isNougatPlus() /*&& !isNoReplySms*/) {
val replyLabel = context.getString(R.string.reply) val replyLabel = context.getString(R.string.reply)
val remoteInput = RemoteInput.Builder(REPLY) val remoteInput = RemoteInput.Builder(REPLY)
...@@ -81,7 +82,7 @@ class NotificationHelper(private val context: Context) { ...@@ -81,7 +82,7 @@ class NotificationHelper(private val context: Context) {
val replyIntent = Intent(context, DirectReplyReceiver::class.java).apply { val replyIntent = Intent(context, DirectReplyReceiver::class.java).apply {
putExtra(THREAD_ID, threadId) putExtra(THREAD_ID, threadId)
putExtra(THREAD_TITLE, address) putExtra(THREAD_TITLE, address)
if (address.contains("*")) { if (address.contains("*") || normalNumber.isNotEmpty()) {
putExtra(THREAD_NUMBER, normalNumber) putExtra(THREAD_NUMBER, normalNumber)
}else{ }else{
putExtra(THREAD_NUMBER, address) putExtra(THREAD_NUMBER, address)
...@@ -137,13 +138,14 @@ class NotificationHelper(private val context: Context) { ...@@ -137,13 +138,14 @@ class NotificationHelper(private val context: Context) {
builder.addAction(com.simplemobiletools.commons.R.drawable.ic_check_vector, context.getString(R.string.mark_as_read), markAsReadPendingIntent) builder.addAction(com.simplemobiletools.commons.R.drawable.ic_check_vector, context.getString(R.string.mark_as_read), markAsReadPendingIntent)
.setChannelId(NOTIFICATION_CHANNEL) .setChannelId(NOTIFICATION_CHANNEL)
// if (isNoReplySms) { /*Log.d("TAG", "showMessageNotification: isNoReplySms = $isNoReplySms")
if (isNoReplySms) {
builder.addAction( builder.addAction(
com.simplemobiletools.commons.R.drawable.ic_delete_vector, com.simplemobiletools.commons.R.drawable.ic_delete_vector,
context.getString(com.simplemobiletools.commons.R.string.delete), context.getString(com.simplemobiletools.commons.R.string.delete),
deleteSmsPendingIntent deleteSmsPendingIntent
).setChannelId(NOTIFICATION_CHANNEL) ).setChannelId(NOTIFICATION_CHANNEL)
// } }*/
notificationManager.notify(notificationId, builder.build()) notificationManager.notify(notificationId, builder.build())
} }
......
...@@ -249,7 +249,7 @@ class SmsReceiver : BroadcastReceiver() { ...@@ -249,7 +249,7 @@ class SmsReceiver : BroadcastReceiver() {
"handleMessage: notificationUserName = $notificationUserName 掩码号码 aesPhoneNumber = $aesPhoneNumber 正常号码 address = $address threadId = $threadId" "handleMessage: notificationUserName = $notificationUserName 掩码号码 aesPhoneNumber = $aesPhoneNumber 正常号码 address = $address threadId = $threadId"
) )
if (notificationUserName.isNotEmpty()) { if (notificationUserName.isNotEmpty()) {
context.showReceivedMessageNotification(newMessageId, notificationUserName, body, threadId, bitmap) context.showReceivedMessageNotification(newMessageId, notificationUserName, body, threadId, bitmap, normalNumber = address)
} else if (aesPhoneNumber.contains("*")) { } else if (aesPhoneNumber.contains("*")) {
Log.d(TAG, "handleMessage: 掩码号码") Log.d(TAG, "handleMessage: 掩码号码")
context.showReceivedMessageNotification(newMessageId, aesPhoneNumber, body, threadId, bitmap, normalNumber = address) context.showReceivedMessageNotification(newMessageId, aesPhoneNumber, body, threadId, bitmap, normalNumber = address)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment