Use CircleImageView instead of ContactBadge view in message list
This commit is contained in:
parent
7cc7d713d4
commit
86c3af8892
4 changed files with 12 additions and 21 deletions
|
@ -17,6 +17,7 @@ import android.view.View
|
|||
import android.view.View.OnClickListener
|
||||
import android.view.ViewGroup
|
||||
import android.widget.BaseAdapter
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.core.graphics.drawable.DrawableCompat
|
||||
import androidx.core.view.isVisible
|
||||
|
@ -24,7 +25,6 @@ import com.fsck.k9.FontSizes
|
|||
import com.fsck.k9.contacts.ContactPictureLoader
|
||||
import com.fsck.k9.controller.MessageReference
|
||||
import com.fsck.k9.mail.Address
|
||||
import com.fsck.k9.ui.ContactBadge
|
||||
import com.fsck.k9.ui.R
|
||||
import com.fsck.k9.ui.messagelist.MessageListAppearance
|
||||
import com.fsck.k9.ui.messagelist.MessageListItem
|
||||
|
@ -105,7 +105,7 @@ class MessageListAdapter internal constructor(
|
|||
|
||||
val holder = MessageViewHolder(view)
|
||||
|
||||
holder.contactBadge.isVisible = appearance.showContactPicture
|
||||
holder.contactPicture.isVisible = appearance.showContactPicture
|
||||
holder.chip.isVisible = appearance.showAccountChip
|
||||
|
||||
appearance.fontSizes.setViewTextSize(holder.subject, subjectViewFontSize)
|
||||
|
@ -148,8 +148,8 @@ class MessageListAdapter internal constructor(
|
|||
holder.flagged.isChecked = isStarred
|
||||
}
|
||||
holder.position = position
|
||||
if (holder.contactBadge.isVisible) {
|
||||
updateContactBadge(holder.contactBadge, counterPartyAddress)
|
||||
if (holder.contactPicture.isVisible) {
|
||||
setContactPicture(holder.contactPicture, counterPartyAddress)
|
||||
}
|
||||
setBackgroundColor(view, isSelected, isRead, isActive)
|
||||
updateWithThreadCount(holder, displayThreadCount)
|
||||
|
@ -223,19 +223,11 @@ class MessageListAdapter internal constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun updateContactBadge(contactBadge: ContactBadge, counterpartyAddress: Address?) {
|
||||
private fun setContactPicture(contactPictureView: ImageView, counterpartyAddress: Address?) {
|
||||
if (counterpartyAddress != null) {
|
||||
contactBadge.setContact(counterpartyAddress)
|
||||
/*
|
||||
* At least in Android 2.2 a different background + padding is used when no
|
||||
* email address is available. ListView reuses the views but ContactBadge
|
||||
* doesn't reset the padding, so we do it ourselves.
|
||||
*/
|
||||
contactBadge.setPadding(0, 0, 0, 0)
|
||||
contactsPictureLoader.setContactPicture(contactBadge, counterpartyAddress)
|
||||
contactsPictureLoader.setContactPicture(contactPictureView, counterpartyAddress)
|
||||
} else {
|
||||
contactBadge.assignContactUri(null)
|
||||
contactBadge.setImageResource(R.drawable.ic_contact_picture)
|
||||
contactPictureView.setImageResource(R.drawable.ic_contact_picture)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,13 +4,12 @@ import android.view.View
|
|||
import android.widget.CheckBox
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import com.fsck.k9.ui.ContactBadge
|
||||
import com.fsck.k9.ui.R
|
||||
|
||||
class MessageViewHolder(view: View) {
|
||||
var position = -1
|
||||
|
||||
val contactBadge: ContactBadge = view.findViewById(R.id.contact_badge)
|
||||
val contactPicture: ImageView = view.findViewById(R.id.contact_picture)
|
||||
val subject: TextView = view.findViewById(R.id.subject)
|
||||
val preview: TextView = view.findViewById(R.id.preview)
|
||||
val date: TextView = view.findViewById(R.id.date)
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
android:layout_gravity="center_vertical"
|
||||
>
|
||||
|
||||
<com.fsck.k9.ui.ContactBadge
|
||||
android:id="@+id/contact_badge"
|
||||
<de.hdodenhof.circleimageview.CircleImageView
|
||||
android:id="@+id/contact_picture"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginTop="4dip"
|
||||
android:layout_marginBottom="3dip"
|
||||
|
|
|
@ -7,6 +7,7 @@ import android.view.ContextThemeWrapper
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.CheckBox
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.core.view.isGone
|
||||
|
@ -19,7 +20,6 @@ import com.fsck.k9.RobolectricTest
|
|||
import com.fsck.k9.contacts.ContactPictureLoader
|
||||
import com.fsck.k9.mail.Address
|
||||
import com.fsck.k9.textString
|
||||
import com.fsck.k9.ui.ContactBadge
|
||||
import com.fsck.k9.ui.R
|
||||
import com.fsck.k9.ui.messagelist.MessageListAppearance
|
||||
import com.fsck.k9.ui.messagelist.MessageListItem
|
||||
|
@ -525,7 +525,7 @@ class MessageListAdapterTest : RobolectricTest() {
|
|||
|
||||
val View.accountChipView: View get() = findViewById(R.id.account_color_chip)
|
||||
val View.starView: CheckBox get() = findViewById(R.id.star)
|
||||
val View.contactPictureView: ContactBadge get() = findViewById(R.id.contact_badge)
|
||||
val View.contactPictureView: ImageView get() = findViewById(R.id.contact_picture)
|
||||
val View.threadCountView: TextView get() = findViewById(R.id.thread_count)
|
||||
val View.firstLineView: TextView get() = findViewById(R.id.subject)
|
||||
val View.secondLineView: TextView get() = findViewById(R.id.preview)
|
||||
|
|
Loading…
Reference in a new issue