Skip to content

Commit

Permalink
Merge branch 'maxrave-dev:jetpack_compose' into jetpack_compose
Browse files Browse the repository at this point in the history
  • Loading branch information
RounakDadsena authored Jan 30, 2025
2 parents 6b19819 + 8d4408f commit 8569808
Show file tree
Hide file tree
Showing 36 changed files with 891 additions and 279 deletions.
6 changes: 3 additions & 3 deletions app/src/main/java/com/maxrave/simpmusic/common/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ object SUPPORTED_LANGUAGE {
"हिन्दी",
"ภาษาไทย",
"Nederlands",
"한국어"
"한국어",
)
val codes: Array<String> =
arrayOf(
Expand All @@ -221,7 +221,7 @@ object SUPPORTED_LANGUAGE {
"hi-IN",
"th-TH",
"nl-NL",
"ko-KR"
"ko-KR",
)

fun getLanguageFromCode(code: String?): String {
Expand Down Expand Up @@ -287,7 +287,7 @@ object SPONSOR_BLOCK {
R.string.preview,
R.string.music_off_topic,
R.string.poi_highlight,
R.string.filter,
R.string.filler,
)

fun fromDbToName(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,25 @@ class DataStoreManager(
}
}

val endlessQueue =
settingsDataStore.data.map { preferences ->
preferences[ENDLESS_QUEUE] ?: FALSE
}

suspend fun setEndlessQueue(endlessQueue: Boolean) {
withContext(Dispatchers.IO) {
if (endlessQueue) {
settingsDataStore.edit { settings ->
settings[ENDLESS_QUEUE] = TRUE
}
} else {
settingsDataStore.edit { settings ->
settings[ENDLESS_QUEUE] = FALSE
}
}
}
}

companion object Settings {
val COOKIE = stringPreferencesKey("cookie")
val LOGGED_IN = stringPreferencesKey("logged_in")
Expand Down Expand Up @@ -691,6 +710,7 @@ class DataStoreManager(
val PROXY_TYPE = stringPreferencesKey("proxy_type")
val PROXY_HOST = stringPreferencesKey("proxy_host")
val PROXY_PORT = intPreferencesKey("proxy_port")
val ENDLESS_QUEUE = stringPreferencesKey("endless_queue")
const val REPEAT_MODE_OFF = "REPEAT_MODE_OFF"
const val REPEAT_ONE = "REPEAT_ONE"
const val REPEAT_ALL = "REPEAT_ALL"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ fun parseMixedContent(
context,
) ?: listOf(),
description = null,
isExplicit = false,
isExplicit = ytItem.explicit,
playlistId = null,
browseId = null,
thumbnails =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,9 @@ class SimpleMediaServiceHandler(
player.playWhenReady = true
}

fun moveMediaItem(
fun currentSongIndex(): Int = player.currentMediaItemIndex

private fun moveMediaItem(
fromIndex: Int,
newIndex: Int,
) {
Expand Down Expand Up @@ -1037,15 +1039,28 @@ class SimpleMediaServiceHandler(
if (list != null) {
Log.w("Check loadMore response", response.toString())
loadMoreCatalog(list)
_queueData.value =
_queueData.value?.copy(
continuation = response.second,
)
} else {
_queueData.value =
_queueData.value?.copy(
continuation = null,
)
if (runBlocking { dataStoreManager.endlessQueue.first() } == TRUE) {
Log.w(TAG, "loadMore: Endless Queue")
val lastTrack = queueData.value?.listTracks?.lastOrNull() ?: return@launch
getRelated(lastTrack.videoId)
}
}
_queueData.value =
_queueData.value?.copy(
continuation = response?.second,
)
// loadingMore.value = false
}
}
}
} else if (runBlocking { dataStoreManager.endlessQueue.first() } == TRUE) {
Log.w(TAG, "loadMore: Endless Queue")
val lastTrack = queueData.value?.listTracks?.lastOrNull() ?: return
getRelated(lastTrack.videoId)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,20 +485,34 @@ fun QuickPicksItem(
bottom = 3.dp,
),
)

Text(
text = data.artists.toListName().connectArtists(),
style = typo.bodySmall,
maxLines = 1,
modifier =
Modifier
.fillMaxWidth()
.wrapContentHeight(align = Alignment.CenterVertically)
.basicMarquee(
iterations = Int.MAX_VALUE,
animationMode = MarqueeAnimationMode.Immediately,
).focusable(),
)
LazyRow(verticalAlignment = Alignment.CenterVertically) {
item {
androidx.compose.animation.AnimatedVisibility(visible = data.isExplicit == true) {
ExplicitBadge(
modifier =
Modifier
.size(20.dp)
.padding(end = 4.dp)
.weight(1f),
)
}
}
item {
Text(
text = data.artists.toListName().connectArtists(),
style = typo.bodySmall,
maxLines = 1,
modifier =
Modifier
.fillMaxWidth()
.wrapContentHeight(align = Alignment.CenterVertically)
.basicMarquee(
iterations = Int.MAX_VALUE,
animationMode = MarqueeAnimationMode.Immediately,
).focusable(),
)
}
}
}
}
}
Expand Down Expand Up @@ -573,20 +587,35 @@ fun HomeItemSong(
animationMode = MarqueeAnimationMode.Immediately,
).focusable(),
)
Text(
text = data.artists.toListName().connectArtists(),
style = typo.bodySmall,
maxLines = 1,
modifier =
Modifier
.width(180.dp)
.wrapContentHeight(align = Alignment.CenterVertically)
.basicMarquee(
iterations = Int.MAX_VALUE,
animationMode = MarqueeAnimationMode.Immediately,
).focusable()
.padding(vertical = 3.dp),
)
LazyRow(verticalAlignment = Alignment.CenterVertically) {
item {
androidx.compose.animation.AnimatedVisibility(visible = data.isExplicit == true) {
ExplicitBadge(
modifier =
Modifier
.size(20.dp)
.padding(end = 4.dp)
.weight(1f),
)
}
}
item {
Text(
text = data.artists.toListName().connectArtists(),
style = typo.bodySmall,
maxLines = 1,
modifier =
Modifier
.width(180.dp)
.wrapContentHeight(align = Alignment.CenterVertically)
.basicMarquee(
iterations = Int.MAX_VALUE,
animationMode = MarqueeAnimationMode.Immediately,
).focusable()
.padding(vertical = 3.dp),
)
}
}
Text(
text = data.album?.name ?: stringResource(id = R.string.songs),
style = typo.bodySmall,
Expand Down
31 changes: 31 additions & 0 deletions app/src/main/java/com/maxrave/simpmusic/ui/component/Badge.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.maxrave.simpmusic.ui.component

import androidx.compose.foundation.layout.Box
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Explicit
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview

@Composable
fun ExplicitBadge(modifier: Modifier = Modifier) {
Box(
modifier = modifier,
contentAlignment = Alignment.Center,
) {
Icon(
imageVector = Icons.Filled.Explicit,
"Explicit",
tint = Color.LightGray,
)
}
}

@Preview(showBackground = true, backgroundColor = 0xFF000000)
@Composable
fun PreviewBadge() {
ExplicitBadge()
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,19 @@ fun SongFullWidthItems(
contentDescription = "",
modifier = Modifier.size(20.dp).padding(2.dp),
)
Spacer(modifier = Modifier.width(10.dp))
Spacer(modifier = Modifier.width(4.dp))
}
}
AnimatedVisibility(
visible =
songEntity?.isExplicit
?: (track?.isExplicit ?: false),
) {
Row(verticalAlignment = Alignment.CenterVertically) {
ExplicitBadge(
modifier = Modifier.size(20.dp).padding(1.dp),
)
Spacer(modifier = Modifier.width(5.dp))
}
}
Text(
Expand All @@ -186,9 +198,11 @@ fun SongFullWidthItems(
)
}
}
RippleIconButton(resId = R.drawable.baseline_more_vert_24, fillMaxSize = false) {
val videoId = track?.videoId ?: songEntity?.videoId
videoId?.let { onMoreClickListener?.invoke(it) }
if (onMoreClickListener != null) {
RippleIconButton(resId = R.drawable.baseline_more_vert_24, fillMaxSize = false) {
val videoId = track?.videoId ?: songEntity?.videoId
videoId?.let { onMoreClickListener.invoke(it) }
}
}
}
}
Expand Down
Loading

0 comments on commit 8569808

Please sign in to comment.