Compare commits

...

3 Commits

Author SHA1 Message Date
Shinokuni ea51df49bc Display feed description in FeedBottomSheet instead of folder name 2024-04-15 16:34:39 +02:00
Shinokuni 99ff159434 Fix some feed parsing failures 2024-04-15 14:21:29 +02:00
Shinokuni c115a1edcc Fix content display for some items in ItemScreen 2024-04-15 12:28:37 +02:00
9 changed files with 37 additions and 25 deletions

View File

@ -29,6 +29,7 @@ class ATOMFeedAdapter : XmlAdapter<Pair<Feed, List<Item>>> {
"link" -> parseLink(this@allChildrenAutoIgnore, feed)
"subtitle" -> description = nullableText()
"entry" -> items += itemAdapter.fromXml(this@allChildrenAutoIgnore)
else -> skipContents()
}
}
}

View File

@ -26,6 +26,7 @@ class RSS1FeedAdapter : XmlAdapter<Pair<Feed, List<Item>>> {
when (tagName) {
"channel" -> parseChannel(this, feed)
"item" -> items += itemAdapter.fromXml(this)
else -> skipContents()
}
}
}

View File

@ -92,22 +92,16 @@ object FeedTab : Tab {
is DialogState.FeedSheet -> {
FeedModalBottomSheet(
feed = dialog.feed,
folder = dialog.folder,
onDismissRequest = { viewModel.closeDialog() },
onOpen = {
uriHandler.openUri(dialog.feed.siteUrl!!)
viewModel.closeDialog()
},
onUpdate = {
viewModel.openDialog(
DialogState.UpdateFeed(
dialog.feed,
dialog.folder
)
)
viewModel.openDialog(DialogState.UpdateFeed(dialog.feed, dialog.folder))
},
onUpdateColor = {},
onDelete = { viewModel.openDialog(DialogState.DeleteFeed(dialog.feed)) },
onDelete = { viewModel.openDialog(DialogState.DeleteFeed(dialog.feed)) }
)
}
@ -170,10 +164,12 @@ object FeedTab : Tab {
onClick = { viewModel.setFolderExpandState(state.areFoldersExpanded.not()) }
) {
Icon(
painter = painterResource(id = if (state.areFoldersExpanded)
R.drawable.ic_unfold_less
else
R.drawable.ic_unfold_more),
painter = painterResource(
id = if (state.areFoldersExpanded)
R.drawable.ic_unfold_less
else
R.drawable.ic_unfold_more
),
contentDescription = null
)
}
@ -282,7 +278,8 @@ object FeedTab : Tab {
}
is FolderAndFeedsState.ErrorState -> {
val exception = (state.foldersAndFeeds as FolderAndFeedsState.ErrorState).exception
val exception =
(state.foldersAndFeeds as FolderAndFeedsState.ErrorState).exception
ErrorMessage(exception = exception)
}
}

View File

