Skip to content

Commit

Permalink
[1.41.*] Pre-release merge (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
tramline-github[bot] authored Jan 24, 2024
2 parents cddd4b3 + 8b282b9 commit 1f6a5ad
Show file tree
Hide file tree
Showing 22 changed files with 690 additions and 81 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2024 Sasikanth Miriyampalli
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dev.sasikanth.rss.reader.core.model.local

import kotlinx.datetime.Instant

data class Post(
val title: String,
val description: String,
val imageUrl: String?,
val date: Instant,
val feedLink: String,
val link: String,
val bookmarked: Boolean,
val commentsLink: String?,
val read: Boolean,
val rawContent: String?,
)
8 changes: 5 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]
kotlin = "1.9.21"
android_gradle_plugin = "8.2.1"
android_gradle_plugin = "8.2.2"
compose = "1.5.11"

android_sdk_compile = "34"
Expand Down Expand Up @@ -39,13 +39,14 @@ sqliteAndroid = "3.45.0"
windowSizeClass = "0.3.2"
desugarJdk = "2.0.4"
lyricist = "1.6.2-1.8.20"
atomicfu = "0.23.1"
atomicfu = "0.23.2"
okio = "3.7.0"
paging = "3.3.0-alpha02-0.4.0"
stately = "2.0.6"
xmlutil = "0.86.3"
ktxml = "0.2.3"
uri = "0.0.16"
webview = "1.8.4"

