From ba7e7e4ba091894236d2b27b093b02df9273e993 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 6 Dec 2019 21:26:10 +0100 Subject: [PATCH] allow clicking on Create New Contact at select contact screen --- .../pro/activities/GroupContactsActivity.kt | 6 +++--- .../pro/activities/InsertOrEditContactActivity.kt | 2 +- .../contacts/pro/activities/MainActivity.kt | 4 ++-- .../contacts/pro/fragments/ContactsFragment.kt | 2 -- .../contacts/pro/fragments/FavoritesFragment.kt | 2 -- .../contacts/pro/fragments/GroupsFragment.kt | 2 -- .../pro/fragments/InsertOrEditContactsFragment.kt | 13 ------------- .../contacts/pro/fragments/MyViewPagerFragment.kt | 14 ++++++++++---- .../pro/interfaces/RefreshContactsListener.kt | 2 +- 9 files changed, 17 insertions(+), 30 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/GroupContactsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/GroupContactsActivity.kt index 8d034e14..0893418b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/GroupContactsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/GroupContactsActivity.kt @@ -104,7 +104,7 @@ class GroupContactsActivity : SimpleActivity(), RemoveFromGroupListener, Refresh val currAdapter = group_contacts_list.adapter if (currAdapter == null) { ContactsAdapter(this, contacts, this, LOCATION_GROUP_CONTACTS, this, group_contacts_list, group_contacts_fastscroller) { - contactClicked(it as Contact) + contactClicked(it as Contact, false) }.apply { group_contacts_list.adapter = this } @@ -123,8 +123,8 @@ class GroupContactsActivity : SimpleActivity(), RemoveFromGroupListener, Refresh refreshContacts() } - override fun contactClicked(contact: Contact) { - handleGenericContactClick(contact) + override fun contactClicked(contact: Contact?, isCreateNewContact: Boolean) { + handleGenericContactClick(contact!!) } override fun removeFromGroup(contacts: ArrayList) { 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 465bb318..b4e72cc2 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 @@ -129,7 +129,7 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener { } } - override fun contactClicked(contact: Contact) { + override fun contactClicked(contact: Contact?, isCreateNewContact: Boolean) { } } diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/MainActivity.kt index b80fa62b..9f95a3f2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/MainActivity.kt @@ -560,8 +560,8 @@ class MainActivity : SimpleActivity(), RefreshContactsListener { } } - override fun contactClicked(contact: Contact) { - handleGenericContactClick(contact) + override fun contactClicked(contact: Contact?, isCreateNewContact: Boolean) { + handleGenericContactClick(contact!!) } private fun getAllFragments() = arrayListOf(contacts_fragment, favorites_fragment, groups_fragment) 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 8f23a93b..17a1b53c 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,6 +16,4 @@ 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 61c07b8a..66be621f 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,6 +28,4 @@ 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 ff83b1bf..22ba261a 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,6 +22,4 @@ 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 index eca2f811..99d5f28f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/InsertOrEditContactsFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/InsertOrEditContactsFragment.kt @@ -2,22 +2,9 @@ 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 8365abe5..4941334a 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 @@ -21,7 +21,11 @@ import com.simplemobiletools.contacts.pro.helpers.* import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener import com.simplemobiletools.contacts.pro.models.Contact import com.simplemobiletools.contacts.pro.models.Group +import kotlinx.android.synthetic.main.fragment_insert_or_edit_contacts.view.* import kotlinx.android.synthetic.main.fragment_layout.view.* +import kotlinx.android.synthetic.main.fragment_layout.view.fragment_fastscroller +import kotlinx.android.synthetic.main.fragment_layout.view.fragment_list +import kotlinx.android.synthetic.main.fragment_layout.view.fragment_wrapper abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) : CoordinatorLayout(context, attributeSet) { protected var activity: SimpleActivity? = null @@ -188,7 +192,7 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) forceListRedraw = false val location = if (this is FavoritesFragment) LOCATION_FAVORITES_TAB else LOCATION_CONTACTS_TAB ContactsAdapter(activity as SimpleActivity, contacts, activity as RefreshContactsListener, location, null, fragment_list, fragment_fastscroller) { - (activity as RefreshContactsListener).contactClicked(it as Contact) + (activity as RefreshContactsListener).contactClicked(it as Contact, false) }.apply { fragment_list.adapter = this } @@ -299,7 +303,11 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) fragment_fastscroller.updateBubbleColors() fragment_fastscroller.allowBubbleDisplay = config.showInfoBubble fragment_placeholder_2?.setTextColor(context.getAdjustedPrimaryColor()) - 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 { + (activity as RefreshContactsListener).contactClicked(null, true) + } } private fun setupViewVisibility(hasItemsToShow: Boolean) { @@ -311,6 +319,4 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) abstract fun fabClicked() abstract fun placeholderClicked() - - abstract fun viewSetup() } diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/interfaces/RefreshContactsListener.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/interfaces/RefreshContactsListener.kt index 1a917f56..4d8179e5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/interfaces/RefreshContactsListener.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/interfaces/RefreshContactsListener.kt @@ -5,5 +5,5 @@ import com.simplemobiletools.contacts.pro.models.Contact interface RefreshContactsListener { fun refreshContacts(refreshTabsMask: Int) - fun contactClicked(contact: Contact) + fun contactClicked(contact: Contact?, isCreateNewContact: Boolean) }