mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 16:27:06 +05:30
android: add support for links in recents
This commit is contained in:
parent
2cc08008fd
commit
a73871f421
2 changed files with 14 additions and 2 deletions
|
@ -1,5 +1,7 @@
|
|||
package dev.msfjarvis.claw.android
|
||||
|
||||
import android.app.assist.AssistContent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
|
@ -14,6 +16,7 @@ import javax.inject.Inject
|
|||
class MainActivity : ComponentActivity() {
|
||||
|
||||
@Inject lateinit var urlLauncher: UrlLauncher
|
||||
private var webUri: String? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
@ -22,7 +25,12 @@ class MainActivity : ComponentActivity() {
|
|||
setContent {
|
||||
LobstersApp(
|
||||
urlLauncher = urlLauncher,
|
||||
)
|
||||
) { url -> webUri = url }
|
||||
}
|
||||
}
|
||||
|
||||
override fun onProvideAssistContent(outContent: AssistContent?) {
|
||||
super.onProvideAssistContent(outContent)
|
||||
webUri?.let { outContent?.webUri = Uri.parse(it) }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ private const val ScrollDelta = 50
|
|||
fun LobstersApp(
|
||||
viewModel: ClawViewModel = viewModel(),
|
||||
urlLauncher: UrlLauncher,
|
||||
setWebUri: (String) -> Unit,
|
||||
) {
|
||||
val copydown = remember { CopyDown() }
|
||||
val systemUiController = rememberSystemUiController()
|
||||
|
@ -117,6 +118,7 @@ fun LobstersApp(
|
|||
) { paddingValues ->
|
||||
NavHost(navController, startDestination = Destinations.Hottest) {
|
||||
composable(Destinations.Hottest) {
|
||||
setWebUri("https://lobste.rs/")
|
||||
HottestPosts(
|
||||
items,
|
||||
listState,
|
||||
|
@ -127,8 +129,10 @@ fun LobstersApp(
|
|||
)
|
||||
}
|
||||
composable(Destinations.Comments.format("{postId}")) { backStackEntry ->
|
||||
val postId = requireNotNull(backStackEntry.arguments?.getString("postId"))
|
||||
setWebUri("https://lobste.rs/s/$postId")
|
||||
CommentsPage(
|
||||
postId = requireNotNull(backStackEntry.arguments?.getString("postId")),
|
||||
postId = postId,
|
||||
getDetails = viewModel::getPostComments,
|
||||
htmlToMarkdown = { source -> copydown.convert(source) },
|
||||
paddingValues = paddingValues,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue