Skip to content

Commit

Permalink
[1.58.*] Pre-release merge (#288)
Browse files Browse the repository at this point in the history
  • Loading branch information
tramline-github[bot] authored Feb 5, 2024
2 parents 0e00c94 + 0729cc6 commit 8972c96
Show file tree
Hide file tree
Showing 12 changed files with 377 additions and 181 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,18 @@ import dev.sasikanth.rss.reader.core.network.parser.FeedParser.Companion.ATTR_TY
import dev.sasikanth.rss.reader.core.network.parser.FeedParser.Companion.RSS_MEDIA_TYPE
import dev.sasikanth.rss.reader.core.network.parser.FeedParser.Companion.TAG_LINK
import io.ktor.client.HttpClient
import io.ktor.client.call.body
import io.ktor.client.request.get
import io.ktor.client.statement.HttpResponse
import io.ktor.client.statement.bodyAsText
import io.ktor.http.ContentType
import io.ktor.http.HttpStatusCode
import io.ktor.http.URLBuilder
import io.ktor.http.URLProtocol
import io.ktor.http.Url
import io.ktor.http.charset
import io.ktor.http.contentType
import io.ktor.utils.io.charsets.Charsets
import io.ktor.utils.io.core.String
import me.tatarka.inject.annotations.Inject

@Inject
Expand Down Expand Up @@ -86,7 +89,8 @@ class FeedFetcher(private val httpClient: HttpClient, private val feedParser: Fe
url: String,
redirectCount: Int
): FeedFetchResult {
val responseContent = response.bodyAsText()
val originalCharset = response.charset() ?: Charsets.UTF_8
val responseContent = String(response.body<ByteArray>(), charset = originalCharset)
return if (response.contentType()?.withoutParameters() == ContentType.Text.Html) {
val feedUrl = fetchFeedLinkFromHtmlIfExists(responseContent, url)
if (feedUrl != url && !feedUrl.isNullOrBlank()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ val EnTwineStrings =
postsAll = "All",
postsUnread = "Unread",
postsToday = "Today",
openSource = "Open Source",
openSource = "Support Open Source",
openSourceDesc =
"Twine is built on open source technologies and is completely free to use, you can find the source code of Twine and some of my other popular projects on GitHub. Click here to head over there.",
"Twine is built on open-source technologies and is free to use. You can find the source code for Twine and some of my other popular projects on GitHub. Click here to open GitHub and tip for the project.",
markAsRead = "Mark as Read",
markAsUnRead = "Mark as Unread",
removeFeed = "Remove feed",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import dev.sasikanth.rss.reader.bookmarks.BookmarksPresenter
import dev.sasikanth.rss.reader.bookmarks.OpenLink
import dev.sasikanth.rss.reader.components.CompactFloatingActionButton
import dev.sasikanth.rss.reader.home.ui.PostListItem
import dev.sasikanth.rss.reader.home.ui.PostMetadataConfig
import dev.sasikanth.rss.reader.platform.LocalLinkHandler
import dev.sasikanth.rss.reader.resources.icons.Bookmarks
import dev.sasikanth.rss.reader.resources.icons.TwineIcons
Expand Down Expand Up @@ -126,7 +127,12 @@ internal fun BookmarksScreen(
if (post != null) {
PostListItem(
item = post,
enablePostSource = false,
postMetadataConfig =
PostMetadataConfig.DEFAULT.copy(
showUnreadIndicator = false,
showToggleReadUnreadOption = false,
enablePostSource = false
),
onClick = { bookmarksPresenter.dispatch(BookmarksEvent.OnPostClicked(post)) },
onPostBookmarkClick = {
bookmarksPresenter.dispatch(BookmarksEvent.OnPostBookmarkClick(post))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.arkivanov.decompose.ComponentContext
import com.arkivanov.essenty.instancekeeper.InstanceKeeper
import com.arkivanov.essenty.instancekeeper.getOrCreate
import com.arkivanov.essenty.lifecycle.doOnCreate
import dev.sasikanth.rss.reader.repository.ObservableSelectedFeed
import dev.sasikanth.rss.reader.repository.RssRepository
import dev.sasikanth.rss.reader.util.DispatchersProvider
import kotlinx.coroutines.CoroutineScope
Expand All @@ -39,6 +40,7 @@ import me.tatarka.inject.annotations.Inject
class FeedPresenter(
dispatchersProvider: DispatchersProvider,
rssRepository: RssRepository,
private val observableSelectedFeed: ObservableSelectedFeed,
@Assisted feedLink: String,
@Assisted componentContext: ComponentContext,
@Assisted private val dismiss: () -> Unit
Expand All @@ -49,7 +51,8 @@ class FeedPresenter(
PresenterInstance(
dispatchersProvider = dispatchersProvider,
rssRepository = rssRepository,
feedLink = feedLink
feedLink = feedLink,
observableSelectedFeed = observableSelectedFeed,
)
}

Expand All @@ -75,7 +78,8 @@ class FeedPresenter(
private class PresenterInstance(
dispatchersProvider: DispatchersProvider,
private val rssRepository: RssRepository,
private val feedLink: String
private val feedLink: String,
private val observableSelectedFeed: ObservableSelectedFeed,
) : InstanceKeeper.Instance {

private val coroutineScope = CoroutineScope(SupervisorJob() + dispatchersProvider.main)
Expand Down Expand Up @@ -109,6 +113,7 @@ class FeedPresenter(
private fun removeFeed() {
coroutineScope.launch {
rssRepository.removeFeed(feedLink)
observableSelectedFeed.clearSelection()
effects.emit(FeedEffect.DismissSheet)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,19 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.ime
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.requiredSize
import androidx.compose.foundation.layout.union
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Delete
import androidx.compose.material3.BottomSheetDefaults
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
Expand Down Expand Up @@ -83,11 +85,16 @@ fun FeedInfoBottomSheet(
onDismissRequest = { feedPresenter.dispatch(FeedEvent.BackClicked) },
containerColor = AppTheme.colorScheme.tintedBackground,
contentColor = AppTheme.colorScheme.tintedForeground,
windowInsets = BottomSheetDefaults.windowInsets.union(WindowInsets.ime),
windowInsets = WindowInsets.ime.only(WindowInsetsSides.Bottom),
) {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.fillMaxWidth().padding(horizontal = 24.dp).padding(bottom = 16.dp)
modifier =
Modifier.fillMaxWidth()
.padding(horizontal = 24.dp)
.padding(
bottom = 16.dp + WindowInsets.systemBars.asPaddingValues().calculateBottomPadding()
)
) {
Spacer(Modifier.requiredHeight(8.dp))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ private fun DefaultFeaturedPostItem(
postRead = item.read,
postBookmarked = item.bookmarked,
commentsLink = item.commentsLink,
enablePostSource = true,
onBookmarkClick = onBookmarkClick,
onCommentsClick = onCommentsClick,
onSourceClick = onSourceClick,
Expand Down Expand Up @@ -244,7 +243,6 @@ private fun LargeScreenFeaturedPostItem(
postRead = item.read,
postBookmarked = item.bookmarked,
commentsLink = item.commentsLink,
enablePostSource = true,
onBookmarkClick = onBookmarkClick,
onCommentsClick = onCommentsClick,
onSourceClick = onSourceClick,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ internal fun PostsList(
if (post != null) {
PostListItem(
item = post,
enablePostSource = true,
reduceReadItemAlpha = true,
onClick = { onPostClicked(post) },
onPostBookmarkClick = { onPostBookmarkClick(post) },
Expand All @@ -131,13 +130,13 @@ internal fun PostsList(
@Composable
fun PostListItem(
item: PostWithMetadata,
enablePostSource: Boolean,
onClick: () -> Unit,
onPostBookmarkClick: () -> Unit,
onPostCommentsClick: () -> Unit,
onPostSourceClick: () -> Unit,
togglePostReadClick: () -> Unit,
reduceReadItemAlpha: Boolean = false
reduceReadItemAlpha: Boolean = false,
postMetadataConfig: PostMetadataConfig = PostMetadataConfig.DEFAULT,
) {
Column(
modifier =
Expand Down Expand Up @@ -175,11 +174,11 @@ fun PostListItem(
PostMetadata(
feedName = item.feedName,
postPublishedAt = item.date.relativeDurationString(),
config = postMetadataConfig,
postLink = item.link,
postRead = item.read,
postBookmarked = item.bookmarked,
commentsLink = item.commentsLink,
enablePostSource = enablePostSource,
onBookmarkClick = onPostBookmarkClick,
onCommentsClick = onPostCommentsClick,
onSourceClick = onPostSourceClick,
Expand Down
Loading

0 comments on commit 8972c96

Please sign in to comment.