From ac26c6c7483bc3a653ce2aa50749d421368ebb0c Mon Sep 17 00:00:00 2001 From: reocat Date: Thu, 23 Jan 2025 23:14:29 +0300 Subject: [PATCH] Fix warnings --- .../dd3boh/outertune/ui/component/Dialog.kt | 21 ++++++++++++------- .../dd3boh/outertune/ui/menu/PlayerMenu.kt | 6 +++--- .../com/dd3boh/outertune/ui/menu/SongMenu.kt | 6 +++--- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/dd3boh/outertune/ui/component/Dialog.kt b/app/src/main/java/com/dd3boh/outertune/ui/component/Dialog.kt index e8d787eb2..7662b7f2c 100644 --- a/app/src/main/java/com/dd3boh/outertune/ui/component/Dialog.kt +++ b/app/src/main/java/com/dd3boh/outertune/ui/component/Dialog.kt @@ -1,5 +1,6 @@ package com.dd3boh.outertune.ui.component +import android.content.ClipData import android.text.format.Formatter import android.widget.Toast import androidx.compose.foundation.background @@ -48,15 +49,16 @@ import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.focusRequester -import androidx.compose.ui.platform.ClipboardManager +import androidx.compose.ui.platform.ClipEntry +import androidx.compose.ui.platform.Clipboard import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource -import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.text.style.TextOverflow @@ -68,6 +70,7 @@ import com.dd3boh.outertune.constants.DialogCornerRadius import com.dd3boh.outertune.db.entities.FormatEntity import com.dd3boh.outertune.models.MediaMetadata import kotlinx.coroutines.delay +import kotlinx.coroutines.launch import java.io.File @Composable @@ -376,7 +379,7 @@ fun CounterDialog( IconButton( onClick = { if (tempValue.intValue < upperBound) { - tempValue.value += 1 + tempValue.intValue += 1 } }, onLongClick = {} @@ -392,7 +395,7 @@ fun CounterDialog( IconButton( onClick = { if (tempValue.intValue > lowerBound) { - tempValue.value -= 1 + tempValue.intValue -= 1 } }, onLongClick = {} @@ -461,10 +464,11 @@ fun DetailsDialog( currentFormat: FormatEntity?, currentPlayCount: Int?, volume: Float, - clipboardManager: ClipboardManager, + clipboard: Clipboard, setVisibility: (newState: Boolean) -> Unit, ) { val context = LocalContext.current + val coroutineScope = rememberCoroutineScope() AlertDialog( properties = DialogProperties(usePlatformDefaultWidth = false), @@ -544,8 +548,11 @@ fun DetailsDialog( interactionSource = remember { MutableInteractionSource() }, indication = null, onClick = { - clipboardManager.setText(AnnotatedString(displayText)) - Toast.makeText(context, R.string.copied, Toast.LENGTH_SHORT).show() + coroutineScope.launch { + val clipData = ClipData.newPlainText("label", displayText) + clipboard.setClipEntry(ClipEntry(clipData)) + Toast.makeText(context, R.string.copied, Toast.LENGTH_SHORT).show() + } } ) ) diff --git a/app/src/main/java/com/dd3boh/outertune/ui/menu/PlayerMenu.kt b/app/src/main/java/com/dd3boh/outertune/ui/menu/PlayerMenu.kt index 108e2ac0d..b9351ffe1 100644 --- a/app/src/main/java/com/dd3boh/outertune/ui/menu/PlayerMenu.kt +++ b/app/src/main/java/com/dd3boh/outertune/ui/menu/PlayerMenu.kt @@ -55,7 +55,7 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.vector.ImageVector -import androidx.compose.ui.platform.LocalClipboardManager +import androidx.compose.ui.platform.LocalClipboard import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.res.stringResource @@ -110,7 +110,7 @@ fun PlayerMenu( val context = LocalContext.current val database = LocalDatabase.current val downloadUtil = LocalDownloadUtil.current - val clipboardManager = LocalClipboardManager.current + val clipboard = LocalClipboard.current val playerConnection = LocalPlayerConnection.current ?: return val playerVolume = playerConnection.service.playerVolume.collectAsState() @@ -303,7 +303,7 @@ fun PlayerMenu( currentFormat = currentFormat, currentPlayCount = librarySong?.playCount?.fastSumBy { it.count }?: 0, volume = playerConnection.player.volume, - clipboardManager = clipboardManager, + clipboard = clipboard, setVisibility = {showDetailsDialog = it } ) } diff --git a/app/src/main/java/com/dd3boh/outertune/ui/menu/SongMenu.kt b/app/src/main/java/com/dd3boh/outertune/ui/menu/SongMenu.kt index 8e9d3c5bb..6c7a9a03f 100644 --- a/app/src/main/java/com/dd3boh/outertune/ui/menu/SongMenu.kt +++ b/app/src/main/java/com/dd3boh/outertune/ui/menu/SongMenu.kt @@ -44,7 +44,7 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip -import androidx.compose.ui.platform.LocalClipboardManager +import androidx.compose.ui.platform.LocalClipboard import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource @@ -99,7 +99,7 @@ fun SongMenu( val context = LocalContext.current val database = LocalDatabase.current val downloadUtil = LocalDownloadUtil.current - val clipboardManager = LocalClipboardManager.current + val clipboard = LocalClipboard.current val playerConnection = LocalPlayerConnection.current ?: return val songState = database.song(originalSong.id).collectAsState(initial = originalSong) @@ -227,7 +227,7 @@ fun SongMenu( currentFormat = currentFormat, currentPlayCount = song.playCount?.fastSumBy { it.count }?: 0, volume = playerConnection.player.volume, - clipboardManager = clipboardManager, + clipboard = clipboard, setVisibility = {showDetailsDialog = it } ) }