This commit is contained in:
lunaticbum 2024-09-12 13:48:41 +09:00
parent 08b9637fa3
commit 3a5f60f17d

View File

@ -78,6 +78,7 @@ class RecentSmsGetter : BaseGetter {
Telephony.Sms.MESSAGE_TYPE_QUEUED -> {dir = "MESSAGE_TYPE_QUEUED"}
}
var log = RecentSms(
id.plus("_").plus(reciveDate).plus("_").plus(sendedDate),
phNumber,
dir,
reciveDate,
@ -85,12 +86,11 @@ class RecentSmsGetter : BaseGetter {
smsBody,
callerName ?: ""
)
log.id = id
log.isMms = false
// BLog.LOGE("RecentSmsGetter resultData put ${phNumber +"_"+ reciveDate} >>> ${log.toJson()}")
log.sender = getContactName(applicationContext.contentResolver,phNumber) ?: ""
WorkersDb.getRealm().apply {
if (query<RecentSms>("id == $0", id).find().size == 0) {
if (query<RecentSms>("uniqKey == $0", log.uniqKey).find().size == 0) {
writeBlocking {
copyToRealm(log)
}
@ -133,6 +133,7 @@ internal class RecentSms : RealmObject {
var sender : String = ""
constructor(
id : String,
addr: String,
type: String,
rcvDate: Long,
@ -140,7 +141,9 @@ internal class RecentSms : RealmObject {
body: String,
person: String
) {
this.uniqKey = id.plus(addr.plus("_").plus(Math.max(rcvDate,pstDate)).plus("_SMS"))
this.id = id
this.uniqKey = id.plus("_").plus(addr).plus("_").plus(Math.max(rcvDate,pstDate)).plus("_SMS")
BLog.LOGE("sender ${sender} ::::: Id >> ${id} , addr ${addr}")
this.addr = addr
this.type = type
this.rcvDate = rcvDate
@ -152,13 +155,16 @@ internal class RecentSms : RealmObject {
constructor(id: String, sender: String, date: Long, body: HashMap<String?,ArrayList<String>>) {
this.id = id
this.uniqKey = body.get("partId")!!.joinToString { "_" }.plus(sender.plus("_").plus(date).plus("_MMS")).plus(this.texts.joinToString("").length)
this.uniqKey = body.get("partId")!!.joinToString("_").plus(sender.plus("_").plus(date).plus("_MMS"))
// BLog.LOGE("sender ${sender} ::::: partId >> ${body.get("partId")!!.joinToString("_")}")
this.rcvDate = date
this.mmsContents = body
this.images.addAll(mmsContents.get("image")!!)
this.audios.addAll(mmsContents.get("audio")!!)
this.texts.addAll(mmsContents.get("text")!!)
this.videos.addAll(mmsContents.get("video")!!)
this.addr = sender
this.isMms = true
}
@ -260,6 +266,8 @@ internal class MmsQueryHelper(
val text = arrayListOf<String>()
val image = arrayListOf<String>()
val audio = arrayListOf<String>()
val partsIds = arrayListOf<String>()
partsIds.add(id.toString())
val projection = arrayOf("*")
val video = arrayListOf<String>()
_contentResolver.query(
@ -276,7 +284,7 @@ internal class MmsQueryHelper(
val partContentType =
partsCursor.getString(partsCursor.getColumnIndexOrThrow(Telephony.Mms.Part.CONTENT_TYPE))
// BLog.LOGE("partContentType >> ${partContentType}")
partsIds.add(partId.toString())
if(partContentType?.contains("text") == true) {
// BLog.LOGE("partContentType text >> ${partContentType} :: ${partId}")
val data =
@ -318,7 +326,7 @@ internal class MmsQueryHelper(
} while (partsCursor.moveToNext())
}
}
returns.put("partId", arrayListOf(id.toString()))
returns.put("partId", partsIds)
returns.put("text", text)
returns.put("image", image)
returns.put("audio", audio)