Handling author field.
This commit is contained in:
parent
a5e86bfb77
commit
fe2410f719
@ -62,7 +62,7 @@ class ItemCardAdapter(
|
|||||||
|
|
||||||
binding.title.setLinkTextColor(c.resources.getColor(R.color.colorAccent))
|
binding.title.setLinkTextColor(c.resources.getColor(R.color.colorAccent))
|
||||||
|
|
||||||
binding.sourceTitleAndDate.text = itm.sourceAndDateText()
|
binding.sourceTitleAndDate.text = itm.sourceAuthorAndDate()
|
||||||
|
|
||||||
if (!appSettingsService.isFullHeightCardsEnabled()) {
|
if (!appSettingsService.isFullHeightCardsEnabled()) {
|
||||||
binding.itemImage.maxHeight = imageMaxHeight
|
binding.itemImage.maxHeight = imageMaxHeight
|
||||||
|
@ -51,7 +51,7 @@ class ItemListAdapter(
|
|||||||
|
|
||||||
binding.title.setLinkTextColor(c.resources.getColor(R.color.colorAccent))
|
binding.title.setLinkTextColor(c.resources.getColor(R.color.colorAccent))
|
||||||
|
|
||||||
binding.sourceTitleAndDate.text = itm.sourceAndDateText()
|
binding.sourceTitleAndDate.text = itm.sourceAuthorAndDate()
|
||||||
|
|
||||||
if (itm.getThumbnail(repository.baseUrl).isEmpty()) {
|
if (itm.getThumbnail(repository.baseUrl).isEmpty()) {
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ class ArticleFragment : Fragment(), DIAware {
|
|||||||
contentText = item.content
|
contentText = item.content
|
||||||
contentTitle = item.title.getHtmlDecoded()
|
contentTitle = item.title.getHtmlDecoded()
|
||||||
contentImage = item.getThumbnail(repository.baseUrl)
|
contentImage = item.getThumbnail(repository.baseUrl)
|
||||||
contentSource = item.sourceAndDateText()
|
contentSource = item.sourceAuthorAndDate()
|
||||||
allImages = item.getImages()
|
allImages = item.getImages()
|
||||||
|
|
||||||
fontSize = appSettingsService.getFontSize()
|
fontSize = appSettingsService.getFontSize()
|
||||||
|
@ -16,7 +16,8 @@ fun SelfossModel.Item.toParcelable() : ParecelableItem =
|
|||||||
this.icon,
|
this.icon,
|
||||||
this.link,
|
this.link,
|
||||||
this.sourcetitle,
|
this.sourcetitle,
|
||||||
this.tags.joinToString(",")
|
this.tags.joinToString(","),
|
||||||
|
this.author
|
||||||
)
|
)
|
||||||
fun ParecelableItem.toModel() : SelfossModel.Item =
|
fun ParecelableItem.toModel() : SelfossModel.Item =
|
||||||
SelfossModel.Item(
|
SelfossModel.Item(
|
||||||
@ -30,7 +31,8 @@ fun ParecelableItem.toModel() : SelfossModel.Item =
|
|||||||
this.icon,
|
this.icon,
|
||||||
this.link,
|
this.link,
|
||||||
this.sourcetitle,
|
this.sourcetitle,
|
||||||
this.tags.split(",")
|
this.tags.split(","),
|
||||||
|
this.author
|
||||||
)
|
)
|
||||||
data class ParecelableItem(
|
data class ParecelableItem(
|
||||||
val id: Int,
|
val id: Int,
|
||||||
@ -43,7 +45,8 @@ data class ParecelableItem(
|
|||||||
val icon: String?,
|
val icon: String?,
|
||||||
val link: String,
|
val link: String,
|
||||||
val sourcetitle: String,
|
val sourcetitle: String,
|
||||||
val tags: String
|
val tags: String,
|
||||||
|
val author: String
|
||||||
) : Parcelable {
|
) : Parcelable {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@ -65,7 +68,8 @@ data class ParecelableItem(
|
|||||||
icon = source.readString(),
|
icon = source.readString(),
|
||||||
link = source.readString().orEmpty(),
|
link = source.readString().orEmpty(),
|
||||||
sourcetitle = source.readString().orEmpty(),
|
sourcetitle = source.readString().orEmpty(),
|
||||||
tags = source.readString().orEmpty()
|
tags = source.readString().orEmpty(),
|
||||||
|
author = source.readString().orEmpty()
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun describeContents() = 0
|
override fun describeContents() = 0
|
||||||
@ -82,5 +86,6 @@ data class ParecelableItem(
|
|||||||
dest.writeString(link)
|
dest.writeString(link)
|
||||||
dest.writeString(sourcetitle)
|
dest.writeString(sourcetitle)
|
||||||
dest.writeString(tags)
|
dest.writeString(tags)
|
||||||
|
dest.writeString(author)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,7 +17,8 @@ fun generateTestDBItems(item: FakeItemParameters = FakeItemParameters()): List<I
|
|||||||
icon = item.icon,
|
icon = item.icon,
|
||||||
link = item.link,
|
link = item.link,
|
||||||
sourcetitle = item.sourcetitle,
|
sourcetitle = item.sourcetitle,
|
||||||
tags = item.tags
|
tags = item.tags,
|
||||||
|
author = item.author
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -35,7 +36,8 @@ fun generateTestApiItem(item: FakeItemParameters = FakeItemParameters()): List<S
|
|||||||
icon = item.icon,
|
icon = item.icon,
|
||||||
link = item.link,
|
link = item.link,
|
||||||
sourcetitle = item.sourcetitle,
|
sourcetitle = item.sourcetitle,
|
||||||
tags = item.tags.split(',')
|
tags = item.tags.split(','),
|
||||||
|
author = item.author
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -54,4 +56,5 @@ class FakeItemParameters {
|
|||||||
"https://ilblogdellasci.wordpress.com/2022/09/09/etica-della-ricerca-sotto-i-riflettori/"
|
"https://ilblogdellasci.wordpress.com/2022/09/09/etica-della-ricerca-sotto-i-riflettori/"
|
||||||
var sourcetitle = "La Chimica e la Società"
|
var sourcetitle = "La Chimica e la Società"
|
||||||
var tags = "Chimica, Testing"
|
var tags = "Chimica, Testing"
|
||||||
|
var author = "Someone important"
|
||||||
}
|
}
|
@ -57,7 +57,6 @@ class SelfossModel {
|
|||||||
val error: String,
|
val error: String,
|
||||||
val icon: String?
|
val icon: String?
|
||||||
)
|
)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class Item(
|
data class Item(
|
||||||
val id: Int,
|
val id: Int,
|
||||||
@ -73,7 +72,8 @@ class SelfossModel {
|
|||||||
val link: String,
|
val link: String,
|
||||||
val sourcetitle: String,
|
val sourcetitle: String,
|
||||||
@Serializable(with = TagsListSerializer::class)
|
@Serializable(with = TagsListSerializer::class)
|
||||||
val tags: List<String>
|
val tags: List<String>,
|
||||||
|
val author: String
|
||||||
) {
|
) {
|
||||||
// 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 {
|
||||||
@ -102,8 +102,14 @@ class SelfossModel {
|
|||||||
return stringUrl
|
return stringUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sourceAndDateText(): String =
|
fun sourceAuthorAndDate(): String {
|
||||||
this.sourcetitle.getHtmlDecoded() + DateUtils.parseRelativeDate(this.datetime)
|
var txt = this.sourcetitle.getHtmlDecoded()
|
||||||
|
if (this.author.isNotEmpty()) {
|
||||||
|
txt += " (by ${this.author}) "
|
||||||
|
}
|
||||||
|
txt += DateUtils.parseRelativeDate(this.datetime)
|
||||||
|
return txt
|
||||||
|
}
|
||||||
|
|
||||||
fun toggleStar(): Item {
|
fun toggleStar(): Item {
|
||||||
this.starred = !this.starred
|
this.starred = !this.starred
|
||||||
@ -111,6 +117,7 @@ class SelfossModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO: this seems to be super slow.
|
// TODO: this seems to be super slow.
|
||||||
object TagsListSerializer : KSerializer<List<String>> {
|
object TagsListSerializer : KSerializer<List<String>> {
|
||||||
override fun deserialize(decoder: Decoder): List<String> {
|
override fun deserialize(decoder: Decoder): List<String> {
|
||||||
|
@ -51,7 +51,8 @@ fun ITEM.toView(): SelfossModel.Item =
|
|||||||
this.icon,
|
this.icon,
|
||||||
this.link,
|
this.link,
|
||||||
this.sourcetitle,
|
this.sourcetitle,
|
||||||
this.tags.split(",")
|
this.tags.split(","),
|
||||||
|
this.author
|
||||||
)
|
)
|
||||||
|
|
||||||
fun SelfossModel.Item.toEntity(): ITEM =
|
fun SelfossModel.Item.toEntity(): ITEM =
|
||||||
@ -66,5 +67,6 @@ fun SelfossModel.Item.toEntity(): ITEM =
|
|||||||
this.icon,
|
this.icon,
|
||||||
this.link,
|
this.link,
|
||||||
this.sourcetitle.getHtmlDecoded(),
|
this.sourcetitle.getHtmlDecoded(),
|
||||||
this.tags.joinToString(",")
|
this.tags.joinToString(","),
|
||||||
|
this.author
|
||||||
)
|
)
|
@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE ITEM ADD COLUMN `author` TEXT NOT NULL;
|
@ -10,6 +10,7 @@ CREATE TABLE ITEM (
|
|||||||
`link` TEXT NOT NULL,
|
`link` TEXT NOT NULL,
|
||||||
`sourcetitle` TEXT NOT NULL,
|
`sourcetitle` TEXT NOT NULL,
|
||||||
`tags` TEXT NOT NULL,
|
`tags` TEXT NOT NULL,
|
||||||
|
`author` TEXT NOT NULL,
|
||||||
PRIMARY KEY(`id`)
|
PRIMARY KEY(`id`)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user