fix: handle three characters lenght hexcode colors.
This commit is contained in:
parent
390c2d0cf3
commit
14ff4dbd05
@ -17,6 +17,7 @@ import bou.amine.apps.readerforselfossv2.android.R
|
||||
import bou.amine.apps.readerforselfossv2.android.databinding.FilterFragmentBinding
|
||||
import bou.amine.apps.readerforselfossv2.android.sendSilentlyWithAcraWithName
|
||||
import bou.amine.apps.readerforselfossv2.repository.Repository
|
||||
import bou.amine.apps.readerforselfossv2.utils.getColorHexCode
|
||||
import bou.amine.apps.readerforselfossv2.utils.getHtmlDecoded
|
||||
import bou.amine.apps.readerforselfossv2.utils.getIcon
|
||||
import com.bumptech.glide.Glide
|
||||
@ -147,9 +148,9 @@ class FilterSheetFragment : BottomSheetDialogFragment(), DIAware {
|
||||
val gd = GradientDrawable()
|
||||
val gdColor =
|
||||
try {
|
||||
Color.parseColor(tag.color)
|
||||
Color.parseColor(tag.getColorHexCode())
|
||||
} catch (e: IllegalArgumentException) {
|
||||
e.sendSilentlyWithAcraWithName("color issue " + tag.color)
|
||||
e.sendSilentlyWithAcraWithName("color issue " + tag.color + " / " + tag.getColorHexCode())
|
||||
resources.getColor(R.color.colorPrimary)
|
||||
}
|
||||
gd.setColor(gdColor)
|
||||
|
@ -73,3 +73,13 @@ fun SelfossModel.Item.toEntity(): ITEM =
|
||||
this.tags.joinToString(","),
|
||||
this.author,
|
||||
)
|
||||
|
||||
fun SelfossModel.Tag.getColorHexCode(): String =
|
||||
if (this.color.length == 4) { // #000
|
||||
val char1 = this.color.get(1)
|
||||
val char2 = this.color.get(2)
|
||||
val char3 = this.color.get(3)
|
||||
"#$char1$char1$char2$char2$char3$char3"
|
||||
} else {
|
||||
this.color
|
||||
}
|
Loading…
Reference in New Issue
Block a user