textDrawable #136

Merged
AmineB merged 8 commits from davidoskky/ReaderForSelfoss-multiplatform:textDrawable into master 2023-03-26 11:12:03 +00:00
4 changed files with 7 additions and 9 deletions
Showing only changes of commit 10ab67d071 - Show all commits

View File

@ -9,7 +9,6 @@ import android.widget.ImageView.ScaleType
import androidx.recyclerview.widget.RecyclerView
import bou.amine.apps.readerforselfossv2.android.R
import bou.amine.apps.readerforselfossv2.android.databinding.CardItemBinding
import bou.amine.apps.readerforselfossv2.android.model.toTextDrawableString
import bou.amine.apps.readerforselfossv2.android.utils.LinkOnTouchListener
import bou.amine.apps.readerforselfossv2.android.utils.glide.bitmapCenterCrop
import bou.amine.apps.readerforselfossv2.android.utils.glide.circularDrawable
@ -80,7 +79,7 @@ class ItemCardAdapter(
}
if (itm.getIcon(repository.baseUrl).isEmpty()) {
binding.sourceImage.setBackgroundAndText(itm.title.getHtmlDecoded(), itm.title.getHtmlDecoded().toTextDrawableString())
binding.sourceImage.setBackgroundAndText(itm.sourcetitle.getHtmlDecoded())
} else {
AmineB marked this conversation as resolved Outdated

You could call setBackgroundAndText with a single parameter, and call toTextDrawableString inside.

Also, here, there is an issue, it should be itm.sourcetitle that should be used.

                binding.sourceImage.setBackgroundAndText(itm.sourcetitle.getHtmlDecoded()) 
You could call `setBackgroundAndText` with a single parameter, and call `toTextDrawableString` inside. Also, here, there is an issue, it should be `itm.sourcetitle` that should be used. ``` binding.sourceImage.setBackgroundAndText(itm.sourcetitle.getHtmlDecoded()) ```
c.circularDrawable(itm.getIcon(repository.baseUrl), binding.sourceImage)
}

View File

@ -7,7 +7,6 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import bou.amine.apps.readerforselfossv2.android.R
import bou.amine.apps.readerforselfossv2.android.databinding.ListItemBinding
import bou.amine.apps.readerforselfossv2.android.model.toTextDrawableString
import bou.amine.apps.readerforselfossv2.android.utils.LinkOnTouchListener
import bou.amine.apps.readerforselfossv2.android.utils.glide.circularDrawable
import bou.amine.apps.readerforselfossv2.android.utils.openItemUrl
@ -52,7 +51,7 @@ class ItemListAdapter(
if (itm.getThumbnail(repository.baseUrl).isEmpty()) {
if (itm.getIcon(repository.baseUrl).isEmpty()) {
binding.itemImage.setBackgroundAndText(itm.title.getHtmlDecoded(), itm.title.getHtmlDecoded().toTextDrawableString())
binding.itemImage.setBackgroundAndText(itm.sourcetitle.getHtmlDecoded())
} else {
AmineB marked this conversation as resolved Outdated

Same as before:

                binding.itemImage.setBackgroundAndText(itm.sourcetitle.getHtmlDecoded()) 
Same as before: ``` binding.itemImage.setBackgroundAndText(itm.sourcetitle.getHtmlDecoded()) ```
c.circularDrawable(itm.getIcon(repository.baseUrl), binding.itemImage)
}

View File

@ -13,7 +13,6 @@ import androidx.recyclerview.widget.RecyclerView
import bou.amine.apps.readerforselfossv2.android.R
import bou.amine.apps.readerforselfossv2.android.UpsertSourceActivity
import bou.amine.apps.readerforselfossv2.android.databinding.SourceListItemBinding
import bou.amine.apps.readerforselfossv2.android.model.toTextDrawableString
import bou.amine.apps.readerforselfossv2.android.utils.glide.circularDrawable
import bou.amine.apps.readerforselfossv2.model.SelfossModel
import bou.amine.apps.readerforselfossv2.repository.Repository
@ -46,7 +45,7 @@ class SourcesListAdapter(
val itm = items[position]
if (itm.getIcon(repository.baseUrl).isEmpty()) {
binding.itemImage.setBackgroundAndText(itm.title.getHtmlDecoded(), itm.title.getHtmlDecoded().toTextDrawableString())
binding.itemImage.setBackgroundAndText(itm.title.getHtmlDecoded())
} else {
c.circularDrawable(itm.getIcon(repository.baseUrl), binding.itemImage)
}

View File

@ -8,6 +8,7 @@ import android.view.View
import android.widget.RelativeLayout
import android.widget.TextView
import bou.amine.apps.readerforselfossv2.android.R
import bou.amine.apps.readerforselfossv2.android.model.toTextDrawableString
import com.google.android.material.imageview.ShapeableImageView
import kotlin.math.abs
@ -46,13 +47,13 @@ class CircleImageView @JvmOverloads constructor(
textView = view.findViewById(R.id.circleText)
}
fun setBackgroundAndText(colorIdentifier: String, text: String) {
fun setBackgroundAndText(text: String) {
val circleDrawable = GradientDrawable()
val color = colorFromIdentifier(colorIdentifier)
val color = colorFromIdentifier(text)
circleDrawable.setColor(color)
imageView.setImageDrawable(circleDrawable)
textView.text = text
textView.text = text.toTextDrawableString()
}
private fun colorFromIdentifier(key: String): Int {