....
This commit is contained in:
parent
7b9dab0891
commit
384881bf07
@ -71,8 +71,6 @@ import androidx.lifecycle.LiveData
|
|||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.viewpager2.widget.ViewPager2
|
import androidx.viewpager2.widget.ViewPager2
|
||||||
import androidx.window.layout.FoldingFeature
|
|
||||||
import androidx.window.layout.WindowLayoutInfo
|
|
||||||
import androidx.work.ExistingPeriodicWorkPolicy
|
import androidx.work.ExistingPeriodicWorkPolicy
|
||||||
import androidx.work.PeriodicWorkRequestBuilder
|
import androidx.work.PeriodicWorkRequestBuilder
|
||||||
import androidx.work.WorkManager
|
import androidx.work.WorkManager
|
||||||
|
|||||||
@ -144,8 +144,7 @@ internal class LauncherHome : Fragment() {
|
|||||||
val commandHandler = Handler(Looper.getMainLooper())
|
val commandHandler = Handler(Looper.getMainLooper())
|
||||||
|
|
||||||
val smsUpdate = Runnable {
|
val smsUpdate = Runnable {
|
||||||
BLog.LOGE("observeForever smsList.size >>> ${smsList.size}")
|
|
||||||
binding.recentSms.text = "최근 문자 [${smsList.size}]"
|
|
||||||
chooseAdpater()
|
chooseAdpater()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -606,41 +605,40 @@ internal class LauncherHome : Fragment() {
|
|||||||
binding.notice.isSelected = false
|
binding.notice.isSelected = false
|
||||||
}
|
}
|
||||||
} else if(binding.recentSms.isSelected){
|
} else if(binding.recentSms.isSelected){
|
||||||
if (smsList.size > 0) {
|
WorkersDb.getRealm().apply {
|
||||||
|
val result = query<RecentSms>().query("rcvDate >= $0 OR pstDate >= $0 ", dateParam)
|
||||||
|
.sort(Pair("pstDate",Sort.DESCENDING),Pair("rcvDate", Sort.DESCENDING)).find()
|
||||||
|
if (result.size > 0) {
|
||||||
try {
|
try {
|
||||||
smsList.sortByDescending { it.rcvDate }
|
BLog.LOGE("observeForever smsList.size >>> ${result.size}")
|
||||||
binding.smsList.visibility = View.VISIBLE
|
binding.recentSms.text = "최근 문자 [${result.size}]"
|
||||||
// Handler(Looper.getMainLooper()).post {
|
|
||||||
binding.smsList.visibility = View.VISIBLE
|
binding.smsList.visibility = View.VISIBLE
|
||||||
|
smsList.clear()
|
||||||
|
smsList.addAll(copyFromRealm(result))
|
||||||
mSmsLogsAdapter.updateData(smsList)
|
mSmsLogsAdapter.updateData(smsList)
|
||||||
binding.missedCalls.isSelected = false
|
binding.missedCalls.isSelected = false
|
||||||
binding.otherCheck.isSelected = false
|
binding.otherCheck.isSelected = false
|
||||||
binding.notice.isSelected = false
|
binding.notice.isSelected = false
|
||||||
// }
|
} catch (e: Exception) {
|
||||||
} catch (e : Exception) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if(binding.otherCheck.isSelected) {
|
} else if(binding.otherCheck.isSelected) {
|
||||||
// Handler(Looper.getMainLooper()).post {
|
|
||||||
binding.missedCalls.isSelected = false
|
binding.missedCalls.isSelected = false
|
||||||
binding.recentSms.isSelected = false
|
binding.recentSms.isSelected = false
|
||||||
binding.notice.isSelected = false
|
binding.notice.isSelected = false
|
||||||
binding.infoList.visibility = View.VISIBLE
|
binding.infoList.visibility = View.VISIBLE
|
||||||
binding.otherCheck.text = "최근 정보[${lasted?.size ?: "-"}]"
|
binding.otherCheck.text = "최근 정보[${lasted?.size ?: "-"}]"
|
||||||
lasted?.let { mRssAdapter.updateData(it) }
|
lasted?.let { mRssAdapter.updateData(it) }
|
||||||
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
else if(binding.notice.isSelected) {
|
else if(binding.notice.isSelected) {
|
||||||
// Handler(Looper.getMainLooper()).post {
|
|
||||||
binding.missedCalls.isSelected = false
|
binding.missedCalls.isSelected = false
|
||||||
binding.recentSms.isSelected = false
|
binding.recentSms.isSelected = false
|
||||||
binding.otherCheck.isSelected = false
|
binding.otherCheck.isSelected = false
|
||||||
binding.notiList.visibility = View.VISIBLE
|
binding.notiList.visibility = View.VISIBLE
|
||||||
binding.notice.text = "알림 센터[${lastedNoti?.size ?: "-"}]"
|
binding.notice.text = "알림 센터[${lastedNoti?.size ?: "-"}]"
|
||||||
lastedNoti?.let { mNotiAdapter.updateData(it)}
|
lastedNoti?.let { mNotiAdapter.updateData(it)}
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
commandHandler.postDelayed(hideListView, UPDATE_DELAY * 5)
|
commandHandler.postDelayed(hideListView, UPDATE_DELAY * 5)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,12 @@ import android.net.Uri
|
|||||||
import android.provider.Telephony
|
import android.provider.Telephony
|
||||||
import androidx.work.WorkerParameters
|
import androidx.work.WorkerParameters
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
|
import io.realm.kotlin.ext.query
|
||||||
|
import io.realm.kotlin.ext.realmListOf
|
||||||
|
import io.realm.kotlin.types.RealmList
|
||||||
|
import io.realm.kotlin.types.RealmObject
|
||||||
|
import io.realm.kotlin.types.annotations.Ignore
|
||||||
|
import io.realm.kotlin.types.annotations.PrimaryKey
|
||||||
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
|
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
|
||||||
import rasel.lunar.launcher.home.LauncherHome.Companion.smsList
|
import rasel.lunar.launcher.home.LauncherHome.Companion.smsList
|
||||||
import rasel.lunar.launcher.utils.BLog
|
import rasel.lunar.launcher.utils.BLog
|
||||||
@ -30,7 +36,7 @@ class RecentSmsGetter : BaseGetter {
|
|||||||
|
|
||||||
@SuppressLint("RestrictedApi")
|
@SuppressLint("RestrictedApi")
|
||||||
override fun realWork(): Result {
|
override fun realWork(): Result {
|
||||||
var dateParam = beforeDay(Date(),7).toString()
|
var dateParam = beforeDay(Date(),30).toString()
|
||||||
val managedCursor = lActivity?.contentResolver?.query(
|
val managedCursor = lActivity?.contentResolver?.query(
|
||||||
Telephony.Sms.CONTENT_URI, arrayOf(
|
Telephony.Sms.CONTENT_URI, arrayOf(
|
||||||
Telephony.Sms.THREAD_ID,
|
Telephony.Sms.THREAD_ID,
|
||||||
@ -83,7 +89,13 @@ class RecentSmsGetter : BaseGetter {
|
|||||||
log.isMms = false
|
log.isMms = false
|
||||||
// BLog.LOGE("RecentSmsGetter resultData put ${phNumber +"_"+ reciveDate} >>> ${log.toJson()}")
|
// BLog.LOGE("RecentSmsGetter resultData put ${phNumber +"_"+ reciveDate} >>> ${log.toJson()}")
|
||||||
log.sender = getContactName(applicationContext.contentResolver,phNumber) ?: ""
|
log.sender = getContactName(applicationContext.contentResolver,phNumber) ?: ""
|
||||||
smsList.add(log)
|
WorkersDb.getRealm().apply {
|
||||||
|
if (query<RecentSms>("id == $0", id).find().size == 0) {
|
||||||
|
writeBlocking {
|
||||||
|
copyToRealm(log)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@ -100,7 +112,8 @@ class RecentSmsGetter : BaseGetter {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class RecentSms {
|
internal class RecentSms : RealmObject {
|
||||||
|
@PrimaryKey
|
||||||
var id : String = ""
|
var id : String = ""
|
||||||
var isMms : Boolean = false
|
var isMms : Boolean = false
|
||||||
var addr : String = ""
|
var addr : String = ""
|
||||||
@ -109,6 +122,11 @@ internal class RecentSms {
|
|||||||
var pstDate : Long = 0L
|
var pstDate : Long = 0L
|
||||||
var body : String = ""
|
var body : String = ""
|
||||||
var person : String = ""
|
var person : String = ""
|
||||||
|
var images : RealmList<String> = realmListOf()
|
||||||
|
var videos : RealmList<String> = realmListOf()
|
||||||
|
var audios : RealmList<String> = realmListOf()
|
||||||
|
var texts : RealmList<String> = realmListOf()
|
||||||
|
@Ignore
|
||||||
var mmsContents : HashMap<String?,ArrayList<String>> = hashMapOf()
|
var mmsContents : HashMap<String?,ArrayList<String>> = hashMapOf()
|
||||||
var sender : String = ""
|
var sender : String = ""
|
||||||
|
|
||||||
@ -133,10 +151,16 @@ internal class RecentSms {
|
|||||||
this.id = id
|
this.id = id
|
||||||
this.rcvDate = date
|
this.rcvDate = date
|
||||||
this.mmsContents = body
|
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.addr = sender
|
||||||
this.isMms = true
|
this.isMms = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constructor()
|
||||||
|
|
||||||
fun toJson() : String {
|
fun toJson() : String {
|
||||||
return Gson().toJson(this)
|
return Gson().toJson(this)
|
||||||
}
|
}
|
||||||
@ -301,7 +325,7 @@ internal class MmsQueryHelper(
|
|||||||
|
|
||||||
fun convertData(cursor: Cursor?) {
|
fun convertData(cursor: Cursor?) {
|
||||||
cursor ?: return
|
cursor ?: return
|
||||||
val dateTime = beforeDay(Date(),7)
|
val dateTime = beforeDay(Date(),30)
|
||||||
cursor.use {
|
cursor.use {
|
||||||
if (cursor.moveToFirst()) {
|
if (cursor.moveToFirst()) {
|
||||||
do {
|
do {
|
||||||
@ -310,7 +334,14 @@ internal class MmsQueryHelper(
|
|||||||
}.getOrNull()
|
}.getOrNull()
|
||||||
data?.let {
|
data?.let {
|
||||||
if (it?.pstDate ?: 0L > dateTime || it?.rcvDate ?: 0L > dateTime) {
|
if (it?.pstDate ?: 0L > dateTime || it?.rcvDate ?: 0L > dateTime) {
|
||||||
smsList.add(it)
|
WorkersDb.getRealm().apply {
|
||||||
|
if (query<RecentSms>("id == $0", it.id).find().size == 0) {
|
||||||
|
writeBlocking {
|
||||||
|
copyToRealm(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// smsList.add(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (cursor.moveToNext())
|
} while (cursor.moveToNext())
|
||||||
|
|||||||
@ -17,7 +17,7 @@ import kotlin.reflect.KClass
|
|||||||
|
|
||||||
object WorkersDb {
|
object WorkersDb {
|
||||||
|
|
||||||
val clazz : Set<KClass<out BaseRealmObject>> = setOf(RssData::class, NotificationItem::class, AppInfo::class,SimpleContact::class, RecentCall::class)
|
val clazz : Set<KClass<out BaseRealmObject>> = setOf(RssData::class, NotificationItem::class, AppInfo::class,SimpleContact::class, RecentCall::class, RecentSms::class)
|
||||||
val schemaVersion : Long = 0L
|
val schemaVersion : Long = 0L
|
||||||
|
|
||||||
private var pRealm : Realm? = null
|
private var pRealm : Realm? = null
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user