@ -21,6 +21,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.style.TextOverflow
@ -31,13 +32,11 @@ import com.readrops.app.compose.util.theme.MediumSpacer
import com.readrops.app.compose.util.theme.VeryShortSpacer
import com.readrops.app.compose.util.theme.spacing
import com.readrops.db.entities.Feed
import com.readrops.db.entities.Folder
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun FeedModalBottomSheet(
feed: Feed,
folder: Folder?,
onDismissRequest: () -> Unit,
onOpen: () -> Unit,
onUpdate: () -> Unit,
@ -58,6 +57,8 @@ fun FeedModalBottomSheet(
AsyncImage(
model = feed.iconUrl,
contentDescription = feed.name!!,
placeholder = painterResource(id = R.drawable.ic_rss_feed_grey),
error = painterResource(id = R.drawable.ic_rss_feed_grey),
modifier = Modifier.size(MaterialTheme.spacing.veryLargeSpacing)
)
@ -71,12 +72,15 @@ fun FeedModalBottomSheet(
overflow = TextOverflow.Ellipsis
)
if (folder != null) {
if (feed.description != null) {
VeryShortSpacer()
Text(
text = folder.name!!,
style = MaterialTheme.typography.labelLarge
text = feed.description!!,
style = MaterialTheme.typography.labelLarge,
color = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.85f),
maxLines = 2,
overflow = TextOverflow.Ellipsis
)
}
}

View File

@ -69,7 +69,7 @@ class ItemWebView(
}
private fun formatText(itemWithFeed: ItemWithFeed): String {
return if (itemWithFeed.item.content != null) {
return if (itemWithFeed.item.text != null) {
val document = if (itemWithFeed.websiteUrl != null) Jsoup.parse(
Parser.unescapeEntities(itemWithFeed.item.text, false), itemWithFeed.websiteUrl
) else Jsoup.parse(

View File

@ -39,6 +39,7 @@ class GetFoldersWithFeeds(
iconUrl = it.feedIcon,
url = it.feedUrl,
siteUrl = it.feedSiteUrl,
description = it.feedDescription,
unreadCount = it.unreadCount
)
}
@ -61,6 +62,7 @@ class GetFoldersWithFeeds(
iconUrl = feedWithoutFolder.feedIcon,
url = feedWithoutFolder.feedUrl,
siteUrl = feedWithoutFolder.feedSiteUrl,
description = feedWithoutFolder.feedDescription,
unreadCount = feedWithoutFolder.unreadCount
)
})

View File

@ -1,5 +1,6 @@
package com.readrops.app.compose.repositories
import android.util.Log
import com.readrops.api.localfeed.LocalRSSDataSource
import com.readrops.api.services.SyncResult
import com.readrops.api.utils.ApiUtils
@ -123,8 +124,12 @@ class LocalRSSRepository(
etag = null
lastModified = null
iconUrl = HtmlParser.getFaviconLink(siteUrl!!, get()).also { feedUrl ->
feedUrl?.let { backgroundColor = FeedColors.getFeedColor(it) }
try {
iconUrl = HtmlParser.getFaviconLink(siteUrl!!, get()).also { feedUrl ->
feedUrl?.let { backgroundColor = FeedColors.getFeedColor(it) }
}
} catch (e: Exception) {
Log.d("LocalRSSRepository", "insertFeed: ${e.message}")
}
id = database.newFeedDao().insert(this).toInt()

View File

@ -19,6 +19,7 @@ data class FolderWithFeed(
val feedName: String? = null,
val feedIcon: String? = null,
val feedUrl: String? = null,
val feedDescription: String? = null,
val feedSiteUrl: String? = null,
val unreadCount: Int = 0,
val accountId: Int = 0
@ -30,6 +31,7 @@ data class FeedWithCount(
val feedIcon: String? = null,
val feedUrl: String? = null,
val feedSiteUrl: String? = null,
val feedDescription: String? = null,
val unreadCount: Int = 0,
val accountId: Int = 0
)

View File

@ -17,11 +17,11 @@ object FoldersAndFeedsQueriesBuilder {
@Language("SQL")
val query = SimpleSQLiteQuery("""
With main As (Select Folder.id As folderId, Folder.name As folderName, Feed.id As feedId,
Feed.name As feedName, Feed.icon_url As feedIcon, Feed.url As feedUrl, Feed.siteUrl As feedSiteUrl,
Feed.name As feedName, Feed.icon_url As feedIcon, Feed.url As feedUrl, Feed.siteUrl As feedSiteUrl, Feed.description as feedDescription,
Folder.account_id As accountId, Item.read as itemRead
From Folder Left Join Feed On Folder.id = Feed.folder_id Left Join Item On Item.feed_id = Feed.id
Where Feed.folder_id is NULL OR Feed.folder_id is NOT NULL And Feed.account_id = $accountId $filter)
Select folderId, folderName, feedId, feedName, feedIcon, feedUrl, feedSiteUrl, accountId,
Select folderId, folderName, feedId, feedName, feedIcon, feedUrl, feedSiteUrl, accountId, feedDescription,
(Select count(*) From main Where (itemRead = 0)) as unreadCount
From main Group by feedId, folderId Order By folderName, feedName
""".trimIndent())
@ -38,10 +38,10 @@ object FoldersAndFeedsQueriesBuilder {
@Language("SQL")
val query = SimpleSQLiteQuery("""
With main As (Select Feed.id As feedId, Feed.name As feedName, Feed.icon_url As feedIcon,
With main As (Select Feed.id As feedId, Feed.name As feedName, Feed.icon_url As feedIcon, feed.description as feedDescription,
Feed.url As feedUrl, Feed.siteUrl As feedSiteUrl, Feed.account_id As accountId, Item.read As itemRead
From Feed Left Join Item On Feed.id = Item.feed_id Where Feed.folder_id is Null And Feed.account_id = $accountId $filter)
Select feedId, feedName, feedIcon, feedUrl, feedSiteUrl, accountId,
Select feedId, feedName, feedIcon, feedUrl, feedSiteUrl, accountId, feedDescription,
(Select count(*) From main Where (itemRead = 0)) as unreadCount From main Group by feedId Order By feedName
""".trimIndent())