apply the contact source filtering to Add Favorite dialog items too

This commit is contained in:
tibbi 2017-12-30 17:53:30 +01:00
parent 82a0f8accb
commit ab0ea57732
3 changed files with 13 additions and 7 deletions

View File

@ -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

View File

@ -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()

View File

@ -6,6 +6,7 @@ import com.simplemobiletools.contacts.dialogs.AddFavoritesDialog
class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet) {
override fun fabClicked() {
finishActMode()
showAddFavoritesDialog()
}