diff --git a/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt b/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt
index e60c498eb..7c41d74d0 100644
--- a/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt
+++ b/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt
@@ -16,8 +16,15 @@
package com.google.samples.apps.nowinandroid.core.ui
+import android.content.ClipData
+import android.os.Build.VERSION
+import android.os.Build.VERSION_CODES
+import android.view.View
import androidx.compose.foundation.Canvas
+import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.Image
+import androidx.compose.foundation.draganddrop.dragAndDropSource
+import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
@@ -45,6 +52,7 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
+import androidx.compose.ui.draganddrop.DragAndDropTransferData
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalInspectionMode
@@ -77,6 +85,7 @@ import java.util.Locale
* [NewsResource] card used on the following screens: For You, Saved
*/
+@OptIn(ExperimentalFoundationApi::class)
@Composable
fun NewsResourceCardExpanded(
userNewsResource: UserNewsResource,
@@ -88,6 +97,19 @@ fun NewsResourceCardExpanded(
modifier: Modifier = Modifier,
) {
val clickActionLabel = stringResource(R.string.core_ui_card_tap_action)
+ val sharingLabel = stringResource(R.string.core_ui_feed_sharing)
+ val sharingContent = stringResource(
+ R.string.core_ui_feed_sharing_data,
+ userNewsResource.title,
+ userNewsResource.url,
+ )
+
+ val dragAndDropFlags = if (VERSION.SDK_INT >= VERSION_CODES.N) {
+ View.DRAG_FLAG_GLOBAL
+ } else {
+ 0
+ }
+
Card(
onClick = onClick,
shape = RoundedCornerShape(16.dp),
@@ -112,7 +134,23 @@ fun NewsResourceCardExpanded(
Row {
NewsResourceTitle(
userNewsResource.title,
- modifier = Modifier.fillMaxWidth((.8f)),
+ modifier = Modifier
+ .fillMaxWidth((.8f))
+ .dragAndDropSource {
+ detectTapGestures(
+ onLongPress = {
+ startTransfer(
+ DragAndDropTransferData(
+ ClipData.newPlainText(
+ sharingLabel,
+ sharingContent,
+ ),
+ flags = dragAndDropFlags,
+ ),
+ )
+ },
+ )
+ },
)
Spacer(modifier = Modifier.weight(1f))
BookmarkButton(isBookmarked, onToggleBookmark)
diff --git a/core/ui/src/main/res/values/strings.xml b/core/ui/src/main/res/values/strings.xml
index ab76748ef..a97746a9c 100644
--- a/core/ui/src/main/res/values/strings.xml
+++ b/core/ui/src/main/res/values/strings.xml
@@ -29,4 +29,6 @@
Follow interest
Unfollow interest
+ Feed sharing
+ %1$s: %2$s