diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/DialpadActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/DialpadActivity.kt index fcb044b4..d20d8aa5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/DialpadActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/DialpadActivity.kt @@ -9,9 +9,12 @@ import com.simplemobiletools.commons.extensions.applyColorFilter import com.simplemobiletools.commons.extensions.updateTextColors import com.simplemobiletools.commons.helpers.isLollipopPlus import com.simplemobiletools.contacts.R +import com.simplemobiletools.contacts.adapters.ContactsAdapter import com.simplemobiletools.contacts.extensions.afterTextChanged import com.simplemobiletools.contacts.extensions.config +import com.simplemobiletools.contacts.extensions.contactClicked 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.models.Contact import kotlinx.android.synthetic.main.activity_dialpad.* @@ -95,8 +98,21 @@ class DialpadActivity : SimpleActivity() { private fun dialpadValueChanged(text: String) { val numericOnly = text.replace(PHONE_NUMBER_PATTERN.toRegex(), "") val filtered = contacts.filter { - it.phoneNumbers.any { it.value.contains(text) || it.value.contains(numericOnly) } || - it.cleanPhoneNumbers.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 { (text.isNotEmpty() && it.value.contains(text)) || (numericOnly.isNotEmpty() && it.value.contains(numericOnly)) } + } as ArrayList + + 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() ?: "") } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/Constants.kt index 34cf1ca8..d3b7fb06 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/Constants.kt @@ -33,6 +33,7 @@ const val LOCATION_FAVORITES_TAB = 1 const val LOCATION_RECENTS_TAB = 2 const val LOCATION_GROUPS_TAB = 3 const val LOCATION_GROUP_CONTACTS = 4 +const val LOCATION_DIALPAD = 5 const val CONTACTS_TAB_MASK = 1 const val FAVORITES_TAB_MASK = 2 diff --git a/app/src/main/res/layout/activity_dialpad.xml b/app/src/main/res/layout/activity_dialpad.xml index 04bb29b0..5a8704f6 100644 --- a/app/src/main/res/layout/activity_dialpad.xml +++ b/app/src/main/res/layout/activity_dialpad.xml @@ -13,14 +13,39 @@ android:layout_height="match_parent" android:layout_alignParentBottom="true" android:layout_marginBottom="@dimen/activity_margin" - android:layout_marginLeft="@dimen/activity_margin" - android:layout_marginRight="@dimen/activity_margin" android:focusableInTouchMode="true"> + + + + + + + +