Skip to content

Commit

Permalink
v2.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
sosauce committed Nov 3, 2024
1 parent ba58845 commit 5a10bcd
Show file tree
Hide file tree
Showing 51 changed files with 1,279 additions and 499 deletions.
Binary file modified .DS_Store
Binary file not shown.
Empty file.
Binary file modified app/.DS_Store
Binary file not shown.
8 changes: 4 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
applicationId = "com.sosauce.cutemusic"
minSdk = 26
targetSdk = 35
versionCode = 14
versionName = "2.2.3"
versionCode = 15
versionName = "2.2.4"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
Expand Down Expand Up @@ -79,9 +79,9 @@ android {
implementation(libs.kotlinx.serialization.json)
implementation(libs.koin.android)
implementation(libs.koin.androidx.compose)
debugImplementation(libs.androidx.ui.tooling)
//implementation("com.materialkolor:material-kolor:1.7.1")
//implementation("com.materialkolor:material-kolor:2.0.0")
implementation(libs.koin.androidx.startup)
implementation(libs.jaudiotagger)
debugImplementation(libs.androidx.ui.tooling)
}
}
Binary file modified app/release/baselineProfiles/0/app-release.dm
Binary file not shown.
Binary file modified app/release/baselineProfiles/1/app-release.dm
Binary file not shown.
4 changes: 2 additions & 2 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 13,
"versionName": "2.2.2",
"versionCode": 15,
"versionName": "2.2.4",
"outputFile": "app-release.apk"
}
],
Expand Down
Binary file modified app/src/.DS_Store
Binary file not shown.
Binary file modified app/src/main/.DS_Store
Binary file not shown.
34 changes: 33 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,55 @@
tools:targetApi="tiramisu">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.MUSIC_PLAYER" />

<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.APP_MUSIC" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>





<activity
android:name=".main.quickplay.QuickPlayActivity"
android:theme="@style/Theme.CuteSplash"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data android:scheme="content" />
<data android:scheme="file" />
<data android:mimeType="audio/*" />
</intent-filter>

<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.SHARE_TARGET" />
<data android:mimeType="audio/*" />

</intent-filter>
</activity>

<receiver
android:name="androidx.media3.session.MediaButtonReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>

<meta-data android:name="com.google.android.gms.car.application"
android:resource="@xml/automotive_app_desc"/>
</application>




</manifest>
5 changes: 4 additions & 1 deletion app/src/main/java/com/sosauce/cutemusic/data/MusicState.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.sosauce.cutemusic.data

import android.net.Uri
import androidx.media3.common.PlaybackParameters
import androidx.media3.common.Player
import com.sosauce.cutemusic.domain.model.Lyrics
import java.io.File

