Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
reocat committed Nov 7, 2024
1 parent 813f8ad commit e8a0962
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 9 deletions.
81 changes: 75 additions & 6 deletions app/src/main/java/com/dd3boh/outertune/db/daos/AlbumsDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.room.RawQuery
import androidx.room.Transaction
import androidx.room.Update
import androidx.room.Upsert
import androidx.room.RewriteQueriesToDropUnusedColumns
import androidx.sqlite.db.SimpleSQLiteQuery
import androidx.sqlite.db.SupportSQLiteQuery
import com.dd3boh.outertune.constants.AlbumFilter
Expand All @@ -34,8 +35,21 @@ interface AlbumsDao : ArtistsDao {

// region Gets
@Transaction
@RewriteQueriesToDropUnusedColumns
@Query("""
SELECT album.*, count(song.dateDownload) downloadCount
SELECT DISTINCT
album.id,
album.playlistId,
album.title,
album.year,
album.thumbnailUrl,
album.themeColor,
album.songCount,
album.duration,
album.lastUpdateTime,
album.bookmarkedAt,
album.isLocal,
COUNT(song.dateDownload) as downloadCount
FROM album
LEFT JOIN song ON song.albumId = album.id
WHERE album.id = :id
Expand All @@ -44,8 +58,21 @@ interface AlbumsDao : ArtistsDao {
fun album(id: String): Flow<Album?>

@Transaction
@RewriteQueriesToDropUnusedColumns
@Query("""
SELECT album.*, count(song.dateDownload) downloadCount
SELECT DISTINCT
album.id,
album.playlistId,
album.title,
album.year,
album.thumbnailUrl,
album.themeColor,
album.songCount,
album.duration,
album.lastUpdateTime,
album.bookmarkedAt,
album.isLocal,
COUNT(song.dateDownload) as downloadCount
FROM album
LEFT JOIN song ON song.albumId = album.id
WHERE album.title LIKE '%' || :query || '%' AND song.inLibrary IS NOT NULL
Expand All @@ -55,8 +82,21 @@ interface AlbumsDao : ArtistsDao {
fun searchAlbums(query: String, previewSize: Int = Int.MAX_VALUE): Flow<List<Album>>

@Transaction
@RewriteQueriesToDropUnusedColumns
@Query("""
SELECT album.*, count(song.dateDownload) downloadCount
SELECT DISTINCT
album.id,
album.playlistId,
album.title,
album.year,
album.thumbnailUrl,
album.themeColor,
album.songCount,
album.duration,
album.lastUpdateTime,
album.bookmarkedAt,
album.isLocal,
COUNT(song.dateDownload) as downloadCount
FROM album
LEFT JOIN song ON song.albumId = album.id
WHERE album.id = :albumId
Expand All @@ -65,12 +105,26 @@ interface AlbumsDao : ArtistsDao {
fun albumWithSongs(albumId: String): Flow<AlbumWithSongs?>

@Transaction
@RewriteQueriesToDropUnusedColumns
@Query("SELECT song.* FROM song JOIN song_album_map ON song.id = song_album_map.songId WHERE song_album_map.albumId = :albumId")
fun albumSongs(albumId: String): Flow<List<Song>>

@Transaction
@RewriteQueriesToDropUnusedColumns
@Query("""
SELECT *, count(song.dateDownload) downloadCount
SELECT DISTINCT
album.id,
album.playlistId,
album.title,
album.year,
album.thumbnailUrl,
album.themeColor,
album.songCount,
album.duration,
album.lastUpdateTime,
album.bookmarkedAt,
album.isLocal,
COUNT(song.dateDownload) as downloadCount
FROM album
JOIN song ON album.id = song.albumId
JOIN event ON song.id = event.songId
Expand Down Expand Up @@ -108,7 +162,19 @@ interface AlbumsDao : ArtistsDao {
}

val query = SimpleSQLiteQuery("""
SELECT album.*, count(song.dateDownload) downloadCount
SELECT DISTINCT
album.id,
album.playlistId,
album.title,
album.year,
album.thumbnailUrl,
album.themeColor,
album.songCount,
album.duration,
album.lastUpdateTime,
album.bookmarkedAt,
album.isLocal,
COUNT(song.dateDownload) as downloadCount
FROM album
LEFT JOIN song ON song.albumId = album.id
WHERE $where
Expand All @@ -123,6 +189,7 @@ interface AlbumsDao : ArtistsDao {
fun albumsLikedAsc() = albums(AlbumFilter.LIKED, AlbumSortType.CREATE_DATE, false)

@Transaction
@RewriteQueriesToDropUnusedColumns
@Query(
"""
SELECT song.*
Expand All @@ -146,7 +213,9 @@ interface AlbumsDao : ArtistsDao {
"""
)
fun forgottenFavorites(now: Long = System.currentTimeMillis()): Flow<List<Song>>

@Transaction
@RewriteQueriesToDropUnusedColumns
@Query(
"""
SELECT song.*
Expand Down Expand Up @@ -233,4 +302,4 @@ interface AlbumsDao : ArtistsDao {
@Query("DELETE FROM album WHERE isLocal = 1")
fun nukeLocalAlbums()
// endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ fun SearchBar(
trailingIcon: @Composable (() -> Unit)? = null,
shape: Shape = SearchBarDefaults.inputFieldShape,
colors: SearchBarColors = SearchBarDefaults.colors(),
inputFieldColors: TextFieldColors = SearchBarDefaults.inputFieldColors(),
tonalElevation: Dp = SearchBarDefaults.TonalElevation,
windowInsets: WindowInsets = WindowInsets.systemBars,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
Expand Down Expand Up @@ -205,7 +206,7 @@ fun SearchBar(
placeholder = placeholder,
leadingIcon = leadingIcon,
trailingIcon = trailingIcon,
colors = colors.inputFieldColors,
colors = inputFieldColors,
interactionSource = interactionSource,
focusRequester = focusRequester,
)
Expand Down Expand Up @@ -330,4 +331,4 @@ internal val SearchBarHorizontalPadding: Dp = 12.dp
val SearchBarIconOffsetX: Dp = 4.dp

// Animation specs
private const val AnimationDurationMillis: Int = MotionTokens.DurationMedium2.toInt()
private const val AnimationDurationMillis: Int = MotionTokens.DurationMedium2.toInt()
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ fun ArtistItemsScreen(
}
if (itemsPage?.continuation != null) {
item(key = "loading") {
ShimmerHost(Modifier.animateItemPlacement()) {
ShimmerHost(Modifier.animateItem()) {
GridItemPlaceHolder(fillMaxWidth = true)
}
}
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/com/dd3boh/outertune/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ fun Scheme.toColorScheme() = ColorScheme(
outline = Color(outline),
outlineVariant = Color(outlineVariant),
scrim = Color(scrim),
surfaceContainer = Color(surface),
surfaceContainerHigh = Color(surface),
surfaceContainerHighest = Color(surface),
surfaceContainerLow = Color(surface),
surfaceContainerLowest = Color(surface),
surfaceBright = Color(surface),
surfaceDim = Color(surface)
)

fun ColorScheme.pureBlack(apply: Boolean) =
Expand Down

0 comments on commit e8a0962

Please sign in to comment.