reuse fragment_letters_layout at SelectContactActivity too
This commit is contained in:
parent
f135d347bf
commit
27ec11cbe6
2 changed files with 20 additions and 71 deletions
|
@ -26,6 +26,7 @@ import com.simplemobiletools.contacts.pro.helpers.ContactsHelper
|
|||
import com.simplemobiletools.contacts.pro.helpers.getProperText
|
||||
import com.simplemobiletools.contacts.pro.models.Contact
|
||||
import kotlinx.android.synthetic.main.activity_select_contact.*
|
||||
import kotlinx.android.synthetic.main.fragment_letters_layout.*
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
|
@ -38,6 +39,7 @@ class SelectContactActivity : SimpleActivity() {
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_select_contact)
|
||||
fragment_fab.beGone()
|
||||
|
||||
if (checkAppSideloading()) {
|
||||
return
|
||||
|
@ -123,7 +125,7 @@ class SelectContactActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun onSearchQueryChanged(text: String) {
|
||||
val adapter = select_contact_list.adapter
|
||||
val adapter = fragment_list.adapter
|
||||
if (adapter != null && adapter is SelectContactsAdapter) {
|
||||
val shouldNormalize = text.normalizeString() == text
|
||||
val filtered = contactsIgnoringSearch.filter {
|
||||
|
@ -145,20 +147,20 @@ class SelectContactActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
if (filtered.isEmpty()) {
|
||||
select_contact_placeholder.text = getString(R.string.no_items_found)
|
||||
fragment_placeholder.text = getString(R.string.no_items_found)
|
||||
}
|
||||
|
||||
select_contact_placeholder.beVisibleIf(filtered.isEmpty())
|
||||
fragment_placeholder.beVisibleIf(filtered.isEmpty())
|
||||
adapter.updateItems(filtered, text.normalizeString())
|
||||
}
|
||||
}
|
||||
|
||||
private fun onSearchOpened() {
|
||||
contactsIgnoringSearch = (select_contact_list.adapter as? SelectContactsAdapter)?.contacts ?: ArrayList()
|
||||
contactsIgnoringSearch = (fragment_list.adapter as? SelectContactsAdapter)?.contacts ?: ArrayList()
|
||||
}
|
||||
|
||||
private fun onSearchClosed() {
|
||||
(select_contact_list.adapter as? SelectContactsAdapter)?.updateItems(contactsIgnoringSearch)
|
||||
(fragment_list.adapter as? SelectContactsAdapter)?.updateItems(contactsIgnoringSearch)
|
||||
}
|
||||
|
||||
private fun showSortingDialog() {
|
||||
|
@ -197,17 +199,17 @@ class SelectContactActivity : SimpleActivity() {
|
|||
|
||||
runOnUiThread {
|
||||
updatePlaceholderVisibility(contacts)
|
||||
SelectContactsAdapter(this, contacts, ArrayList(), false, select_contact_list) {
|
||||
SelectContactsAdapter(this, contacts, ArrayList(), false, fragment_list) {
|
||||
confirmSelection(it)
|
||||
}.apply {
|
||||
select_contact_list.adapter = this
|
||||
fragment_list.adapter = this
|
||||
}
|
||||
|
||||
if (areSystemAnimationsEnabled) {
|
||||
select_contact_list.scheduleLayoutAnimation()
|
||||
fragment_list.scheduleLayoutAnimation()
|
||||
}
|
||||
|
||||
letter_fastscroller.setupWithRecyclerView(select_contact_list, { position ->
|
||||
letter_fastscroller.setupWithRecyclerView(fragment_list, { position ->
|
||||
try {
|
||||
val name = contacts[position].getNameToDisplay()
|
||||
val character = if (name.isNotEmpty()) name.substring(0, 1) else ""
|
||||
|
@ -241,10 +243,10 @@ class SelectContactActivity : SimpleActivity() {
|
|||
|
||||
private fun setupViews() {
|
||||
val adjustedPrimaryColor = getAdjustedPrimaryColor()
|
||||
select_contact_placeholder.setTextColor(config.textColor)
|
||||
select_contact_placeholder_2.setTextColor(adjustedPrimaryColor)
|
||||
select_contact_placeholder_2.underlineText()
|
||||
select_contact_placeholder_2.setOnClickListener {
|
||||
fragment_placeholder.setTextColor(config.textColor)
|
||||
fragment_placeholder_2.setTextColor(adjustedPrimaryColor)
|
||||
fragment_placeholder_2.underlineText()
|
||||
fragment_placeholder_2.setOnClickListener {
|
||||
FilterContactSourcesDialog(this) {
|
||||
initContacts()
|
||||
}
|
||||
|
@ -259,10 +261,10 @@ class SelectContactActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun updatePlaceholderVisibility(contacts: ArrayList<Contact>) {
|
||||
select_contact_list.beVisibleIf(contacts.isNotEmpty())
|
||||
select_contact_placeholder_2.beVisibleIf(contacts.isEmpty())
|
||||
select_contact_placeholder.beVisibleIf(contacts.isEmpty())
|
||||
select_contact_placeholder.setText(
|
||||
fragment_list.beVisibleIf(contacts.isNotEmpty())
|
||||
fragment_placeholder_2.beVisibleIf(contacts.isEmpty())
|
||||
fragment_placeholder.beVisibleIf(contacts.isEmpty())
|
||||
fragment_placeholder.setText(
|
||||
when (specialMimeType) {
|
||||
Email.CONTENT_ITEM_TYPE -> R.string.no_contacts_with_emails
|
||||
Phone.CONTENT_ITEM_TYPE -> R.string.no_contacts_with_phone_numbers
|
||||
|
|
|
@ -1,62 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/select_contact_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/select_contact_placeholder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:alpha="0.8"
|
||||
android:gravity="center"
|
||||
android:paddingStart="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:paddingEnd="@dimen/activity_margin"
|
||||
android:text="@string/no_contacts_found"
|
||||
android:textSize="@dimen/bigger_text_size"
|
||||
android:textStyle="italic"
|
||||
android:visibility="gone" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/select_contact_placeholder_2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/select_contact_placeholder"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center"
|
||||
android:padding="@dimen/activity_margin"
|
||||
android:text="@string/change_filter"
|
||||
android:textSize="@dimen/bigger_text_size"
|
||||
android:visibility="gone" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||
android:id="@+id/select_contact_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
android:layoutAnimation="@anim/layout_animation"
|
||||
android:scrollbars="none"
|
||||
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
|
||||
|
||||
<com.reddit.indicatorfastscroll.FastScrollerView
|
||||
android:id="@+id/letter_fastscroller"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:paddingTop="@dimen/big_margin"
|
||||
android:paddingBottom="@dimen/big_margin" />
|
||||
|
||||
<com.reddit.indicatorfastscroll.FastScrollerThumbView
|
||||
android:id="@+id/letter_fastscroller_thumb"
|
||||
android:layout_width="@dimen/fab_size"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignTop="@+id/letter_fastscroller"
|
||||
android:layout_alignBottom="@+id/letter_fastscroller"
|
||||
android:layout_marginEnd="@dimen/activity_margin"
|
||||
android:layout_toStartOf="@+id/letter_fastscroller" />
|
||||
<include layout="@layout/fragment_letters_layout" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
Loading…
Reference in a new issue