mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-01-31 16:04:54 +01:00
use the new fastscroller at groups
This commit is contained in:
parent
e436073156
commit
fceeca441a
@ -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<Contact>) {
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
@ -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<Contact>, 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<Contact>, 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<Cont
|
||||
findItem(R.id.cab_remove).isVisible = location == LOCATION_FAVORITES_TAB || location == LOCATION_GROUP_CONTACTS
|
||||
findItem(R.id.cab_add_to_favorites).isVisible = location == LOCATION_CONTACTS_TAB
|
||||
findItem(R.id.cab_add_to_group).isVisible = location == LOCATION_CONTACTS_TAB || location == LOCATION_FAVORITES_TAB
|
||||
findItem(R.id.cab_send_sms_to_contacts).isVisible = location == LOCATION_CONTACTS_TAB || location == LOCATION_FAVORITES_TAB || location == LOCATION_GROUP_CONTACTS
|
||||
findItem(R.id.cab_send_email_to_contacts).isVisible = location == LOCATION_CONTACTS_TAB || location == LOCATION_FAVORITES_TAB || location == LOCATION_GROUP_CONTACTS
|
||||
findItem(R.id.cab_send_sms_to_contacts).isVisible =
|
||||
location == LOCATION_CONTACTS_TAB || location == LOCATION_FAVORITES_TAB || location == LOCATION_GROUP_CONTACTS
|
||||
findItem(R.id.cab_send_email_to_contacts).isVisible =
|
||||
location == LOCATION_CONTACTS_TAB || location == LOCATION_FAVORITES_TAB || location == LOCATION_GROUP_CONTACTS
|
||||
findItem(R.id.cab_delete).isVisible = location == LOCATION_CONTACTS_TAB || location == LOCATION_GROUP_CONTACTS
|
||||
findItem(R.id.cab_create_shortcut).isVisible = isOreoPlus() && isOneItemSelected() && (location == LOCATION_FAVORITES_TAB || location == LOCATION_CONTACTS_TAB)
|
||||
findItem(R.id.cab_create_shortcut).isVisible =
|
||||
isOreoPlus() && isOneItemSelected() && (location == LOCATION_FAVORITES_TAB || location == LOCATION_CONTACTS_TAB)
|
||||
|
||||
if (location == LOCATION_GROUP_CONTACTS) {
|
||||
findItem(R.id.cab_remove).title = activity.getString(R.string.remove_from_group)
|
||||
@ -133,7 +137,6 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
|
||||
textToHighlight = highlightText
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
fastScroller?.measureRecyclerView()
|
||||
}
|
||||
|
||||
private fun editContact() {
|
||||
@ -170,7 +173,8 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
|
||||
ensureBackgroundThread {
|
||||
contactsToRemove.forEach {
|
||||
val contactToRemove = it
|
||||
val duplicates = allContacts.filter { it.id != contactToRemove.id && it.getHashToCompare() == contactToRemove.getHashToCompare() }.toMutableList() as ArrayList<Contact>
|
||||
val duplicates = allContacts.filter { it.id != contactToRemove.id && it.getHashToCompare() == contactToRemove.getHashToCompare() }
|
||||
.toMutableList() as ArrayList<Contact>
|
||||
duplicates.add(contactToRemove)
|
||||
ContactsHelper(activity).deleteContacts(duplicates)
|
||||
}
|
||||
@ -392,4 +396,6 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onChange(position: Int) = contactItems.getOrNull(position)?.getBubbleText() ?: ""
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import android.util.TypedValue
|
||||
import android.view.Menu
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||
@ -12,7 +13,6 @@ import com.simplemobiletools.commons.extensions.highlightTextPart
|
||||
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
||||
import com.simplemobiletools.commons.helpers.TAB_GROUPS
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
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
|
||||
@ -25,8 +25,10 @@ import com.simplemobiletools.contacts.pro.models.Group
|
||||
import kotlinx.android.synthetic.main.item_group.view.*
|
||||
import java.util.*
|
||||
|
||||
class GroupsAdapter(activity: SimpleActivity, var groups: ArrayList<Group>, val refreshListener: RefreshContactsListener?, recyclerView: MyRecyclerView,
|
||||
fastScroller: FastScroller, itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
|
||||
class GroupsAdapter(
|
||||
activity: SimpleActivity, var groups: ArrayList<Group>, 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<Group>, val
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onChange(position: Int) = groups.getOrNull(position)?.getBubbleText() ?: ""
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -28,7 +28,12 @@ class ContactsHelper(val context: Context) {
|
||||
private val BATCH_SIZE = 50
|
||||
private var displayContactSources = ArrayList<String>()
|
||||
|
||||
fun getContacts(getAll: Boolean = false, gettingDuplicates: Boolean = false, ignoredContactSources: HashSet<String> = HashSet(), callback: (ArrayList<Contact>) -> Unit) {
|
||||
fun getContacts(
|
||||
getAll: Boolean = false,
|
||||
gettingDuplicates: Boolean = false,
|
||||
ignoredContactSources: HashSet<String> = HashSet(),
|
||||
callback: (ArrayList<Contact>) -> Unit
|
||||
) {
|
||||
ensureBackgroundThread {
|
||||
val contacts = SparseArray<Contact>()
|
||||
displayContactSources = context.getVisibleContactSources()
|
||||
@ -187,8 +192,10 @@ class ContactsHelper(val context: Context) {
|
||||
val organization = Organization("", "")
|
||||
val websites = ArrayList<String>()
|
||||
val ims = ArrayList<IM>()
|
||||
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<Contact>) -> Unit) {
|
||||
ensureBackgroundThread {
|
||||
getContacts(true, true) { contacts ->
|
||||
val duplicates = contacts.filter { it.id != contact.id && it.getHashToCompare() == contact.getHashToCompare() }.toMutableList() as ArrayList<Contact>
|
||||
val duplicates =
|
||||
contacts.filter { it.id != contact.id && it.getHashToCompare() == contact.getHashToCompare() }.toMutableList() as ArrayList<Contact>
|
||||
if (addOriginal) {
|
||||
duplicates.add(contact)
|
||||
}
|
||||
|
@ -38,25 +38,21 @@
|
||||
android:textSize="@dimen/bigger_text_size"
|
||||
android:visibility="gone" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||
android:id="@+id/group_contacts_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:layoutAnimation="@anim/layout_animation"
|
||||
android:scrollbars="none"
|
||||
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
|
||||
|
||||
<com.simplemobiletools.commons.views.FastScroller
|
||||
<com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
||||
android:id="@+id/group_contacts_fastscroller"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:paddingStart="@dimen/normal_margin">
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<include layout="@layout/fastscroller_handle_vertical" />
|
||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||
android:id="@+id/group_contacts_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:layoutAnimation="@anim/layout_animation"
|
||||
android:scrollbars="none"
|
||||
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
|
||||
|
||||
</com.simplemobiletools.commons.views.FastScroller>
|
||||
</com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller>
|
||||
</RelativeLayout>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyFloatingActionButton
|
||||
|
@ -35,25 +35,21 @@
|
||||
android:textSize="@dimen/bigger_text_size"
|
||||
android:visibility="gone" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||
android:id="@+id/fragment_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:layoutAnimation="@anim/layout_animation"
|
||||
android:scrollbars="none"
|
||||
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
|
||||
|
||||
<com.simplemobiletools.commons.views.FastScroller
|
||||
<com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
||||
android:id="@+id/fragment_fastscroller"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:paddingStart="@dimen/normal_margin">
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<include layout="@layout/fastscroller_handle_vertical" />
|
||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||
android:id="@+id/fragment_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:layoutAnimation="@anim/layout_animation"
|
||||
android:scrollbars="none"
|
||||
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
|
||||
|
||||
</com.simplemobiletools.commons.views.FastScroller>
|
||||
</com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller>
|
||||
</RelativeLayout>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyFloatingActionButton
|
||||
|
Loading…
x
Reference in New Issue
Block a user