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) :
|
val isFavoritesFragment: Boolean, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) :
|
||||||
MyRecyclerViewAdapter(activity, recyclerView, itemClick) {
|
MyRecyclerViewAdapter(activity, recyclerView, itemClick) {
|
||||||
|
|
||||||
var config = activity.config
|
|
||||||
lateinit private var contactDrawable: Drawable
|
lateinit private var contactDrawable: Drawable
|
||||||
|
var config = activity.config
|
||||||
var startNameWithSurname: Boolean
|
var startNameWithSurname: Boolean
|
||||||
var showPhoneNumbers: Boolean
|
var showPhoneNumbers: Boolean
|
||||||
|
|
||||||
|
|
|
@ -11,14 +11,19 @@ import com.simplemobiletools.contacts.models.Contact
|
||||||
import kotlinx.android.synthetic.main.dialog_add_favorites.view.*
|
import kotlinx.android.synthetic.main.dialog_add_favorites.view.*
|
||||||
|
|
||||||
class AddFavoritesDialog(val activity: SimpleActivity, val callback: () -> Unit) {
|
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 var view = activity.layoutInflater.inflate(R.layout.dialog_add_favorites, null)
|
||||||
|
private val config = activity.config
|
||||||
|
|
||||||
init {
|
init {
|
||||||
ContactsHelper(activity).getContacts {
|
ContactsHelper(activity).getContacts {
|
||||||
Contact.sorting = activity.config.sorting
|
var contacts = it
|
||||||
it.sort()
|
Contact.sorting = config.sorting
|
||||||
view.add_favorites_list.adapter = AddFavoritesAdapter(activity, it, activity.config.favorites)
|
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 {
|
activity.runOnUiThread {
|
||||||
dialog = AlertDialog.Builder(activity)
|
dialog = AlertDialog.Builder(activity)
|
||||||
|
@ -33,8 +38,8 @@ class AddFavoritesDialog(val activity: SimpleActivity, val callback: () -> Unit)
|
||||||
|
|
||||||
private fun dialogConfirmed() {
|
private fun dialogConfirmed() {
|
||||||
val selectedItems = (view.add_favorites_list.adapter as AddFavoritesAdapter).getSelectedItemsSet()
|
val selectedItems = (view.add_favorites_list.adapter as AddFavoritesAdapter).getSelectedItemsSet()
|
||||||
if (activity.config.favorites != selectedItems) {
|
if (config.favorites != selectedItems) {
|
||||||
activity.config.favorites = selectedItems
|
config.favorites = selectedItems
|
||||||
callback()
|
callback()
|
||||||
}
|
}
|
||||||
dialog?.dismiss()
|
dialog?.dismiss()
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.simplemobiletools.contacts.dialogs.AddFavoritesDialog
|
||||||
|
|
||||||
class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet) {
|
class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet) {
|
||||||
override fun fabClicked() {
|
override fun fabClicked() {
|
||||||
|
finishActMode()
|
||||||
showAddFavoritesDialog()
|
showAddFavoritesDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue