11package org.schabi.newpipe.ui.components.video.comment
22
33import android.content.res.Configuration
4- import android.os.Build
5- import android.widget.Toast
64import androidx.compose.animation.animateContentSize
75import androidx.compose.foundation.ExperimentalFoundationApi
86import androidx.compose.foundation.clickable
@@ -34,7 +32,6 @@ import androidx.compose.runtime.setValue
3432import androidx.compose.ui.Alignment
3533import androidx.compose.ui.Modifier
3634import androidx.compose.ui.draw.clip
37- import androidx.compose.ui.platform.LocalClipboardManager
3835import androidx.compose.ui.platform.LocalContext
3936import androidx.compose.ui.res.painterResource
4037import androidx.compose.ui.res.pluralStringResource
@@ -53,12 +50,12 @@ import org.schabi.newpipe.ui.components.common.rememberParsedDescription
5350import org.schabi.newpipe.ui.theme.AppTheme
5451import org.schabi.newpipe.util.Localization
5552import org.schabi.newpipe.util.NavigationHelper
53+ import org.schabi.newpipe.util.external_communication.copyToClipboardCallback
5654import org.schabi.newpipe.util.image.ImageStrategy
5755
5856@OptIn(ExperimentalFoundationApi ::class )
5957@Composable
6058fun Comment (comment : CommentsInfoItem , onCommentAuthorOpened : () -> Unit ) {
61- val clipboardManager = LocalClipboardManager .current
6259 val context = LocalContext .current
6360 var isExpanded by rememberSaveable { mutableStateOf(false ) }
6461 var showReplies by rememberSaveable { mutableStateOf(false ) }
@@ -68,14 +65,8 @@ fun Comment(comment: CommentsInfoItem, onCommentAuthorOpened: () -> Unit) {
6865 modifier = Modifier
6966 .animateContentSize()
7067 .combinedClickable(
71- onLongClick = {
72- clipboardManager.setText(parsedDescription)
73- if (Build .VERSION .SDK_INT < 33 ) {
74- // Android 13 has its own "copied to clipboard" dialog
75- Toast .makeText(context, R .string.msg_copied, Toast .LENGTH_SHORT ).show()
76- }
77- },
78- onClick = { isExpanded = ! isExpanded }
68+ onLongClick = copyToClipboardCallback { parsedDescription },
69+ onClick = { isExpanded = ! isExpanded },
7970 )
8071 .padding(start = 8 .dp, top = 10 .dp, end = 8 .dp, bottom = 4 .dp),
8172 horizontalArrangement = Arrangement .spacedBy(8 .dp)
0 commit comments