Expand All @@ -20,5 +22,6 @@ data class MusicState(
val currentAlbum: String = "",
val currentAlbumId: Long = 0,
val currentSize: Long = 0,
val currentLrcFile: File? = null
val currentLrcFile: File? = null,
val playbackParameters: PlaybackParameters = PlaybackParameters.DEFAULT,
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ sealed interface MetadataActions {
val path: String
) : MetadataActions

data class SaveChanges(
val path: String
) : MetadataActions
data object SaveChanges : MetadataActions

data object ClearState : MetadataActions
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.sosauce.cutemusic.data.actions

import android.net.Uri

sealed interface PlayerActions {
data object PlayOrPause : PlayerActions
data object SeekToNextMusic : PlayerActions
Expand All @@ -8,6 +10,7 @@ sealed interface PlayerActions {
data object PlayRandom : PlayerActions
data object ApplyLoop : PlayerActions
data object ApplyShuffle : PlayerActions
data object StopPlayback : PlayerActions
data class SeekTo(val position: Long) : PlayerActions
data class SeekToSlider(val position: Long) : PlayerActions
data class RewindTo(val position: Long) : PlayerActions
Expand All @@ -26,4 +29,13 @@ sealed interface PlayerActions {
val speed: Float,
val pitch: Float
) : PlayerActions

data class UpdateCurrentPosition(
val position: Long
) : PlayerActions


data class QuickPlay(
val uri: Uri
) : PlayerActions
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.sosauce.cutemusic.data.datastore.PreferencesKeys.APPLY_LOOP
import com.sosauce.cutemusic.data.datastore.PreferencesKeys.BLACKLISTED_FOLDERS
import com.sosauce.cutemusic.data.datastore.PreferencesKeys.FOLLOW_SYS
import com.sosauce.cutemusic.data.datastore.PreferencesKeys.HAS_SEEN_TIP
import com.sosauce.cutemusic.data.datastore.PreferencesKeys.SHOW_X_BUTTON
import com.sosauce.cutemusic.data.datastore.PreferencesKeys.SNAP_SPEED_N_PITCH
import com.sosauce.cutemusic.data.datastore.PreferencesKeys.SORT_ORDER
import com.sosauce.cutemusic.data.datastore.PreferencesKeys.SORT_ORDER_ALBUMS
Expand Down Expand Up @@ -40,6 +41,7 @@ private data object PreferencesKeys {
val USE_ART_THEME = booleanPreferencesKey("use_art_theme")
val APPLY_LOOP = booleanPreferencesKey("apply_loop")
val USE_CLASSIC_SLIDER = booleanPreferencesKey("use_classic_slider")
val SHOW_X_BUTTON = booleanPreferencesKey("show_x_button")
}

@Composable
Expand Down Expand Up @@ -95,3 +97,7 @@ fun rememberShouldApplyLoop() =
@Composable
fun rememberUseClassicSlider() =
rememberPreference(key = USE_CLASSIC_SLIDER, defaultValue = false)

@Composable
fun rememberShowXButton() =
rememberPreference(key = SHOW_X_BUTTON, defaultValue = true)
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.IntentSenderRequest
import androidx.media3.common.MediaItem
import androidx.media3.common.MediaMetadata
import androidx.media3.common.util.UnstableApi
import com.sosauce.cutemusic.domain.model.Album
import com.sosauce.cutemusic.domain.model.Artist
import com.sosauce.cutemusic.domain.model.Folder
Expand All @@ -20,6 +21,7 @@ class MediaStoreHelperImpl(
private val context: Context
) : MediaStoreHelper {

@UnstableApi
override fun fetchMusics(): List<MediaItem> {
val musics = mutableListOf<MediaItem>()

Expand All @@ -32,6 +34,7 @@ class MediaStoreHelperImpl(
MediaStore.Audio.Media.ALBUM_ID,
MediaStore.Audio.Media.DATA,
MediaStore.Audio.Media.SIZE,
MediaStore.Audio.Media.DURATION,
//MediaStore.Audio.Media.IS_FAVORITE,
)

Expand All @@ -52,6 +55,7 @@ class MediaStoreHelperImpl(
val albumIdColumn = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ALBUM_ID)
val folderColumn = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA)
val sizeColumn = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.SIZE)
val durationColumn = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DURATION)
//val isFavColumn = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.IS_FAVORITE)

while (cursor.moveToNext()) {
Expand All @@ -64,6 +68,7 @@ class MediaStoreHelperImpl(
val filePath = cursor.getString(folderColumn)
val folder = filePath.substring(0, filePath.lastIndexOf('/'))
val size = cursor.getLong(sizeColumn)
val duration = cursor.getLong(durationColumn)
//val isFavorite = cursor.getInt(isFavColumn) // 1 = is favorite, 0 = no
val uri = ContentUris.withAppendedId(
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
Expand All @@ -87,6 +92,7 @@ class MediaStoreHelperImpl(
.setArtist(artist)
.setAlbumTitle(album)
.setArtworkUri(artUri)
.setDurationMs(duration)
.setExtras(
Bundle()
.apply {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:OptIn(ExperimentalSharedTransitionApi::class)

package com.sosauce.cutemusic.main.quickplay

import android.content.Intent
Expand All @@ -7,23 +9,18 @@ import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.animation.ExperimentalSharedTransitionApi
import androidx.compose.foundation.background
import androidx.compose.foundation.basicMarquee
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Pause
import androidx.compose.material.icons.rounded.PlayArrow
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
Expand All @@ -35,6 +32,7 @@ import androidx.compose.ui.unit.sp
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.sosauce.cutemusic.data.actions.PlayerActions
import com.sosauce.cutemusic.ui.screens.playing.components.ActionsButtonsRowQuickPlay
import com.sosauce.cutemusic.ui.screens.playing.components.MusicSlider
import com.sosauce.cutemusic.ui.shared_components.CuteText
import com.sosauce.cutemusic.ui.shared_components.MusicViewModel
Expand All @@ -60,6 +58,7 @@ class QuickPlayActivity : ComponentActivity() {
val viewModel = koinViewModel<MusicViewModel>()
val musicState by viewModel.musicState.collectAsStateWithLifecycle()


when {
intent?.action == Intent.ACTION_SEND -> {
if (intent?.type?.startsWith("audio/") == true) {
Expand All @@ -76,6 +75,13 @@ class QuickPlayActivity : ComponentActivity() {
}
}
}

LaunchedEffect(Unit) {
viewModel.handlePlayerActions(
PlayerActions.QuickPlay(uri!!)
)
}

Column(
modifier = Modifier
.fillMaxSize()
Expand Down Expand Up @@ -104,25 +110,14 @@ class QuickPlayActivity : ComponentActivity() {
musicState = musicState
)
Spacer(modifier = Modifier.height(7.dp))
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically
) {
FloatingActionButton(
onClick = {
if (!viewModel.isPlayerReady()) viewModel.quickPlay(uri) else viewModel.handlePlayerActions(
PlayerActions.PlayOrPause
)
}
) {
Icon(
imageVector = if (musicState.isCurrentlyPlaying) Icons.Rounded.Pause else Icons.Rounded.PlayArrow,
contentDescription = "pause/play button"
)
}
}
ActionsButtonsRowQuickPlay(
onClickLoop = { viewModel.handlePlayerActions(PlayerActions.ApplyLoop) },
onClickShuffle = { viewModel.handlePlayerActions(PlayerActions.ApplyShuffle) },
onEvent = { viewModel.handlePlayerActions(it) },
musicState = musicState
)
}

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,14 @@ fun Nav() {


SharedTransitionLayout {

this
NavHost(
navController = navController,
startDestination = Screen.Main
) {

this@SharedTransitionLayout
composable<Screen.Main> {
MainScreen(
musics = musics,
Expand Down Expand Up @@ -99,6 +103,7 @@ fun Nav() {
postViewModel.artistSongs(it)
postViewModel.artistAlbums(it)
},
musicState = musicState
)

}
Expand Down Expand Up @@ -130,8 +135,8 @@ fun Nav() {
launchSingleTop = true
}
},
selectedIndex = viewModel.selectedItem

selectedIndex = viewModel.selectedItem,
musicState = musicState
)
}
composable<Screen.Artists> {
Expand Down Expand Up @@ -165,7 +170,8 @@ fun Nav() {
listToHandle = ListToHandle.ARTISTS,
query = query
)
}
},
musicState = musicState
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ fun AlbumDetailsLandscape(
it
)
)
}
},
isPlayerReady = viewModel.isPlayerReady()
)
}
}
Expand Down
Loading

0 comments on commit 5a10bcd

Please sign in to comment.