mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-02-08 23:58:47 +01:00
allow using SelectContactsDialog for selecting a single contact too
This commit is contained in:
parent
67a3053227
commit
5207abb620
@ -70,7 +70,7 @@ class GroupContactsActivity : SimpleActivity(), RemoveFromGroupListener, Refresh
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun fabClicked() {
|
private fun fabClicked() {
|
||||||
SelectContactsDialog(this, allContacts, groupContacts) { addedContacts, removedContacts ->
|
SelectContactsDialog(this, allContacts, true, groupContacts) { addedContacts, removedContacts ->
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
addContactsToGroup(addedContacts, group.id!!)
|
addContactsToGroup(addedContacts, group.id!!)
|
||||||
removeContactsFromGroup(removedContacts, group.id!!)
|
removeContactsFromGroup(removedContacts, group.id!!)
|
||||||
|
@ -11,7 +11,7 @@ import com.simplemobiletools.contacts.pro.extensions.getVisibleContactSources
|
|||||||
import com.simplemobiletools.contacts.pro.models.Contact
|
import com.simplemobiletools.contacts.pro.models.Contact
|
||||||
import kotlinx.android.synthetic.main.layout_select_contact.view.*
|
import kotlinx.android.synthetic.main.layout_select_contact.view.*
|
||||||
|
|
||||||
class SelectContactsDialog(val activity: SimpleActivity, initialContacts: ArrayList<Contact>, selectContacts: ArrayList<Contact>? = null,
|
class SelectContactsDialog(val activity: SimpleActivity, initialContacts: ArrayList<Contact>, val allowSelectMultiple: Boolean, selectContacts: ArrayList<Contact>? = null,
|
||||||
val callback: (addedContacts: ArrayList<Contact>, removedContacts: ArrayList<Contact>) -> Unit) {
|
val callback: (addedContacts: ArrayList<Contact>, removedContacts: ArrayList<Contact>) -> Unit) {
|
||||||
private var view = activity.layoutInflater.inflate(R.layout.layout_select_contact, null)
|
private var view = activity.layoutInflater.inflate(R.layout.layout_select_contact, null)
|
||||||
private var initiallySelectedContacts = ArrayList<Contact>()
|
private var initiallySelectedContacts = ArrayList<Contact>()
|
||||||
@ -29,7 +29,8 @@ class SelectContactsDialog(val activity: SimpleActivity, initialContacts: ArrayL
|
|||||||
|
|
||||||
activity.runOnUiThread {
|
activity.runOnUiThread {
|
||||||
view.apply {
|
view.apply {
|
||||||
select_contact_list.adapter = SelectContactsAdapter(activity, allContacts, initiallySelectedContacts, true, select_contact_list, select_contact_fastscroller)
|
select_contact_list.adapter = SelectContactsAdapter(activity, allContacts, initiallySelectedContacts, allowSelectMultiple,
|
||||||
|
select_contact_list, select_contact_fastscroller)
|
||||||
select_contact_fastscroller.allowBubbleDisplay = activity.baseConfig.showInfoBubble
|
select_contact_fastscroller.allowBubbleDisplay = activity.baseConfig.showInfoBubble
|
||||||
select_contact_fastscroller.setViews(select_contact_list) {
|
select_contact_fastscroller.setViews(select_contact_list) {
|
||||||
select_contact_fastscroller.updateBubbleText(allContacts[it].getBubbleText())
|
select_contact_fastscroller.updateBubbleText(allContacts[it].getBubbleText())
|
||||||
@ -37,10 +38,13 @@ class SelectContactsDialog(val activity: SimpleActivity, initialContacts: ArrayL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AlertDialog.Builder(activity)
|
val builder = AlertDialog.Builder(activity)
|
||||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
if (allowSelectMultiple) {
|
||||||
.setNegativeButton(R.string.cancel, null)
|
builder.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||||
.create().apply {
|
builder.setNegativeButton(R.string.cancel, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.create().apply {
|
||||||
activity.setupDialogStuff(view, this)
|
activity.setupDialogStuff(view, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun showAddFavoritesDialog() {
|
private fun showAddFavoritesDialog() {
|
||||||
SelectContactsDialog(activity!!, allContacts) { addedContacts, removedContacts ->
|
SelectContactsDialog(activity!!, allContacts, true) { addedContacts, removedContacts ->
|
||||||
ContactsHelper(activity as SimpleActivity).apply {
|
ContactsHelper(activity as SimpleActivity).apply {
|
||||||
addFavorites(addedContacts)
|
addFavorites(addedContacts)
|
||||||
removeFavorites(removedContacts)
|
removeFavorites(removedContacts)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user