* perf: improve lazy loading and remove spinner * perf: optimize message loading by caching and reducing queries * docs: update changelog * style: use constant for cache size * refactor: minor consistency improvement * fix: override loaded preview size * refactor: streamline message loading logic in scroll listener * refactor: organize some dedup related code * build: bump detekt return count limit 2 is 2 low * fix: check contacts permissions before registering observer * fix: disable fetching media resolutions in threads * refactor: remove resolution fetching related code * perf: cache MMS thread participants * refactor: remove unused BitmapFactory import * fix: invalidate participants cache when necessary * fix: return copied participants from cache * fix: adjust image loading dimensions in threads * fix: use stable ids for header items * fix: always rely on database check before flipping `allMessagesFetched`
38 lines
1.2 KiB
Kotlin
38 lines
1.2 KiB
Kotlin
package org.fossify.messages
|
|
|
|
import android.database.ContentObserver
|
|
import android.net.Uri
|
|
import android.os.Handler
|
|
import android.os.Looper
|
|
import android.provider.ContactsContract
|
|
import org.fossify.commons.FossifyApp
|
|
import org.fossify.commons.extensions.hasPermission
|
|
import org.fossify.commons.helpers.PERMISSION_READ_CONTACTS
|
|
import org.fossify.messages.helpers.MessagingCache
|
|
|
|
class App : FossifyApp() {
|
|
override val isAppLockFeatureAvailable = true
|
|
|
|
override fun onCreate() {
|
|
super.onCreate()
|
|
if (hasPermission(PERMISSION_READ_CONTACTS)) {
|
|
listOf(
|
|
ContactsContract.Contacts.CONTENT_URI,
|
|
ContactsContract.Data.CONTENT_URI,
|
|
ContactsContract.DisplayPhoto.CONTENT_URI
|
|
).forEach {
|
|
try {
|
|
contentResolver.registerContentObserver(it, true, contactsObserver)
|
|
} catch (_: Exception){
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private val contactsObserver = object : ContentObserver(Handler(Looper.getMainLooper())) {
|
|
override fun onChange(selfChange: Boolean, uri: Uri?) {
|
|
MessagingCache.namePhoto.evictAll()
|
|
MessagingCache.participantsCache.evictAll()
|
|
}
|
|
}
|
|
}
|