From a5af4f888035a269158a7cd30eefa7f311068f46 Mon Sep 17 00:00:00 2001 From: davidoskky Date: Sat, 25 Mar 2023 15:28:51 +0100 Subject: [PATCH 1/8] Add a new layout to handle text on top of a round background --- .../android/utils/CircleImageView.kt | 61 +++++++++++++++++++ .../src/main/res/layout/circle_image_view.xml | 26 ++++++++ androidApp/src/main/res/values/styles.xml | 6 ++ 3 files changed, 93 insertions(+) create mode 100644 androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/CircleImageView.kt create mode 100644 androidApp/src/main/res/layout/circle_image_view.xml diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/CircleImageView.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/CircleImageView.kt new file mode 100644 index 0000000..2ebd1d4 --- /dev/null +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/CircleImageView.kt @@ -0,0 +1,61 @@ +package bou.amine.apps.readerforselfossv2.android.utils + +import android.content.Context +import android.graphics.drawable.GradientDrawable +import android.util.AttributeSet +import android.view.LayoutInflater +import android.view.View +import android.widget.RelativeLayout +import android.widget.TextView +import bou.amine.apps.readerforselfossv2.android.R +import com.google.android.material.imageview.ShapeableImageView +import kotlin.math.abs + +class CircleImageView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : RelativeLayout(context, attrs, defStyleAttr) { + val view: View + val imageView: ShapeableImageView + val textView: TextView + + private val colorScheme = listOf( + -0x1a8c8d, + -0xf9d6e, + -0x459738, + -0x6a8a33, + -0x867935, + -0x9b4a0a, + -0xb03c09, + -0xb22f1f, + -0xb24954, + -0x7e387c, + -0x512a7f, + -0x759b, + -0x2b1ea9, + -0x2ab1, + -0x48b3, + -0x5e7781, + -0x6f5b52 + ) + + init { + view = LayoutInflater.from(context).inflate(R.layout.circle_image_view, this, true) + imageView = view.findViewById(R.id.circleImage) + textView = view.findViewById(R.id.circleText) + } + + fun setBackgroundAndText(colorIdentifier: String, text: String) { + val circleDrawable = GradientDrawable() + val color = colorFromIdentifier(colorIdentifier) + circleDrawable.setColor(color) + imageView.setImageDrawable(circleDrawable) + + textView.text = text + } + + private fun colorFromIdentifier(key: String): Int { + return colorScheme[abs(key.hashCode()) % colorScheme.size] + } +} \ No newline at end of file diff --git a/androidApp/src/main/res/layout/circle_image_view.xml b/androidApp/src/main/res/layout/circle_image_view.xml new file mode 100644 index 0000000..040361b --- /dev/null +++ b/androidApp/src/main/res/layout/circle_image_view.xml @@ -0,0 +1,26 @@ + + + + + + + diff --git a/androidApp/src/main/res/values/styles.xml b/androidApp/src/main/res/values/styles.xml index 9ba9049..166644e 100644 --- a/androidApp/src/main/res/values/styles.xml +++ b/androidApp/src/main/res/values/styles.xml @@ -32,4 +32,10 @@ @null true + + + -- 2.34.1 From 452d13c48cb15c712e860d98e7c7a09fcde490c1 Mon Sep 17 00:00:00 2001 From: davidoskky Date: Sat, 25 Mar 2023 16:31:01 +0100 Subject: [PATCH 2/8] Operate glide on the circular image view --- .../readerforselfossv2/android/utils/glide/GlideUtils.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/glide/GlideUtils.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/glide/GlideUtils.kt index 5d91e62..979daf7 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/glide/GlideUtils.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/glide/GlideUtils.kt @@ -4,6 +4,7 @@ import android.content.Context import android.graphics.Bitmap import android.widget.ImageView import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory +import bou.amine.apps.readerforselfossv2.android.utils.CircleImageView import com.bumptech.glide.Glide import com.bumptech.glide.request.RequestOptions import com.bumptech.glide.request.target.BitmapImageViewTarget @@ -34,6 +35,14 @@ fun Context.circularBitmapDrawable(url: String, iv: ImageView) = } }) +fun Context.circularDrawable(url: String, view: CircleImageView) { + view.textView.text ="" + + Glide.with(this) + .load(url) + .into(view.imageView) +} + fun getBitmapInputStream(bitmap:Bitmap,compressFormat: Bitmap.CompressFormat): InputStream { val byteArrayOutputStream = ByteArrayOutputStream() bitmap.compress(compressFormat, 80, byteArrayOutputStream) -- 2.34.1 From 6ef6743527d6586613618a426cfbf22eae1dbccc Mon Sep 17 00:00:00 2001 From: davidoskky Date: Sat, 25 Mar 2023 16:31:49 +0100 Subject: [PATCH 3/8] Use the circular image view in the card adapter --- .../android/adapters/ItemCardAdapter.kt | 16 +++------------- androidApp/src/main/res/layout/card_item.xml | 2 +- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemCardAdapter.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemCardAdapter.kt index f21bd77..3e98d9c 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemCardAdapter.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemCardAdapter.kt @@ -12,7 +12,7 @@ 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.circularBitmapDrawable +import bou.amine.apps.readerforselfossv2.android.utils.glide.circularDrawable import bou.amine.apps.readerforselfossv2.android.utils.openInBrowserAsNewTask import bou.amine.apps.readerforselfossv2.android.utils.openItemUrl import bou.amine.apps.readerforselfossv2.android.utils.shareLink @@ -22,8 +22,6 @@ import bou.amine.apps.readerforselfossv2.service.AppSettingsService import bou.amine.apps.readerforselfossv2.utils.getHtmlDecoded import bou.amine.apps.readerforselfossv2.utils.getIcon import bou.amine.apps.readerforselfossv2.utils.getThumbnail -import com.amulyakhare.textdrawable.TextDrawable -import com.amulyakhare.textdrawable.util.ColorGenerator import com.bumptech.glide.Glide import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -38,7 +36,6 @@ class ItemCardAdapter( override val updateItems: (ArrayList) -> Unit ) : ItemsAdapter() { private val c: Context = app.baseContext - private val generator: ColorGenerator = ColorGenerator.MATERIAL private val imageMaxHeight: Int = c.resources.getDimension(R.dimen.card_image_max_height).toInt() @@ -83,16 +80,9 @@ class ItemCardAdapter( } if (itm.getIcon(repository.baseUrl).isEmpty()) { - val color = generator.getColor(itm.title.getHtmlDecoded()) - - val drawable = - TextDrawable - .builder() - .round() - .build(itm.title.getHtmlDecoded().toTextDrawableString(), color) - binding.sourceImage.setImageDrawable(drawable) + binding.sourceImage.setBackgroundAndText(itm.title.getHtmlDecoded(), itm.title.getHtmlDecoded().toTextDrawableString()) } else { - c.circularBitmapDrawable(itm.getIcon(repository.baseUrl), binding.sourceImage) + c.circularDrawable(itm.getIcon(repository.baseUrl), binding.sourceImage) } } } diff --git a/androidApp/src/main/res/layout/card_item.xml b/androidApp/src/main/res/layout/card_item.xml index 329b68e..b153220 100644 --- a/androidApp/src/main/res/layout/card_item.xml +++ b/androidApp/src/main/res/layout/card_item.xml @@ -39,7 +39,7 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/itemImage"> - Date: Sat, 25 Mar 2023 16:34:38 +0100 Subject: [PATCH 4/8] Use the circular image view in the Source list --- .../android/adapters/SourcesListAdapter.kt | 18 ++++-------------- .../src/main/res/layout/source_list_item.xml | 2 +- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/SourcesListAdapter.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/SourcesListAdapter.kt index 2eba4c1..8315eb6 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/SourcesListAdapter.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/SourcesListAdapter.kt @@ -10,17 +10,15 @@ import android.widget.Button import android.widget.Toast import androidx.constraintlayout.widget.ConstraintLayout import androidx.recyclerview.widget.RecyclerView -import bou.amine.apps.readerforselfossv2.android.UpsertSourceActivity 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.circularBitmapDrawable +import bou.amine.apps.readerforselfossv2.android.utils.glide.circularDrawable import bou.amine.apps.readerforselfossv2.model.SelfossModel import bou.amine.apps.readerforselfossv2.repository.Repository import bou.amine.apps.readerforselfossv2.utils.getHtmlDecoded import bou.amine.apps.readerforselfossv2.utils.getIcon -import com.amulyakhare.textdrawable.TextDrawable -import com.amulyakhare.textdrawable.util.ColorGenerator import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -34,7 +32,6 @@ class SourcesListAdapter( private val items: ArrayList ) : RecyclerView.Adapter(), DIAware { private val c: Context = app.baseContext - private val generator: ColorGenerator = ColorGenerator.MATERIAL private lateinit var binding: SourceListItemBinding override val di: DI by closestDI(app) @@ -49,16 +46,9 @@ class SourcesListAdapter( val itm = items[position] if (itm.getIcon(repository.baseUrl).isEmpty()) { - val color = generator.getColor(itm.title.getHtmlDecoded()) - - val drawable = - TextDrawable - .builder() - .round() - .build(itm.title.getHtmlDecoded().toTextDrawableString(), color) - binding.itemImage.setImageDrawable(drawable) + binding.itemImage.setBackgroundAndText(itm.title.getHtmlDecoded(), itm.title.getHtmlDecoded().toTextDrawableString()) } else { - c.circularBitmapDrawable(itm.getIcon(repository.baseUrl), binding.itemImage) + c.circularDrawable(itm.getIcon(repository.baseUrl), binding.itemImage) } if (!itm.error.isNullOrBlank()) { diff --git a/androidApp/src/main/res/layout/source_list_item.xml b/androidApp/src/main/res/layout/source_list_item.xml index d924c01..9ea0cfa 100644 --- a/androidApp/src/main/res/layout/source_list_item.xml +++ b/androidApp/src/main/res/layout/source_list_item.xml @@ -25,7 +25,7 @@ app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.0" /> - Date: Sat, 25 Mar 2023 16:37:37 +0100 Subject: [PATCH 5/8] Use the circular image view in the item list --- .../android/adapters/ItemListAdapter.kt | 20 ++++--------------- androidApp/src/main/res/layout/list_item.xml | 2 +- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemListAdapter.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemListAdapter.kt index bbd53c2..1cbe9ba 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemListAdapter.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemListAdapter.kt @@ -9,8 +9,7 @@ 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.bitmapCenterCrop -import bou.amine.apps.readerforselfossv2.android.utils.glide.circularBitmapDrawable +import bou.amine.apps.readerforselfossv2.android.utils.glide.circularDrawable import bou.amine.apps.readerforselfossv2.android.utils.openItemUrl import bou.amine.apps.readerforselfossv2.model.SelfossModel import bou.amine.apps.readerforselfossv2.repository.Repository @@ -18,8 +17,6 @@ import bou.amine.apps.readerforselfossv2.service.AppSettingsService import bou.amine.apps.readerforselfossv2.utils.getHtmlDecoded import bou.amine.apps.readerforselfossv2.utils.getIcon import bou.amine.apps.readerforselfossv2.utils.getThumbnail -import com.amulyakhare.textdrawable.TextDrawable -import com.amulyakhare.textdrawable.util.ColorGenerator import org.kodein.di.DI import org.kodein.di.android.closestDI import org.kodein.di.instance @@ -29,7 +26,6 @@ class ItemListAdapter( override var items: ArrayList, override val updateItems: (ArrayList) -> Unit ) : ItemsAdapter() { - private val generator: ColorGenerator = ColorGenerator.MATERIAL private val c: Context = app.baseContext override val di: DI by closestDI(app) @@ -56,20 +52,12 @@ class ItemListAdapter( if (itm.getThumbnail(repository.baseUrl).isEmpty()) { if (itm.getIcon(repository.baseUrl).isEmpty()) { - val color = generator.getColor(itm.title.getHtmlDecoded()) - - val drawable = - TextDrawable - .builder() - .round() - .build(itm.title.getHtmlDecoded().toTextDrawableString(), color) - - binding.itemImage.setImageDrawable(drawable) + binding.itemImage.setBackgroundAndText(itm.title.getHtmlDecoded(), itm.title.getHtmlDecoded().toTextDrawableString()) } else { - c.circularBitmapDrawable(itm.getIcon(repository.baseUrl), binding.itemImage) + c.circularDrawable(itm.getIcon(repository.baseUrl), binding.itemImage) } } else { - c.bitmapCenterCrop(itm.getThumbnail(repository.baseUrl), binding.itemImage) + c.circularDrawable(itm.getThumbnail(repository.baseUrl), binding.itemImage) } } } diff --git a/androidApp/src/main/res/layout/list_item.xml b/androidApp/src/main/res/layout/list_item.xml index 8e36b3b..9b66604 100644 --- a/androidApp/src/main/res/layout/list_item.xml +++ b/androidApp/src/main/res/layout/list_item.xml @@ -5,7 +5,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - Date: Sat, 25 Mar 2023 16:37:59 +0100 Subject: [PATCH 6/8] Remove unused dependency --- androidApp/build.gradle.kts | 1 - 1 file changed, 1 deletion(-) diff --git a/androidApp/build.gradle.kts b/androidApp/build.gradle.kts index 40983fb..2435ea6 100644 --- a/androidApp/build.gradle.kts +++ b/androidApp/build.gradle.kts @@ -142,7 +142,6 @@ dependencies { // Material-ish things implementation("com.ashokvarma.android:bottom-navigation-bar:2.2.0") - implementation("com.amulyakhare:com.amulyakhare.textdrawable:1.0.1") // glide kapt("com.github.bumptech.glide:compiler:4.15.0") -- 2.34.1 From 1ad529067d68608240aa246ff0a46edd8a0f5e43 Mon Sep 17 00:00:00 2001 From: davidoskky Date: Sat, 25 Mar 2023 16:42:04 +0100 Subject: [PATCH 7/8] Remove unused function --- .../android/utils/glide/GlideUtils.kt | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/glide/GlideUtils.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/glide/GlideUtils.kt index 979daf7..ead2bec 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/glide/GlideUtils.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/glide/GlideUtils.kt @@ -3,11 +3,9 @@ package bou.amine.apps.readerforselfossv2.android.utils.glide import android.content.Context import android.graphics.Bitmap import android.widget.ImageView -import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory import bou.amine.apps.readerforselfossv2.android.utils.CircleImageView import com.bumptech.glide.Glide import com.bumptech.glide.request.RequestOptions -import com.bumptech.glide.request.target.BitmapImageViewTarget import java.io.ByteArrayInputStream import java.io.ByteArrayOutputStream import java.io.InputStream @@ -19,22 +17,6 @@ fun Context.bitmapCenterCrop(url: String, iv: ImageView) = .apply(RequestOptions.centerCropTransform()) .into(iv) -fun Context.circularBitmapDrawable(url: String, iv: ImageView) = - Glide.with(this) - .asBitmap() - .load(url) - .apply(RequestOptions.centerCropTransform()) - .into(object : BitmapImageViewTarget(iv) { - override fun setResource(resource: Bitmap?) { - val circularBitmapDrawable = RoundedBitmapDrawableFactory.create( - resources, - resource - ) - circularBitmapDrawable.isCircular = true - iv.setImageDrawable(circularBitmapDrawable) - } - }) - fun Context.circularDrawable(url: String, view: CircleImageView) { view.textView.text ="" -- 2.34.1 From 10ab67d071b85e7f7555fa0f32248809ea871608 Mon Sep 17 00:00:00 2001 From: davidoskky Date: Sat, 25 Mar 2023 21:58:36 +0100 Subject: [PATCH 8/8] CircleImageView: directly transform the text into appropriate Drawable String --- .../readerforselfossv2/android/adapters/ItemCardAdapter.kt | 3 +-- .../readerforselfossv2/android/adapters/ItemListAdapter.kt | 3 +-- .../android/adapters/SourcesListAdapter.kt | 3 +-- .../readerforselfossv2/android/utils/CircleImageView.kt | 7 ++++--- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemCardAdapter.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemCardAdapter.kt index 3e98d9c..11f6f62 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemCardAdapter.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemCardAdapter.kt @@ -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 { c.circularDrawable(itm.getIcon(repository.baseUrl), binding.sourceImage) } diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemListAdapter.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemListAdapter.kt index 1cbe9ba..c557b10 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemListAdapter.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemListAdapter.kt @@ -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 { c.circularDrawable(itm.getIcon(repository.baseUrl), binding.itemImage) } diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/SourcesListAdapter.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/SourcesListAdapter.kt index 8315eb6..731ec51 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/SourcesListAdapter.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/SourcesListAdapter.kt @@ -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) } diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/CircleImageView.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/CircleImageView.kt index 2ebd1d4..afe81ce 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/CircleImageView.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/CircleImageView.kt @@ -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 { -- 2.34.1