[libraries]
compose_runtime = { module = "org.jetbrains.compose.runtime:runtime", version.ref = "compose" }
Expand All @@ -60,7 +61,7 @@ ktor_client_okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "kto
ktor_client_darwin = { module = "io.ktor:ktor-client-darwin", version.ref = "ktor" }
ktor_client_logging = { module = "io.ktor:ktor-client-logging", version.ref = "ktor" }
napier = { module = "io.github.aakira:napier", version.ref = "napier" }
kotlin_test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
kotlin_test = { module = "org.jetbrains.kotlin:kotlin-test", version = { strictly = "[1.9.0, 1.9.21[", prefer="1.9.21" } }
kotlinx_coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx_coroutines" }
kotlinx_coroutines_test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx_coroutines" }
kotlinx_datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinx_date_time" }
Expand Down Expand Up @@ -106,6 +107,7 @@ xmlutil-core = { module = "io.github.pdvrieze.xmlutil:core", version.ref = "xmlu
xmlutil-serialization = { module = "io.github.pdvrieze.xmlutil:serialization", version.ref = "xmlutil" }
ktxml = { module = "org.kobjects.ktxml:core", version.ref = "ktxml" }
uri = { module = "com.eygraber:uri-kmp", version.ref = "uri" }
webview = { module = "io.github.kevinnzou:compose-webview-multiplatform", version.ref = "webview" }

[plugins]
android_application = { id = "com.android.application", version.ref = "android_gradle_plugin" }
Expand Down
2 changes: 2 additions & 0 deletions shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ kotlin {

implementation(projects.resources.strings)
implementation(projects.resources.icons)
implementation(projects.thirdparty.readability)

implementation(libs.bundles.compose)
implementation(libs.bundles.kotlinx)
Expand All @@ -118,6 +119,7 @@ kotlin {
implementation(libs.stately.isolate)
implementation(libs.stately.iso.collections)
implementation(libs.bundles.xmlutil)
api(libs.webview)
}
commonTest.dependencies {
implementation(libs.kotlin.test)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import dev.sasikanth.rss.reader.components.rememberDynamicColorState
import dev.sasikanth.rss.reader.home.ui.HomeScreen
import dev.sasikanth.rss.reader.platform.LinkHandler
import dev.sasikanth.rss.reader.platform.LocalLinkHandler
import dev.sasikanth.rss.reader.reader.ui.ReaderScreen
import dev.sasikanth.rss.reader.resources.strings.ProvideStrings
import dev.sasikanth.rss.reader.search.ui.SearchScreen
import dev.sasikanth.rss.reader.settings.ui.SettingsScreen
Expand Down Expand Up @@ -91,6 +92,9 @@ fun App(
is Screen.About -> {
AboutScreen(aboutPresenter = screen.presenter, modifier = fillMaxSizeModifier)
}
is Screen.Reader -> {
ReaderScreen(presenter = screen.presenter, modifier = fillMaxSizeModifier)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import dev.sasikanth.rss.reader.about.AboutPresenter
import dev.sasikanth.rss.reader.bookmarks.BookmarksPresenter
import dev.sasikanth.rss.reader.di.scopes.ActivityScope
import dev.sasikanth.rss.reader.home.HomePresenter
import dev.sasikanth.rss.reader.reader.ReaderPresenter
import dev.sasikanth.rss.reader.refresh.LastUpdatedAt
import dev.sasikanth.rss.reader.repository.RssRepository
import dev.sasikanth.rss.reader.search.SearchPresenter
Expand All @@ -44,19 +45,25 @@ import me.tatarka.inject.annotations.Inject

private typealias HomePresenterFactory =
(
ComponentContext, openSearch: () -> Unit, openBookmarks: () -> Unit, openSettings: () -> Unit
ComponentContext,
openSearch: () -> Unit,
openBookmarks: () -> Unit,
openSettings: () -> Unit,
openPost: (String) -> Unit,
) -> HomePresenter

private typealias SearchPresentFactory =
(
ComponentContext,
goBack: () -> Unit,
openPost: (String) -> Unit,
) -> SearchPresenter

private typealias BookmarkPresenterFactory =
(
ComponentContext,
goBack: () -> Unit,
openPost: (String) -> Unit,
) -> BookmarksPresenter

private typealias SettingsPresenterFactory =
Expand All @@ -72,6 +79,13 @@ private typealias AboutPresenterFactory =
goBack: () -> Unit,
) -> AboutPresenter

private typealias ReaderPresenterFactory =
(
feedLink: String,
ComponentContext,
goBack: () -> Unit,
) -> ReaderPresenter

@Inject
@ActivityScope
class AppPresenter(
Expand All @@ -82,6 +96,7 @@ class AppPresenter(
private val bookmarksPresenter: BookmarkPresenterFactory,
private val settingsPresenter: SettingsPresenterFactory,
private val aboutPresenter: AboutPresenterFactory,
private val readerPresenter: ReaderPresenterFactory,
private val lastUpdatedAt: LastUpdatedAt,
private val rssRepository: RssRepository
) : ComponentContext by componentContext {
Expand Down Expand Up @@ -122,15 +137,30 @@ class AppPresenter(
componentContext,
{ navigation.push(Config.Search) },
{ navigation.push(Config.Bookmarks) },
{ navigation.push(Config.Settings) }
{ navigation.push(Config.Settings) },
{ navigation.push(Config.Reader(it)) }
)
)
}
Config.Search -> {
Screen.Search(presenter = searchPresenter(componentContext) { navigation.pop() })
Screen.Search(
presenter =
searchPresenter(
componentContext,
{ navigation.pop() },
{ navigation.push(Config.Reader(it)) }
)
)
}
Config.Bookmarks -> {
Screen.Bookmarks(presenter = bookmarksPresenter(componentContext) { navigation.pop() })
Screen.Bookmarks(
presenter =
bookmarksPresenter(
componentContext,
{ navigation.pop() },
{ navigation.push(Config.Reader(it)) }
)
)
}
Config.Settings -> {
Screen.Settings(
Expand All @@ -145,6 +175,11 @@ class AppPresenter(
Config.About -> {
Screen.About(presenter = aboutPresenter(componentContext) { navigation.pop() })
}
is Config.Reader -> {
Screen.Reader(
presenter = readerPresenter(config.feedLink, componentContext) { navigation.pop() }
)
}
}

private class PresenterInstance(
Expand Down Expand Up @@ -179,5 +214,7 @@ class AppPresenter(
@Parcelize data object Settings : Config

@Parcelize data object About : Config

@Parcelize data class Reader(val feedLink: String) : Config
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package dev.sasikanth.rss.reader.app
import dev.sasikanth.rss.reader.about.AboutPresenter
import dev.sasikanth.rss.reader.bookmarks.BookmarksPresenter
import dev.sasikanth.rss.reader.home.HomePresenter
import dev.sasikanth.rss.reader.reader.ReaderPresenter
import dev.sasikanth.rss.reader.search.SearchPresenter
import dev.sasikanth.rss.reader.settings.SettingsPresenter

Expand All @@ -31,4 +32,6 @@ internal sealed interface Screen {
class Settings(val presenter: SettingsPresenter) : Screen

class About(val presenter: AboutPresenter) : Screen

class Reader(val presenter: ReaderPresenter) : Screen
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,4 @@

package dev.sasikanth.rss.reader.bookmarks

import dev.sasikanth.rss.reader.core.model.local.PostWithMetadata

sealed interface BookmarksEffect {

data class OpenPost(val post: PostWithMetadata) : BookmarksEffect
}
sealed interface BookmarksEffect
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class BookmarksPresenter(
private val rssRepository: RssRepository,
@Assisted componentContext: ComponentContext,
@Assisted private val goBack: () -> Unit,
@Assisted private val openPost: (postLink: String) -> Unit,
) : ComponentContext by componentContext {

private val presenterInstance =
Expand All @@ -62,6 +63,7 @@ class BookmarksPresenter(
fun dispatch(event: BookmarksEvent) {
when (event) {
BookmarksEvent.BackClicked -> goBack()
is BookmarksEvent.OnPostClicked -> openPost(event.post.link)
else -> {
// no-op
}
Expand Down Expand Up @@ -93,15 +95,8 @@ class BookmarksPresenter(
/* no-op */
}
is BookmarksEvent.OnPostBookmarkClick -> onPostBookmarkClicked(event.post)
is BookmarksEvent.OnPostClicked -> onPostClicked(event.post)
}
}

private fun onPostClicked(post: PostWithMetadata) {
coroutineScope.launch {
effects.emit(BookmarksEffect.OpenPost(post))
if (!post.read) {
rssRepository.updatePostReadStatus(read = true, link = post.link)
is BookmarksEvent.OnPostClicked -> {
// no-op
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
Expand All @@ -50,7 +49,6 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.unit.dp
import app.cash.paging.compose.collectAsLazyPagingItems
import dev.sasikanth.rss.reader.bookmarks.BookmarksEffect
import dev.sasikanth.rss.reader.bookmarks.BookmarksEvent
import dev.sasikanth.rss.reader.bookmarks.BookmarksPresenter
import dev.sasikanth.rss.reader.components.CompactFloatingActionButton
Expand All @@ -60,7 +58,6 @@ import dev.sasikanth.rss.reader.resources.icons.Bookmarks
import dev.sasikanth.rss.reader.resources.icons.TwineIcons
import dev.sasikanth.rss.reader.resources.strings.LocalStrings
import dev.sasikanth.rss.reader.ui.AppTheme
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch

@Composable
Expand All @@ -76,16 +73,6 @@ internal fun BookmarksScreen(
val layoutDirection = LocalLayoutDirection.current
val linkHandler = LocalLinkHandler.current

LaunchedEffect(Unit) {
bookmarksPresenter.effects.collectLatest { effect ->
when (effect) {
is BookmarksEffect.OpenPost -> {
linkHandler.openLink(effect.post.link)
}
}
}
}

Scaffold(
modifier = modifier,
topBar = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@
*/
package dev.sasikanth.rss.reader.home

import dev.sasikanth.rss.reader.core.model.local.PostWithMetadata

sealed interface HomeEffect {

data class OpenPost(val post: PostWithMetadata) : HomeEffect

data object MinimizeSheet : HomeEffect

class ShowError(val homeErrorType: HomeErrorType) : HomeEffect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class HomePresenter(
@Assisted private val openSearch: () -> Unit,
@Assisted private val openBookmarks: () -> Unit,
@Assisted private val openSettings: () -> Unit,
@Assisted private val openPost: (postLink: String) -> Unit,
) : ComponentContext by componentContext {

private val backCallback = BackCallback { dispatch(HomeEvent.BackClicked) }
Expand Down Expand Up @@ -117,6 +118,7 @@ class HomePresenter(
is HomeEvent.SearchClicked -> openSearch()
is HomeEvent.BookmarksClicked -> openBookmarks()
is HomeEvent.SettingsClicked -> openSettings()
is HomeEvent.OnPostClicked -> openPost(event.post.link)
else -> {
// no-op
}
Expand Down Expand Up @@ -148,7 +150,9 @@ class HomePresenter(
when (event) {
HomeEvent.Init -> init()
HomeEvent.OnSwipeToRefresh -> refreshContent()
is HomeEvent.OnPostClicked -> onPostClicked(event.post)
is HomeEvent.OnPostClicked -> {
// no-op
}
is HomeEvent.FeedsSheetStateChanged -> feedsSheetStateChanged(event.feedsSheetState)
HomeEvent.OnHomeSelected -> onHomeSelected()
HomeEvent.OnAddFeedClicked -> onAddFeedClicked()
Expand Down Expand Up @@ -387,15 +391,6 @@ class HomePresenter(
coroutineScope.launch { observableSelectedFeed.clearSelection() }
}

private fun onPostClicked(post: PostWithMetadata) {
coroutineScope.launch {
effects.emit(HomeEffect.OpenPost(post))
if (!post.read) {
rssRepository.updatePostReadStatus(read = true, link = post.link)
}
}
}

private fun refreshContent() {
coroutineScope.launch {
_state.update { it.copy(loadingState = HomeLoadingState.Loading) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,6 @@ internal fun HomeScreen(homePresenter: HomePresenter, modifier: Modifier = Modif
LaunchedEffect(Unit) {
homePresenter.effects.collectLatest { effect ->
when (effect) {
is HomeEffect.OpenPost -> {
linkHandler.openLink(effect.post.link)
}
HomeEffect.MinimizeSheet -> {
bottomSheetState.collapse()
}
Expand Down
Loading

0 comments on commit 1f6a5ad

Please sign in to comment.