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 2f803349..c0e76908 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 @@ -65,8 +65,10 @@ class GroupContactsActivity : SimpleActivity(), RemoveFromGroupListener, Refresh fabClicked() } + val adjustedPrimaryColor = getAdjustedPrimaryColor() + group_contacts_fastscroller?.updateColors(adjustedPrimaryColor, adjustedPrimaryColor.getContrastColor()) group_contacts_placeholder_2.underlineText() - group_contacts_placeholder_2.setTextColor(getAdjustedPrimaryColor()) + group_contacts_placeholder_2.setTextColor(adjustedPrimaryColor) } override fun onResume() { @@ -133,7 +135,7 @@ class GroupContactsActivity : SimpleActivity(), RemoveFromGroupListener, Refresh private fun updateContacts(contacts: ArrayList) { val currAdapter = group_contacts_list.adapter if (currAdapter == null) { - ContactsAdapter(this, contacts, this, LOCATION_GROUP_CONTACTS, this, group_contacts_list, group_contacts_fastscroller) { + ContactsAdapter(this, contacts, this, LOCATION_GROUP_CONTACTS, this, group_contacts_list) { contactClicked(it as Contact) }.apply { group_contacts_list.adapter = this @@ -142,12 +144,6 @@ class GroupContactsActivity : SimpleActivity(), RemoveFromGroupListener, Refresh if (areSystemAnimationsEnabled) { group_contacts_list.scheduleLayoutAnimation() } - - group_contacts_fastscroller.setScrollToY(0) - group_contacts_fastscroller.setViews(group_contacts_list) { - val item = (group_contacts_list.adapter as ContactsAdapter).contactItems.getOrNull(it) - group_contacts_fastscroller.updateBubbleText(item?.getBubbleText() ?: "") - } } else { (currAdapter as ContactsAdapter).updateItems(contacts) } @@ -183,9 +179,9 @@ class GroupContactsActivity : SimpleActivity(), RemoveFromGroupListener, Refresh putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, defaultRingtoneUri) } } - + private fun setRingtoneOnSelected(uri: Uri) { - groupContacts.forEach{ + groupContacts.forEach { ContactsHelper(this).updateRingtone(it.contactId.toString(), uri.toString()) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/adapters/ContactsAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/adapters/ContactsAdapter.kt index 7465d5cc..207cd67a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/adapters/ContactsAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/adapters/ContactsAdapter.kt @@ -19,13 +19,13 @@ import com.bumptech.glide.Glide import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.request.RequestOptions import com.bumptech.glide.signature.ObjectKey +import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter import com.simplemobiletools.commons.dialogs.ConfirmationDialog import com.simplemobiletools.commons.dialogs.RadioGroupDialog import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.commons.models.RadioItem -import com.simplemobiletools.commons.views.FastScroller import com.simplemobiletools.commons.views.MyRecyclerView import com.simplemobiletools.contacts.pro.R import com.simplemobiletools.contacts.pro.activities.SimpleActivity @@ -38,10 +38,11 @@ import com.simplemobiletools.contacts.pro.interfaces.RemoveFromGroupListener import com.simplemobiletools.contacts.pro.models.Contact import java.util.* -class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList, private val refreshListener: RefreshContactsListener?, - private val location: Int, private val removeListener: RemoveFromGroupListener?, recyclerView: MyRecyclerView, - fastScroller: FastScroller?, highlightText: String = "", itemClick: (Any) -> Unit) : - MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) { +class ContactsAdapter( + activity: SimpleActivity, var contactItems: ArrayList, private val refreshListener: RefreshContactsListener?, + private val location: Int, private val removeListener: RemoveFromGroupListener?, recyclerView: MyRecyclerView, + highlightText: String = "", itemClick: (Any) -> Unit +) : MyRecyclerViewAdapter(activity, recyclerView, null, itemClick), RecyclerViewFastScroller.OnPopupTextUpdate { private val NEW_GROUP_ID = -1 private var config = activity.config @@ -66,10 +67,13 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList + val duplicates = allContacts.filter { it.id != contactToRemove.id && it.getHashToCompare() == contactToRemove.getHashToCompare() } + .toMutableList() as ArrayList duplicates.add(contactToRemove) ContactsHelper(activity).deleteContacts(duplicates) } @@ -392,4 +396,6 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList, val refreshListener: RefreshContactsListener?, recyclerView: MyRecyclerView, - fastScroller: FastScroller, itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) { +class GroupsAdapter( + activity: SimpleActivity, var groups: ArrayList, val refreshListener: RefreshContactsListener?, recyclerView: MyRecyclerView, + itemClick: (Any) -> Unit +) : MyRecyclerViewAdapter(activity, recyclerView, null, itemClick), RecyclerViewFastScroller.OnPopupTextUpdate { private var textToHighlight = "" var showContactThumbnails = activity.config.showContactThumbnails @@ -172,4 +174,6 @@ class GroupsAdapter(activity: SimpleActivity, var groups: ArrayList, val } } } + + override fun onChange(position: Int) = groups.getOrNull(position)?.getBubbleText() ?: "" } 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 9d6e2abe..c1e17e92 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 @@ -84,8 +84,7 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) } context.updateTextColors(fragment_wrapper.parent as ViewGroup) - fragment_fastscroller?.updatePrimaryColor() - fragment_fastscroller?.updateBubblePrimaryColor() + fragment_fastscroller?.updateColors(adjustedPrimaryColor, adjustedPrimaryColor.getContrastColor()) fragment_placeholder_2?.setTextColor(adjustedPrimaryColor) letter_fastscroller?.textColor = textColor.getColorStateList() @@ -169,7 +168,7 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) val currAdapter = fragment_list.adapter if (currAdapter == null) { - GroupsAdapter(activity as SimpleActivity, storedGroups, activity as RefreshContactsListener, fragment_list, fragment_fastscroller) { + GroupsAdapter(activity as SimpleActivity, storedGroups, activity as RefreshContactsListener, fragment_list) { Intent(activity, GroupContactsActivity::class.java).apply { putExtra(GROUP, it as Group) activity!!.startActivity(this) @@ -181,12 +180,6 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) if (context.areSystemAnimationsEnabled) { fragment_list.scheduleLayoutAnimation() } - - fragment_fastscroller.setScrollToY(0) - fragment_fastscroller.setViews(fragment_list) { - val item = (fragment_list.adapter as GroupsAdapter).groups.getOrNull(it) - fragment_fastscroller.updateBubbleText(item?.getBubbleText() ?: "") - } } else { (currAdapter as GroupsAdapter).apply { showContactThumbnails = activity.config.showContactThumbnails @@ -209,7 +202,7 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) else -> LOCATION_CONTACTS_TAB } - ContactsAdapter(activity as SimpleActivity, contacts, activity as RefreshContactsListener, location, null, fragment_list, null) { + ContactsAdapter(activity as SimpleActivity, contacts, activity as RefreshContactsListener, location, null, fragment_list) { (activity as RefreshContactsListener).contactClicked(it as Contact) }.apply { fragment_list.adapter = this diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/ContactsHelper.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/ContactsHelper.kt index d87d92de..c45eaffa 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/ContactsHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/ContactsHelper.kt @@ -28,7 +28,12 @@ class ContactsHelper(val context: Context) { private val BATCH_SIZE = 50 private var displayContactSources = ArrayList() - fun getContacts(getAll: Boolean = false, gettingDuplicates: Boolean = false, ignoredContactSources: HashSet = HashSet(), callback: (ArrayList) -> Unit) { + fun getContacts( + getAll: Boolean = false, + gettingDuplicates: Boolean = false, + ignoredContactSources: HashSet = HashSet(), + callback: (ArrayList) -> Unit + ) { ensureBackgroundThread { val contacts = SparseArray() displayContactSources = context.getVisibleContactSources() @@ -187,8 +192,10 @@ class ContactsHelper(val context: Context) { val organization = Organization("", "") val websites = ArrayList() val ims = ArrayList() - val contact = Contact(id, prefix, firstName, middleName, surname, suffix, nickname, photoUri, numbers, emails, addresses, - events, accountName, starred, contactId, thumbnailUri, null, notes, groups, organization, websites, ims, mimetype, ringtone) + val contact = Contact( + id, prefix, firstName, middleName, surname, suffix, nickname, photoUri, numbers, emails, addresses, + events, accountName, starred, contactId, thumbnailUri, null, notes, groups, organization, websites, ims, mimetype, ringtone + ) contacts.put(id, contact) } @@ -733,8 +740,10 @@ class ContactsHelper(val context: Context) { val organization = getOrganizations(id)[id] ?: Organization("", "") val websites = getWebsites(id)[id] ?: ArrayList() val ims = getIMs(id)[id] ?: ArrayList() - return Contact(id, prefix, firstName, middleName, surname, suffix, nickname, photoUri, number, emails, addresses, events, - accountName, starred, contactId, thumbnailUri, null, notes, groups, organization, websites, ims, mimetype, ringtone) + return Contact( + id, prefix, firstName, middleName, surname, suffix, nickname, photoUri, number, emails, addresses, events, + accountName, starred, contactId, thumbnailUri, null, notes, groups, organization, websites, ims, mimetype, ringtone + ) } } @@ -1499,7 +1508,8 @@ class ContactsHelper(val context: Context) { fun getDuplicatesOfContact(contact: Contact, addOriginal: Boolean, callback: (ArrayList) -> Unit) { ensureBackgroundThread { getContacts(true, true) { contacts -> - val duplicates = contacts.filter { it.id != contact.id && it.getHashToCompare() == contact.getHashToCompare() }.toMutableList() as ArrayList + val duplicates = + contacts.filter { it.id != contact.id && it.getHashToCompare() == contact.getHashToCompare() }.toMutableList() as ArrayList if (addOriginal) { duplicates.add(contact) } diff --git a/app/src/main/res/layout/activity_group_contacts.xml b/app/src/main/res/layout/activity_group_contacts.xml index ebccff66..1727fa49 100644 --- a/app/src/main/res/layout/activity_group_contacts.xml +++ b/app/src/main/res/layout/activity_group_contacts.xml @@ -38,25 +38,21 @@ android:textSize="@dimen/bigger_text_size" android:visibility="gone" /> - - - + android:layout_width="match_parent" + android:layout_height="wrap_content"> - + - + - - - + android:layout_width="match_parent" + android:layout_height="wrap_content"> - + - +