Merge branch 'master' into feature/downsize-big-images

This commit is contained in:
Tibor Kaputa 2022-02-03 10:07:24 +01:00 committed by GitHub
commit d39dea0f78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 89 additions and 72 deletions

View file

@ -10,6 +10,7 @@ import android.media.MediaMetadataRetriever
import android.net.Uri
import android.os.Bundle
import android.os.Handler
import android.provider.ContactsContract
import android.provider.Telephony
import android.telephony.SubscriptionManager
import android.text.TextUtils
@ -231,6 +232,8 @@ class ThreadActivity : SimpleActivity() {
private fun setupThread() {
val privateCursor = getMyContactsCursor(false, true)?.loadInBackground()
ensureBackgroundThread {
privateContacts = MyContactsContentProvider.getSimpleContacts(this, privateCursor)
val cachedMessagesCode = messages.clone().hashCode()
messages = getMessages(threadId)
@ -240,6 +243,7 @@ class ThreadActivity : SimpleActivity() {
try {
if (participants.isNotEmpty() && messages.hashCode() == cachedMessagesCode && !hasParticipantWithoutName) {
setupAdapter()
return@ensureBackgroundThread
}
} catch (ignored: Exception) {
@ -248,7 +252,6 @@ class ThreadActivity : SimpleActivity() {
setupParticipants()
// check if no participant came from a privately stored contact in Simple Contacts
privateContacts = MyContactsContentProvider.getSimpleContacts(this, privateCursor)
if (privateContacts.isNotEmpty()) {
val senderNumbersToReplace = HashMap<String, String>()
participants.filter { it.doesHavePhoneNumber(it.name) }.forEach { participant ->
@ -903,6 +906,31 @@ class ThreadActivity : SimpleActivity() {
return participants
}
fun startContactDetailsIntent(contact: SimpleContact) {
val simpleContacts = "com.simplemobiletools.contacts.pro"
val simpleContactsDebug = "com.simplemobiletools.contacts.pro.debug"
if (contact.rawId > 1000000 && contact.contactId > 1000000 && contact.rawId == contact.contactId &&
(isPackageInstalled(simpleContacts) || isPackageInstalled(simpleContactsDebug))
) {
Intent().apply {
action = Intent.ACTION_VIEW
putExtra(CONTACT_ID, contact.rawId)
putExtra(IS_PRIVATE, true)
`package` = if (isPackageInstalled(simpleContacts)) simpleContacts else simpleContactsDebug
setDataAndType(ContactsContract.Contacts.CONTENT_LOOKUP_URI, "vnd.android.cursor.dir/person")
launchActivityIntent(this)
}
} else {
ensureBackgroundThread {
val lookupKey = SimpleContactsHelper(this).getContactLookupKey((contact).rawId.toString())
val publicUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, lookupKey)
runOnUiThread {
launchViewContactIntent(publicUri)
}
}
}
}
fun saveMMS(mimeType: String, path: String) {
lastAttachmentUri = path
Intent(Intent.ACTION_CREATE_DOCUMENT).apply {