Decode the title of sources containing special html characters (#326)

#325
This commit is contained in:
davidoskky 2021-01-07 21:22:01 +01:00 committed by GitHub
parent db124ab9de
commit 6fa8c901fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 19 additions and 11 deletions

View File

@ -604,7 +604,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
} else {
for (tag in maybeSources) {
val item = PrimaryDrawerItem()
.withName(tag.title)
.withName(tag.getTitleDecoded())
.withIdentifier(tag.id.toLong())
.withOnDrawerItemClickListener { _, _, _ ->
allItems = ArrayList()

View File

@ -90,13 +90,13 @@ class ItemCardAdapter(
}
if (itm.getIcon(c).isEmpty()) {
val color = generator.getColor(itm.sourcetitle)
val color = generator.getColor(itm.getSourceTitle())
val drawable =
TextDrawable
.builder()
.round()
.build(itm.sourcetitle.toTextDrawableString(c), color)
.build(itm.getSourceTitle().toTextDrawableString(c), color)
holder.mView.sourceImage.setImageDrawable(drawable)
} else {
c.circularBitmapDrawable(config, itm.getIcon(c), holder.mView.sourceImage)

View File

@ -81,13 +81,13 @@ class ItemListAdapter(
if (itm.getThumbnail(c).isEmpty()) {
if (itm.getIcon(c).isEmpty()) {
val color = generator.getColor(itm.sourcetitle)
val color = generator.getColor(itm.getSourceTitle())
val drawable =
TextDrawable
.builder()
.round()
.build(itm.sourcetitle.toTextDrawableString(c), color)
.build(itm.getSourceTitle().toTextDrawableString(c), color)
holder.mView.itemImage.setImageDrawable(drawable)
} else {

View File

@ -46,19 +46,19 @@ class SourcesListAdapter(
config = Config(c)
if (itm.getIcon(c).isEmpty()) {
val color = generator.getColor(itm.title)
val color = generator.getColor(itm.getTitleDecoded())
val drawable =
TextDrawable
.builder()
.round()
.build(itm.title.toTextDrawableString(c), color)
.build(itm.getTitleDecoded().toTextDrawableString(c), color)
holder.mView.itemImage.setImageDrawable(drawable)
} else {
c.circularBitmapDrawable(config, itm.getIcon(c), holder.mView.itemImage)
}
holder.mView.sourceTitle.text = itm.title
holder.mView.sourceTitle.text = itm.getTitleDecoded()
}
override fun getItemCount(): Int = items.size

View File

@ -64,6 +64,10 @@ data class Source(
}
return constructUrl(config, "favicons", icon)
}
fun getTitleDecoded(): String {
return Html.fromHtml(title).toString()
}
}
data class Item(
@ -167,6 +171,10 @@ data class Item(
return Html.fromHtml(title).toString()
}
fun getSourceTitle(): String {
return Html.fromHtml(sourcetitle).toString()
}
// TODO: maybe find a better way to handle these kind of urls
fun getLinkDecoded(): String {
var stringUrl: String

View File

@ -32,7 +32,7 @@ fun Item.sourceAndDateText(): String {
""
}
return this.sourcetitle + formattedDate
return this.getSourceTitle() + formattedDate
}
fun Item.toggleStar(): Item {

View File

@ -28,7 +28,7 @@ fun SourceEntity.toView(): Source =
fun Source.toEntity(): SourceEntity =
SourceEntity(
this.id,
this.title,
this.getTitleDecoded(),
this.tags.tags,
this.spout,
this.error,
@ -68,6 +68,6 @@ fun Item.toEntity(): ItemEntity =
this.thumbnail,
this.icon,
this.link,
this.sourcetitle,
this.getSourceTitle(),
this.tags.tags
)