diff --git a/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsFeed.kt b/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsFeed.kt index e72b6286e..28c7217ff 100644 --- a/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsFeed.kt +++ b/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsFeed.kt @@ -73,7 +73,7 @@ fun LazyGridScope.newsFeed( } } -private fun launchCustomChromeTab(context: Context, uri: Uri, toolbarColor: Int) { +fun launchCustomChromeTab(context: Context, uri: Uri, toolbarColor: Int) { val customTabBarColor = CustomTabColorSchemeParams.Builder() .setToolbarColor(toolbarColor).build() val customTabsIntent = CustomTabsIntent.Builder() diff --git a/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCardList.kt b/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCardList.kt index 25a7bd2dc..6c5e7ffcb 100644 --- a/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCardList.kt +++ b/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCardList.kt @@ -20,7 +20,9 @@ import android.content.Intent import android.net.Uri import androidx.compose.foundation.lazy.LazyListScope import androidx.compose.foundation.lazy.items +import androidx.compose.material3.MaterialTheme import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.platform.LocalContext import androidx.core.content.ContextCompat import com.google.samples.apps.nowinandroid.core.model.data.NewsResource @@ -47,8 +49,8 @@ fun LazyListScope.newsResourceCardItems( key = { newsResourceMapper(it).id }, itemContent = { item -> val newsResource = newsResourceMapper(item) - val launchResourceIntent = - Intent(Intent.ACTION_VIEW, Uri.parse(newsResource.url)) + val resourceUrl = Uri.parse(newsResource.url) + val backgroundColor = MaterialTheme.colorScheme.background.toArgb() val context = LocalContext.current NewsResourceCardExpanded( @@ -57,7 +59,7 @@ fun LazyListScope.newsResourceCardItems( onToggleBookmark = { onToggleBookmark(item) }, onClick = { when (onItemClick) { - null -> ContextCompat.startActivity(context, launchResourceIntent, null) + null -> launchCustomChromeTab(context, resourceUrl, backgroundColor) else -> onItemClick(item) } },