store the subscription ID at incoming messages too
This commit is contained in:
parent
34eb659a7d
commit
6fb8d963a8
|
@ -56,7 +56,7 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:5.27.24'
|
implementation 'com.simplemobiletools:commons:5.27.27'
|
||||||
implementation 'org.greenrobot:eventbus:3.2.0'
|
implementation 'org.greenrobot:eventbus:3.2.0'
|
||||||
implementation 'com.klinkerapps:android-smsmms:5.2.6'
|
implementation 'com.klinkerapps:android-smsmms:5.2.6'
|
||||||
implementation 'com.github.tibbi:IndicatorFastScroll:08f512858a'
|
implementation 'com.github.tibbi:IndicatorFastScroll:08f512858a'
|
||||||
|
|
|
@ -39,7 +39,8 @@ fun Context.getMessages(threadId: Int): ArrayList<Message> {
|
||||||
Sms.ADDRESS,
|
Sms.ADDRESS,
|
||||||
Sms.DATE,
|
Sms.DATE,
|
||||||
Sms.READ,
|
Sms.READ,
|
||||||
Sms.THREAD_ID
|
Sms.THREAD_ID,
|
||||||
|
Sms.SUBSCRIPTION_ID
|
||||||
)
|
)
|
||||||
|
|
||||||
val selection = "${Sms.THREAD_ID} = ?"
|
val selection = "${Sms.THREAD_ID} = ?"
|
||||||
|
@ -415,7 +416,7 @@ fun Context.getNameAndPhotoFromPhoneNumber(number: String): NamePhoto? {
|
||||||
return NamePhoto(number, null)
|
return NamePhoto(number, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.insertNewSMS(address: String, subject: String, body: String, date: Long, read: Int, threadId: Long, type: Int) {
|
fun Context.insertNewSMS(address: String, subject: String, body: String, date: Long, read: Int, threadId: Long, type: Int, subscriptionId: Int) {
|
||||||
val uri = Sms.CONTENT_URI
|
val uri = Sms.CONTENT_URI
|
||||||
val contentValues = ContentValues().apply {
|
val contentValues = ContentValues().apply {
|
||||||
put(Sms.ADDRESS, address)
|
put(Sms.ADDRESS, address)
|
||||||
|
@ -425,6 +426,7 @@ fun Context.insertNewSMS(address: String, subject: String, body: String, date: L
|
||||||
put(Sms.READ, read)
|
put(Sms.READ, read)
|
||||||
put(Sms.THREAD_ID, threadId)
|
put(Sms.THREAD_ID, threadId)
|
||||||
put(Sms.TYPE, type)
|
put(Sms.TYPE, type)
|
||||||
|
put(Sms.SUBSCRIPTION_ID, subscriptionId)
|
||||||
}
|
}
|
||||||
|
|
||||||
contentResolver.insert(uri, contentValues)
|
contentResolver.insert(uri, contentValues)
|
||||||
|
|
|
@ -20,6 +20,7 @@ class SmsReceiver : BroadcastReceiver() {
|
||||||
var threadId = 0L
|
var threadId = 0L
|
||||||
val type = Telephony.Sms.MESSAGE_TYPE_INBOX
|
val type = Telephony.Sms.MESSAGE_TYPE_INBOX
|
||||||
val read = 0
|
val read = 0
|
||||||
|
val subscriptionId = intent.getIntExtra("subscription", -1)
|
||||||
|
|
||||||
messages.forEach {
|
messages.forEach {
|
||||||
address = it.originatingAddress ?: ""
|
address = it.originatingAddress ?: ""
|
||||||
|
@ -30,7 +31,7 @@ class SmsReceiver : BroadcastReceiver() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!context.isNumberBlocked(address)) {
|
if (!context.isNumberBlocked(address)) {
|
||||||
context.insertNewSMS(address, subject, body, date, read, threadId, type)
|
context.insertNewSMS(address, subject, body, date, read, threadId, type, subscriptionId)
|
||||||
context.showReceivedMessageNotification(address, body, threadId.toInt())
|
context.showReceivedMessageNotification(address, body, threadId.toInt())
|
||||||
refreshMessages()
|
refreshMessages()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue