mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-02-21 05:50:41 +01:00
fix #59, properly fetch contact photos at Recents tab
This commit is contained in:
parent
5b339eec5b
commit
eabbf41ab7
@ -3,10 +3,8 @@ package com.simplemobiletools.dialer.helpers
|
|||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.ContentResolver
|
import android.content.ContentResolver
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Build
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.provider.CallLog.Calls
|
import android.provider.CallLog.Calls
|
||||||
import androidx.annotation.RequiresApi
|
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.commons.models.SimpleContact
|
import com.simplemobiletools.commons.models.SimpleContact
|
||||||
@ -44,6 +42,8 @@ class RecentsHelper(private val context: Context) {
|
|||||||
var previousRecentCallFrom = ""
|
var previousRecentCallFrom = ""
|
||||||
var previousStartTS = 0
|
var previousStartTS = 0
|
||||||
val contactsNumbersMap = HashMap<String, String>()
|
val contactsNumbersMap = HashMap<String, String>()
|
||||||
|
val contactPhotosMap = HashMap<String, String>()
|
||||||
|
|
||||||
val uri = Calls.CONTENT_URI
|
val uri = Calls.CONTENT_URI
|
||||||
val projection = arrayOf(
|
val projection = arrayOf(
|
||||||
Calls._ID,
|
Calls._ID,
|
||||||
@ -107,7 +107,19 @@ class RecentsHelper(private val context: Context) {
|
|||||||
name = context.getString(R.string.unknown)
|
name = context.getString(R.string.unknown)
|
||||||
}
|
}
|
||||||
|
|
||||||
val photoUri = cursor.getStringValue(Calls.CACHED_PHOTO_URI) ?: ""
|
var photoUri = cursor.getStringValue(Calls.CACHED_PHOTO_URI) ?: ""
|
||||||
|
if (photoUri.isEmpty()) {
|
||||||
|
if (contactPhotosMap.containsKey(number)) {
|
||||||
|
photoUri = contactPhotosMap[number]!!
|
||||||
|
} else {
|
||||||
|
val contact = contacts.firstOrNull { it.doesContainPhoneNumber(number) }
|
||||||
|
if (contact != null) {
|
||||||
|
photoUri = contact.photoUri
|
||||||
|
contactPhotosMap[number] = contact.photoUri
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val startTS = (cursor.getLongValue(Calls.DATE) / 1000L).toInt()
|
val startTS = (cursor.getLongValue(Calls.DATE) / 1000L).toInt()
|
||||||
if (previousStartTS == startTS) {
|
if (previousStartTS == startTS) {
|
||||||
continue
|
continue
|
||||||
|
Loading…
x
Reference in New Issue
Block a user