Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
reocat committed Jan 23, 2025
1 parent 0e1130c commit ac26c6c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
21 changes: 14 additions & 7 deletions app/src/main/java/com/dd3boh/outertune/ui/component/Dialog.kt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -376,7 +379,7 @@ fun CounterDialog(
IconButton(
onClick = {
if (tempValue.intValue < upperBound) {
tempValue.value += 1
tempValue.intValue += 1
}
},
onLongClick = {}
Expand All @@ -392,7 +395,7 @@ fun CounterDialog(
IconButton(
onClick = {
if (tempValue.intValue > lowerBound) {
tempValue.value -= 1
tempValue.intValue -= 1
}
},
onLongClick = {}
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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()
}
}
)
)
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/dd3boh/outertune/ui/menu/PlayerMenu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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 }
)
}
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/dd3boh/outertune/ui/menu/SongMenu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 }
)
}
Expand Down

0 comments on commit ac26c6c

Please sign in to comment.