apply the contact source filtering to Add Favorite dialog items too
This commit is contained in:
parent
82a0f8accb
commit
ab0ea57732
|
@ -27,8 +27,8 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: MutableList<Co
|
|||
val isFavoritesFragment: Boolean, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) :
|
||||
MyRecyclerViewAdapter(activity, recyclerView, itemClick) {
|
||||
|
||||
var config = activity.config
|
||||
lateinit private var contactDrawable: Drawable
|
||||
var config = activity.config
|
||||
var startNameWithSurname: Boolean
|
||||
var showPhoneNumbers: Boolean
|
||||
|
||||
|
|
|
@ -11,14 +11,19 @@ import com.simplemobiletools.contacts.models.Contact
|
|||
import kotlinx.android.synthetic.main.dialog_add_favorites.view.*
|
||||
|
||||
class AddFavoritesDialog(val activity: SimpleActivity, val callback: () -> Unit) {
|
||||
var dialog: AlertDialog? = null
|
||||
private var dialog: AlertDialog? = null
|
||||
private var view = activity.layoutInflater.inflate(R.layout.dialog_add_favorites, null)
|
||||
private val config = activity.config
|
||||
|
||||
init {
|
||||
ContactsHelper(activity).getContacts {
|
||||
Contact.sorting = activity.config.sorting
|
||||
it.sort()
|
||||
view.add_favorites_list.adapter = AddFavoritesAdapter(activity, it, activity.config.favorites)
|
||||
var contacts = it
|
||||
Contact.sorting = config.sorting
|
||||
contacts.sort()
|
||||
|
||||
val contactSources = config.displayContactSources
|
||||
contacts = contacts.filter { contactSources.contains(it.source) } as ArrayList<Contact>
|
||||
view.add_favorites_list.adapter = AddFavoritesAdapter(activity, contacts, config.favorites)
|
||||
|
||||
activity.runOnUiThread {
|
||||
dialog = AlertDialog.Builder(activity)
|
||||
|
@ -33,8 +38,8 @@ class AddFavoritesDialog(val activity: SimpleActivity, val callback: () -> Unit)
|
|||
|
||||
private fun dialogConfirmed() {
|
||||
val selectedItems = (view.add_favorites_list.adapter as AddFavoritesAdapter).getSelectedItemsSet()
|
||||
if (activity.config.favorites != selectedItems) {
|
||||
activity.config.favorites = selectedItems
|
||||
if (config.favorites != selectedItems) {
|
||||
config.favorites = selectedItems
|
||||
callback()
|
||||
}
|
||||
dialog?.dismiss()
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.simplemobiletools.contacts.dialogs.AddFavoritesDialog
|
|||
|
||||
class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet) {
|
||||
override fun fabClicked() {
|
||||
finishActMode()
|
||||
showAddFavoritesDialog()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue