Sort the call history before restoring, so that it is saved in the right order

This commit is contained in:
merkost
2023-07-01 12:04:07 +10:00
parent ec57e45770
commit 7f2fa6cf7e

View File

@ -226,15 +226,17 @@ class RecentsHelper(private val context: Context) {
activity.handlePermission(PERMISSION_WRITE_CALL_LOG) {
if (it) {
ensureBackgroundThread {
val values = objects.map {
ContentValues().apply {
put(Calls.NUMBER, it.phoneNumber)
put(Calls.TYPE, it.type)
put(Calls.DATE, it.startTS.toLong() * 1000L)
put(Calls.DURATION, it.duration)
put(Calls.CACHED_NAME, it.name)
}
}.toTypedArray()
val values = objects
.sortedBy { it.startTS }
.map {
ContentValues().apply {
put(Calls.NUMBER, it.phoneNumber)
put(Calls.TYPE, it.type)
put(Calls.DATE, it.startTS.toLong() * 1000L)
put(Calls.DURATION, it.duration)
put(Calls.CACHED_NAME, it.name)
}
}.toTypedArray()
context.contentResolver.bulkInsert(contentUri, values)