Skip to content

Commit 92c2a3b

Browse files
committed
v2.3.0
1 parent 8683251 commit 92c2a3b

File tree

73 files changed

+866
-367
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+866
-367
lines changed

app/.DS_Store

0 Bytes
Binary file not shown.

app/build.gradle.kts

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ android {
1313
applicationId = "com.sosauce.cutemusic"
1414
minSdk = 26
1515
targetSdk = 35
16-
versionCode = 16
17-
versionName = "2.2.5"
16+
versionCode = 17
17+
versionName = "2.3.0"
1818
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
1919
vectorDrawables {
2020
useSupportLibrary = true
-15 Bytes
Binary file not shown.
-33 Bytes
Binary file not shown.

app/release/output-metadata.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"type": "SINGLE",
1212
"filters": [],
1313
"attributes": [],
14-
"versionCode": 15,
15-
"versionName": "2.2.4",
14+
"versionCode": 16,
15+
"versionName": "2.2.5",
1616
"outputFile": "app-release.apk"
1717
}
1818
],

app/src/.DS_Store

0 Bytes
Binary file not shown.

app/src/main/.DS_Store

0 Bytes
Binary file not shown.
922 Bytes
Loading

app/src/main/java/com/sosauce/cutemusic/data/MusicState.kt

+1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ data class MusicState(
2323
val currentSize: Long = 0,
2424
val currentLrcFile: File? = null,
2525
val playbackParameters: PlaybackParameters = PlaybackParameters.DEFAULT,
26+
val isPlayerReady: Boolean = false
2627
)

app/src/main/java/com/sosauce/cutemusic/data/actions/MetadataActions.kt

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package com.sosauce.cutemusic.data.actions
22

