Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ sentry.properties
/desktopApp/generated.conveyor.conf
# Conveyor output directory
/output/

# Local workspace files
MEMORY.md
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "core"]
path = core
url = https://github.com/maxrave-dev/core
url = https://github.com/blimjoe/core.git
34 changes: 21 additions & 13 deletions composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,30 @@ kotlin {
}
}

// listOf(
// iosArm64(),
// iosSimulatorArm64()
// ).forEach { iosTarget ->
// iosTarget.binaries.framework {
// baseName = "ComposeApp"
// isStatic = true
// }
// }
// The iOS port is in progress. Opt in to compile/link diagnostics without
// making the unfinished Native source sets part of normal Android/Desktop builds.
if (providers.gradleProperty("enableIos").map(String::toBoolean).getOrElse(false)) {
listOf(iosArm64(), iosSimulatorArm64()).forEach { iosTarget ->
iosTarget.binaries.framework {
baseName = "ComposeApp"
isStatic = true
}
}
}

jvm()
applyDefaultHierarchyTemplate()

sourceSets {
dependencies {
val composeBom = project.dependencies.platform(libs.compose.bom)
val koinBom = project.dependencies.platform(libs.koin.bom)
implementation(composeBom)
implementation(koinBom)
implementation(libs.commons.io)
}
androidMain.dependencies {
implementation(libs.commons.io)
api(libs.coil.network.okhttp)
api(project.dependencies.platform(libs.koin.bom))
api(libs.koin.android)
implementation(libs.koin.androidx.compose)
Expand Down Expand Up @@ -123,7 +126,6 @@ kotlin {
implementation(libs.compose.material3.adaptive)
implementation(libs.compose.material.ripple)

implementation(libs.ui.tooling.preview)

// Other module
api(projects.common)
Expand All @@ -149,7 +151,7 @@ kotlin {

// Coil
api(libs.coil.compose)
api(libs.coil.network.okhttp)
api(libs.coil.network.core)
api(libs.kmpalette.core)
api(libs.kmpalette.network)
implementation(libs.materialkolor)
Expand Down Expand Up @@ -186,10 +188,16 @@ kotlin {
implementation(libs.liquid.glass)
implementation(libs.liquid.glass.shape)
}
findByName("iosMain")?.dependencies {
implementation("io.coil-kt.coil3:coil-network-ktor3:${libs.versions.coil3.get()}")
implementation(libs.ktor.client.darwin)
}
commonTest.dependencies {
implementation(libs.kotlin.test)
}
jvmMain.dependencies {
implementation(libs.commons.io)
api(libs.coil.network.okhttp)
// Desktop app entry (main.kt), jpackage/Conveyor
// packaging, and tray icon live in :desktopApp per the
// JetBrains 2026 KMP default structure. This module keeps the
Expand Down Expand Up @@ -969,4 +977,4 @@ afterEvaluate {
.configureEach {
dependsOn("generateBuildKonfig")
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package com.maxrave.simpmusic

actual fun getPlatform(): Platform = Platform.Android
actual fun getPlatform(): Platform = Platform.Android

internal actual fun desktopOsName(): String = System.getProperty("os.name") ?: "jvm"
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.maxrave.simpmusic.extension

import java.io.File
import java.io.InputStream
import java.io.OutputStream
import java.util.zip.ZipInputStream
import java.util.zip.ZipOutputStream

fun InputStream.zipInputStream(): ZipInputStream = ZipInputStream(this)

fun OutputStream.zipOutputStream(): ZipOutputStream = ZipOutputStream(this)

fun getSizeOfFile(dir: File): Long {
var dirSize: Long = 0
if (!dir.listFiles().isNullOrEmpty()) {
for (f in dir.listFiles()!!) {
dirSize += f.length()
if (f.isDirectory) {
dirSize += getSizeOfFile(f)
}
}
}
return dirSize
}
6 changes: 3 additions & 3 deletions composeApp/src/commonMain/kotlin/com/maxrave/simpmusic/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -559,10 +559,10 @@ fun App(
) {
// On Android both materials go through the folding bar, which draws the mini
// player itself. Desktop keeps the always-open flat bar under its own one.
val useFoldingBar = getPlatform() == Platform.Android || isLiquidGlassEnabled == TRUE
val useFoldingBar = getPlatform() == Platform.Android || (getPlatform() == Platform.Desktop && isLiquidGlassEnabled == TRUE)
Column {
AnimatedVisibility(
isShowMiniPlayer && !useFoldingBar && isLiquidGlassEnabled == DataStoreManager.FALSE,
isShowMiniPlayer && !useFoldingBar,
enter = fadeIn() + slideInHorizontally(),
exit = fadeOut(),
) {
Expand Down Expand Up @@ -634,7 +634,7 @@ fun App(
exit = fadeOut(),
) {
MiniPlayer(
if (getPlatform() == Platform.Android) {
if (getPlatform() != Platform.Desktop) {
Modifier
// Glass keeps its 52dp card; the flat one is 56dp.
.height(if (isLiquidGlassEnabled == TRUE) 56.dp else 60.dp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ sealed class Platform {
fun osName(): String = when (this) {
Android -> "android"
iOS -> "iOS"
Desktop -> System.getProperty("os.name") ?: "jvm"
Desktop -> desktopOsName()
}
}

expect fun getPlatform(): Platform
expect fun getPlatform(): Platform

internal expect fun desktopOsName(): String
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@ import simpmusic.composeapp.generated.resources.recently
import simpmusic.composeapp.generated.resources.self_promotion
import simpmusic.composeapp.generated.resources.sponsor
import simpmusic.composeapp.generated.resources.title
import java.io.File
import java.io.InputStream
import java.io.OutputStream
import java.util.Locale
import java.util.concurrent.TimeUnit
import java.util.zip.ZipInputStream
import java.util.zip.ZipOutputStream
import kotlin.time.ExperimentalTime

fun String?.removeDuplicateWords(): String {
Expand Down Expand Up @@ -120,12 +113,7 @@ fun TimeLine.lengthLabel(): String = if (isLive) stringResource(Res.string.live_
@Composable
fun formatDuration(duration: Long): String {
if (duration < 0L) return stringResource(Res.string.na_na)
val minutes: Long = TimeUnit.MINUTES.convert(duration, TimeUnit.MILLISECONDS)
val seconds: Long = (
TimeUnit.SECONDS.convert(duration, TimeUnit.MILLISECONDS) -
minutes * TimeUnit.SECONDS.convert(1, TimeUnit.MINUTES)
)
return String.format(Locale.ENGLISH, "%02d:%02d", minutes, seconds)
return formatPlaybackDuration(duration)
}

fun parseTimestampToMilliseconds(timestamp: String): Double {
Expand Down Expand Up @@ -165,28 +153,11 @@ fun parseTimestampToMilliseconds(timestamp: String): Double {
return totalSeconds * 1000
}

fun InputStream.zipInputStream(): ZipInputStream = ZipInputStream(this)

fun OutputStream.zipOutputStream(): ZipOutputStream = ZipOutputStream(this)

fun Long?.bytesToMB(): Long {
val mbInBytes = 1024 * 1024
return this?.div(mbInBytes) ?: 0L
}

fun getSizeOfFile(dir: File): Long {
var dirSize: Long = 0
if (!dir.listFiles().isNullOrEmpty()) {
for (f in dir.listFiles()!!) {
dirSize += f.length()
if (f.isDirectory) {
dirSize += getSizeOfFile(f)
}
}
}
return dirSize
}

fun ArtistBrowse.toArtistScreenData(): ArtistScreenData =
ArtistScreenData(
title = this.name,
Expand Down Expand Up @@ -289,4 +260,4 @@ fun SponsorBlockType.displayRes(): StringResource =
SponsorBlockType.PREVIEW -> Res.string.preview
SponsorBlockType.SELF_PROMOTION -> Res.string.self_promotion
SponsorBlockType.SPONSOR -> Res.string.sponsor
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.maxrave.simpmusic.extension

import kotlinx.datetime.TimeZone
import kotlinx.datetime.toLocalDateTime
import kotlin.time.Instant

internal fun formatLocalTimestamp(epochMillis: Long, zone: TimeZone = TimeZone.currentSystemDefault()): String {
val local = Instant.fromEpochMilliseconds(epochMillis).toLocalDateTime(zone)
fun Int.padded(width: Int = 2) = toString().padStart(width, '0')
return "${local.year.padded(4)}-${local.month.ordinal.plus(1).padded()}-${local.day.padded()} " +
"${local.hour.padded()}:${local.minute.padded()}:${local.second.padded()}"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.maxrave.simpmusic.extension

import kotlin.math.roundToInt

internal fun formatPlaybackSpeed(speed: Float): String {
val tenths = (speed * 10).roundToInt()
return "${tenths / 10}.${tenths % 10}"
}

internal fun formatGroupedNumber(value: Int?): String = value?.toString()?.reversed()?.chunked(3)?.joinToString(",")?.reversed() ?: "null"
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.maxrave.simpmusic.extension

/** Locale-independent mm:ss, keeping total minutes for tracks longer than an hour. */
internal fun formatPlaybackDuration(milliseconds: Long): String {
require(milliseconds >= 0) { "Playback duration must be non-negative" }
val totalSeconds = milliseconds / 1_000
val minutes = (totalSeconds / 60).toString().padStart(2, '0')
val seconds = (totalSeconds % 60).toString().padStart(2, '0')
return "$minutes:$seconds"
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.layout.onGloballyPositioned
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fun ExpandableText(
text
.substring(startIndex = 0, endIndex = lastCharIndex)
.dropLast(showMoreText.length)
.dropLastWhile { Character.isWhitespace(it) || it == '.' }
.dropLastWhile { it.isWhitespace() || it == '.' }
append(adjustText)
withStyle(style = showMoreStyle) { append(showMoreText) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,20 @@ import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextDirection
import androidx.compose.ui.unit.LayoutDirection
import java.text.Bidi
import androidx.compose.ui.text.rememberTextMeasurer
import androidx.compose.ui.text.style.ResolvedTextDirection

@Composable
internal fun rememberLyricLayoutDirection(text: String): LayoutDirection =
remember(text) {
if (Bidi(text, Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT).baseIsLeftToRight()) LayoutDirection.Ltr else LayoutDirection.Rtl
internal fun rememberLyricLayoutDirection(text: String): LayoutDirection {
val measurer = rememberTextMeasurer()
return remember(text, measurer) {
if (text.isEmpty()) LayoutDirection.Ltr
else {
val layout = measurer.measure(text, style = TextStyle(textDirection = TextDirection.ContentOrLtr))
if (layout.getParagraphDirection(0) == ResolvedTextDirection.Rtl) LayoutDirection.Rtl else LayoutDirection.Ltr
}
}
}

/**
* A lyric and its subtitles share an edge, while each text keeps its own reading direction.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ import com.maxrave.simpmusic.viewModel.SharedViewModel
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
import org.jetbrains.compose.resources.painterResource
import java.text.Bidi
import androidx.compose.ui.text.rememberTextMeasurer
import androidx.compose.ui.text.style.ResolvedTextDirection
import kotlin.math.abs
import kotlin.math.exp
import kotlin.math.sqrt
Expand Down Expand Up @@ -1078,13 +1079,20 @@ private fun AnimatedWord(
// Null keeps Classic's DimRichPendingColor untouched.
pendingColorOverride: Color? = null,
) {
val wordBidi =
remember(word, lineDirection) {
val fallback =
if (lineDirection == LayoutDirection.Rtl) Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT else Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT
Bidi(word, fallback)
}
val wordDirection = if (wordBidi.baseIsLeftToRight()) TextDirection.Ltr else TextDirection.Rtl
val bidiMeasurer = rememberTextMeasurer()
val wordBidi = remember(word, lineDirection, bidiMeasurer) {
bidiMeasurer.measure(
word,
style = androidx.compose.ui.text.TextStyle(
textDirection = if (lineDirection == LayoutDirection.Rtl) TextDirection.ContentOrRtl else TextDirection.ContentOrLtr,
),
)
}
val wordDirection = if (word.isEmpty()) {
if (lineDirection == LayoutDirection.Rtl) TextDirection.Rtl else TextDirection.Ltr
} else if (wordBidi.getParagraphDirection(0) == ResolvedTextDirection.Rtl) TextDirection.Rtl else TextDirection.Ltr
val isEntirelyLeftToRight = wordDirection == TextDirection.Ltr &&
word.indices.all { wordBidi.getBidiRunDirection(it) == ResolvedTextDirection.Ltr }
val style =
typo().headlineLarge.copy(
fontSize = customFontSize ?: typo().headlineLarge.fontSize,
Expand Down Expand Up @@ -1215,7 +1223,7 @@ private fun AnimatedWord(
translationY = -eased * EMP_RISE_EM * amount * fontPx
},
) {
if (!wordBidi.isLeftToRight) {
if (!isEntirelyLeftToRight) {
// Keep Arabic shaping and combining marks intact, including RTL words in an LTR line.
ShapedLyricsWord(
word = word,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2194,7 +2194,7 @@ fun PlaybackSpeedPitchBottomSheet(
)
}
Text(
text = "x${String.format("%.1f", playbackSpeed)}",
text = "x${com.maxrave.simpmusic.extension.formatPlaybackSpeed(playbackSpeed)}",
style = typo().titleMedium,
color = rememberSurfaceDarkColors().subtitle,
modifier = Modifier.widthIn(min = 60.dp),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ fun MiniPlayer(
job4.join()
}

if (getPlatform() == Platform.Android) {
if (getPlatform() != Platform.Desktop) {
// One shape for both the Card and the clip below. They must not diverge: the clip wraps
// the Card's own background draw, so the larger radius wins and silently becomes the
// visible one.
Expand Down
Loading
Loading