Skip to content

Commit

Permalink
feat(select): bulk like + album revamp #12
Browse files Browse the repository at this point in the history
  • Loading branch information
Malopieds committed Apr 17, 2024
1 parent 453cfc8 commit 81c74fd
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
9 changes: 9 additions & 0 deletions app/src/main/java/com/zionhuang/music/ui/menu/AlbumMenu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ fun AlbumMenu(
originalAlbum: Album,
navController: NavController,
onDismiss: () -> Unit,
selectAction: () -> Unit = {},
) {
val context = LocalContext.current
val database = LocalDatabase.current
Expand Down Expand Up @@ -281,5 +282,13 @@ fun AlbumMenu(
}
context.startActivity(Intent.createChooser(intent, null))
}

GridMenuItem(
icon = R.drawable.select_all,
title = R.string.select
) {
onDismiss()
selectAction()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -205,5 +205,21 @@ fun SelectionSongMenu(
showRemoveDownloadDialog = true
}
)

GridMenuItem(
icon = if (songSelection.all{it.song.liked}) R.drawable.favorite else R.drawable.favorite_border,
title = R.string.like_all
) {
val allLiked = songSelection.all {
it.song.liked
}
onDismiss()
database.query {
songSelection.forEach { song ->
if ((!allLiked && !song.song.liked) || allLiked)
update(song.song.toggleLike())
}
}
}
}
}
15 changes: 2 additions & 13 deletions app/src/main/java/com/zionhuang/music/ui/screens/AlbumScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ fun AlbumScreen(
AlbumMenu(
originalAlbum = Album(albumWithSongs.album, albumWithSongs.artists),
navController = navController,
onDismiss = menuState::dismiss
onDismiss = menuState::dismiss,
selectAction = { selection = true }
)
}
}
Expand Down Expand Up @@ -397,18 +398,6 @@ fun AlbumScreen(
)
}
}
else {
Spacer(modifier = Modifier.weight(1f))
IconButton(
onClick = { selection = !selection },
modifier = Modifier.padding(horizontal = 6.dp)
) {
Icon(
painter = painterResource(if (selection) R.drawable.deselect else R.drawable.select_all),
contentDescription = null
)
}
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@
<string name="search_online">Search online</string>
<string name="sync">Sync</string>
<string name="advanced">Advanced</string>
<string name="select">Select all</string>
<string name="like_all">Like all</string>

<!-- Sort menu -->
<string name="sort_by_create_date">Date added</string>
Expand Down

0 comments on commit 81c74fd

Please sign in to comment.