-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6616 from thundernest/crypto_status
Message View Redesign: Display crypto status
- Loading branch information
Showing
10 changed files
with
256 additions
and
205 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
app/ui/legacy/src/main/java/com/fsck/k9/ui/messagedetails/CryptoStatusItem.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.fsck.k9.ui.messagedetails | ||
|
||
import android.content.res.ColorStateList | ||
import android.view.View | ||
import android.widget.ImageView | ||
import android.widget.TextView | ||
import com.fsck.k9.ui.R | ||
import com.fsck.k9.ui.resolveColorAttribute | ||
import com.mikepenz.fastadapter.FastAdapter | ||
import com.mikepenz.fastadapter.items.AbstractItem | ||
|
||
internal class CryptoStatusItem(val cryptoDetails: CryptoDetails) : AbstractItem<CryptoStatusItem.ViewHolder>() { | ||
override val type = R.id.message_details_crypto_status | ||
override val layoutRes = R.layout.message_details_crypto_status_item | ||
|
||
override fun getViewHolder(v: View) = ViewHolder(v) | ||
|
||
class ViewHolder(view: View) : FastAdapter.ViewHolder<CryptoStatusItem>(view) { | ||
private val titleTextView = view.findViewById<TextView>(R.id.crypto_status_title) | ||
private val descriptionTextView = view.findViewById<TextView>(R.id.crypto_status_description) | ||
private val imageView = view.findViewById<ImageView>(R.id.crypto_status_icon) | ||
private val originalBackground = view.background | ||
|
||
override fun bindView(item: CryptoStatusItem, payloads: List<Any>) { | ||
val context = itemView.context | ||
val cryptoDetails = item.cryptoDetails | ||
val cryptoStatus = cryptoDetails.cryptoStatus | ||
|
||
imageView.setImageResource(cryptoStatus.statusIconRes) | ||
val tintColor = context.theme.resolveColorAttribute(cryptoStatus.colorAttr) | ||
imageView.imageTintList = ColorStateList.valueOf(tintColor) | ||
|
||
cryptoStatus.titleTextRes?.let { stringResId -> | ||
titleTextView.text = context.getString(stringResId) | ||
} | ||
cryptoStatus.descriptionTextRes?.let { stringResId -> | ||
descriptionTextView.text = context.getString(stringResId) | ||
} | ||
|
||
if (!cryptoDetails.isClickable) { | ||
itemView.background = null | ||
} | ||
} | ||
|
||
override fun unbindView(item: CryptoStatusItem) { | ||
imageView.setImageDrawable(null) | ||
titleTextView.text = null | ||
descriptionTextView.text = null | ||
itemView.background = originalBackground | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.