Skip to content

Commit 5a10bcd

Browse files
committed
v2.2.4
1 parent ba58845 commit 5a10bcd

Some content is hidden

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

51 files changed

+1279
-499
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.kotlin/sessions/kotlin-compiler-16555594222562041686.salive

Whitespace-only changes.

app/.DS_Store

0 Bytes
Binary file not shown.

app/build.gradle.kts

+4-4
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 = 14
17-
versionName = "2.2.3"
16+
versionCode = 15
17+
versionName = "2.2.4"
1818
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
1919
vectorDrawables {
2020
useSupportLibrary = true
@@ -79,9 +79,9 @@ android {
7979
implementation(libs.kotlinx.serialization.json)
8080
implementation(libs.koin.android)
8181
implementation(libs.koin.androidx.compose)
82-
debugImplementation(libs.androidx.ui.tooling)
83-
//implementation("com.materialkolor:material-kolor:1.7.1")
82+
//implementation("com.materialkolor:material-kolor:2.0.0")
8483
implementation(libs.koin.androidx.startup)
8584
implementation(libs.jaudiotagger)
85+
debugImplementation(libs.androidx.ui.tooling)
8686
}
8787
}
83 Bytes
Binary file not shown.
83 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": 13,
15-
"versionName": "2.2.2",
14+
"versionCode": 15,
15+
"versionName": "2.2.4",
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.

app/src/main/AndroidManifest.xml

+33-1
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,55 @@
4949
tools:targetApi="tiramisu">
5050
<intent-filter>
5151
<action android:name="android.intent.action.MAIN" />
52+
<action android:name="android.intent.action.MUSIC_PLAYER" />
53+
5254
<category android:name="android.intent.category.LAUNCHER" />
53-
<category android:name="android.intent.category.DEFAULT" />
5455
<category android:name="android.intent.category.APP_MUSIC" />
56+
<category android:name="android.intent.category.DEFAULT" />
5557
</intent-filter>
5658
</activity>
59+
60+
61+
62+
63+
5764
<activity
5865
android:name=".main.quickplay.QuickPlayActivity"
66+
android:theme="@style/Theme.CuteSplash"
5967
android:exported="true">
68+
<intent-filter>
69+
<action android:name="android.intent.action.VIEW" />
70+
<category android:name="android.intent.category.DEFAULT" />
71+
<category android:name="android.intent.category.BROWSABLE" />
72+
73+
<data android:scheme="content" />
74+
<data android:scheme="file" />
75+
<data android:mimeType="audio/*" />
76+
</intent-filter>
77+
6078
<intent-filter>
6179
<action android:name="android.intent.action.SEND" />
6280
<category android:name="android.intent.category.DEFAULT" />
81+
<category android:name="android.intent.category.SHARE_TARGET" />
6382
<data android:mimeType="audio/*" />
83+
6484
</intent-filter>
6585
</activity>
6686

87+
<receiver
88+
android:name="androidx.media3.session.MediaButtonReceiver"
89+
android:exported="true">
90+
<intent-filter>
91+
<action android:name="android.intent.action.MEDIA_BUTTON" />
92+
<category android:name="android.intent.category.DEFAULT" />
93+
</intent-filter>
94+
</receiver>
95+
6796
<meta-data android:name="com.google.android.gms.car.application"
6897
android:resource="@xml/automotive_app_desc"/>
6998
</application>
7099

100+
101+
102+
71103
</manifest>

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

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

33
import android.net.Uri
4+
import androidx.media3.common.PlaybackParameters
5+
import androidx.media3.common.Player
46
import com.sosauce.cutemusic.domain.model.Lyrics
57
import java.io.File
68

@@ -20,5 +22,6 @@ data class MusicState(
2022
val currentAlbum: String = "",
2123
val currentAlbumId: Long = 0,
2224
val currentSize: Long = 0,
23-
val currentLrcFile: File? = null
25+
val currentLrcFile: File? = null,
26+
val playbackParameters: PlaybackParameters = PlaybackParameters.DEFAULT,
2427
)

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ sealed interface MetadataActions {
55
val path: String
66
) : MetadataActions
77

8-
data class SaveChanges(
9-
val path: String
10-
) : MetadataActions
8+
data object SaveChanges : MetadataActions
119

1210
data object ClearState : MetadataActions
1311
}

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

+12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.sosauce.cutemusic.data.actions
22

