Decode the title of sources containing special html characters (#326)
#325
This commit is contained in:
parent
db124ab9de
commit
6fa8c901fc
@ -604,7 +604,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
|||||||
} else {
|
} else {
|
||||||
for (tag in maybeSources) {
|
for (tag in maybeSources) {
|
||||||
val item = PrimaryDrawerItem()
|
val item = PrimaryDrawerItem()
|
||||||
.withName(tag.title)
|
.withName(tag.getTitleDecoded())
|
||||||
.withIdentifier(tag.id.toLong())
|
.withIdentifier(tag.id.toLong())
|
||||||
.withOnDrawerItemClickListener { _, _, _ ->
|
.withOnDrawerItemClickListener { _, _, _ ->
|
||||||
allItems = ArrayList()
|
allItems = ArrayList()
|
||||||
|
@ -90,13 +90,13 @@ class ItemCardAdapter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (itm.getIcon(c).isEmpty()) {
|
if (itm.getIcon(c).isEmpty()) {
|
||||||
val color = generator.getColor(itm.sourcetitle)
|
val color = generator.getColor(itm.getSourceTitle())
|
||||||
|
|
||||||
val drawable =
|
val drawable =
|
||||||
TextDrawable
|
TextDrawable
|
||||||
.builder()
|
.builder()
|
||||||
.round()
|
.round()
|
||||||
.build(itm.sourcetitle.toTextDrawableString(c), color)
|
.build(itm.getSourceTitle().toTextDrawableString(c), color)
|
||||||
holder.mView.sourceImage.setImageDrawable(drawable)
|
holder.mView.sourceImage.setImageDrawable(drawable)
|
||||||
} else {
|
} else {
|
||||||
c.circularBitmapDrawable(config, itm.getIcon(c), holder.mView.sourceImage)
|
c.circularBitmapDrawable(config, itm.getIcon(c), holder.mView.sourceImage)
|
||||||
|
@ -81,13 +81,13 @@ class ItemListAdapter(
|
|||||||
if (itm.getThumbnail(c).isEmpty()) {
|
if (itm.getThumbnail(c).isEmpty()) {
|
||||||
|
|
||||||
if (itm.getIcon(c).isEmpty()) {
|
if (itm.getIcon(c).isEmpty()) {
|
||||||
val color = generator.getColor(itm.sourcetitle)
|
val color = generator.getColor(itm.getSourceTitle())
|
||||||
|
|
||||||
val drawable =
|
val drawable =
|
||||||
TextDrawable
|
TextDrawable
|
||||||
.builder()
|
.builder()
|
||||||
.round()
|
.round()
|
||||||
.build(itm.sourcetitle.toTextDrawableString(c), color)
|
.build(itm.getSourceTitle().toTextDrawableString(c), color)
|
||||||
|
|
||||||
holder.mView.itemImage.setImageDrawable(drawable)
|
holder.mView.itemImage.setImageDrawable(drawable)
|
||||||
} else {
|
} else {
|
||||||
|
@ -46,19 +46,19 @@ class SourcesListAdapter(
|
|||||||
config = Config(c)
|
config = Config(c)
|
||||||
|
|
||||||
if (itm.getIcon(c).isEmpty()) {
|
if (itm.getIcon(c).isEmpty()) {
|
||||||
val color = generator.getColor(itm.title)
|
val color = generator.getColor(itm.getTitleDecoded())
|
||||||
|
|
||||||
val drawable =
|
val drawable =
|
||||||
TextDrawable
|
TextDrawable
|
||||||
.builder()
|
.builder()
|
||||||
.round()
|
.round()
|
||||||
.build(itm.title.toTextDrawableString(c), color)
|
.build(itm.getTitleDecoded().toTextDrawableString(c), color)
|
||||||
holder.mView.itemImage.setImageDrawable(drawable)
|
holder.mView.itemImage.setImageDrawable(drawable)
|
||||||
} else {
|
} else {
|
||||||
c.circularBitmapDrawable(config, itm.getIcon(c), holder.mView.itemImage)
|
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
|
override fun getItemCount(): Int = items.size
|
||||||
|
@ -64,6 +64,10 @@ data class Source(
|
|||||||
}
|
}
|
||||||
return constructUrl(config, "favicons", icon)
|
return constructUrl(config, "favicons", icon)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getTitleDecoded(): String {
|
||||||
|
return Html.fromHtml(title).toString()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data class Item(
|
data class Item(
|
||||||
@ -167,6 +171,10 @@ data class Item(
|
|||||||
return Html.fromHtml(title).toString()
|
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
|
// TODO: maybe find a better way to handle these kind of urls
|
||||||
fun getLinkDecoded(): String {
|
fun getLinkDecoded(): String {
|
||||||
var stringUrl: String
|
var stringUrl: String
|
||||||
|
@ -32,7 +32,7 @@ fun Item.sourceAndDateText(): String {
|
|||||||
""
|
""
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.sourcetitle + formattedDate
|
return this.getSourceTitle() + formattedDate
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Item.toggleStar(): Item {
|
fun Item.toggleStar(): Item {
|
||||||
|
@ -28,7 +28,7 @@ fun SourceEntity.toView(): Source =
|
|||||||
fun Source.toEntity(): SourceEntity =
|
fun Source.toEntity(): SourceEntity =
|
||||||
SourceEntity(
|
SourceEntity(
|
||||||
this.id,
|
this.id,
|
||||||
this.title,
|
this.getTitleDecoded(),
|
||||||
this.tags.tags,
|
this.tags.tags,
|
||||||
this.spout,
|
this.spout,
|
||||||
this.error,
|
this.error,
|
||||||
@ -68,6 +68,6 @@ fun Item.toEntity(): ItemEntity =
|
|||||||
this.thumbnail,
|
this.thumbnail,
|
||||||
this.icon,
|
this.icon,
|
||||||
this.link,
|
this.link,
|
||||||
this.sourcetitle,
|
this.getSourceTitle(),
|
||||||
this.tags.tags
|
this.tags.tags
|
||||||
)
|
)
|
Loading…
Reference in New Issue
Block a user