From 08b9637fa334c8ef18fd8695c6e0e6ff4946b15c Mon Sep 17 00:00:00 2001 From: lunaticbum <> Date: Wed, 11 Sep 2024 18:45:58 +0900 Subject: [PATCH] //// --- .../rasel/lunar/launcher/home/LauncherHome.kt | 2 +- .../rasel/lunar/launcher/todos/SmsLogsAdapter.kt | 2 +- .../lunar/launcher/workers/RecentSmsGetter.kt | 14 ++++++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/rasel/lunar/launcher/home/LauncherHome.kt b/app/src/main/kotlin/rasel/lunar/launcher/home/LauncherHome.kt index 79163cfd..f382259a 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/home/LauncherHome.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/home/LauncherHome.kt @@ -591,7 +591,7 @@ internal class LauncherHome : Fragment() { binding.infoList.visibility = View.INVISIBLE binding.notiList.visibility = View.INVISIBLE - var dateParam = beforeDay(Date(),7).toString() + var dateParam = beforeDay(Date(),30).toString() if (binding.missedCalls.isSelected) { WorkersDb.getRealm().apply { val result = query().query("callDayTime >= $0", dateParam).sort("callDayTime", Sort.DESCENDING).find() diff --git a/app/src/main/kotlin/rasel/lunar/launcher/todos/SmsLogsAdapter.kt b/app/src/main/kotlin/rasel/lunar/launcher/todos/SmsLogsAdapter.kt index dba485fc..65d002c4 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/todos/SmsLogsAdapter.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/todos/SmsLogsAdapter.kt @@ -61,7 +61,7 @@ internal class SmsLogsAdapter( getContactName(lActivity!!.contentResolver,todo.addr) } if(todo.isMms) { - var body = todo.mmsContents.get("text")?.joinToString("\n")?.replace("\n"," ") + var body = todo.texts?.joinToString("\n")?.replace("\n"," ") body = if (body?.length ?: 0 > 60) body?.substring(0,60).plus("...") else body holder.view.itemText.text = "\u25CF ${if(name != null && name.length > 0) name else if(todo.person != null && todo.person.length > 0){todo.person} else todo.addr} : ${ SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format( diff --git a/app/src/main/kotlin/rasel/lunar/launcher/workers/RecentSmsGetter.kt b/app/src/main/kotlin/rasel/lunar/launcher/workers/RecentSmsGetter.kt index 8e2e2efa..c7a72f31 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/workers/RecentSmsGetter.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/workers/RecentSmsGetter.kt @@ -114,6 +114,8 @@ class RecentSmsGetter : BaseGetter { internal class RecentSms : RealmObject { @PrimaryKey + var uniqKey : String = "" + var id : String = "" var isMms : Boolean = false var addr : String = "" @@ -138,6 +140,7 @@ internal class RecentSms : RealmObject { body: String, person: String ) { + this.uniqKey = id.plus(addr.plus("_").plus(Math.max(rcvDate,pstDate)).plus("_SMS")) this.addr = addr this.type = type this.rcvDate = rcvDate @@ -149,6 +152,7 @@ internal class RecentSms : RealmObject { constructor(id: String, sender: String, date: Long, body: HashMap>) { this.id = id + this.uniqKey = body.get("partId")!!.joinToString { "_" }.plus(sender.plus("_").plus(date).plus("_MMS")).plus(this.texts.joinToString("").length) this.rcvDate = date this.mmsContents = body this.images.addAll(mmsContents.get("image")!!) @@ -256,7 +260,6 @@ internal class MmsQueryHelper( val text = arrayListOf() val image = arrayListOf() val audio = arrayListOf() - val projection = arrayOf("*") val video = arrayListOf() _contentResolver.query( @@ -315,6 +318,7 @@ internal class MmsQueryHelper( } while (partsCursor.moveToNext()) } } + returns.put("partId", arrayListOf(id.toString())) returns.put("text", text) returns.put("image", image) returns.put("audio", audio) @@ -335,11 +339,17 @@ internal class MmsQueryHelper( data?.let { if (it?.pstDate ?: 0L > dateTime || it?.rcvDate ?: 0L > dateTime) { WorkersDb.getRealm().apply { - if (query("id == $0", it.id).find().size == 0) { + if (query("uniqKey == $0", it.uniqKey).find().size == 0) { writeBlocking { copyToRealm(it) } } +// else if (it.isMms && it.addr.contains("#CMAS#")){ +// writeBlocking { +// it.uniqKey = it.uniqKey.plus("1") +// copyToRealm(it) +// } +// } } // smsList.add(it) }