3+
import android.net.Uri
4+
35
sealed interface PlayerActions {
46
data object PlayOrPause : PlayerActions
57
data object SeekToNextMusic : PlayerActions
@@ -8,6 +10,7 @@ sealed interface PlayerActions {
810
data object PlayRandom : PlayerActions
911
data object ApplyLoop : PlayerActions
1012
data object ApplyShuffle : PlayerActions
13+
data object StopPlayback : PlayerActions
1114
data class SeekTo(val position: Long) : PlayerActions
1215
data class SeekToSlider(val position: Long) : PlayerActions
1316
data class RewindTo(val position: Long) : PlayerActions
@@ -26,4 +29,13 @@ sealed interface PlayerActions {
2629
val speed: Float,
2730
val pitch: Float
2831
) : PlayerActions
32+
33+
data class UpdateCurrentPosition(
34+
val position: Long
35+
) : PlayerActions
36+
37+
38+
data class QuickPlay(
39+
val uri: Uri
40+
) : PlayerActions
2941
}

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

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ 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_X_BUTTON
1415
import com.sosauce.cutemusic.data.datastore.PreferencesKeys.SNAP_SPEED_N_PITCH
1516
import com.sosauce.cutemusic.data.datastore.PreferencesKeys.SORT_ORDER
1617
import com.sosauce.cutemusic.data.datastore.PreferencesKeys.SORT_ORDER_ALBUMS
@@ -40,6 +41,7 @@ private data object PreferencesKeys {
4041
val USE_ART_THEME = booleanPreferencesKey("use_art_theme")
4142
val APPLY_LOOP = booleanPreferencesKey("apply_loop")
4243
val USE_CLASSIC_SLIDER = booleanPreferencesKey("use_classic_slider")
44+
val SHOW_X_BUTTON = booleanPreferencesKey("show_x_button")
4345
}
4446

4547
@Composable
@@ -95,3 +97,7 @@ fun rememberShouldApplyLoop() =
9597
@Composable
9698
fun rememberUseClassicSlider() =
9799
rememberPreference(key = USE_CLASSIC_SLIDER, defaultValue = false)
100+
101+
@Composable
102+
fun rememberShowXButton() =
103+
rememberPreference(key = SHOW_X_BUTTON, defaultValue = true)

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

+6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import androidx.activity.result.ActivityResultLauncher
1212
import androidx.activity.result.IntentSenderRequest
1313
import androidx.media3.common.MediaItem
1414
import androidx.media3.common.MediaMetadata
15+
import androidx.media3.common.util.UnstableApi
1516
import com.sosauce.cutemusic.domain.model.Album
1617
import com.sosauce.cutemusic.domain.model.Artist
1718
import com.sosauce.cutemusic.domain.model.Folder
@@ -20,6 +21,7 @@ class MediaStoreHelperImpl(
2021
private val context: Context
2122
) : MediaStoreHelper {
2223

24+
@UnstableApi
2325
override fun fetchMusics(): List<MediaItem> {
2426
val musics = mutableListOf<MediaItem>()
2527

@@ -32,6 +34,7 @@ class MediaStoreHelperImpl(
3234
MediaStore.Audio.Media.ALBUM_ID,
3335
MediaStore.Audio.Media.DATA,
3436
MediaStore.Audio.Media.SIZE,
37+
MediaStore.Audio.Media.DURATION,
3538
//MediaStore.Audio.Media.IS_FAVORITE,
3639
)
3740

@@ -52,6 +55,7 @@ class MediaStoreHelperImpl(
5255
val albumIdColumn = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ALBUM_ID)
5356
val folderColumn = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA)
5457
val sizeColumn = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.SIZE)
58+
val durationColumn = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DURATION)
5559
//val isFavColumn = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.IS_FAVORITE)
5660

