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 848ea9b1..ab35f298 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 @@ -86,11 +86,6 @@ class GroupContactsActivity : SimpleActivity(), RemoveFromGroupListener, Refresh group_contacts_placeholder_2.beVisibleIf(groupContacts.isEmpty()) group_contacts_placeholder.beVisibleIf(groupContacts.isEmpty()) group_contacts_list.beVisibleIf(groupContacts.isNotEmpty()) - - Contact.sorting = config.sorting - Contact.startWithSurname = config.startNameWithSurname - groupContacts.sort() - updateContacts(groupContacts) } } 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 b2303819..1b0f8da8 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 @@ -58,10 +58,6 @@ class InsertOrEditContactActivity : SimpleActivity() { } private fun gotContacts(contacts: ArrayList) { - Contact.sorting = config.sorting - Contact.startWithSurname = config.startNameWithSurname - contacts.sort() - ContactsAdapter(this, contacts, null, LOCATION_INSERT_OR_EDIT, null, existing_contact_list, existing_contact_fastscroller) { Intent(applicationContext, EditContactActivity::class.java).apply { data = getContactPublicUri(it as Contact) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/SelectContactActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/SelectContactActivity.kt index d31c6462..a09d7f86 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/SelectContactActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/SelectContactActivity.kt @@ -99,10 +99,6 @@ class SelectContactActivity : SimpleActivity() { val contactSources = getVisibleContactSources() contacts = contacts.filter { contactSources.contains(it.source) } as ArrayList - Contact.sorting = config.sorting - Contact.startWithSurname = config.startNameWithSurname - contacts.sort() - runOnUiThread { updatePlaceholderVisibility(contacts) SelectContactsAdapter(this, contacts, ArrayList(), false, select_contact_list) { diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/SelectContactsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/SelectContactsDialog.kt index b01bfacd..16872932 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/SelectContactsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/SelectContactsDialog.kt @@ -6,12 +6,11 @@ import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.contacts.pro.R import com.simplemobiletools.contacts.pro.activities.SimpleActivity import com.simplemobiletools.contacts.pro.adapters.SelectContactsAdapter -import com.simplemobiletools.contacts.pro.extensions.config import com.simplemobiletools.contacts.pro.extensions.getVisibleContactSources import com.simplemobiletools.contacts.pro.models.Contact import kotlinx.android.synthetic.main.layout_select_contact.view.* -class SelectContactsDialog(val activity: SimpleActivity, initialContacts: ArrayList, val selectContacts: ArrayList? = null, +class SelectContactsDialog(val activity: SimpleActivity, initialContacts: ArrayList, selectContacts: ArrayList? = null, val callback: (addedContacts: ArrayList, removedContacts: ArrayList) -> Unit) { private var view = activity.layoutInflater.inflate(R.layout.layout_select_contact, null) private var initiallySelectedContacts = ArrayList() @@ -27,10 +26,6 @@ class SelectContactsDialog(val activity: SimpleActivity, initialContacts: ArrayL initiallySelectedContacts = selectContacts } - Contact.sorting = activity.config.sorting - Contact.startWithSurname = activity.config.startNameWithSurname - allContacts.sort() - activity.runOnUiThread { view.apply { select_contact_list.adapter = SelectContactsAdapter(activity, allContacts, initiallySelectedContacts, true, select_contact_list) 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 00f97747..8699bb06 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 @@ -108,9 +108,6 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) config.lastUsedContactSource = grouped?.key ?: "" } - Contact.sorting = config.sorting - Contact.startWithSurname = config.startNameWithSurname - contacts.sort() allContacts = contacts val filtered = when { @@ -253,9 +250,6 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) it.websites.any { it.contains(text, true) } } as ArrayList - Contact.sorting = config.sorting - Contact.startWithSurname = config.startNameWithSurname - filtered.sort() filtered.sortBy { !getProperText(it.getNameToDisplay(), shouldNormalize).startsWith(text, true) } if (filtered.isEmpty() && this@MyViewPagerFragment is FavoritesFragment) { 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 a3c8a6f8..5b4595f4 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 @@ -82,6 +82,10 @@ class ContactsHelper(val activity: Activity) { resultContacts.firstOrNull { it.contactId == key }?.groups = groups.valueAt(i) } + Contact.sorting = activity.config.sorting + Contact.startWithSurname = activity.config.startNameWithSurname + resultContacts.sort() + activity.runOnUiThread { callback(resultContacts) }