mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-06-05 21:49:23 +02:00
show which SIM was used at the Recents tab
This commit is contained in:
@ -7,6 +7,7 @@ import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.PERMISSION_READ_CALL_LOG
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.commons.overloads.times
|
||||
import com.simplemobiletools.dialer.extensions.getAvailableSIMCardLabels
|
||||
import com.simplemobiletools.dialer.models.RecentCall
|
||||
|
||||
class RecentsHelper(private val context: Context) {
|
||||
@ -27,13 +28,19 @@ class RecentsHelper(private val context: Context) {
|
||||
Calls.CACHED_PHOTO_URI,
|
||||
Calls.DATE,
|
||||
Calls.DURATION,
|
||||
Calls.TYPE
|
||||
Calls.TYPE,
|
||||
"phone_account_address"
|
||||
)
|
||||
|
||||
val numberToSimIDMap = HashMap<String, Int>()
|
||||
context.getAvailableSIMCardLabels().forEach {
|
||||
numberToSimIDMap[it.phoneNumber] = it.id
|
||||
}
|
||||
|
||||
val sortOrder = "${Calls._ID} DESC LIMIT 100"
|
||||
|
||||
var previousRecentCallFrom = ""
|
||||
context.queryCursor(uri, projection, sortOrder = sortOrder) { cursor ->
|
||||
context.queryCursor(uri, projection, sortOrder = sortOrder, showErrors = true) { cursor ->
|
||||
val id = cursor.getIntValue(Calls._ID)
|
||||
val number = cursor.getStringValue(Calls.NUMBER)
|
||||
val name = cursor.getStringValue(Calls.CACHED_NAME) ?: number
|
||||
@ -41,8 +48,10 @@ class RecentsHelper(private val context: Context) {
|
||||
val startTS = (cursor.getLongValue(Calls.DATE) / 1000L).toInt()
|
||||
val duration = cursor.getIntValue(Calls.DURATION)
|
||||
val type = cursor.getIntValue(Calls.TYPE)
|
||||
val accountAddress = cursor.getStringValue("phone_account_address")
|
||||
val simID = numberToSimIDMap[accountAddress] ?: 1
|
||||
val neighbourIDs = ArrayList<Int>()
|
||||
val recentCall = RecentCall(id, number, name, photoUri, startTS, duration, type, neighbourIDs)
|
||||
val recentCall = RecentCall(id, number, name, photoUri, startTS, duration, type, neighbourIDs, simID)
|
||||
|
||||
// if we have 3 missed calls from the same number, show it just once
|
||||
if ("$number$name" != previousRecentCallFrom) {
|
||||
|
Reference in New Issue
Block a user