mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-06-05 21:49:23 +02:00
Sort the call history before restoring, so that it is saved in the right order
This commit is contained in:
@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user