fix #489, increase contact spacing with disabled avatars and numbers
This commit is contained in:
parent
093384f00e
commit
cfc97d9453
|
@ -43,9 +43,11 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
|
|||
private var textToHighlight = highlightText
|
||||
|
||||
var adjustedPrimaryColor = activity.getAdjustedPrimaryColor()
|
||||
var startNameWithSurname: Boolean
|
||||
var showContactThumbnails: Boolean
|
||||
var showPhoneNumbers: Boolean
|
||||
var startNameWithSurname = config.startNameWithSurname
|
||||
var showContactThumbnails = config.showContactThumbnails
|
||||
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 mediumPadding = activity.resources.getDimension(R.dimen.medium_margin).toInt()
|
||||
|
@ -54,9 +56,6 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
|
|||
init {
|
||||
setupDragListener(true)
|
||||
initDrawables()
|
||||
showContactThumbnails = config.showContactThumbnails
|
||||
showPhoneNumbers = config.showPhoneNumbers
|
||||
startNameWithSurname = config.startNameWithSurname
|
||||
}
|
||||
|
||||
override fun getActionMenuId() = R.menu.cab
|
||||
|
@ -109,10 +108,7 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
|
|||
|
||||
override fun onActionModeDestroyed() {}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val layout = if (showPhoneNumbers) R.layout.item_contact_with_number else R.layout.item_contact_without_number
|
||||
return createViewHolder(layout, parent)
|
||||
}
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(itemLayout, parent)
|
||||
|
||||
override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) {
|
||||
val contact = contactItems[position]
|
||||
|
@ -290,7 +286,11 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
|
|||
}
|
||||
|
||||
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) {
|
||||
val phoneNumberToUse = if (textToHighlight.isEmpty()) {
|
||||
|
|
|
@ -33,6 +33,7 @@ class GroupsAdapter(activity: SimpleActivity, var groups: ArrayList<Group>, val
|
|||
|
||||
var adjustedPrimaryColor = activity.getAdjustedPrimaryColor()
|
||||
var showContactThumbnails = activity.config.showContactThumbnails
|
||||
var showPhoneNumbers = activity.config.showPhoneNumbers
|
||||
|
||||
init {
|
||||
setupDragListener(true)
|
||||
|
@ -165,7 +166,12 @@ class GroupsAdapter(activity: SimpleActivity, var groups: ArrayList<Group>, val
|
|||
group_name.apply {
|
||||
setTextColor(textColor)
|
||||
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)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.simplemobiletools.contacts.pro.adapters
|
||||
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.util.SparseArray
|
||||
import android.view.View
|
||||
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.activities.SimpleActivity
|
||||
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.models.Contact
|
||||
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 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 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) {
|
||||
val eventType = contacts[position]
|
||||
itemViews.put(position, holder.bindView(eventType, contactDrawable, config, showContactThumbnails, smallPadding, bigPadding))
|
||||
val contact = contacts[position]
|
||||
itemViews.put(position, holder.bindView(contact))
|
||||
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) {
|
||||
fun bindView(contact: Contact, contactDrawable: Drawable, config: Config, showContactThumbnails: Boolean,
|
||||
smallPadding: Int, bigPadding: Int): View {
|
||||
fun bindView(contact: Contact): View {
|
||||
itemView.apply {
|
||||
contact_checkbox.beVisibleIf(allowPickMultiple)
|
||||
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.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) {
|
||||
val phoneNumberToUse = if (textToHighlight.isEmpty()) {
|
||||
|
|
Loading…
Reference in New Issue