renaming the helper class ContactsHelper to SimpleContactsHelper
This commit is contained in:
parent
9c5255701b
commit
f1edebb2dc
|
@ -56,7 +56,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:5.27.13'
|
||||
implementation 'com.simplemobiletools:commons:5.27.18'
|
||||
implementation 'org.greenrobot:eventbus:3.2.0'
|
||||
implementation 'com.klinkerapps:android-smsmms:5.2.6'
|
||||
implementation 'com.github.tibbi:IndicatorFastScroll:08f512858a'
|
||||
|
|
|
@ -7,8 +7,8 @@ import android.view.Menu
|
|||
import android.view.WindowManager
|
||||
import com.reddit.indicatorfastscroll.FastScrollItemIndicator
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.ContactsHelper
|
||||
import com.simplemobiletools.commons.helpers.PERMISSION_READ_CONTACTS
|
||||
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.commons.models.SimpleContact
|
||||
import com.simplemobiletools.smsmessenger.R
|
||||
|
@ -103,7 +103,7 @@ class NewConversationActivity : SimpleActivity() {
|
|||
|
||||
private fun fetchContacts() {
|
||||
fillSuggestedContacts {
|
||||
ContactsHelper(this).getAvailableContacts {
|
||||
SimpleContactsHelper(this).getAvailableContacts {
|
||||
allContacts = it
|
||||
|
||||
runOnUiThread {
|
||||
|
@ -149,7 +149,7 @@ class NewConversationActivity : SimpleActivity() {
|
|||
val contact = it
|
||||
layoutInflater.inflate(R.layout.item_suggested_contact, null).apply {
|
||||
suggested_contact_name.text = contact.name
|
||||
ContactsHelper(this@NewConversationActivity).loadContactImage(contact.photoUri, suggested_contact_image, contact.name)
|
||||
SimpleContactsHelper(this@NewConversationActivity).loadContactImage(contact.photoUri, suggested_contact_image, contact.name)
|
||||
suggestions_holder.addView(this)
|
||||
setOnClickListener {
|
||||
launchThreadActivity(contact.phoneNumber, contact.name)
|
||||
|
|
|
@ -30,8 +30,8 @@ import com.klinker.android.send_message.Settings
|
|||
import com.klinker.android.send_message.Transaction
|
||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.ContactsHelper
|
||||
import com.simplemobiletools.commons.helpers.PERMISSION_READ_PHONE_STATE
|
||||
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.commons.helpers.isNougatPlus
|
||||
import com.simplemobiletools.commons.models.SimpleContact
|
||||
|
@ -106,7 +106,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
return@ensureBackgroundThread
|
||||
}
|
||||
|
||||
val contact = SimpleContact(0, name, "", number)
|
||||
val contact = SimpleContact(0, 0, name, "", number)
|
||||
participants.add(contact)
|
||||
}
|
||||
|
||||
|
@ -202,7 +202,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
thread_messages_list.adapter = adapter
|
||||
}
|
||||
|
||||
ContactsHelper(this).getAvailableContacts {
|
||||
SimpleContactsHelper(this).getAvailableContacts {
|
||||
runOnUiThread {
|
||||
val adapter = AutoCompleteTextViewAdapter(this, it)
|
||||
add_contact_or_number.setAdapter(adapter)
|
||||
|
@ -221,7 +221,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
|
||||
confirm_inserted_number.setOnClickListener {
|
||||
val number = add_contact_or_number.value
|
||||
val contact = SimpleContact(number.hashCode(), number, "", number)
|
||||
val contact = SimpleContact(number.hashCode(), number.hashCode(), number, "", number)
|
||||
addSelectedContact(contact)
|
||||
}
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
if (availableSIMs.size > 1) {
|
||||
availableSIMs.forEachIndexed { index, subscriptionInfo ->
|
||||
var label = subscriptionInfo.displayName.toString()
|
||||
if (subscriptionInfo.number.isNotEmpty()) {
|
||||
if (subscriptionInfo.number?.isNotEmpty() == true) {
|
||||
label += " (${subscriptionInfo.number})"
|
||||
}
|
||||
val SIMCard = SIMCard(index + 1, subscriptionInfo.subscriptionId, label)
|
||||
|
@ -350,8 +350,8 @@ class ThreadActivity : SimpleActivity() {
|
|||
layoutInflater.inflate(R.layout.item_selected_contact, null).apply {
|
||||
selected_contact_name.text = contact.name
|
||||
selected_contact_remove.setOnClickListener {
|
||||
if (contact.id != participants.first().id) {
|
||||
removeSelectedContact(contact.id)
|
||||
if (contact.rawId != participants.first().rawId) {
|
||||
removeSelectedContact(contact.rawId)
|
||||
}
|
||||
}
|
||||
views.add(this)
|
||||
|
@ -362,7 +362,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
|
||||
private fun addSelectedContact(contact: SimpleContact) {
|
||||
add_contact_or_number.setText("")
|
||||
if (participants.map { it.id }.contains(contact.id)) {
|
||||
if (participants.map { it.rawId }.contains(contact.rawId)) {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -557,7 +557,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun removeSelectedContact(id: Int) {
|
||||
participants = participants.filter { it.id != id }.toMutableList() as ArrayList<SimpleContact>
|
||||
participants = participants.filter { it.rawId != id }.toMutableList() as ArrayList<SimpleContact>
|
||||
showSelectedContacts()
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import android.widget.ArrayAdapter
|
|||
import android.widget.Filter
|
||||
import android.widget.TextView
|
||||
import com.simplemobiletools.commons.extensions.normalizeString
|
||||
import com.simplemobiletools.commons.helpers.ContactsHelper
|
||||
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
||||
import com.simplemobiletools.commons.models.SimpleContact
|
||||
import com.simplemobiletools.smsmessenger.R
|
||||
import com.simplemobiletools.smsmessenger.activities.SimpleActivity
|
||||
|
@ -28,7 +28,7 @@ class AutoCompleteTextViewAdapter(val activity: SimpleActivity, val contacts: Ar
|
|||
findViewById<TextView>(R.id.item_contact_name).text = contact.name
|
||||
findViewById<TextView>(R.id.item_contact_number).text = contact.phoneNumber
|
||||
|
||||
ContactsHelper(context).loadContactImage(contact.photoUri, findViewById(R.id.item_contact_image), contact.name)
|
||||
SimpleContactsHelper(context).loadContactImage(contact.photoUri, findViewById(R.id.item_contact_image), contact.name)
|
||||
}
|
||||
|
||||
return listItem
|
||||
|
|
|
@ -7,7 +7,7 @@ import android.widget.ImageView
|
|||
import android.widget.TextView
|
||||
import com.bumptech.glide.Glide
|
||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||
import com.simplemobiletools.commons.helpers.ContactsHelper
|
||||
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
||||
import com.simplemobiletools.commons.models.SimpleContact
|
||||
import com.simplemobiletools.commons.views.FastScroller
|
||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||
|
@ -28,9 +28,9 @@ class ContactsAdapter(activity: SimpleActivity, var contacts: ArrayList<SimpleCo
|
|||
|
||||
override fun getIsItemSelectable(position: Int) = true
|
||||
|
||||
override fun getItemSelectionKey(position: Int) = contacts.getOrNull(position)?.id
|
||||
override fun getItemSelectionKey(position: Int) = contacts.getOrNull(position)?.rawId
|
||||
|
||||
override fun getItemKeyPosition(key: Int) = contacts.indexOfFirst { it.id == key }
|
||||
override fun getItemKeyPosition(key: Int) = contacts.indexOfFirst { it.rawId == key }
|
||||
|
||||
override fun onActionModeCreated() {}
|
||||
|
||||
|
@ -63,7 +63,7 @@ class ContactsAdapter(activity: SimpleActivity, var contacts: ArrayList<SimpleCo
|
|||
findViewById<TextView>(R.id.item_contact_number).text = contact.phoneNumber
|
||||
findViewById<TextView>(R.id.item_contact_number).setTextColor(textColor)
|
||||
|
||||
ContactsHelper(context).loadContactImage(contact.photoUri, findViewById(R.id.item_contact_image), contact.name)
|
||||
SimpleContactsHelper(context).loadContactImage(contact.photoUri, findViewById(R.id.item_contact_image), contact.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import com.bumptech.glide.Glide
|
|||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||
import com.simplemobiletools.commons.extensions.formatDateOrTime
|
||||
import com.simplemobiletools.commons.helpers.ContactsHelper
|
||||
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.commons.views.FastScroller
|
||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||
|
@ -136,12 +136,12 @@ class ConversationsAdapter(activity: SimpleActivity, var conversations: ArrayLis
|
|||
|
||||
// at group conversations we use an icon as the placeholder, not any letter
|
||||
val placeholder = if (conversation.isGroupConversation) {
|
||||
ContactsHelper(context).getColoredGroupIcon(conversation.title)
|
||||
SimpleContactsHelper(context).getColoredGroupIcon(conversation.title)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
ContactsHelper(context).loadContactImage(conversation.photoUri, conversation_image, conversation.title, placeholder)
|
||||
SimpleContactsHelper(context).loadContactImage(conversation.photoUri, conversation_image, conversation.title, placeholder)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import com.bumptech.glide.request.target.Target
|
|||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.ContactsHelper
|
||||
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.commons.views.FastScroller
|
||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||
|
@ -182,7 +182,7 @@ class ThreadAdapter(activity: SimpleActivity, var messages: ArrayList<ThreadItem
|
|||
if (message.isReceivedMessage()) {
|
||||
thread_message_sender_photo.beVisible()
|
||||
thread_message_body.setTextColor(textColor)
|
||||
ContactsHelper(context).loadContactImage(message.senderPhotoUri, thread_message_sender_photo, message.senderName)
|
||||
SimpleContactsHelper(context).loadContactImage(message.senderPhotoUri, thread_message_sender_photo, message.senderName)
|
||||
} else {
|
||||
thread_message_sender_photo?.beGone()
|
||||
val background = context.getAdjustedPrimaryColor()
|
||||
|
|
|
@ -62,7 +62,7 @@ fun Context.getMessages(threadId: Int): ArrayList<Message> {
|
|||
val date = (cursor.getLongValue(Sms.DATE) / 1000).toInt()
|
||||
val read = cursor.getIntValue(Sms.READ) == 1
|
||||
val thread = cursor.getIntValue(Sms.THREAD_ID)
|
||||
val participant = SimpleContact(0, senderName, photoUri, senderNumber)
|
||||
val participant = SimpleContact(0, 0, senderName, photoUri, senderNumber)
|
||||
val isMMS = false
|
||||
val message = Message(id, body, type, arrayListOf(participant), date, read, thread, isMMS, null, senderName, photoUri)
|
||||
messages.add(message)
|
||||
|
@ -126,7 +126,7 @@ fun Context.getMMS(threadId: Int? = null, sortOrder: String? = null): ArrayList<
|
|||
messages.add(message)
|
||||
|
||||
participants.forEach {
|
||||
contactsMap.put(it.id, it)
|
||||
contactsMap.put(it.rawId, it)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ fun Context.getConversations(): ArrayList<Conversation> {
|
|||
|
||||
val names = getThreadContactNames(phoneNumbers)
|
||||
val title = TextUtils.join(", ", names.toTypedArray())
|
||||
val photoUri = if (phoneNumbers.size == 1) ContactsHelper(this).getPhotoUriFromPhoneNumber(phoneNumbers.first()) else ""
|
||||
val photoUri = if (phoneNumbers.size == 1) SimpleContactsHelper(this).getPhotoUriFromPhoneNumber(phoneNumbers.first()) else ""
|
||||
val isGroupConversation = phoneNumbers.size > 1
|
||||
val conversation = Conversation(id, snippet, date.toInt(), read, title, photoUri, isGroupConversation)
|
||||
conversations.add(conversation)
|
||||
|
@ -293,7 +293,7 @@ fun Context.getThreadParticipants(threadId: Int, contactsMap: HashMap<Int, Simpl
|
|||
val namePhoto = getNameAndPhotoFromPhoneNumber(phoneNumber)
|
||||
val name = namePhoto?.name ?: ""
|
||||
val photoUri = namePhoto?.photoUri ?: ""
|
||||
val contact = SimpleContact(addressId, name, photoUri, phoneNumber)
|
||||
val contact = SimpleContact(addressId, addressId, name, photoUri, phoneNumber)
|
||||
participants.add(contact)
|
||||
}
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ fun Context.getThreadPhoneNumbers(recipientIds: List<Int>): ArrayList<String> {
|
|||
fun Context.getThreadContactNames(phoneNumbers: List<String>): ArrayList<String> {
|
||||
val names = ArrayList<String>()
|
||||
phoneNumbers.forEach {
|
||||
names.add(ContactsHelper(this).getNameFromPhoneNumber(it))
|
||||
names.add(SimpleContactsHelper(this).getNameFromPhoneNumber(it))
|
||||
}
|
||||
return names
|
||||
}
|
||||
|
@ -361,7 +361,7 @@ fun Context.getSuggestedContacts(): ArrayList<SimpleContact> {
|
|||
|
||||
val senderName = namePhoto.name
|
||||
val photoUri = namePhoto.photoUri ?: ""
|
||||
val contact = SimpleContact(0, senderName, photoUri, senderNumber)
|
||||
val contact = SimpleContact(0, 0, senderName, photoUri, senderNumber)
|
||||
if (!contacts.map { it.phoneNumber.trimToComparableNumber() }.contains(senderNumber.trimToComparableNumber())) {
|
||||
contacts.add(contact)
|
||||
}
|
||||
|
@ -499,7 +499,7 @@ fun Context.showReceivedMessageNotification(address: String, body: String, threa
|
|||
val summaryText = getString(R.string.new_message)
|
||||
val sender = getNameAndPhotoFromPhoneNumber(address)?.name ?: ""
|
||||
|
||||
val largeIcon = bitmap ?: ContactsHelper(this).getContactLetterIcon(sender)
|
||||
val largeIcon = bitmap ?: SimpleContactsHelper(this).getContactLetterIcon(sender)
|
||||
val builder = NotificationCompat.Builder(this, channelId)
|
||||
.setContentTitle(sender)
|
||||
.setContentText(body)
|
||||
|
|
Loading…
Reference in New Issue