show the selected contacts at the top
This commit is contained in:
parent
1b3c6d9dac
commit
d15005bfd7
|
@ -7,6 +7,7 @@ import android.provider.ContactsContract.CommonDataKinds
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import android.view.inputmethod.EditorInfo
|
import android.view.inputmethod.EditorInfo
|
||||||
|
import com.simplemobiletools.commons.extensions.beVisible
|
||||||
import com.simplemobiletools.commons.extensions.getIntValue
|
import com.simplemobiletools.commons.extensions.getIntValue
|
||||||
import com.simplemobiletools.commons.extensions.getStringValue
|
import com.simplemobiletools.commons.extensions.getStringValue
|
||||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||||
|
@ -15,6 +16,7 @@ import com.simplemobiletools.smsmessenger.R
|
||||||
import com.simplemobiletools.smsmessenger.adapters.AutoCompleteTextViewAdapter
|
import com.simplemobiletools.smsmessenger.adapters.AutoCompleteTextViewAdapter
|
||||||
import com.simplemobiletools.smsmessenger.models.Contact
|
import com.simplemobiletools.smsmessenger.models.Contact
|
||||||
import kotlinx.android.synthetic.main.activity_new_message.*
|
import kotlinx.android.synthetic.main.activity_new_message.*
|
||||||
|
import kotlinx.android.synthetic.main.item_selected_contact.view.*
|
||||||
|
|
||||||
class NewMessageActivity : SimpleActivity() {
|
class NewMessageActivity : SimpleActivity() {
|
||||||
private var contacts = ArrayList<Contact>()
|
private var contacts = ArrayList<Contact>()
|
||||||
|
@ -63,7 +65,16 @@ class NewMessageActivity : SimpleActivity() {
|
||||||
new_message_to.setOnItemClickListener { parent, view, position, id ->
|
new_message_to.setOnItemClickListener { parent, view, position, id ->
|
||||||
val currContacts = (new_message_to.adapter as AutoCompleteTextViewAdapter).resultList
|
val currContacts = (new_message_to.adapter as AutoCompleteTextViewAdapter).resultList
|
||||||
val selectedContact = currContacts[position]
|
val selectedContact = currContacts[position]
|
||||||
selectedContacts.add(selectedContact)
|
addSelectedContact(selectedContact)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun addSelectedContact(contact: Contact) {
|
||||||
|
selectedContacts.add(contact)
|
||||||
|
selected_contacts.beVisible()
|
||||||
|
layoutInflater.inflate(R.layout.item_selected_contact, null).apply {
|
||||||
|
selected_contact_name.text = contact.name
|
||||||
|
selected_contacts.addView(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<size
|
||||||
|
android:width="@dimen/medium_margin"
|
||||||
|
android:height="0dp" />
|
||||||
|
</shape>
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
|
||||||
|
<corners android:radius="@dimen/normal_margin" />
|
||||||
|
|
||||||
|
<solid android:color="@color/activated_item_foreground" />
|
||||||
|
|
||||||
|
</shape>
|
|
@ -4,17 +4,29 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/selected_contacts"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="@dimen/activity_margin"
|
||||||
|
android:divider="@drawable/empty_divider"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:showDividers="middle"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyAutoCompleteTextView
|
<com.simplemobiletools.commons.views.MyAutoCompleteTextView
|
||||||
android:id="@+id/new_message_to"
|
android:id="@+id/new_message_to"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/normal_icon_size"
|
android:layout_height="@dimen/normal_icon_size"
|
||||||
|
android:layout_below="@+id/selected_contacts"
|
||||||
android:layout_marginStart="@dimen/activity_margin"
|
android:layout_marginStart="@dimen/activity_margin"
|
||||||
android:layout_marginEnd="@dimen/activity_margin"
|
android:layout_marginEnd="@dimen/activity_margin"
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
android:completionThreshold="2"
|
android:completionThreshold="2"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:hint="@string/send_to"
|
android:hint="@string/send_to"
|
||||||
android:inputType="textCapWords" />
|
android:inputType="textCapWords"
|
||||||
|
android:textSize="@dimen/big_text_size" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/message_divider"
|
android:id="@+id/message_divider"
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/selected_contact_holder"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/item_selected_contact_background">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/selected_contact_name"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="@dimen/normal_margin"
|
||||||
|
android:paddingTop="@dimen/normal_margin"
|
||||||
|
android:paddingBottom="@dimen/normal_margin"
|
||||||
|
android:textSize="@dimen/bigger_text_size"
|
||||||
|
tools:text="John" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/selected_contact_remove"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignTop="@+id/selected_contact_name"
|
||||||
|
android:layout_alignBottom="@id/selected_contact_name"
|
||||||
|
android:layout_toEndOf="@+id/selected_contact_name"
|
||||||
|
android:paddingStart="@dimen/medium_margin"
|
||||||
|
android:paddingEnd="@dimen/medium_margin"
|
||||||
|
android:src="@drawable/ic_cross_vector" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
Loading…
Reference in New Issue