3+
import android.net.Uri
4+
35
sealed interface MetadataActions {
46
data class LoadSong(
5-
val path: String
7+
val path: String,
8+
val uri: Uri
69
) : MetadataActions
710

811
data object SaveChanges : MetadataActions

app/src/main/java/com/sosauce/cutemusic/data/datastore/DataStore.kt

+18-18
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import com.sosauce.cutemusic.data.datastore.PreferencesKeys.APPLY_LOOP
1111
import com.sosauce.cutemusic.data.datastore.PreferencesKeys.BLACKLISTED_FOLDERS
1212
import com.sosauce.cutemusic.data.datastore.PreferencesKeys.FOLLOW_SYS
1313
import com.sosauce.cutemusic.data.datastore.PreferencesKeys.HAS_SEEN_TIP
14+
import com.sosauce.cutemusic.data.datastore.PreferencesKeys.SHOW_ALBUMS_TAB
15+
import com.sosauce.cutemusic.data.datastore.PreferencesKeys.SHOW_ARTISTS_TAB
16+
import com.sosauce.cutemusic.data.datastore.PreferencesKeys.SHOW_FOLDERS_TAB
1417
import com.sosauce.cutemusic.data.datastore.PreferencesKeys.SHOW_X_BUTTON
1518
import com.sosauce.cutemusic.data.datastore.PreferencesKeys.SNAP_SPEED_N_PITCH
16-
import com.sosauce.cutemusic.data.datastore.PreferencesKeys.SORT_ORDER
17-
import com.sosauce.cutemusic.data.datastore.PreferencesKeys.SORT_ORDER_ALBUMS
18-
import com.sosauce.cutemusic.data.datastore.PreferencesKeys.SORT_ORDER_ARTISTS
1919
import com.sosauce.cutemusic.data.datastore.PreferencesKeys.USE_AMOLED_MODE
2020
import com.sosauce.cutemusic.data.datastore.PreferencesKeys.USE_ART_THEME
2121
import com.sosauce.cutemusic.data.datastore.PreferencesKeys.USE_CLASSIC_SLIDER
@@ -28,9 +28,6 @@ private const val PREFERENCES_NAME = "settings"
2828
val Context.dataStore: DataStore<Preferences> by preferencesDataStore(PREFERENCES_NAME)
2929

3030
private data object PreferencesKeys {
31-
val SORT_ORDER = booleanPreferencesKey("sort_order")
32-
val SORT_ORDER_ARTISTS = booleanPreferencesKey("sort_order_artists")
33-
val SORT_ORDER_ALBUMS = booleanPreferencesKey("sort_order_albums")
3431
val USE_DARK_MODE = booleanPreferencesKey("use_dark_mode")
3532
val USE_AMOLED_MODE = booleanPreferencesKey("use_amoled_mode")
3633
val FOLLOW_SYS = booleanPreferencesKey("follow_sys")
@@ -43,20 +40,11 @@ private data object PreferencesKeys {
4340
val APPLY_LOOP = booleanPreferencesKey("apply_loop")
4441
val USE_CLASSIC_SLIDER = booleanPreferencesKey("use_classic_slider")
4542
val SHOW_X_BUTTON = booleanPreferencesKey("show_x_button")
43+
val SHOW_ALBUMS_TAB = booleanPreferencesKey("show_albums_tab")
44+
val SHOW_ARTISTS_TAB = booleanPreferencesKey("show_artists_tab")
45+
val SHOW_FOLDERS_TAB = booleanPreferencesKey("show_folders_tab")
4646
}
4747

48-
@Composable
49-
fun rememberSortASC() =
50-
rememberPreference(key = SORT_ORDER, defaultValue = true)
51-
52-
@Composable
53-
fun rememberSortASCArtists() =
54-
rememberPreference(key = SORT_ORDER_ARTISTS, defaultValue = true)
55-
56-
@Composable
57-
fun rememberSortASCAlbums() =
58-
rememberPreference(key = SORT_ORDER_ALBUMS, defaultValue = true)
59-
6048
@Composable
6149
fun rememberUseDarkMode() =
6250
rememberPreference(key = USE_DARK_MODE, defaultValue = false)
@@ -103,6 +91,18 @@ fun rememberUseClassicSlider() =
10391
fun rememberShowXButton() =
10492
rememberPreference(key = SHOW_X_BUTTON, defaultValue = true)
10593

94+
@Composable
95+
fun rememberShowAlbumsTab() =
96+
rememberPreference(key = SHOW_ALBUMS_TAB, defaultValue = true)
97+
98+
@Composable
99+
fun rememberShowArtistsTab() =
100+
rememberPreference(key = SHOW_ARTISTS_TAB, defaultValue = true)
101+
102+
@Composable
103+
fun rememberShowFoldersTab() =
104+
rememberPreference(key = SHOW_FOLDERS_TAB, defaultValue = true)
105+
106106

107107
suspend fun getBlacklistedFolder(context: Context): Set<String> {
108108
val preferences = context.dataStore.data.first()

app/src/main/java/com/sosauce/cutemusic/data/datastore/SettingsExt.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ fun <T> rememberPreferenceNonComposable(
5858
val coroutineScope = CoroutineScope(Dispatchers.Default)
5959

6060
val state = context.dataStore.data
61-
.map { it[key] ?: defaultValue }.stateIn(coroutineScope, SharingStarted.WhileSubscribed(5000), defaultValue)
61+
.map { it[key] ?: defaultValue }
62+
.stateIn(coroutineScope, SharingStarted.WhileSubscribed(5000), defaultValue)
6263

6364
return object : MutableState<T> {
6465
override var value: T

app/src/main/java/com/sosauce/cutemusic/domain/repository/MediaStoreHelper.kt

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ interface MediaStoreHelper {
1313
val musics: List<MediaItem>
1414
val albums: List<Album>
1515
val artists: List<Artist>
16+
val folders: List<Folder>
1617

1718
fun fetchMusics(): List<MediaItem>
1819

app/src/main/java/com/sosauce/cutemusic/domain/repository/MediaStoreHelperImpl.kt

+15-10
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,17 @@ class MediaStoreHelperImpl(
2626
private val context: Context
2727
) : MediaStoreHelper {
2828

29-
private fun getBlacklistedFoldersAsync(): Set<String> = runBlocking { getBlacklistedFolder(context) }
29+
private fun getBlacklistedFoldersAsync(): Set<String> =
30+
runBlocking { getBlacklistedFolder(context) }
31+
32+
private val blacklistedFolders = getBlacklistedFoldersAsync()
33+
private val selection =
34+
blacklistedFolders.joinToString(" AND ") { "${MediaStore.Audio.Media.DATA} NOT LIKE ?" }
35+
private val selectionArgs = blacklistedFolders.map { "$it%" }.toTypedArray()
3036

3137
@UnstableApi
3238
override fun fetchMusics(): List<MediaItem> {
3339

34-
var blacklistedFolders = getBlacklistedFoldersAsync()
3540
val musics = mutableListOf<MediaItem>()
3641

3742
val projection = arrayOf(
@@ -43,14 +48,9 @@ class MediaStoreHelperImpl(
4348
MediaStore.Audio.Media.ALBUM_ID,
4449
MediaStore.Audio.Media.DATA,
4550
MediaStore.Audio.Media.SIZE,
46-
MediaStore.Audio.Media.DURATION,
47-
//MediaStore.Audio.Media.IS_FAVORITE,
51+
MediaStore.Audio.Media.DURATION
4852
)
4953

50-
val selection = blacklistedFolders.joinToString(" AND ") { "${MediaStore.Audio.Media.DATA} NOT LIKE ?" }
51-
val selectionArgs = blacklistedFolders.map { "$it%" }.toTypedArray()
52-
53-
5454

5555
context.contentResolver.query(
5656
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
@@ -153,7 +153,9 @@ class MediaStoreHelperImpl(
153153
val albumInfo = Album(id, album, artist)
154154

155155
if (albums.none { it.name == albumInfo.name }) {
156-
albums.add(albumInfo)
156+
if (musics.map { it.mediaMetadata.extras?.getLong("album_id") }.contains(id)) {
157+
albums.add(albumInfo)
158+
}
157159
}
158160
}
159161
}
@@ -187,7 +189,9 @@ class MediaStoreHelperImpl(
187189
id = id,
188190
name = artist
189191
)
190-
artists.add(artistInfo)
192+
if (musics.map { it.mediaMetadata.extras?.getLong("artist_id") }.contains(id)) {
193+
artists.add(artistInfo)
194+
}
191195
}
192196
}
193197

@@ -275,4 +279,5 @@ class MediaStoreHelperImpl(
275279
override val musics: List<MediaItem> = fetchMusics()
276280
override val albums: List<Album> = fetchAlbums()
277281
override val artists: List<Artist> = fetchArtists()
282+
override val folders: List<Folder> = fetchFoldersWithMusics()
278283
}

app/src/main/java/com/sosauce/cutemusic/main/PlaybackService.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class PlaybackService : MediaLibraryService(),
9595
.build()
9696
setMediaNotificationProvider(
9797
DefaultMediaNotificationProvider.Builder(this).build().apply {
98-
setSmallIcon(R.drawable.round_music_note_24)
98+
setSmallIcon(R.drawable.music_note_rounded)
9999
}
100100
)
101101

app/src/main/java/com/sosauce/cutemusic/ui/navigation/Navigation.kt

+27-11
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import androidx.navigation.compose.rememberNavController
1313
import androidx.navigation.toRoute
1414
import com.sosauce.cutemusic.data.actions.MetadataActions
1515
import com.sosauce.cutemusic.data.actions.PlayerActions
16-
import com.sosauce.cutemusic.data.datastore.rememberAllBlacklistedFolders
1716
import com.sosauce.cutemusic.ui.screens.album.AlbumDetailsScreen
1817
import com.sosauce.cutemusic.ui.screens.album.AlbumsScreen
18+
import com.sosauce.cutemusic.ui.screens.all_folders.AllFoldersScreen
1919
import com.sosauce.cutemusic.ui.screens.artist.ArtistDetails
2020
import com.sosauce.cutemusic.ui.screens.artist.ArtistsScreen
2121
import com.sosauce.cutemusic.ui.screens.blacklisted.BlacklistedScreen
@@ -39,25 +39,21 @@ fun Nav() {
3939
val viewModel = koinViewModel<MusicViewModel>()
4040
val postViewModel = koinViewModel<PostViewModel>()
4141
val metadataViewModel = koinViewModel<MetadataViewModel>()
42-
val blacklistedFolders by rememberAllBlacklistedFolders()
4342
val musics = postViewModel.musics
4443
val musicState by viewModel.musicState.collectAsStateWithLifecycle()
44+
val folders = postViewModel.folders
4545

4646

4747
SharedTransitionLayout {
48-
49-
this
5048
NavHost(
5149
navController = navController,
5250
startDestination = Screen.Main
5351
) {
54-
55-
this@SharedTransitionLayout
5652
composable<Screen.Main> {
5753
MainScreen(
5854
musics = musics,
5955
selectedIndex = viewModel.selectedItem,
60-
onNavigateTo = { navController.navigate(it) },
56+
onNavigate = { navController.navigate(it) },
6157
currentlyPlaying = musicState.currentlyPlaying,
6258
isCurrentlyPlaying = musicState.isCurrentlyPlaying,
6359
onShortClick = { viewModel.handlePlayerActions(PlayerActions.StartPlayback(it)) },
@@ -68,15 +64,16 @@ fun Nav() {
6864
}
6965
},
7066
animatedVisibilityScope = this,
71-
onLoadMetadata = { uri ->
67+
onLoadMetadata = { path, uri ->
7268
metadataViewModel.onHandleMetadataActions(MetadataActions.ClearState)
7369
metadataViewModel.onHandleMetadataActions(
7470
MetadataActions.LoadSong(
71+
path,
7572
uri
7673
)
7774
)
7875
},
79-
isPlayerReady = viewModel.isPlayerReady(),
76+
isPlayerReady = musicState.isPlayerReady,
8077
currentMusicUri = musicState.currentMusicUri,
8178
onHandlePlayerAction = { viewModel.handlePlayerActions(it) },
8279
onDeleteMusic = { uris, intentSender ->
@@ -124,7 +121,7 @@ fun Nav() {
124121
},
125122
currentlyPlaying = musicState.currentlyPlaying,
126123
chargePVMAlbumSongs = postViewModel::albumSongs,
127-
isPlayerReady = viewModel.isPlayerReady(),
124+
isPlayerReady = musicState.isPlayerReady,
128125
isPlaying = musicState.isCurrentlyPlaying,
129126
onHandlePlayerActions = viewModel::handlePlayerActions,
130127
onNavigate = { navController.navigate(it) },
@@ -157,7 +154,7 @@ fun Nav() {
157154
onHandlePlayerActions = viewModel::handlePlayerActions,
158155
isPlaying = musicState.isCurrentlyPlaying,
159156
animatedVisibilityScope = this,
160-
isPlayerReady = viewModel.isPlayerReady(),
157+
isPlayerReady = musicState.isPlayerReady,
161158
onHandleSorting = { sortingType ->
162159
postViewModel.handleFiltering(
163160
listToHandle = ListToHandle.ARTISTS,
@@ -245,6 +242,25 @@ fun Nav() {
245242
)
246243
}
247244
}
245+
246+
composable<Screen.AllFolders> {
247+
AllFoldersScreen(
248+
musics = musics,
249+
onNavigationItemClicked = { index, item ->
250+
navController.navigate(item.navigateTo) {
251+
viewModel.selectedItem = index
252+
launchSingleTop = true
253+
}
254+
},
255+
selectedIndex = viewModel.selectedItem,
256+
onNavigate = { navController.navigate(it) },
257+
currentlyPlaying = musicState.currentlyPlaying,
258+
isCurrentlyPlaying = musicState.isCurrentlyPlaying,
259+
onHandlePlayerActions = viewModel::handlePlayerActions,
260+
isPlayerReady = musicState.isPlayerReady,
261+
animatedVisibilityScope = this,
262+
)
263+
}
248264
}
249265
}
250266
}

app/src/main/java/com/sosauce/cutemusic/ui/navigation/Screen.kt

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ sealed class Screen {
2222
@Serializable
2323
data object Artists : Screen()
2424

25+
@Serializable
26+
data object AllFolders : Screen()
27+
2528
@Serializable
2629
data class AlbumsDetails(
2730
val id: Long

app/src/main/java/com/sosauce/cutemusic/ui/screens/album/AlbumDetailsLandscape.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ fun AlbumDetailsLandscape(
111111
)
112112
)
113113
},
114-
isPlayerReady = viewModel.isPlayerReady()
114+
isPlayerReady = musicState.isPlayerReady
115115
)
116116
}
117117
}

app/src/main/java/com/sosauce/cutemusic/ui/screens/album/AlbumDetailsScreen.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ private fun SharedTransitionScope.AlbumDetailsContent(
184184
)
185185
},
186186
currentMusicUri = musicState.currentMusicUri,
187-
isPlayerReady = viewModel.isPlayerReady()
187+
isPlayerReady = musicState.isPlayerReady
188188
)
189189
}
190190
}
@@ -193,7 +193,7 @@ private fun SharedTransitionScope.AlbumDetailsContent(
193193

194194
CuteSearchbar(
195195
currentlyPlaying = musicState.currentlyPlaying,
196-
isPlayerReady = viewModel.isPlayerReady(),
196+
isPlayerReady = musicState.isPlayerReady,
197197
isPlaying = musicState.isCurrentlyPlaying,
198198
onHandlePlayerActions = viewModel::handlePlayerActions,
199199
animatedVisibilityScope = animatedVisibilityScope,

app/src/main/java/com/sosauce/cutemusic/ui/screens/album/AlbumScreen.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
2626
import androidx.compose.foundation.lazy.grid.itemsIndexed
2727
import androidx.compose.foundation.shape.RoundedCornerShape
2828
import androidx.compose.material.icons.Icons
29-
import androidx.compose.material.icons.rounded.Album
3029
import androidx.compose.material.icons.rounded.ArrowUpward
3130
import androidx.compose.material.icons.rounded.Settings
3231
import androidx.compose.material3.DropdownMenu
@@ -43,6 +42,7 @@ import androidx.compose.ui.draw.clip
4342
import androidx.compose.ui.draw.rotate
4443
import androidx.compose.ui.layout.ContentScale
4544
import androidx.compose.ui.platform.LocalContext
45+
import androidx.compose.ui.res.painterResource
4646
import androidx.compose.ui.res.stringResource
4747
import androidx.compose.ui.text.style.TextAlign
4848
import androidx.compose.ui.unit.dp
@@ -160,7 +160,7 @@ fun SharedTransitionScope.AlbumsScreen(
160160
leadingIcon = {
161161
IconButton(onClick = { screenSelectionExpanded = true }) {
162162
Icon(
163-
imageVector = Icons.Rounded.Album,
163+
painter = painterResource(androidx.media3.session.R.drawable.media3_icon_album),
164164
contentDescription = null
165165
)
166166
}

0 commit comments

Comments
 (0)