fix #489, increase contact spacing with disabled avatars and numbers

This commit is contained in:
tibbi 2020-01-19 20:54:21 +01:00
parent 093384f00e
commit cfc97d9453
3 changed files with 28 additions and 20 deletions

View File

@ -43,9 +43,11 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
private var textToHighlight = highlightText private var textToHighlight = highlightText
var adjustedPrimaryColor = activity.getAdjustedPrimaryColor() var adjustedPrimaryColor = activity.getAdjustedPrimaryColor()
var startNameWithSurname: Boolean var startNameWithSurname = config.startNameWithSurname
var showContactThumbnails: Boolean var showContactThumbnails = config.showContactThumbnails
var showPhoneNumbers: Boolean var showPhoneNumbers = config.showPhoneNumbers
private val itemLayout = if (showPhoneNumbers) R.layout.item_contact_with_number else R.layout.item_contact_without_number
private var smallPadding = activity.resources.getDimension(R.dimen.small_margin).toInt() private var smallPadding = activity.resources.getDimension(R.dimen.small_margin).toInt()
private var mediumPadding = activity.resources.getDimension(R.dimen.medium_margin).toInt() private var mediumPadding = activity.resources.getDimension(R.dimen.medium_margin).toInt()
@ -54,9 +56,6 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
init { init {
setupDragListener(true) setupDragListener(true)
initDrawables() initDrawables()
showContactThumbnails = config.showContactThumbnails
showPhoneNumbers = config.showPhoneNumbers
startNameWithSurname = config.startNameWithSurname
} }
override fun getActionMenuId() = R.menu.cab override fun getActionMenuId() = R.menu.cab
@ -109,10 +108,7 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
override fun onActionModeDestroyed() {} override fun onActionModeDestroyed() {}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(itemLayout, parent)
val layout = if (showPhoneNumbers) R.layout.item_contact_with_number else R.layout.item_contact_without_number
return createViewHolder(layout, parent)
}
override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) { override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) {
val contact = contactItems[position] val contact = contactItems[position]
@ -290,7 +286,11 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
} }
contact_name.setTextColor(textColor) contact_name.setTextColor(textColor)
contact_name.setPadding(if (showContactThumbnails) smallPadding else bigPadding, smallPadding, smallPadding, 0) if (!showContactThumbnails && !showPhoneNumbers) {
contact_name.setPadding(bigPadding, bigPadding, bigPadding, bigPadding)
} else {
contact_name.setPadding(if (showContactThumbnails) smallPadding else bigPadding, smallPadding, smallPadding, 0)
}
if (contact_number != null) { if (contact_number != null) {
val phoneNumberToUse = if (textToHighlight.isEmpty()) { val phoneNumberToUse = if (textToHighlight.isEmpty()) {

View File

@ -33,6 +33,7 @@ class GroupsAdapter(activity: SimpleActivity, var groups: ArrayList<Group>, val
var adjustedPrimaryColor = activity.getAdjustedPrimaryColor() var adjustedPrimaryColor = activity.getAdjustedPrimaryColor()
var showContactThumbnails = activity.config.showContactThumbnails var showContactThumbnails = activity.config.showContactThumbnails
var showPhoneNumbers = activity.config.showPhoneNumbers
init { init {
setupDragListener(true) setupDragListener(true)
@ -165,7 +166,12 @@ class GroupsAdapter(activity: SimpleActivity, var groups: ArrayList<Group>, val
group_name.apply { group_name.apply {
setTextColor(textColor) setTextColor(textColor)
text = groupTitle text = groupTitle
setPadding(if (showContactThumbnails) smallPadding else bigPadding, smallPadding, smallPadding, 0)
if (showContactThumbnails) {
setPadding(smallPadding, bigPadding, bigPadding, bigPadding)
} else {
setPadding(bigPadding, bigPadding, bigPadding, bigPadding)
}
} }
group_tmb.beVisibleIf(showContactThumbnails) group_tmb.beVisibleIf(showContactThumbnails)

View File

@ -1,6 +1,5 @@
package com.simplemobiletools.contacts.pro.adapters package com.simplemobiletools.contacts.pro.adapters
import android.graphics.drawable.Drawable
import android.util.SparseArray import android.util.SparseArray
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -19,7 +18,6 @@ import com.simplemobiletools.commons.views.MyRecyclerView
import com.simplemobiletools.contacts.pro.R import com.simplemobiletools.contacts.pro.R
import com.simplemobiletools.contacts.pro.activities.SimpleActivity import com.simplemobiletools.contacts.pro.activities.SimpleActivity
import com.simplemobiletools.contacts.pro.extensions.config import com.simplemobiletools.contacts.pro.extensions.config
import com.simplemobiletools.contacts.pro.helpers.Config
import com.simplemobiletools.contacts.pro.helpers.highlightTextFromNumbers import com.simplemobiletools.contacts.pro.helpers.highlightTextFromNumbers
import com.simplemobiletools.contacts.pro.models.Contact import com.simplemobiletools.contacts.pro.models.Contact
import kotlinx.android.synthetic.main.item_add_favorite_with_number.view.* import kotlinx.android.synthetic.main.item_add_favorite_with_number.view.*
@ -36,7 +34,8 @@ class SelectContactsAdapter(val activity: SimpleActivity, var contacts: ArrayLis
private val contactDrawable = activity.resources.getColoredDrawableWithColor(R.drawable.ic_person_vector, textColor) private val contactDrawable = activity.resources.getColoredDrawableWithColor(R.drawable.ic_person_vector, textColor)
private val showContactThumbnails = config.showContactThumbnails private val showContactThumbnails = config.showContactThumbnails
private val itemLayout = if (config.showPhoneNumbers) R.layout.item_add_favorite_with_number else R.layout.item_add_favorite_without_number private val showPhoneNumbers = config.showPhoneNumbers
private val itemLayout = if (showPhoneNumbers) R.layout.item_add_favorite_with_number else R.layout.item_add_favorite_without_number
private var textToHighlight = "" private var textToHighlight = ""
private var smallPadding = activity.resources.getDimension(R.dimen.small_margin).toInt() private var smallPadding = activity.resources.getDimension(R.dimen.small_margin).toInt()
@ -79,8 +78,8 @@ class SelectContactsAdapter(val activity: SimpleActivity, var contacts: ArrayLis
} }
override fun onBindViewHolder(holder: ViewHolder, position: Int) { override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val eventType = contacts[position] val contact = contacts[position]
itemViews.put(position, holder.bindView(eventType, contactDrawable, config, showContactThumbnails, smallPadding, bigPadding)) itemViews.put(position, holder.bindView(contact))
toggleItemSelection(selectedPositions.contains(position), position) toggleItemSelection(selectedPositions.contains(position), position)
} }
@ -106,8 +105,7 @@ class SelectContactsAdapter(val activity: SimpleActivity, var contacts: ArrayLis
} }
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
fun bindView(contact: Contact, contactDrawable: Drawable, config: Config, showContactThumbnails: Boolean, fun bindView(contact: Contact): View {
smallPadding: Int, bigPadding: Int): View {
itemView.apply { itemView.apply {
contact_checkbox.beVisibleIf(allowPickMultiple) contact_checkbox.beVisibleIf(allowPickMultiple)
contact_checkbox.setColors(config.textColor, context.getAdjustedPrimaryColor(), config.backgroundColor) contact_checkbox.setColors(config.textColor, context.getAdjustedPrimaryColor(), config.backgroundColor)
@ -123,7 +121,11 @@ class SelectContactsAdapter(val activity: SimpleActivity, var contacts: ArrayLis
} }
contact_name.setTextColor(textColor) contact_name.setTextColor(textColor)
contact_name.setPadding(if (showContactThumbnails) smallPadding else bigPadding, smallPadding, smallPadding, 0) if (!showContactThumbnails && !showPhoneNumbers) {
contact_name.setPadding(bigPadding, bigPadding, bigPadding, bigPadding)
} else {
contact_name.setPadding(if (showContactThumbnails) smallPadding else bigPadding, smallPadding, smallPadding, 0)
}
if (contact_number != null) { if (contact_number != null) {
val phoneNumberToUse = if (textToHighlight.isEmpty()) { val phoneNumberToUse = if (textToHighlight.isEmpty()) {