adding a couple checks of contacts permissions

This commit is contained in:
tibbi 2018-04-06 22:32:58 +02:00
parent d3c87e241c
commit 25c9abb92d
3 changed files with 8 additions and 4 deletions

View File

@ -109,7 +109,7 @@ class GroupContactsActivity : SimpleActivity(), RemoveFromGroupListener, Refresh
}
override fun removeFromGroup(contacts: ArrayList<Contact>) {
ContactsHelper(this).removeContactsFromGroup(contacts, group.id)
removeContactsFromGroup(contacts, group.id)
if (groupContacts.size == 0) {
refreshContacts()
}

View File

@ -126,7 +126,7 @@ fun BaseSimpleActivity.addContactsToGroup(contacts: ArrayList<Contact>, groupId:
fun BaseSimpleActivity.removeContactsFromGroup(contacts: ArrayList<Contact>, groupId: Long) {
val publicContacts = contacts.filter { it.source != SMT_PRIVATE }
val privateContacts = contacts.filter { it.source == SMT_PRIVATE }
if (publicContacts.isNotEmpty()) {
if (publicContacts.isNotEmpty() && hasContactPermissions()) {
ContactsHelper(this).removeContactsFromGroup(contacts, groupId)
}

View File

@ -1024,12 +1024,16 @@ class ContactsHelper(val activity: BaseSimpleActivity) {
fun addFavorites(contacts: ArrayList<Contact>) {
toggleLocalFavorites(contacts, true)
toggleFavorites(contacts, true)
if (activity.hasContactPermissions()) {
toggleFavorites(contacts, true)
}
}
fun removeFavorites(contacts: ArrayList<Contact>) {
toggleLocalFavorites(contacts, false)
toggleFavorites(contacts, false)
if (activity.hasContactPermissions()) {
toggleFavorites(contacts, false)
}
}
private fun toggleFavorites(contacts: ArrayList<Contact>, addToFavorites: Boolean) {