Add re-fetch lyrics button (#163)
This commit is contained in:
parent
939b674133
commit
c6ee435eef
2 changed files with 67 additions and 50 deletions
|
@ -119,7 +119,7 @@ interface Database {
|
||||||
fun lyrics(songId: String): Flow<String?>
|
fun lyrics(songId: String): Flow<String?>
|
||||||
|
|
||||||
@Query("UPDATE Song SET lyrics = :lyrics WHERE id = :songId")
|
@Query("UPDATE Song SET lyrics = :lyrics WHERE id = :songId")
|
||||||
fun updateLyrics(songId: String, lyrics: String): Int
|
fun updateLyrics(songId: String, lyrics: String?): Int
|
||||||
|
|
||||||
@Query("SELECT * FROM Artist WHERE id = :id")
|
@Query("SELECT * FROM Artist WHERE id = :id")
|
||||||
fun artist(id: String): Flow<Artist?>
|
fun artist(id: String): Flow<Artist?>
|
||||||
|
|
|
@ -90,6 +90,8 @@ import it.vfsfitvnm.vimusic.ui.components.SeekBar
|
||||||
import it.vfsfitvnm.vimusic.ui.components.rememberBottomSheetState
|
import it.vfsfitvnm.vimusic.ui.components.rememberBottomSheetState
|
||||||
import it.vfsfitvnm.vimusic.ui.components.themed.BaseMediaItemMenu
|
import it.vfsfitvnm.vimusic.ui.components.themed.BaseMediaItemMenu
|
||||||
import it.vfsfitvnm.vimusic.ui.components.themed.LoadingOrError
|
import it.vfsfitvnm.vimusic.ui.components.themed.LoadingOrError
|
||||||
|
import it.vfsfitvnm.vimusic.ui.components.themed.Menu
|
||||||
|
import it.vfsfitvnm.vimusic.ui.components.themed.MenuEntry
|
||||||
import it.vfsfitvnm.vimusic.ui.components.themed.TextFieldDialog
|
import it.vfsfitvnm.vimusic.ui.components.themed.TextFieldDialog
|
||||||
import it.vfsfitvnm.vimusic.ui.components.themed.TextPlaceholder
|
import it.vfsfitvnm.vimusic.ui.components.themed.TextPlaceholder
|
||||||
import it.vfsfitvnm.vimusic.ui.styling.BlackColorPalette
|
import it.vfsfitvnm.vimusic.ui.styling.BlackColorPalette
|
||||||
|
@ -354,7 +356,8 @@ fun PlayerView(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.clickable {
|
.clickable {
|
||||||
menuState.display {
|
menuState.display {
|
||||||
val resultRegistryOwner = LocalActivityResultRegistryOwner.current
|
val resultRegistryOwner =
|
||||||
|
LocalActivityResultRegistryOwner.current
|
||||||
|
|
||||||
BaseMediaItemMenu(
|
BaseMediaItemMenu(
|
||||||
mediaItem = mediaItem,
|
mediaItem = mediaItem,
|
||||||
|
@ -667,58 +670,72 @@ private fun Lyrics(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Row(
|
val menuState = LocalMenuState.current
|
||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
|
||||||
verticalAlignment = Alignment.Bottom,
|
|
||||||
modifier = Modifier
|
|
||||||
.aspectRatio(1f)
|
|
||||||
.size(size)
|
|
||||||
) {
|
|
||||||
Image(
|
|
||||||
painter = painterResource(R.drawable.search),
|
|
||||||
contentDescription = null,
|
|
||||||
colorFilter = ColorFilter.tint(DarkColorPalette.text),
|
|
||||||
modifier = Modifier
|
|
||||||
.padding(all = 4.dp)
|
|
||||||
.clickable {
|
|
||||||
val mediaMetadata = mediaMetadataProvider()
|
|
||||||
|
|
||||||
val intent = Intent(Intent.ACTION_WEB_SEARCH).apply {
|
Image(
|
||||||
putExtra(
|
painter = painterResource(R.drawable.ellipsis_horizontal),
|
||||||
SearchManager.QUERY,
|
contentDescription = null,
|
||||||
"${mediaMetadata.title} ${mediaMetadata.artist} lyrics"
|
colorFilter = ColorFilter.tint(DarkColorPalette.text),
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(all = 4.dp)
|
||||||
|
.clickable {
|
||||||
|
menuState.display {
|
||||||
|
Menu {
|
||||||
|
MenuEntry(
|
||||||
|
icon = R.drawable.pencil,
|
||||||
|
text = "Edit lyrics",
|
||||||
|
onClick = {
|
||||||
|
menuState.hide()
|
||||||
|
isEditingLyrics = true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
MenuEntry(
|
||||||
|
icon = R.drawable.search,
|
||||||
|
text = "Search lyrics online",
|
||||||
|
onClick = {
|
||||||
|
menuState.hide()
|
||||||
|
val mediaMetadata = mediaMetadataProvider()
|
||||||
|
|
||||||
|
val intent =
|
||||||
|
Intent(Intent.ACTION_WEB_SEARCH).apply {
|
||||||
|
putExtra(
|
||||||
|
SearchManager.QUERY,
|
||||||
|
"${mediaMetadata.title} ${mediaMetadata.artist} lyrics"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (intent.resolveActivity(context.packageManager) != null) {
|
||||||
|
context.startActivity(intent)
|
||||||
|
} else {
|
||||||
|
Toast
|
||||||
|
.makeText(
|
||||||
|
context,
|
||||||
|
"No browser app found!",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
)
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
MenuEntry(
|
||||||
|
icon = R.drawable.download,
|
||||||
|
text = "Fetch lyrics again",
|
||||||
|
onClick = {
|
||||||
|
menuState.hide()
|
||||||
|
query {
|
||||||
|
Database.updateLyrics(mediaId, null)
|
||||||
|
}
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (intent.resolveActivity(context.packageManager) != null) {
|
|
||||||
context.startActivity(intent)
|
|
||||||
} else {
|
|
||||||
Toast
|
|
||||||
.makeText(
|
|
||||||
context,
|
|
||||||
"No browser app found!",
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
)
|
|
||||||
.show()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.padding(all = 8.dp)
|
}
|
||||||
.size(20.dp)
|
.padding(all = 8.dp)
|
||||||
)
|
.size(20.dp)
|
||||||
|
.align(Alignment.BottomEnd)
|
||||||
Image(
|
)
|
||||||
painter = painterResource(R.drawable.pencil),
|
|
||||||
contentDescription = null,
|
|
||||||
colorFilter = ColorFilter.tint(DarkColorPalette.text),
|
|
||||||
modifier = Modifier
|
|
||||||
.padding(all = 4.dp)
|
|
||||||
.clickable {
|
|
||||||
isEditingLyrics = true
|
|
||||||
}
|
|
||||||
.padding(all = 8.dp)
|
|
||||||
.size(20.dp)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue