handle clicks at contact suggestions

This commit is contained in:
tibbi
2020-04-12 11:01:08 +02:00
parent 827be7225b
commit 8263327f70
2 changed files with 9 additions and 6 deletions

View File

@@ -66,14 +66,14 @@ class NewMessageActivity : SimpleActivity() {
new_message_confirm.applyColorFilter(config.textColor) new_message_confirm.applyColorFilter(config.textColor)
new_message_confirm.setOnClickListener { new_message_confirm.setOnClickListener {
val number = new_message_to.value val number = new_message_to.value
launchThreadActivity(number, number, "") launchThreadActivity(number, number)
} }
} }
private fun isThirdPartyIntent(): Boolean { private fun isThirdPartyIntent(): Boolean {
if (intent.action == Intent.ACTION_SENDTO && intent.dataString != null) { if (intent.action == Intent.ACTION_SENDTO && intent.dataString != null) {
val number = intent.dataString!!.removePrefix("sms:").removePrefix("smsto:").removePrefix("mms").removePrefix("mmsto:").trim() val number = intent.dataString!!.removePrefix("sms:").removePrefix("smsto:").removePrefix("mms").removePrefix("mmsto:").trim()
launchThreadActivity(number, "", "") launchThreadActivity(number, "")
return true return true
} }
return false return false
@@ -82,9 +82,7 @@ class NewMessageActivity : SimpleActivity() {
private fun setupAdapter(contacts: ArrayList<Contact>) { private fun setupAdapter(contacts: ArrayList<Contact>) {
ContactsAdapter(this, contacts, contacts_list, null) { ContactsAdapter(this, contacts, contacts_list, null) {
hideKeyboard() hideKeyboard()
launchThreadActivity((it as Contact).phoneNumber, it.name)
val text = intent.getStringExtra(Intent.EXTRA_TEXT) ?: ""
launchThreadActivity((it as Contact).phoneNumber, it.name, text)
}.apply { }.apply {
contacts_list.adapter = this contacts_list.adapter = this
} }
@@ -105,6 +103,9 @@ class NewMessageActivity : SimpleActivity() {
suggested_contact_name.text = contact.name suggested_contact_name.text = contact.name
loadImage(contact.photoUri, suggested_contact_image, contact.name) loadImage(contact.photoUri, suggested_contact_image, contact.name)
suggestions_holder.addView(this) suggestions_holder.addView(this)
setOnClickListener {
launchThreadActivity(contact.phoneNumber, contact.name)
}
} }
} }
} }
@@ -113,7 +114,8 @@ class NewMessageActivity : SimpleActivity() {
} }
} }
private fun launchThreadActivity(phoneNumber: String, name: String, text: String) { private fun launchThreadActivity(phoneNumber: String, name: String) {
val text = intent.getStringExtra(Intent.EXTRA_TEXT) ?: ""
Intent(this, ThreadActivity::class.java).apply { Intent(this, ThreadActivity::class.java).apply {
putExtra(THREAD_ID, getThreadId(phoneNumber).toInt()) putExtra(THREAD_ID, getThreadId(phoneNumber).toInt())
putExtra(THREAD_TITLE, name) putExtra(THREAD_TITLE, name)

View File

@@ -3,6 +3,7 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/suggested_contact_holder" android:id="@+id/suggested_contact_holder"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:background="?selectableItemBackground"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<ImageView <ImageView