5761
while (cursor.moveToNext()) {
@@ -64,6 +68,7 @@ class MediaStoreHelperImpl(
6468
val filePath = cursor.getString(folderColumn)
6569
val folder = filePath.substring(0, filePath.lastIndexOf('/'))
6670
val size = cursor.getLong(sizeColumn)
71+
val duration = cursor.getLong(durationColumn)
6772
//val isFavorite = cursor.getInt(isFavColumn) // 1 = is favorite, 0 = no
6873
val uri = ContentUris.withAppendedId(
6974
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
@@ -87,6 +92,7 @@ class MediaStoreHelperImpl(
8792
.setArtist(artist)
8893
.setAlbumTitle(album)
8994
.setArtworkUri(artUri)
95+
.setDurationMs(duration)
9096
.setExtras(
9197
Bundle()
9298
.apply {

app/src/main/java/com/sosauce/cutemusic/main/quickplay/QuickPlayActivity.kt

+20-25
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@file:OptIn(ExperimentalSharedTransitionApi::class)
2+
13
package com.sosauce.cutemusic.main.quickplay
24

35
import android.content.Intent
@@ -7,23 +9,18 @@ import android.os.Bundle
79
import androidx.activity.ComponentActivity
810
import androidx.activity.compose.setContent
911
import androidx.activity.enableEdgeToEdge
12+
import androidx.compose.animation.ExperimentalSharedTransitionApi
1013
import androidx.compose.foundation.background
1114
import androidx.compose.foundation.basicMarquee
1215
import androidx.compose.foundation.layout.Arrangement
1316
import androidx.compose.foundation.layout.Column
14-
import androidx.compose.foundation.layout.Row
1517
import androidx.compose.foundation.layout.Spacer
1618
import androidx.compose.foundation.layout.fillMaxSize
17-
import androidx.compose.foundation.layout.fillMaxWidth
1819
import androidx.compose.foundation.layout.height
1920
import androidx.compose.foundation.layout.padding
20-
import androidx.compose.material.icons.Icons
21-
import androidx.compose.material.icons.rounded.Pause
22-
import androidx.compose.material.icons.rounded.PlayArrow
23-
import androidx.compose.material3.FloatingActionButton
24-
import androidx.compose.material3.Icon
2521
import androidx.compose.material3.MaterialTheme
2622
import androidx.compose.material3.Scaffold
23+
import androidx.compose.runtime.LaunchedEffect
2724
import androidx.compose.runtime.getValue
2825
import androidx.compose.runtime.mutableStateOf
2926
import androidx.compose.runtime.remember
@@ -35,6 +32,7 @@ import androidx.compose.ui.unit.sp
3532
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
3633
import androidx.lifecycle.compose.collectAsStateWithLifecycle
3734
import com.sosauce.cutemusic.data.actions.PlayerActions
35+
import com.sosauce.cutemusic.ui.screens.playing.components.ActionsButtonsRowQuickPlay
3836
import com.sosauce.cutemusic.ui.screens.playing.components.MusicSlider
3937
import com.sosauce.cutemusic.ui.shared_components.CuteText
4038
import com.sosauce.cutemusic.ui.shared_components.MusicViewModel
@@ -60,6 +58,7 @@ class QuickPlayActivity : ComponentActivity() {
6058
val viewModel = koinViewModel<MusicViewModel>()
6159
val musicState by viewModel.musicState.collectAsStateWithLifecycle()
6260

61+
6362
when {
6463
intent?.action == Intent.ACTION_SEND -> {
6564
if (intent?.type?.startsWith("audio/") == true) {
@@ -76,6 +75,13 @@ class QuickPlayActivity : ComponentActivity() {
7675
}
7776
}
7877
}
78+
79+
LaunchedEffect(Unit) {
80+
viewModel.handlePlayerActions(
81+
PlayerActions.QuickPlay(uri!!)
82+
)
83+
}
84+
7985
Column(
8086
modifier = Modifier
8187
.fillMaxSize()
@@ -104,25 +110,14 @@ class QuickPlayActivity : ComponentActivity() {
104110
musicState = musicState
105111
)
106112
Spacer(modifier = Modifier.height(7.dp))
107-
Row(
108-
modifier = Modifier.fillMaxWidth(),
109-
horizontalArrangement = Arrangement.Center,
110-
verticalAlignment = Alignment.CenterVertically
111-
) {
112-
FloatingActionButton(
113-
onClick = {
114-
if (!viewModel.isPlayerReady()) viewModel.quickPlay(uri) else viewModel.handlePlayerActions(
115-
PlayerActions.PlayOrPause
116-
)
117-
}
118-
) {
119-
Icon(
120-
imageVector = if (musicState.isCurrentlyPlaying) Icons.Rounded.Pause else Icons.Rounded.PlayArrow,
121-
contentDescription = "pause/play button"
122-
)
123-
}
124-
}
113+
ActionsButtonsRowQuickPlay(
114+
onClickLoop = { viewModel.handlePlayerActions(PlayerActions.ApplyLoop) },
115+
onClickShuffle = { viewModel.handlePlayerActions(PlayerActions.ApplyShuffle) },
116+
onEvent = { viewModel.handlePlayerActions(it) },
117+
musicState = musicState
118+
)
125119
}
120+
126121
}
127122
}
128123
}

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

+9-3
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,14 @@ fun Nav() {
4646

4747

4848
SharedTransitionLayout {
49+
50+
this
4951
NavHost(
5052
navController = navController,
5153
startDestination = Screen.Main
5254
) {
55+
56+
this@SharedTransitionLayout
5357
composable<Screen.Main> {
5458
MainScreen(
5559
musics = musics,
@@ -99,6 +103,7 @@ fun Nav() {
99103
postViewModel.artistSongs(it)
100104
postViewModel.artistAlbums(it)
101105
},
106+
musicState = musicState
102107
)
103108

104109
}
@@ -130,8 +135,8 @@ fun Nav() {
130135
launchSingleTop = true
131136
}
132137
},
133-
selectedIndex = viewModel.selectedItem
134-
138+
selectedIndex = viewModel.selectedItem,
139+
musicState = musicState
135140
)
136141
}
137142
composable<Screen.Artists> {
@@ -165,7 +170,8 @@ fun Nav() {
165170
listToHandle = ListToHandle.ARTISTS,
166171
query = query
167172
)
168-
}
173+
},
174+
musicState = musicState
169175
)
170176
}
171177

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ fun AlbumDetailsLandscape(
110110
it
111111
)
112112
)
113-
}
113+
},
114+
isPlayerReady = viewModel.isPlayerReady()
114115
)
115116
}
116117
}

0 commit comments

Comments
 (0)