show the filtered contacts on a list above dialpad
This commit is contained in:
parent
2aadd93fa6
commit
6718fb9a20
|
@ -9,9 +9,12 @@ import com.simplemobiletools.commons.extensions.applyColorFilter
|
||||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||||
import com.simplemobiletools.commons.helpers.isLollipopPlus
|
import com.simplemobiletools.commons.helpers.isLollipopPlus
|
||||||
import com.simplemobiletools.contacts.R
|
import com.simplemobiletools.contacts.R
|
||||||
|
import com.simplemobiletools.contacts.adapters.ContactsAdapter
|
||||||
import com.simplemobiletools.contacts.extensions.afterTextChanged
|
import com.simplemobiletools.contacts.extensions.afterTextChanged
|
||||||
import com.simplemobiletools.contacts.extensions.config
|
import com.simplemobiletools.contacts.extensions.config
|
||||||
|
import com.simplemobiletools.contacts.extensions.contactClicked
|
||||||
import com.simplemobiletools.contacts.helpers.ContactsHelper
|
import com.simplemobiletools.contacts.helpers.ContactsHelper
|
||||||
|
import com.simplemobiletools.contacts.helpers.LOCATION_DIALPAD
|
||||||
import com.simplemobiletools.contacts.helpers.PHONE_NUMBER_PATTERN
|
import com.simplemobiletools.contacts.helpers.PHONE_NUMBER_PATTERN
|
||||||
import com.simplemobiletools.contacts.models.Contact
|
import com.simplemobiletools.contacts.models.Contact
|
||||||
import kotlinx.android.synthetic.main.activity_dialpad.*
|
import kotlinx.android.synthetic.main.activity_dialpad.*
|
||||||
|
@ -95,8 +98,21 @@ class DialpadActivity : SimpleActivity() {
|
||||||
private fun dialpadValueChanged(text: String) {
|
private fun dialpadValueChanged(text: String) {
|
||||||
val numericOnly = text.replace(PHONE_NUMBER_PATTERN.toRegex(), "")
|
val numericOnly = text.replace(PHONE_NUMBER_PATTERN.toRegex(), "")
|
||||||
val filtered = contacts.filter {
|
val filtered = contacts.filter {
|
||||||
it.phoneNumbers.any { it.value.contains(text) || it.value.contains(numericOnly) } ||
|
it.phoneNumbers.any { (text.isNotEmpty() && it.value.contains(text)) || (numericOnly.isNotEmpty() && it.value.contains(numericOnly)) } ||
|
||||||
it.cleanPhoneNumbers.any { it.value.contains(text) || it.value.contains(numericOnly) }
|
it.cleanPhoneNumbers.any { (text.isNotEmpty() && it.value.contains(text)) || (numericOnly.isNotEmpty() && it.value.contains(numericOnly)) }
|
||||||
|
} as ArrayList<Contact>
|
||||||
|
|
||||||
|
ContactsAdapter(this, filtered, null, LOCATION_DIALPAD, null, dialpad_list, dialpad_fastscroller) {
|
||||||
|
contactClicked(it as Contact)
|
||||||
|
}.apply {
|
||||||
|
addVerticalDividers(true)
|
||||||
|
dialpad_list.adapter = this
|
||||||
|
}
|
||||||
|
|
||||||
|
dialpad_fastscroller.setScrollToY(0)
|
||||||
|
dialpad_fastscroller.setViews(dialpad_list) {
|
||||||
|
val item = (dialpad_list.adapter as ContactsAdapter).contactItems.getOrNull(it)
|
||||||
|
dialpad_fastscroller.updateBubbleText(item?.getBubbleText() ?: "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ const val LOCATION_FAVORITES_TAB = 1
|
||||||
const val LOCATION_RECENTS_TAB = 2
|
const val LOCATION_RECENTS_TAB = 2
|
||||||
const val LOCATION_GROUPS_TAB = 3
|
const val LOCATION_GROUPS_TAB = 3
|
||||||
const val LOCATION_GROUP_CONTACTS = 4
|
const val LOCATION_GROUP_CONTACTS = 4
|
||||||
|
const val LOCATION_DIALPAD = 5
|
||||||
|
|
||||||
const val CONTACTS_TAB_MASK = 1
|
const val CONTACTS_TAB_MASK = 1
|
||||||
const val FAVORITES_TAB_MASK = 2
|
const val FAVORITES_TAB_MASK = 2
|
||||||
|
|
|
@ -13,14 +13,39 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_marginBottom="@dimen/activity_margin"
|
android:layout_marginBottom="@dimen/activity_margin"
|
||||||
android:layout_marginLeft="@dimen/activity_margin"
|
|
||||||
android:layout_marginRight="@dimen/activity_margin"
|
|
||||||
android:focusableInTouchMode="true">
|
android:focusableInTouchMode="true">
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
|
android:id="@+id/dialpad_list"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:scrollbars="none"
|
||||||
|
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/dialpad_input"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"/>
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.FastScroller
|
||||||
|
android:id="@+id/dialpad_fastscroller"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:paddingLeft="@dimen/normal_margin"
|
||||||
|
android:paddingStart="@dimen/normal_margin"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/dialpad_list"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/dialpad_list">
|
||||||
|
|
||||||
|
<include layout="@layout/fastscroller_handle_vertical"/>
|
||||||
|
|
||||||
|
</com.simplemobiletools.commons.views.FastScroller>
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyEditText
|
<com.simplemobiletools.commons.views.MyEditText
|
||||||
android:id="@+id/dialpad_input"
|
android:id="@+id/dialpad_input"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="@dimen/activity_margin"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:inputType="phone"
|
android:inputType="phone"
|
||||||
android:textCursorDrawable="@null"
|
android:textCursorDrawable="@null"
|
||||||
|
@ -34,6 +59,7 @@
|
||||||
style="@style/MyBorderlessBackgroundStyle"
|
style="@style/MyBorderlessBackgroundStyle"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
|
android:layout_marginRight="@dimen/activity_margin"
|
||||||
android:paddingLeft="@dimen/activity_margin"
|
android:paddingLeft="@dimen/activity_margin"
|
||||||
android:paddingRight="@dimen/activity_margin"
|
android:paddingRight="@dimen/activity_margin"
|
||||||
android:src="@drawable/ic_clear_char"
|
android:src="@drawable/ic_clear_char"
|
||||||
|
@ -46,6 +72,7 @@
|
||||||
style="@style/DialpadNumberStyle"
|
style="@style/DialpadNumberStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="@dimen/activity_margin"
|
||||||
android:text="1"
|
android:text="1"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/dialpad_4"
|
app:layout_constraintBottom_toTopOf="@+id/dialpad_4"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/dialpad_2"
|
app:layout_constraintEnd_toStartOf="@+id/dialpad_2"
|
||||||
|
@ -68,6 +95,7 @@
|
||||||
style="@style/DialpadNumberStyle"
|
style="@style/DialpadNumberStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="@dimen/activity_margin"
|
||||||
android:text="3"
|
android:text="3"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/dialpad_6"
|
app:layout_constraintBottom_toTopOf="@+id/dialpad_6"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
@ -79,6 +107,7 @@
|
||||||
style="@style/DialpadNumberStyle"
|
style="@style/DialpadNumberStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="@dimen/activity_margin"
|
||||||
android:text="4"
|
android:text="4"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/dialpad_7"
|
app:layout_constraintBottom_toTopOf="@+id/dialpad_7"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/dialpad_5"
|
app:layout_constraintEnd_toStartOf="@+id/dialpad_5"
|
||||||
|
@ -101,6 +130,7 @@
|
||||||
style="@style/DialpadNumberStyle"
|
style="@style/DialpadNumberStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="@dimen/activity_margin"
|
||||||
android:text="6"
|
android:text="6"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/dialpad_9"
|
app:layout_constraintBottom_toTopOf="@+id/dialpad_9"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
@ -112,6 +142,7 @@
|
||||||
style="@style/DialpadNumberStyle"
|
style="@style/DialpadNumberStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="@dimen/activity_margin"
|
||||||
android:text="7"
|
android:text="7"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/dialpad_asterisk"
|
app:layout_constraintBottom_toTopOf="@+id/dialpad_asterisk"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/dialpad_8"
|
app:layout_constraintEnd_toStartOf="@+id/dialpad_8"
|
||||||
|
@ -134,6 +165,7 @@
|
||||||
style="@style/DialpadNumberStyle"
|
style="@style/DialpadNumberStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="@dimen/activity_margin"
|
||||||
android:text="9"
|
android:text="9"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/dialpad_hashtag"
|
app:layout_constraintBottom_toTopOf="@+id/dialpad_hashtag"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
@ -145,6 +177,7 @@
|
||||||
style="@style/DialpadNumberStyle"
|
style="@style/DialpadNumberStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="@dimen/activity_margin"
|
||||||
android:text="*"
|
android:text="*"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/dialpad_0"
|
app:layout_constraintEnd_toStartOf="@+id/dialpad_0"
|
||||||
|
@ -168,6 +201,7 @@
|
||||||
style="@style/DialpadNumberStyle"
|
style="@style/DialpadNumberStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="@dimen/activity_margin"
|
||||||
android:text="#"
|
android:text="#"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
|
Loading…
Reference in New Issue