From 9cb85e40ced82954e77eed326cfe5adb8b2653ea Mon Sep 17 00:00:00 2001 From: twistios <54811436+twistios@users.noreply.github.com> Date: Wed, 8 Jan 2025 23:26:16 +0100 Subject: [PATCH 01/17] added method for dislike in database --- composeApp/src/androidMain/kotlin/it/fast4x/rimusic/Database.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/Database.kt b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/Database.kt index beb584a54e..f4d1570000 100644 --- a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/Database.kt +++ b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/Database.kt @@ -1347,6 +1347,8 @@ interface Database { @Query("UPDATE Song SET likedAt = :likedAt WHERE id = :songId") fun like(songId: String, likedAt: Long?): Int + fun dislike(songId: String): Int = like(songId, -1L) + @Query("UPDATE Song SET durationText = :durationText WHERE id = :songId") fun updateDurationText(songId: String, durationText: String): Int From c192f6a83ff7098399679bd5d738b24e8db86242 Mon Sep 17 00:00:00 2001 From: twistios <54811436+twistios@users.noreply.github.com> Date: Wed, 8 Jan 2025 23:27:02 +0100 Subject: [PATCH 02/17] added method `setDislike` --- .../src/androidMain/kotlin/it/fast4x/rimusic/models/Song.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/models/Song.kt b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/models/Song.kt index 37b5279fa9..f41ebaf71f 100644 --- a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/models/Song.kt +++ b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/models/Song.kt @@ -40,6 +40,12 @@ data class Song( ) } + fun setDislike(): Song { + return copy( + likedAt = -1L + ) + } + fun cleanTitle() = cleanPrefix( this.title ) fun relativePlayTime(): Double { From e7ae37ad7da1281e71a32b3d77493ed47ff9490e Mon Sep 17 00:00:00 2001 From: twistios <54811436+twistios@users.noreply.github.com> Date: Wed, 8 Jan 2025 23:31:35 +0100 Subject: [PATCH 03/17] implemented "dislike" by long-tap on like-icon in controls --- .../ui/components/themed/IconButton.kt | 11 ++++++-- .../player/components/controls/Essential.kt | 28 +++++++++++++++++++ .../player/components/controls/Modern.kt | 13 +++++++++ 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/components/themed/IconButton.kt b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/components/themed/IconButton.kt index 31f6f92d74..1dda9e046b 100644 --- a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/components/themed/IconButton.kt +++ b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/components/themed/IconButton.kt @@ -1,9 +1,11 @@ package it.fast4x.rimusic.ui.components.themed import androidx.annotation.DrawableRes +import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.Image import androidx.compose.foundation.Indication import androidx.compose.foundation.clickable +import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size @@ -39,6 +41,7 @@ fun HeaderIconButton( ) } +@OptIn(ExperimentalFoundationApi::class) @Composable fun IconButton( onClick: () -> Unit, @@ -46,18 +49,20 @@ fun IconButton( color: Color, modifier: Modifier = Modifier, enabled: Boolean = true, - indication: Indication? = null + indication: Indication? = null, + onLongClick: (() -> Unit)? = null, ) { Image( painter = painterResource(icon), contentDescription = null, colorFilter = ColorFilter.tint(color), modifier = Modifier - .clickable( + .combinedClickable( indication = indication ?: ripple(bounded = false), interactionSource = remember { MutableInteractionSource() }, enabled = enabled, - onClick = onClick + onClick = onClick, + onLongClick = onLongClick ) .then(modifier) ) diff --git a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Essential.kt b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Essential.kt index 596821f6ab..daf3c458ea 100644 --- a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Essential.kt +++ b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Essential.kt @@ -1,5 +1,6 @@ package it.fast4x.rimusic.ui.screens.player.components.controls +import android.annotation.SuppressLint import androidx.compose.animation.core.LinearEasing import androidx.compose.animation.core.animateDp import androidx.compose.animation.core.tween @@ -99,6 +100,7 @@ import it.fast4x.rimusic.utils.HorizontalfadingEdge2 import it.fast4x.rimusic.utils.conditional +@SuppressLint("UnusedBoxWithConstraintsScope") @UnstableApi @ExperimentalFoundationApi @Composable @@ -243,6 +245,19 @@ fun InfoAlbumAndArtistEssential( } if (effectRotationEnabled) isRotated = !isRotated }, + onLongClick = { + val currentMediaItem = binder.player.currentMediaItem + Database.asyncTransaction { + if (dislike(mediaId) == 0) { + currentMediaItem + ?.takeIf { it.mediaId == mediaId } + ?.let { + insert(currentMediaItem, Song::setDislike) + } + } + } + if (effectRotationEnabled) isRotated = !isRotated + }, modifier = Modifier .padding(start = 5.dp) .size(24.dp) @@ -403,6 +418,19 @@ fun ControlsEssential( } if (effectRotationEnabled) isRotated = !isRotated }, + onLongClick = { + val currentMediaItem = binder.player.currentMediaItem + Database.asyncTransaction { + if (dislike(mediaId) == 0) { + currentMediaItem + ?.takeIf { it.mediaId == mediaId } + ?.let { + insert(currentMediaItem, Song::setDislike) + } + } + } + if (effectRotationEnabled) isRotated = !isRotated + }, modifier = Modifier //.padding(10.dp) .size(26.dp) diff --git a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Modern.kt b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Modern.kt index d9cb9cfc9a..40b9a950ad 100644 --- a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Modern.kt +++ b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Modern.kt @@ -246,6 +246,19 @@ fun InfoAlbumAndArtistModern( } if (effectRotationEnabled) isRotated = !isRotated }, + onLongClick = { + val currentMediaItem = binder.player.currentMediaItem + Database.asyncTransaction { + if (dislike(mediaId) == 0) { + currentMediaItem + ?.takeIf { it.mediaId == mediaId } + ?.let { + insert(currentMediaItem, Song::setDislike) + } + } + } + if (effectRotationEnabled) isRotated = !isRotated + }, modifier = Modifier .padding(start = 5.dp) .size(24.dp) From 80f162d3e67d8659817da0bbf7cb0db754b88fee Mon Sep 17 00:00:00 2001 From: twistios <54811436+twistios@users.noreply.github.com> Date: Wed, 8 Jan 2025 23:34:46 +0100 Subject: [PATCH 04/17] renamed to "setDisliked" --- .../src/androidMain/kotlin/it/fast4x/rimusic/models/Song.kt | 2 +- .../ui/screens/player/components/controls/Essential.kt | 4 ++-- .../rimusic/ui/screens/player/components/controls/Modern.kt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/models/Song.kt b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/models/Song.kt index f41ebaf71f..dfd6326e90 100644 --- a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/models/Song.kt +++ b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/models/Song.kt @@ -40,7 +40,7 @@ data class Song( ) } - fun setDislike(): Song { + fun setDisliked(): Song { return copy( likedAt = -1L ) diff --git a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Essential.kt b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Essential.kt index daf3c458ea..d778fea304 100644 --- a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Essential.kt +++ b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Essential.kt @@ -252,7 +252,7 @@ fun InfoAlbumAndArtistEssential( currentMediaItem ?.takeIf { it.mediaId == mediaId } ?.let { - insert(currentMediaItem, Song::setDislike) + insert(currentMediaItem, Song::setDisliked) } } } @@ -425,7 +425,7 @@ fun ControlsEssential( currentMediaItem ?.takeIf { it.mediaId == mediaId } ?.let { - insert(currentMediaItem, Song::setDislike) + insert(currentMediaItem, Song::setDisliked) } } } diff --git a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Modern.kt b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Modern.kt index 40b9a950ad..6f8fa4925b 100644 --- a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Modern.kt +++ b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Modern.kt @@ -253,7 +253,7 @@ fun InfoAlbumAndArtistModern( currentMediaItem ?.takeIf { it.mediaId == mediaId } ?.let { - insert(currentMediaItem, Song::setDislike) + insert(currentMediaItem, Song::setDisliked) } } } From 3eef7525e122c6e678678fe88df616d6871678b1 Mon Sep 17 00:00:00 2001 From: twistios <54811436+twistios@users.noreply.github.com> Date: Wed, 8 Jan 2025 23:37:14 +0100 Subject: [PATCH 05/17] refactor: moved argument in parameter list --- .../it/fast4x/rimusic/ui/components/themed/IconButton.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/components/themed/IconButton.kt b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/components/themed/IconButton.kt index 1dda9e046b..39d55e70ff 100644 --- a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/components/themed/IconButton.kt +++ b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/components/themed/IconButton.kt @@ -45,12 +45,12 @@ fun HeaderIconButton( @Composable fun IconButton( onClick: () -> Unit, + onLongClick: (() -> Unit)? = null, @DrawableRes icon: Int, color: Color, modifier: Modifier = Modifier, enabled: Boolean = true, - indication: Indication? = null, - onLongClick: (() -> Unit)? = null, + indication: Indication? = null ) { Image( painter = painterResource(icon), From 75364bc37b504b9c00f2314530b543e6a09bb393 Mon Sep 17 00:00:00 2001 From: twistios <54811436+twistios@users.noreply.github.com> Date: Thu, 9 Jan 2025 23:51:57 +0100 Subject: [PATCH 06/17] improved code formatting --- .../player/components/controls/Essential.kt | 57 ++++++++++--------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Essential.kt b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Essential.kt index 2359546875..cf5cf9ba52 100644 --- a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Essential.kt +++ b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Essential.kt @@ -246,34 +246,35 @@ fun InfoAlbumAndArtistEssential( if (effectRotationEnabled) isRotated = !isRotated }, onLongClick = { - val currentMediaItem = binder.player.currentMediaItem - Database.asyncTransaction { - if (dislike(mediaId) == 0) { - currentMediaItem - ?.takeIf { it.mediaId == mediaId } - ?.let { - insert(currentMediaItem, Song::setDisliked) - } - } - } - if (effectRotationEnabled) isRotated = !isRotated - }, - modifier = Modifier - .padding(start = 5.dp) - .size(24.dp) - ) - if (playerBackgroundColors == PlayerBackgroundColors.BlurredCoverColor) { - Icon( - painter = painterResource(id = getUnlikedIcon()), - tint = colorPalette().text, - contentDescription = null, - modifier = Modifier - .padding(start = 5.dp) - .size(24.dp) - ) - } - } - }} + val currentMediaItem = binder.player.currentMediaItem + Database.asyncTransaction { + if (dislike(mediaId) == 0) { + currentMediaItem + ?.takeIf { it.mediaId == mediaId } + ?.let { + insert(currentMediaItem, Song::setDisliked) + } + } + } + if (effectRotationEnabled) isRotated = !isRotated + }, + modifier = Modifier + .padding(start = 5.dp) + .size(24.dp) + ) + if (playerBackgroundColors == PlayerBackgroundColors.BlurredCoverColor) { + Icon( + painter = painterResource(id = getUnlikedIcon()), + tint = colorPalette().text, + contentDescription = null, + modifier = Modifier + .padding(start = 5.dp) + .size(24.dp) + ) + } + } + } + } } } From 18a0cf621ab9cf0d3b6809c1b1fce2819069264f Mon Sep 17 00:00:00 2001 From: twistios <54811436+twistios@users.noreply.github.com> Date: Fri, 10 Jan 2025 00:01:29 +0100 Subject: [PATCH 07/17] added `setDislikeState` - similar to `setLikeState`, but for disliking --- .../kotlin/it/fast4x/rimusic/utils/LikeState.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/utils/LikeState.kt b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/utils/LikeState.kt index 60ed97b9af..daf5a4876c 100644 --- a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/utils/LikeState.kt +++ b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/utils/LikeState.kt @@ -36,6 +36,15 @@ fun setLikeState(likedAt: Long?): Long? { } //println("mediaItem setLikeState: $current") return current +} +fun setDisLikeState(likedAt: Long?): Long? { + val current = + when (likedAt) { + -1L -> null + null -> -1L + else -> -1L + } + return current } From 2c104bb5623168108632d16e636874ebf3447fe5 Mon Sep 17 00:00:00 2001 From: twistios <54811436+twistios@users.noreply.github.com> Date: Fri, 10 Jan 2025 00:04:09 +0100 Subject: [PATCH 08/17] renamed `setDisLiked` to `toggleDislike`, use `setDislikeState` - now uses `setDislikeState`, i.e. changes the value depending on the current value --- .../src/androidMain/kotlin/it/fast4x/rimusic/models/Song.kt | 5 +++-- .../ui/screens/player/components/controls/Essential.kt | 4 ++-- .../rimusic/ui/screens/player/components/controls/Modern.kt | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/models/Song.kt b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/models/Song.kt index dfd6326e90..da9ab230d1 100644 --- a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/models/Song.kt +++ b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/models/Song.kt @@ -5,6 +5,7 @@ import androidx.room.Entity import androidx.room.PrimaryKey import it.fast4x.rimusic.cleanPrefix import it.fast4x.rimusic.utils.durationTextToMillis +import it.fast4x.rimusic.utils.setDisLikeState import it.fast4x.rimusic.utils.setLikeState import kotlinx.serialization.Serializable @@ -40,9 +41,9 @@ data class Song( ) } - fun setDisliked(): Song { + fun toggleDislike(): Song { return copy( - likedAt = -1L + likedAt = setDisLikeState(likedAt) ) } diff --git a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Essential.kt b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Essential.kt index cf5cf9ba52..874ceb71aa 100644 --- a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Essential.kt +++ b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Essential.kt @@ -252,7 +252,7 @@ fun InfoAlbumAndArtistEssential( currentMediaItem ?.takeIf { it.mediaId == mediaId } ?.let { - insert(currentMediaItem, Song::setDisliked) + insert(currentMediaItem, Song::toggleDislike) } } } @@ -426,7 +426,7 @@ fun ControlsEssential( currentMediaItem ?.takeIf { it.mediaId == mediaId } ?.let { - insert(currentMediaItem, Song::setDisliked) + insert(currentMediaItem, Song::toggleDislike) } } } diff --git a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Modern.kt b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Modern.kt index 648de917ca..44516079b4 100644 --- a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Modern.kt +++ b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Modern.kt @@ -253,7 +253,7 @@ fun InfoAlbumAndArtistModern( currentMediaItem ?.takeIf { it.mediaId == mediaId } ?.let { - insert(currentMediaItem, Song::setDisliked) + insert(currentMediaItem, Song::toggleDislike) } } } From 4ed3a9a13dc92e065e3ac35023534c84bb578367 Mon Sep 17 00:00:00 2001 From: twistios <54811436+twistios@users.noreply.github.com> Date: Fri, 10 Jan 2025 00:29:33 +0100 Subject: [PATCH 09/17] implemented toggling between disliked and "unliked" - removed `dislike` from database as not needed anymore - implemented toggling similar to like-toggle via `setDisLikeState` --- .../src/androidMain/kotlin/it/fast4x/rimusic/Database.kt | 2 -- .../ui/screens/player/components/controls/Essential.kt | 5 +++-- .../rimusic/ui/screens/player/components/controls/Modern.kt | 3 ++- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/Database.kt b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/Database.kt index f4d1570000..beb584a54e 100644 --- a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/Database.kt +++ b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/Database.kt @@ -1347,8 +1347,6 @@ interface Database { @Query("UPDATE Song SET likedAt = :likedAt WHERE id = :songId") fun like(songId: String, likedAt: Long?): Int - fun dislike(songId: String): Int = like(songId, -1L) - @Query("UPDATE Song SET durationText = :durationText WHERE id = :songId") fun updateDurationText(songId: String, durationText: String): Int diff --git a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Essential.kt b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Essential.kt index 874ceb71aa..c9b6a39ec8 100644 --- a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Essential.kt +++ b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Essential.kt @@ -93,6 +93,7 @@ import it.fast4x.rimusic.utils.playerControlsTypeKey import it.fast4x.rimusic.utils.queueLoopTypeKey import it.fast4x.rimusic.utils.rememberPreference import it.fast4x.rimusic.utils.semiBold +import it.fast4x.rimusic.utils.setDisLikeState import it.fast4x.rimusic.utils.setLikeState import it.fast4x.rimusic.utils.setQueueLoopState import it.fast4x.rimusic.utils.showthumbnailKey @@ -248,7 +249,7 @@ fun InfoAlbumAndArtistEssential( onLongClick = { val currentMediaItem = binder.player.currentMediaItem Database.asyncTransaction { - if (dislike(mediaId) == 0) { + if (like(mediaId, setDisLikeState(likedAt)) == 0) { currentMediaItem ?.takeIf { it.mediaId == mediaId } ?.let { @@ -422,7 +423,7 @@ fun ControlsEssential( onLongClick = { val currentMediaItem = binder.player.currentMediaItem Database.asyncTransaction { - if (dislike(mediaId) == 0) { + if (like(mediaId, setDisLikeState(likedAt)) == 0) { currentMediaItem ?.takeIf { it.mediaId == mediaId } ?.let { diff --git a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Modern.kt b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Modern.kt index 44516079b4..8e2fd07df6 100644 --- a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Modern.kt +++ b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Modern.kt @@ -83,6 +83,7 @@ import it.fast4x.rimusic.utils.playerControlsTypeKey import it.fast4x.rimusic.utils.playerInfoShowIconsKey import it.fast4x.rimusic.utils.rememberPreference import it.fast4x.rimusic.utils.semiBold +import it.fast4x.rimusic.utils.setDisLikeState import it.fast4x.rimusic.utils.setLikeState import it.fast4x.rimusic.utils.showthumbnailKey import it.fast4x.rimusic.utils.textCopyToClipboard @@ -249,7 +250,7 @@ fun InfoAlbumAndArtistModern( onLongClick = { val currentMediaItem = binder.player.currentMediaItem Database.asyncTransaction { - if (dislike(mediaId) == 0) { + if (like(mediaId, setDisLikeState(likedAt)) == 0) { currentMediaItem ?.takeIf { it.mediaId == mediaId } ?.let { From 57da819985f67c89587514e27a62fde73222d214 Mon Sep 17 00:00:00 2001 From: twistios <54811436+twistios@users.noreply.github.com> Date: Fri, 10 Jan 2025 21:55:27 +0100 Subject: [PATCH 10/17] fixed `mediaItemToggleLike` - did not work properly with disliked songs - was automatically unliking songs if they where not in the db (so it seemed not to do anything on the first tap) - added `getLikedAt` as was required (likedAt returns a flow) --- .../kotlin/it/fast4x/rimusic/Database.kt | 3 +++ .../kotlin/it/fast4x/rimusic/utils/Utils.kt | 18 ++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/Database.kt b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/Database.kt index beb584a54e..4d6f4be5e7 100644 --- a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/Database.kt +++ b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/Database.kt @@ -1341,6 +1341,9 @@ interface Database { @Query("SELECT likedAt FROM Song WHERE id = :songId") fun likedAt(songId: String): Flow + @Query("SELECT likedAt FROM Song WHERE id = :songId") + fun getLikedAt(songId: String): Long? + @Query("UPDATE Album SET bookmarkedAt = :bookmarkedAt WHERE id = :id") fun bookmarkAlbum(id: String, bookmarkedAt: Long?): Int diff --git a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/utils/Utils.kt b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/utils/Utils.kt index 103c790419..d2f972e4e7 100644 --- a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/utils/Utils.kt +++ b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/utils/Utils.kt @@ -83,18 +83,16 @@ fun songToggleLike( song: Song ) { fun mediaItemToggleLike( mediaItem: MediaItem ) { Database.asyncTransaction { if (songExist(mediaItem.mediaId) == 0) - insert(mediaItem, Song::toggleLike) - //else { - if (songliked(mediaItem.mediaId) == 0) - like( - mediaItem.mediaId, - System.currentTimeMillis() - ) - else like( + insert(mediaItem) + if (getLikedAt(mediaItem.mediaId) in listOf(null, -1L)) + like( mediaItem.mediaId, - null + System.currentTimeMillis() ) - //} + else like( + mediaItem.mediaId, + null + ) } } From 59d6b2a633faa7f936ae24da29a15996626ba08b Mon Sep 17 00:00:00 2001 From: twistios <54811436+twistios@users.noreply.github.com> Date: Fri, 10 Jan 2025 23:02:13 +0100 Subject: [PATCH 11/17] added method `mediaItemSetLiked` - like a song if it was unliked/disliked - insert the song into the db if it was not there --- .../kotlin/it/fast4x/rimusic/utils/Utils.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/utils/Utils.kt b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/utils/Utils.kt index d2f972e4e7..50989e94e5 100644 --- a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/utils/Utils.kt +++ b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/utils/Utils.kt @@ -96,6 +96,18 @@ fun mediaItemToggleLike( mediaItem: MediaItem ) { } } +fun mediaItemSetLiked( mediaItem: MediaItem ) { + Database.asyncTransaction { + if (songExist(mediaItem.mediaId) == 0) + insert(mediaItem) + if (getLikedAt(mediaItem.mediaId) in listOf(null, -1L)) + like( + mediaItem.mediaId, + System.currentTimeMillis() + ) + } +} + fun albumItemToggleBookmarked( albumItem: Innertube.AlbumItem ) { Database.asyncTransaction { //if (Database.albumExist(albumItem.key) == 0) From eb236edfc61ae3b9b15787d13a4df291c0068468 Mon Sep 17 00:00:00 2001 From: twistios <54811436+twistios@users.noreply.github.com> Date: Fri, 10 Jan 2025 23:07:10 +0100 Subject: [PATCH 12/17] improved mass-liking for playlists and albums - also added smart message feedback to `AlbumDetails`, `LocalPlayListSongsModern` --- .../it/fast4x/rimusic/ui/screens/album/AlbumDetails.kt | 10 ++++------ .../screens/localplaylist/LocalPlaylistSongsModern.kt | 6 +++--- .../rimusic/ui/screens/playlist/PlaylistSongList.kt | 7 ++----- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/album/AlbumDetails.kt b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/album/AlbumDetails.kt index 66a6b6c386..1de95a31d1 100644 --- a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/album/AlbumDetails.kt +++ b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/album/AlbumDetails.kt @@ -141,6 +141,7 @@ import it.fast4x.rimusic.colorPalette import it.fast4x.rimusic.models.SongAlbumMap import it.fast4x.rimusic.service.MyDownloadHelper import it.fast4x.rimusic.typography +import it.fast4x.rimusic.utils.mediaItemSetLiked import it.fast4x.rimusic.utils.mediaItemToggleLike import kotlinx.coroutines.flow.first import timber.log.Timber @@ -980,12 +981,9 @@ fun AlbumDetails( }, onAddToFavourites = { songs.forEach { song -> - - val likedAt: Long? = song.likedAt - if(likedAt == null) { - mediaItemToggleLike(song.asMediaItem) - } - } + mediaItemSetLiked(song.asMediaItem) + } + SmartMessage(context.resources.getString(R.string.done), context = context) }, disableScrollingText = disableScrollingText ) diff --git a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/localplaylist/LocalPlaylistSongsModern.kt b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/localplaylist/LocalPlaylistSongsModern.kt index 2e782b74cb..ce6113341f 100644 --- a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/localplaylist/LocalPlaylistSongsModern.kt +++ b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/localplaylist/LocalPlaylistSongsModern.kt @@ -187,6 +187,7 @@ import it.fast4x.rimusic.utils.isDownloadedSong import it.fast4x.rimusic.utils.isNowPlaying import it.fast4x.rimusic.utils.saveImageToInternalStorage import it.fast4x.rimusic.models.SongEntity +import it.fast4x.rimusic.utils.mediaItemSetLiked import it.fast4x.rimusic.utils.mediaItemToggleLike import kotlinx.coroutines.flow.map @@ -1268,10 +1269,9 @@ fun LocalPlaylistSongsModern( }, onAddToPreferites = { playlistSongs.forEachIndexed { _, song -> - if(song.song.likedAt == null) { - mediaItemToggleLike(song.asMediaItem) - } + mediaItemSetLiked(song.asMediaItem) } + SmartMessage(context.resources.getString(R.string.done), context = context) }, onRenumberPositions = { if (playlistNotMonthlyType) diff --git a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/playlist/PlaylistSongList.kt b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/playlist/PlaylistSongList.kt index 52f28dd3dd..2bd4caafa3 100644 --- a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/playlist/PlaylistSongList.kt +++ b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/playlist/PlaylistSongList.kt @@ -136,6 +136,7 @@ import kotlinx.coroutines.withContext import it.fast4x.rimusic.colorPalette import it.fast4x.rimusic.models.Song import it.fast4x.rimusic.typography +import it.fast4x.rimusic.utils.mediaItemSetLiked import it.fast4x.rimusic.utils.setLikeState import timber.log.Timber @@ -655,11 +656,7 @@ fun PlaylistSongList( .combinedClickable( onClick = { playlistPage!!.songsPage?.items?.forEachIndexed { _, song -> - Database.asyncTransaction { - if ( like( song.asMediaItem.mediaId, setLikeState(song.asSong.likedAt) ) == 0 ) { - insert(song.asMediaItem, Song::toggleLike) - } - } + mediaItemSetLiked(song.asMediaItem) } SmartMessage(context.resources.getString(R.string.done), context = context) }, From a96d010ba48a729783053127fdbcb390e73d7d60 Mon Sep 17 00:00:00 2001 From: twistios <54811436+twistios@users.noreply.github.com> Date: Fri, 10 Jan 2025 23:30:08 +0100 Subject: [PATCH 13/17] implemented dislike in `MediaItemGridMenu` - directly via long-tap (skipping the step via single-tap cycling) --- .../ui/components/themed/MediaItemGridMenu.kt | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/components/themed/MediaItemGridMenu.kt b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/components/themed/MediaItemGridMenu.kt index 8126181cb6..eb9301ab48 100644 --- a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/components/themed/MediaItemGridMenu.kt +++ b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/components/themed/MediaItemGridMenu.kt @@ -91,7 +91,12 @@ import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import it.fast4x.rimusic.colorPalette +import it.fast4x.rimusic.context +import it.fast4x.rimusic.models.Song +import it.fast4x.rimusic.service.MyDownloadHelper import it.fast4x.rimusic.typography +import it.fast4x.rimusic.utils.getLikeState +import it.fast4x.rimusic.utils.setDisLikeState @OptIn(UnstableApi::class) @Composable @@ -292,14 +297,13 @@ fun MediaItemGridMenu ( val isLocal by remember { derivedStateOf { mediaItem.isLocal } } - var updateData by remember { - mutableStateOf(false) - } var likedAt by remember { mutableStateOf(null) } - LaunchedEffect(Unit, mediaItem.mediaId, updateData) { - Database.likedAt(mediaItem.mediaId).collect { likedAt = it } + LaunchedEffect(Unit, mediaItem.mediaId) { + Database.likedAt(mediaItem.mediaId).collect { + likedAt = it + } } var downloadState by remember { @@ -422,11 +426,22 @@ fun MediaItemGridMenu ( Column(verticalArrangement = Arrangement.spacedBy(4.dp)) { IconButton( - icon = if (likedAt == null) R.drawable.heart_outline else R.drawable.heart, + icon = getLikeState(mediaItem.mediaId), color = colorPalette().favoritesIcon, onClick = { mediaItemToggleLike(mediaItem) - updateData = !updateData + Database.asyncQuery { + if(songliked(mediaItem.mediaId) != 0){ + MyDownloadHelper.autoDownloadWhenLiked(context(), mediaItem) + } + } + }, + onLongClick = { + Database.asyncTransaction { + if (like(mediaItem.mediaId, setDisLikeState(likedAt)) == 0) { + insert(mediaItem, Song::toggleDislike) + } + } }, modifier = Modifier .padding(all = 4.dp) From 748b01fbea306ef98719f15f9de2852e07e7e828 Mon Sep 17 00:00:00 2001 From: twistios <54811436+twistios@users.noreply.github.com> Date: Fri, 10 Jan 2025 23:33:31 +0100 Subject: [PATCH 14/17] implemented dislike via long-tap in `MediaItemMenu` - also improved related code --- .../rimusic/ui/components/themed/MediaItemMenu.kt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/components/themed/MediaItemMenu.kt b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/components/themed/MediaItemMenu.kt index f559283280..574551b92b 100644 --- a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/components/themed/MediaItemMenu.kt +++ b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/components/themed/MediaItemMenu.kt @@ -116,6 +116,8 @@ import it.fast4x.rimusic.colorPalette import it.fast4x.rimusic.context import it.fast4x.rimusic.service.MyDownloadHelper import it.fast4x.rimusic.typography +import it.fast4x.rimusic.utils.mediaItemToggleLike +import it.fast4x.rimusic.utils.setDisLikeState import timber.log.Timber import java.time.LocalTime.now import java.time.format.DateTimeFormatter @@ -1110,12 +1112,19 @@ fun MediaItemMenu( color = colorPalette().favoritesIcon, //color = if (likedAt == null) colorPalette().textDisabled else colorPalette().text, onClick = { + mediaItemToggleLike(mediaItem) + Database.asyncQuery { + if(songliked(mediaItem.mediaId) != 0){ + MyDownloadHelper.autoDownloadWhenLiked(context(), mediaItem) + } + } + }, + onLongClick = { Database.asyncTransaction { - if ( like( mediaItem.mediaId, setLikeState(likedAt) ) == 0 ) { - insert(mediaItem, Song::toggleLike) + if (like(mediaItem.mediaId, setDisLikeState(likedAt)) == 0) { + insert(mediaItem, Song::toggleDislike) } } - MyDownloadHelper.autoDownloadWhenLiked(context(),mediaItem) }, modifier = Modifier .padding(all = 4.dp) From d12d719cc5bf997c3de4758fef972c048118b94e Mon Sep 17 00:00:00 2001 From: twistios <54811436+twistios@users.noreply.github.com> Date: Fri, 10 Jan 2025 23:39:22 +0100 Subject: [PATCH 15/17] improved single-tap consistency and autodownload fix - InfoAlbumAndArtistEssential/-Modern: single tap now is consistent with long tap (also does not dislike anymore) - ControlsEssential: additionally (to changes in previous item) implemented autodownload-on-like --- .../player/components/controls/Essential.kt | 28 +++++++++---------- .../player/components/controls/Modern.kt | 15 +++++----- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Essential.kt b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Essential.kt index 3dfaae929a..6a6e88e67d 100644 --- a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Essential.kt +++ b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Essential.kt @@ -86,6 +86,7 @@ import it.fast4x.rimusic.utils.getIconQueueLoopState import it.fast4x.rimusic.utils.getLikeState import it.fast4x.rimusic.utils.getUnlikedIcon import it.fast4x.rimusic.utils.jumpPreviousKey +import it.fast4x.rimusic.utils.mediaItemToggleLike import it.fast4x.rimusic.utils.playNext import it.fast4x.rimusic.utils.playPrevious import it.fast4x.rimusic.utils.playerBackgroundColorsKey @@ -257,15 +258,13 @@ fun InfoAlbumAndArtistEssential( icon = getLikeState(mediaId), onClick = { val currentMediaItem = binder.player.currentMediaItem - Database.asyncTransaction { - if (like(mediaId, setLikeState(likedAt)) == 0) { - currentMediaItem - ?.takeIf { it.mediaId == mediaId } - ?.let { - insert(currentMediaItem, Song::toggleLike) + currentMediaItem?.takeIf { it.mediaId == mediaId }.let { mediaItem -> + if (mediaItem != null) { + mediaItemToggleLike(mediaItem) + Database.asyncQuery { + if(songliked(mediaId) != 0){ + MyDownloadHelper.autoDownloadWhenLiked(context(), mediaItem) } - if (currentMediaItem != null) { - MyDownloadHelper.autoDownloadWhenLiked(context(),currentMediaItem) } } } @@ -434,13 +433,14 @@ fun ControlsEssential( icon = getLikeState(mediaId), onClick = { val currentMediaItem = binder.player.currentMediaItem - Database.asyncTransaction { - if ( like( mediaId, setLikeState(likedAt) ) == 0 ) { - currentMediaItem - ?.takeIf { it.mediaId == mediaId } - ?.let { - insert(currentMediaItem, Song::toggleLike) + currentMediaItem?.takeIf { it.mediaId == mediaId }.let { mediaItem -> + if (mediaItem != null) { + mediaItemToggleLike(mediaItem) + Database.asyncQuery { + if(songliked(mediaId) != 0){ + MyDownloadHelper.autoDownloadWhenLiked(context(), mediaItem) } + } } } if (effectRotationEnabled) isRotated = !isRotated diff --git a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Modern.kt b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Modern.kt index 5742a3b88f..8057bceb43 100644 --- a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Modern.kt +++ b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/components/controls/Modern.kt @@ -76,6 +76,7 @@ import it.fast4x.rimusic.utils.effectRotationKey import it.fast4x.rimusic.utils.getLikeState import it.fast4x.rimusic.utils.getUnlikedIcon import it.fast4x.rimusic.utils.jumpPreviousKey +import it.fast4x.rimusic.utils.mediaItemToggleLike import it.fast4x.rimusic.utils.playNext import it.fast4x.rimusic.utils.playPrevious import it.fast4x.rimusic.utils.playerBackgroundColorsKey @@ -233,15 +234,13 @@ fun InfoAlbumAndArtistModern( icon = getLikeState(mediaId), onClick = { val currentMediaItem = binder.player.currentMediaItem - Database.asyncTransaction { - if ( like( mediaId, setLikeState(likedAt) ) == 0 ) { - currentMediaItem - ?.takeIf { it.mediaId == mediaId } - ?.let { - insert(currentMediaItem, Song::toggleLike) + currentMediaItem?.takeIf { it.mediaId == mediaId }.let { mediaItem -> + if (mediaItem != null) { + mediaItemToggleLike(mediaItem) + Database.asyncQuery { + if(songliked(mediaId) != 0){ + MyDownloadHelper.autoDownloadWhenLiked(context(), mediaItem) } - if (currentMediaItem != null) { - MyDownloadHelper.autoDownloadWhenLiked(context(),currentMediaItem) } } } From 85d5d06f68039fb9b2b7d7df125184efe37660e2 Mon Sep 17 00:00:00 2001 From: twistios <54811436+twistios@users.noreply.github.com> Date: Fri, 10 Jan 2025 23:50:19 +0100 Subject: [PATCH 16/17] fixed `songLiked` - now does not consider disliked songs as liked --- composeApp/src/androidMain/kotlin/it/fast4x/rimusic/Database.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/Database.kt b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/Database.kt index 4d6f4be5e7..d2d9678849 100644 --- a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/Database.kt +++ b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/Database.kt @@ -1329,7 +1329,7 @@ interface Database { @Query("UPDATE Playlist SET name = REPLACE(name,'${PINNED_PREFIX}','') WHERE id = :playlistId") fun unPinPlaylist(playlistId: Long): Int - @Query("SELECT count(id) FROM Song WHERE id = :songId and likedAt IS NOT NULL") + @Query("SELECT count(id) FROM Song WHERE id = :songId and likedAt IS NOT NULL and likedAt > 0") fun songliked(songId: String): Int @Query("SELECT * FROM Song WHERE id = :id") From 2cc267d70e45e67c396f1307eaacfa514944c12f Mon Sep 17 00:00:00 2001 From: twistios <54811436+twistios@users.noreply.github.com> Date: Sat, 11 Jan 2025 00:09:59 +0100 Subject: [PATCH 17/17] fixed `songsFavorites*` methods - now don't consider disliked songs as liked --- .../kotlin/it/fast4x/rimusic/Database.kt | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/Database.kt b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/Database.kt index d2d9678849..cffc079e0e 100644 --- a/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/Database.kt +++ b/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/Database.kt @@ -194,19 +194,19 @@ interface Database { @SuppressWarnings(RoomWarnings.QUERY_MISMATCH) @Transaction - @Query("SELECT * FROM Song WHERE likedAt IS NOT NULL ORDER BY artistsText") + @Query("SELECT * FROM Song WHERE likedAt IS NOT NULL AND likedAt > 0 ORDER BY artistsText") @RewriteQueriesToDropUnusedColumns fun songsFavoritesByArtistAsc(): Flow> @SuppressWarnings(RoomWarnings.QUERY_MISMATCH) @Transaction - @Query("SELECT * FROM Song WHERE likedAt IS NOT NULL ORDER BY artistsText DESC") + @Query("SELECT * FROM Song WHERE likedAt IS NOT NULL AND likedAt > 0 ORDER BY artistsText DESC") @RewriteQueriesToDropUnusedColumns fun songsFavoritesByArtistDesc(): Flow> @SuppressWarnings(RoomWarnings.QUERY_MISMATCH) @Transaction - @Query("SELECT * FROM Song WHERE likedAt IS NOT NULL ORDER BY totalPlayTimeMs") + @Query("SELECT * FROM Song WHERE likedAt IS NOT NULL AND likedAt > 0 ORDER BY totalPlayTimeMs") @RewriteQueriesToDropUnusedColumns fun songsFavoritesByPlayTimeAsc(): Flow> @@ -222,7 +222,7 @@ interface Database { @SuppressWarnings(RoomWarnings.QUERY_MISMATCH) @Transaction - @Query("SELECT * FROM Song WHERE likedAt IS NOT NULL ORDER BY totalPlayTimeMs DESC") + @Query("SELECT * FROM Song WHERE likedAt IS NOT NULL AND likedAt > 0 ORDER BY totalPlayTimeMs DESC") @RewriteQueriesToDropUnusedColumns fun songsFavoritesByPlayTimeDesc(): Flow> @@ -238,63 +238,63 @@ interface Database { @SuppressWarnings(RoomWarnings.QUERY_MISMATCH) @Transaction - @Query("SELECT * FROM Song WHERE likedAt IS NOT NULL ORDER BY title COLLATE NOCASE ASC") + @Query("SELECT * FROM Song WHERE likedAt IS NOT NULL AND likedAt > 0 ORDER BY title COLLATE NOCASE ASC") @RewriteQueriesToDropUnusedColumns fun songsFavoritesByTitleAsc(): Flow> @SuppressWarnings(RoomWarnings.QUERY_MISMATCH) @Transaction - @Query("SELECT * FROM Song WHERE likedAt IS NOT NULL ORDER BY title COLLATE NOCASE DESC") + @Query("SELECT * FROM Song WHERE likedAt IS NOT NULL AND likedAt > 0 ORDER BY title COLLATE NOCASE DESC") @RewriteQueriesToDropUnusedColumns fun songsFavoritesByTitleDesc(): Flow> @SuppressWarnings(RoomWarnings.QUERY_MISMATCH) @Transaction - @Query("SELECT * FROM Song WHERE likedAt IS NOT NULL ORDER BY ROWID") + @Query("SELECT * FROM Song WHERE likedAt IS NOT NULL AND likedAt > 0 ORDER BY ROWID") @RewriteQueriesToDropUnusedColumns fun songsFavoritesByRowIdAsc(): Flow> @SuppressWarnings(RoomWarnings.QUERY_MISMATCH) @Transaction - @Query("SELECT * FROM Song WHERE likedAt IS NOT NULL ORDER BY ROWID DESC") + @Query("SELECT * FROM Song WHERE likedAt IS NOT NULL AND likedAt > 0 ORDER BY ROWID DESC") @RewriteQueriesToDropUnusedColumns fun songsFavoritesByRowIdDesc(): Flow> @SuppressWarnings(RoomWarnings.QUERY_MISMATCH) @Transaction - @Query("SELECT * FROM Song WHERE likedAt IS NOT NULL ORDER BY likedAt") + @Query("SELECT * FROM Song WHERE likedAt IS NOT NULL AND likedAt > 0 ORDER BY likedAt") @RewriteQueriesToDropUnusedColumns fun songsFavoritesByLikedAtAsc(): Flow> @SuppressWarnings(RoomWarnings.QUERY_MISMATCH) @Transaction - @Query("SELECT * FROM Song WHERE likedAt IS NOT NULL ORDER BY likedAt DESC") + @Query("SELECT * FROM Song WHERE likedAt IS NOT NULL AND likedAt > 0 ORDER BY likedAt DESC") @RewriteQueriesToDropUnusedColumns fun songsFavoritesByLikedAtDesc(): Flow> @SuppressWarnings(RoomWarnings.QUERY_MISMATCH) @Transaction @Query("SELECT DISTINCT S.* FROM Song S LEFT JOIN Event E ON E.songId=S.id " + - "WHERE likedAt IS NOT NULL " + + "WHERE likedAt IS NOT NULL AND likedAt > 0 " + "ORDER BY E.timestamp DESC") fun songsFavoritesByDatePlayedDesc(): Flow> @SuppressWarnings(RoomWarnings.QUERY_MISMATCH) @Transaction @Query("SELECT DISTINCT S.* FROM Song S LEFT JOIN Event E ON E.songId=S.id " + - "WHERE likedAt IS NOT NULL " + + "WHERE likedAt IS NOT NULL AND likedAt > 0 " + "ORDER BY E.timestamp") fun songsFavoritesByDatePlayedAsc(): Flow> @SuppressWarnings(RoomWarnings.QUERY_MISMATCH) @Transaction - @Query("SELECT * FROM Song WHERE likedAt IS NOT NULL ORDER BY durationText") + @Query("SELECT * FROM Song WHERE likedAt IS NOT NULL AND likedAt > 0 ORDER BY durationText") @RewriteQueriesToDropUnusedColumns fun songsFavoritesByDurationAsc(): Flow> @SuppressWarnings(RoomWarnings.QUERY_MISMATCH) @Transaction - @Query("SELECT * FROM Song WHERE likedAt IS NOT NULL ORDER BY durationText DESC") + @Query("SELECT * FROM Song WHERE likedAt IS NOT NULL AND likedAt > 0 ORDER BY durationText DESC") @RewriteQueriesToDropUnusedColumns fun songsFavoritesByDurationDesc(): Flow>