[1.227.*] Pre-release merge (#700)
This commit is contained in:
@@ -15,7 +15,7 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||
import com.deliveryhero.whetstone.activity.ContributesActivityInjector
|
||||
import dev.msfjarvis.claw.android.ui.screens.LobstersPostsScreen
|
||||
import dev.msfjarvis.claw.android.ui.screens.TwoPaneLayout
|
||||
import dev.msfjarvis.claw.android.ui.screens.TabletScreen
|
||||
|
||||
@ContributesActivityInjector
|
||||
class MainActivity : BaseActivity() {
|
||||
@@ -36,7 +36,7 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
else -> {
|
||||
TwoPaneLayout(
|
||||
TabletScreen(
|
||||
urlLauncher = urlLauncher,
|
||||
htmlConverter = htmlConverter,
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
|
||||
@@ -7,12 +7,8 @@
|
||||
package dev.msfjarvis.claw.android.ui
|
||||
|
||||
import android.content.Context
|
||||
import android.content.ContextWrapper
|
||||
import android.content.Intent
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.navigation.NavController
|
||||
import com.slack.eithernet.ApiResult
|
||||
import dev.msfjarvis.claw.android.ui.navigation.Comments
|
||||
import dev.msfjarvis.claw.android.viewmodel.ClawViewModel
|
||||
import dev.msfjarvis.claw.common.posts.PostActions
|
||||
import dev.msfjarvis.claw.common.urllauncher.UrlLauncher
|
||||
@@ -21,19 +17,11 @@ import dev.msfjarvis.claw.model.UIPost
|
||||
import java.io.IOException
|
||||
import java.net.HttpURLConnection
|
||||
|
||||
fun Context.getActivity(): ComponentActivity? {
|
||||
return when (this) {
|
||||
is ComponentActivity -> this
|
||||
is ContextWrapper -> baseContext.getActivity()
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
fun PostActions(
|
||||
context: Context,
|
||||
urlLauncher: UrlLauncher,
|
||||
navController: NavController,
|
||||
viewModel: ClawViewModel,
|
||||
navigateToComments: (String) -> Unit,
|
||||
): PostActions {
|
||||
return object : PostActions {
|
||||
override fun viewPost(postId: String, postUrl: String, commentsUrl: String) {
|
||||
@@ -43,7 +31,7 @@ fun PostActions(
|
||||
|
||||
override fun viewComments(postId: String) {
|
||||
viewModel.markPostAsRead(postId)
|
||||
navController.navigate(Comments(postId))
|
||||
navigateToComments(postId)
|
||||
}
|
||||
|
||||
override fun viewCommentsPage(post: UIPost) {
|
||||
@@ -80,57 +68,6 @@ fun PostActions(
|
||||
}
|
||||
}
|
||||
|
||||
fun TwoPaneLayoutPostActions(
|
||||
context: Context,
|
||||
urlLauncher: UrlLauncher,
|
||||
viewModel: ClawViewModel,
|
||||
setSelectedPost: (String) -> Unit,
|
||||
): PostActions {
|
||||
return object : PostActions {
|
||||
override fun viewPost(postId: String, postUrl: String, commentsUrl: String) {
|
||||
viewModel.markPostAsRead(postId)
|
||||
urlLauncher.openUri(postUrl.ifEmpty { commentsUrl })
|
||||
}
|
||||
|
||||
override fun viewComments(postId: String) {
|
||||
viewModel.markPostAsRead(postId)
|
||||
setSelectedPost(postId)
|
||||
}
|
||||
|
||||
override fun viewCommentsPage(post: UIPost) {
|
||||
urlLauncher.openUri(post.commentsUrl)
|
||||
}
|
||||
|
||||
override fun toggleSave(post: UIPost) {
|
||||
viewModel.toggleSave(post)
|
||||
}
|
||||
|
||||
override fun share(post: UIPost) {
|
||||
val sendIntent =
|
||||
Intent().apply {
|
||||
action = Intent.ACTION_SEND
|
||||
putExtra(Intent.EXTRA_TEXT, post.url.ifEmpty { post.commentsUrl })
|
||||
putExtra(Intent.EXTRA_TITLE, post.title)
|
||||
type = "text/plain"
|
||||
}
|
||||
val shareIntent = Intent.createChooser(sendIntent, null)
|
||||
context.startActivity(shareIntent)
|
||||
}
|
||||
|
||||
override fun isPostRead(post: UIPost): Boolean = viewModel.isPostRead(post)
|
||||
|
||||
override fun isPostSaved(post: UIPost): Boolean = viewModel.isPostSaved(post)
|
||||
|
||||
override suspend fun getComments(postId: String): UIPost {
|
||||
return viewModel.getPostComments(postId)
|
||||
}
|
||||
|
||||
override suspend fun getLinkMetadata(url: String): LinkMetadata {
|
||||
return viewModel.getLinkMetadata(url)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an [ApiResult.Failure.HttpFailure] to a scoped down error with a more useful user-facing
|
||||
* message.
|
||||
|
||||
+7
-6
@@ -7,6 +7,7 @@
|
||||
package dev.msfjarvis.claw.android.ui.screens
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.activity.compose.LocalActivity
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.animation.fadeIn
|
||||
@@ -66,7 +67,6 @@ import dev.msfjarvis.claw.android.ui.PostActions
|
||||
import dev.msfjarvis.claw.android.ui.decorations.ClawNavigationBar
|
||||
import dev.msfjarvis.claw.android.ui.decorations.ClawNavigationRail
|
||||
import dev.msfjarvis.claw.android.ui.decorations.NavigationItem
|
||||
import dev.msfjarvis.claw.android.ui.getActivity
|
||||
import dev.msfjarvis.claw.android.ui.lists.DatabasePosts
|
||||
import dev.msfjarvis.claw.android.ui.lists.NetworkPosts
|
||||
import dev.msfjarvis.claw.android.ui.navigation.AboutLibraries
|
||||
@@ -100,6 +100,7 @@ fun LobstersPostsScreen(
|
||||
viewModel: ClawViewModel = injectedViewModel(),
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val activity = LocalActivity.current
|
||||
val hottestListState = rememberLazyListState()
|
||||
val newestListState = rememberLazyListState()
|
||||
val savedListState = rememberLazyListState()
|
||||
@@ -108,7 +109,9 @@ fun LobstersPostsScreen(
|
||||
val currentDestination = navBackStackEntry?.destination
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
val snackbarHostState = remember { SnackbarHostState() }
|
||||
val postActions = remember { PostActions(context, urlLauncher, navController, viewModel) }
|
||||
val postActions = remember {
|
||||
PostActions(context, urlLauncher, viewModel) { navController.navigate(Comments(it)) }
|
||||
}
|
||||
val hazeState = remember { HazeState() }
|
||||
|
||||
val hottestPosts = viewModel.hottestPosts.collectAsLazyPagingItems()
|
||||
@@ -117,7 +120,7 @@ fun LobstersPostsScreen(
|
||||
|
||||
val navigationType = ClawNavigationType.fromSize(windowSizeClass.widthSizeClass)
|
||||
|
||||
val postIdOverride = context.getActivity()?.intent?.extras?.getString(MainActivity.NAVIGATION_KEY)
|
||||
val postIdOverride = activity?.intent?.extras?.getString(MainActivity.NAVIGATION_KEY)
|
||||
LaunchedEffect(Unit) {
|
||||
if (postIdOverride != null) {
|
||||
navController.navigate(Comments(postIdOverride))
|
||||
@@ -165,9 +168,7 @@ fun LobstersPostsScreen(
|
||||
if (
|
||||
navController.previousBackStackEntry != null && currentDestination.none(navDestinations)
|
||||
) {
|
||||
IconButton(
|
||||
onClick = { if (!navController.popBackStack()) context.getActivity()?.finish() }
|
||||
) {
|
||||
IconButton(onClick = { if (!navController.popBackStack()) activity?.finish() }) {
|
||||
Icon(
|
||||
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
|
||||
contentDescription = "Go back to previous screen",
|
||||
|
||||
@@ -39,7 +39,9 @@ fun SearchScreen(
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val navController = rememberNavController()
|
||||
val postActions = remember { PostActions(context, urlLauncher, navController, viewModel) }
|
||||
val postActions = remember {
|
||||
PostActions(context, urlLauncher, viewModel) { navController.navigate(Comments(it)) }
|
||||
}
|
||||
val listState = rememberLazyListState()
|
||||
val searchResults = viewModel.searchResults.collectAsLazyPagingItems()
|
||||
|
||||
|
||||
+3
-3
@@ -42,7 +42,7 @@ import androidx.navigation.compose.rememberNavController
|
||||
import androidx.paging.compose.collectAsLazyPagingItems
|
||||
import com.deliveryhero.whetstone.compose.injectedViewModel
|
||||
import dev.msfjarvis.claw.android.R
|
||||
import dev.msfjarvis.claw.android.ui.TwoPaneLayoutPostActions
|
||||
import dev.msfjarvis.claw.android.ui.PostActions
|
||||
import dev.msfjarvis.claw.android.ui.lists.NetworkPosts
|
||||
import dev.msfjarvis.claw.android.ui.navigation.Comments
|
||||
import dev.msfjarvis.claw.android.ui.navigation.User
|
||||
@@ -60,7 +60,7 @@ private fun ThreePaneScaffoldNavigator<*>.isDetailExpanded() =
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun TwoPaneLayout(
|
||||
fun TabletScreen(
|
||||
urlLauncher: UrlLauncher,
|
||||
htmlConverter: HTMLConverter,
|
||||
modifier: Modifier = Modifier,
|
||||
@@ -80,7 +80,7 @@ fun TwoPaneLayout(
|
||||
}
|
||||
|
||||
val postActions = remember {
|
||||
TwoPaneLayoutPostActions(context, urlLauncher, viewModel) {
|
||||
PostActions(context, urlLauncher, viewModel) {
|
||||
coroutineScope.launch {
|
||||
navigator.navigateTo(pane = ListDetailPaneScaffoldRole.Detail, contentKey = Comments(it))
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
[versions]
|
||||
aboutLibraries = "11.2.3"
|
||||
agp = "8.7.1"
|
||||
agp = "8.7.2"
|
||||
android-junit5 = "1.11.2.0"
|
||||
androidx-test = "1.6.1"
|
||||
benchmark = "1.4.0-alpha04"
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionSha256Sum=2522b1593704b6b26e03cb2dec86d792b1c6ca5c33d10e078fab7a146354130e
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-rc-1-bin.zip
|
||||
distributionSha256Sum=7565ee2f3d2193fce6e752f474be66eb0c6252f0c9ef792a8bffda6e7fd31b36
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-rc-2-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
Reference in New Issue
Block a user