From ea6261c975719f546c2247e76246d0a1370fd2f2 Mon Sep 17 00:00:00 2001 From: davidoskky Date: Sat, 25 Mar 2023 21:58:36 +0100 Subject: [PATCH] Use the text itself as a color identifier --- .../readerforselfossv2/android/adapters/ItemCardAdapter.kt | 4 +++- .../readerforselfossv2/android/adapters/ItemListAdapter.kt | 4 +++- .../readerforselfossv2/android/adapters/SourcesListAdapter.kt | 4 +++- .../apps/readerforselfossv2/android/utils/CircleImageView.kt | 4 ++-- 4 files changed, 11 insertions(+), 5 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..b8ac3ac 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 @@ -80,7 +80,9 @@ class ItemCardAdapter( } if (itm.getIcon(repository.baseUrl).isEmpty()) { - binding.sourceImage.setBackgroundAndText(itm.title.getHtmlDecoded(), itm.title.getHtmlDecoded().toTextDrawableString()) + binding.sourceImage.setBackgroundAndText( + itm.sourcetitle.getHtmlDecoded().toTextDrawableString() + ) } 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..a3f7014 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 @@ -52,7 +52,9 @@ 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().toTextDrawableString() + ) } 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..089549c 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 @@ -46,7 +46,9 @@ 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().toTextDrawableString() + ) } 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..118dc43 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 @@ -46,9 +46,9 @@ 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)