moving some View Contact intent related things in Commons
This commit is contained in:
parent
080401bc37
commit
3bebf4445e
|
@ -57,7 +57,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:5.27.13'
|
||||
implementation 'com.simplemobiletools:commons:5.27.17'
|
||||
implementation 'joda-time:joda-time:2.10.1'
|
||||
implementation 'com.googlecode.ez-vcard:ez-vcard:0.10.5'
|
||||
implementation 'com.github.tibbi:IndicatorFastScroll:08f512858a'
|
||||
|
|
|
@ -16,6 +16,7 @@ import com.bumptech.glide.request.RequestOptions
|
|||
import com.bumptech.glide.request.target.Target
|
||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
import com.simplemobiletools.contacts.pro.R
|
||||
import com.simplemobiletools.contacts.pro.extensions.sendEmailIntent
|
||||
|
@ -30,8 +31,7 @@ abstract class ContactActivity : SimpleActivity() {
|
|||
protected var currentContactPhotoPath = ""
|
||||
|
||||
fun showPhotoPlaceholder(photoView: ImageView) {
|
||||
val placeholder = BitmapDrawable(resources, com.simplemobiletools.commons.helpers.ContactsHelper(this).getContactLetterIcon(contact?.getNameToDisplay()
|
||||
?: "A"))
|
||||
val placeholder = BitmapDrawable(resources, SimpleContactsHelper(this).getContactLetterIcon(contact?.getNameToDisplay() ?: "A"))
|
||||
photoView.setImageDrawable(placeholder)
|
||||
currentContactPhotoPath = ""
|
||||
contact?.photo = null
|
||||
|
|
|
@ -244,15 +244,8 @@ class ViewContactActivity : ContactActivity() {
|
|||
}
|
||||
|
||||
private fun openWith() {
|
||||
Intent().apply {
|
||||
action = ContactsContract.QuickContact.ACTION_QUICK_CONTACT
|
||||
data = getContactPublicUri(contact!!)
|
||||
if (resolveActivity(packageManager) != null) {
|
||||
startActivity(this)
|
||||
} else {
|
||||
toast(R.string.no_app_found)
|
||||
}
|
||||
}
|
||||
val uri = getContactPublicUri(contact!!)
|
||||
launchViewContactIntent(uri)
|
||||
}
|
||||
|
||||
private fun setupFavorite() {
|
||||
|
|
|
@ -19,6 +19,7 @@ import com.simplemobiletools.commons.extensions.beVisibleIf
|
|||
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
|
||||
import com.simplemobiletools.commons.extensions.getTextSize
|
||||
import com.simplemobiletools.commons.extensions.highlightTextPart
|
||||
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
import com.simplemobiletools.commons.views.FastScroller
|
||||
|
@ -299,7 +300,7 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
|
|||
findViewById<TextView>(R.id.item_contact_image).beVisibleIf(showContactThumbnails)
|
||||
|
||||
if (showContactThumbnails) {
|
||||
val placeholderImage = BitmapDrawable(resources, com.simplemobiletools.commons.helpers.ContactsHelper(context).getContactLetterIcon(fullName))
|
||||
val placeholderImage = BitmapDrawable(resources, SimpleContactsHelper(context).getContactLetterIcon(fullName))
|
||||
if (contact.photoUri.isEmpty() && contact.photo == null) {
|
||||
findViewById<ImageView>(R.id.item_contact_image).setImageDrawable(placeholderImage)
|
||||
} else {
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.simplemobiletools.commons.extensions.beVisibleIf
|
|||
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
|
||||
import com.simplemobiletools.commons.extensions.getTextSize
|
||||
import com.simplemobiletools.commons.extensions.highlightTextPart
|
||||
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.commons.views.FastScroller
|
||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||
|
@ -170,7 +171,7 @@ class GroupsAdapter(activity: SimpleActivity, var groups: ArrayList<Group>, val
|
|||
|
||||
group_tmb.beVisibleIf(showContactThumbnails)
|
||||
if (showContactThumbnails) {
|
||||
group_tmb.setImageDrawable(com.simplemobiletools.commons.helpers.ContactsHelper(activity).getColoredGroupIcon(group.title))
|
||||
group_tmb.setImageDrawable(SimpleContactsHelper(activity).getColoredGroupIcon(group.title))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import com.simplemobiletools.commons.extensions.beVisibleIf
|
|||
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
|
||||
import com.simplemobiletools.commons.extensions.getTextSize
|
||||
import com.simplemobiletools.commons.extensions.highlightTextPart
|
||||
import com.simplemobiletools.commons.helpers.ContactsHelper
|
||||
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
||||
import com.simplemobiletools.commons.views.FastScroller
|
||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||
import com.simplemobiletools.contacts.pro.R
|
||||
|
@ -150,7 +150,7 @@ class SelectContactsAdapter(val activity: SimpleActivity, var contacts: ArrayLis
|
|||
else -> contact.firstName
|
||||
}
|
||||
|
||||
val placeholderImage = BitmapDrawable(resources, ContactsHelper(context).getContactLetterIcon(avatarName))
|
||||
val placeholderImage = BitmapDrawable(resources, SimpleContactsHelper(context).getContactLetterIcon(avatarName))
|
||||
|
||||
if (contact.photoUri.isEmpty() && contact.photo == null) {
|
||||
contact_tmb.setImageDrawable(placeholderImage)
|
||||
|
|
|
@ -17,6 +17,7 @@ import com.simplemobiletools.commons.extensions.telecomManager
|
|||
import com.simplemobiletools.commons.extensions.toast
|
||||
import com.simplemobiletools.commons.helpers.PERMISSION_READ_CONTACTS
|
||||
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_CONTACTS
|
||||
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
||||
import com.simplemobiletools.contacts.pro.BuildConfig
|
||||
import com.simplemobiletools.contacts.pro.R
|
||||
import com.simplemobiletools.contacts.pro.activities.EditContactActivity
|
||||
|
@ -310,7 +311,7 @@ fun Context.getContactPublicUri(contact: Contact): Uri {
|
|||
val lookupKey = if (contact.isPrivate()) {
|
||||
"local_${contact.id}"
|
||||
} else {
|
||||
ContactsHelper(this).getContactLookupKey(contact.id.toString())
|
||||
SimpleContactsHelper(this).getContactLookupKey(contact.id.toString())
|
||||
}
|
||||
return Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, lookupKey)
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.content.Context
|
|||
import android.net.Uri
|
||||
import android.telecom.Call
|
||||
import android.telecom.VideoProfile
|
||||
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.contacts.pro.extensions.contactsDB
|
||||
import com.simplemobiletools.contacts.pro.models.CallContact
|
||||
|
@ -59,11 +60,10 @@ class CallManager {
|
|||
|
||||
val uri = Uri.decode(call!!.details.handle.toString())
|
||||
if (uri.startsWith("tel:")) {
|
||||
val contactsHelper = com.simplemobiletools.commons.helpers.ContactsHelper(context)
|
||||
val number = uri.substringAfter("tel:")
|
||||
callContact.number = number
|
||||
callContact.name = contactsHelper.getNameFromPhoneNumber(number)
|
||||
callContact.photoUri = contactsHelper.getPhotoUriFromPhoneNumber(number)
|
||||
callContact.name = SimpleContactsHelper(context).getNameFromPhoneNumber(number)
|
||||
callContact.photoUri = SimpleContactsHelper(context).getPhotoUriFromPhoneNumber(number)
|
||||
|
||||
if (callContact.name == callContact.number) {
|
||||
ensureBackgroundThread {
|
||||
|
|
|
@ -1351,24 +1351,6 @@ class ContactsHelper(val context: Context) {
|
|||
fileDescriptor.close()
|
||||
}
|
||||
|
||||
fun getContactLookupKey(contactId: String): String {
|
||||
val uri = Data.CONTENT_URI
|
||||
val projection = arrayOf(Data.CONTACT_ID, Data.LOOKUP_KEY)
|
||||
val selection = "${Data.MIMETYPE} = ? AND ${Data.RAW_CONTACT_ID} = ?"
|
||||
val selectionArgs = arrayOf(StructuredName.CONTENT_ITEM_TYPE, contactId)
|
||||
|
||||
val cursor = context.contentResolver.query(uri, projection, selection, selectionArgs, null)
|
||||
cursor?.use {
|
||||
if (cursor.moveToFirst()) {
|
||||
val id = cursor.getIntValue(Data.CONTACT_ID)
|
||||
val lookupKey = cursor.getStringValue(Data.LOOKUP_KEY)
|
||||
return "$lookupKey/$id"
|
||||
}
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
fun getContactMimeTypeId(contactId: String, mimeType: String): String {
|
||||
val uri = Data.CONTENT_URI
|
||||
val projection = arrayOf(Data._ID, Data.RAW_CONTACT_ID, Data.MIMETYPE)
|
||||
|
|
Loading…
Reference in New Issue