From 21cd58f0bb7c7b2eb43295dca9f2c663c3f5518a Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 6 Dec 2019 21:14:59 +0100 Subject: [PATCH] create a separate layout for the Select Contact contacts fragment --- .../activities/InsertOrEditContactActivity.kt | 6 +- .../pro/fragments/ContactsFragment.kt | 2 + .../pro/fragments/FavoritesFragment.kt | 2 + .../contacts/pro/fragments/GroupsFragment.kt | 2 + .../fragments/InsertOrEditContactsFragment.kt | 23 ++++++ .../pro/fragments/MyViewPagerFragment.kt | 15 ++-- .../fragment_insert_or_edit_contacts.xml | 81 +++++++++++++++++++ 7 files changed, 122 insertions(+), 9 deletions(-) create mode 100644 app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/InsertOrEditContactsFragment.kt create mode 100644 app/src/main/res/layout/fragment_insert_or_edit_contacts.xml diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/InsertOrEditContactActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/InsertOrEditContactActivity.kt index 8758a294..465bb318 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/InsertOrEditContactActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/InsertOrEditContactActivity.kt @@ -17,8 +17,8 @@ import com.simplemobiletools.contacts.pro.helpers.FAVORITES_TAB_MASK import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener import com.simplemobiletools.contacts.pro.models.Contact import kotlinx.android.synthetic.main.activity_insert_edit_contact.* -import kotlinx.android.synthetic.main.fragment_contacts.* import kotlinx.android.synthetic.main.fragment_favorites.* +import kotlinx.android.synthetic.main.fragment_insert_or_edit_contacts.* class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener { private val START_INSERT_ACTIVITY = 1 @@ -110,7 +110,7 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener { } if (viewpager.adapter == null) { - val fragments = arrayListOf(R.layout.fragment_contacts, R.layout.fragment_favorites) + val fragments = arrayListOf(R.layout.fragment_insert_or_edit_contacts, R.layout.fragment_favorites) viewpager.adapter = ViewPagerAdapter(this, contactsFavoritesList, CONTACTS_TAB_MASK or FAVORITES_TAB_MASK, fragments) } @@ -120,7 +120,7 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener { } if (refreshTabsMask and CONTACTS_TAB_MASK != 0) { - contacts_fragment?.refreshContacts(contacts) + insert_or_edit_contacts_fragment?.refreshContacts(contacts) } if (refreshTabsMask and FAVORITES_TAB_MASK != 0) { diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/ContactsFragment.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/ContactsFragment.kt index 17a1b53c..8f23a93b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/ContactsFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/ContactsFragment.kt @@ -16,4 +16,6 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag override fun placeholderClicked() { (activity as? MainActivity)?.showFilterDialog() } + + override fun viewSetup() {} } diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/FavoritesFragment.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/FavoritesFragment.kt index 66be621f..61c07b8a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/FavoritesFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/FavoritesFragment.kt @@ -28,4 +28,6 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa (activity as? MainActivity)?.refreshContacts(FAVORITES_TAB_MASK) } } + + override fun viewSetup() {} } diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/GroupsFragment.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/GroupsFragment.kt index 22ba261a..ff83b1bf 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/GroupsFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/GroupsFragment.kt @@ -22,4 +22,6 @@ class GroupsFragment(context: Context, attributeSet: AttributeSet) : MyViewPager (activity as? MainActivity)?.refreshContacts(GROUPS_TAB_MASK) } } + + override fun viewSetup() {} } diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/InsertOrEditContactsFragment.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/InsertOrEditContactsFragment.kt new file mode 100644 index 00000000..eca2f811 --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/InsertOrEditContactsFragment.kt @@ -0,0 +1,23 @@ +package com.simplemobiletools.contacts.pro.fragments + +import android.content.Context +import android.util.AttributeSet +import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor +import com.simplemobiletools.commons.extensions.getColoredDrawableWithColor +import com.simplemobiletools.contacts.pro.R +import com.simplemobiletools.contacts.pro.extensions.config +import kotlinx.android.synthetic.main.fragment_insert_or_edit_contacts.view.* + +class InsertOrEditContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet) { + override fun fabClicked() {} + + override fun placeholderClicked() {} + + override fun viewSetup() { + select_contact_label.setTextColor(context.getAdjustedPrimaryColor()) + new_contact_tmb.setImageDrawable(resources.getColoredDrawableWithColor(R.drawable.ic_new_contact_vector, context.config.textColor)) + new_contact_holder.setOnClickListener { + + } + } +} diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/MyViewPagerFragment.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/MyViewPagerFragment.kt index 5371be75..8365abe5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/MyViewPagerFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/MyViewPagerFragment.kt @@ -39,15 +39,15 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) config = activity.config if (this.activity == null) { this.activity = activity - fragment_fab.setOnClickListener { + fragment_fab?.setOnClickListener { fabClicked() } - fragment_placeholder_2.setOnClickListener { + fragment_placeholder_2?.setOnClickListener { placeholderClicked() } - fragment_placeholder_2.underlineText() + fragment_placeholder_2?.underlineText() updateViewStuff() when { @@ -298,16 +298,19 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) context.updateTextColors(fragment_wrapper.parent as ViewGroup) fragment_fastscroller.updateBubbleColors() fragment_fastscroller.allowBubbleDisplay = config.showInfoBubble - fragment_placeholder_2.setTextColor(context.getAdjustedPrimaryColor()) + fragment_placeholder_2?.setTextColor(context.getAdjustedPrimaryColor()) + viewSetup() } private fun setupViewVisibility(hasItemsToShow: Boolean) { - fragment_placeholder_2.beVisibleIf(!hasItemsToShow) - fragment_placeholder.beVisibleIf(!hasItemsToShow) + fragment_placeholder_2?.beVisibleIf(!hasItemsToShow) + fragment_placeholder?.beVisibleIf(!hasItemsToShow) fragment_list.beVisibleIf(hasItemsToShow) } abstract fun fabClicked() abstract fun placeholderClicked() + + abstract fun viewSetup() } diff --git a/app/src/main/res/layout/fragment_insert_or_edit_contacts.xml b/app/src/main/res/layout/fragment_insert_or_edit_contacts.xml new file mode 100644 index 00000000..cd2ca45d --- /dev/null +++ b/app/src/main/res/layout/fragment_insert_or_edit_contacts.xml @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + +