-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
50eea09
commit 1e267a6
Showing
26 changed files
with
927 additions
and
87 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
app/src/main/java/org/listenbrainz/android/model/yimdata/Yim23AdditionalMetadata.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.listenbrainz.android.model.yimdata | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class Yim23AdditionalMetadata ( | ||
@SerializedName("caa_id") var caaId : String = "", | ||
@SerializedName("caa_release_mbid") var caaReleaseMbid : String = "", | ||
|
||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
app/src/main/java/org/listenbrainz/android/model/yimdata/Yim23TopDiscoveries.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.listenbrainz.android.model.yimdata | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class Yim23TopDiscoveries ( | ||
@SerializedName("playlist" ) var playlist : Yim23TopDiscoveriesPlaylist = Yim23TopDiscoveriesPlaylist() | ||
|
||
) |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/org/listenbrainz/android/model/yimdata/Yim23TopDiscoveriesPlaylist.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.listenbrainz.android.model.yimdata | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class Yim23TopDiscoveriesPlaylist ( | ||
@SerializedName("creator" ) var creator : String = "", | ||
@SerializedName("identifier" ) var identifier : String = "", | ||
@SerializedName("track" ) var tracks : List<Yim23Track> = listOf() | ||
) |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/org/listenbrainz/android/model/yimdata/Yim23Track.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.listenbrainz.android.model.yimdata | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class Yim23Track ( | ||
@SerializedName("creator" ) var creator : String = "", | ||
@SerializedName("identifier" ) var identifier : String = "", | ||
@SerializedName("extension") var extension : Yim23TrackExtension = Yim23TrackExtension(), | ||
@SerializedName("title" ) var title : String = "" | ||
) |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/org/listenbrainz/android/model/yimdata/Yim23TrackExtension.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.listenbrainz.android.model.yimdata | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class Yim23TrackExtension ( | ||
@SerializedName("https://musicbrainz.org/doc/jspf#track") var extensionData : Yim23TrackExtensionData = Yim23TrackExtensionData(), | ||
|
||
) |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/org/listenbrainz/android/model/yimdata/Yim23trackExtensionData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.listenbrainz.android.model.yimdata | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class Yim23TrackExtensionData ( | ||
@SerializedName("added_at") var addedAt : String = "", | ||
@SerializedName("added_by") var addedBy : String = "", | ||
@SerializedName("additional_metadata") var additionalMetadata : Yim23AdditionalMetadata = Yim23AdditionalMetadata(), | ||
|
||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
app/src/main/java/org/listenbrainz/android/ui/components/Yim23ListenCard.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
package org.listenbrainz.android.ui.components | ||
|
||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Surface | ||
import androidx.compose.material3.Text | ||
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.layout.ContentScale | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.text.style.TextOverflow | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi | ||
import com.bumptech.glide.integration.compose.GlideImage | ||
import org.listenbrainz.android.R | ||
import org.listenbrainz.android.ui.theme.ListenBrainzTheme | ||
import org.listenbrainz.android.ui.theme.lb_purple | ||
import org.listenbrainz.android.util.Utils | ||
|
||
|
||
@Composable | ||
@OptIn(ExperimentalGlideComposeApi::class) | ||
fun Yim23ListenCard( | ||
releaseName: String, | ||
artistName: String, | ||
caaId : String, | ||
caaReleaseMbid : String , | ||
onClick: () -> Unit = {} | ||
) { | ||
Surface( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(vertical = 4.dp) | ||
.clickable(enabled = true) { | ||
onClick() | ||
}, | ||
shape = RoundedCornerShape(5.dp), | ||
shadowElevation = 5.dp, | ||
color = Color.White | ||
) { | ||
Row( | ||
modifier = Modifier | ||
.fillMaxWidth(), | ||
verticalAlignment = Alignment.CenterVertically | ||
) { | ||
|
||
// Album cover art | ||
if(caaId != "" && caaReleaseMbid != ""){ | ||
GlideImage( | ||
model = Utils.getCoverArtUrl( | ||
caaReleaseMbid = caaReleaseMbid, | ||
caaId = caaId.toLong(), | ||
size = 250, | ||
), | ||
modifier = Modifier.size(60.dp), | ||
contentScale = ContentScale.Fit, | ||
contentDescription = "Album Cover Art" | ||
) { | ||
it.placeholder(R.drawable.ic_erroralbumart) | ||
.override(75) | ||
} | ||
} | ||
else{ | ||
Image(painter = painterResource(id = R.drawable.ic_erroralbumart) , contentDescription = "") | ||
} | ||
|
||
|
||
Spacer(modifier = Modifier.width(16.dp)) | ||
|
||
Column(modifier = Modifier) { | ||
Text( | ||
text = releaseName, | ||
style = MaterialTheme.typography.bodyMedium | ||
.copy( | ||
fontWeight = FontWeight.Bold, | ||
color = lb_purple, | ||
fontSize = 14.sp | ||
), | ||
maxLines = 1, | ||
overflow = TextOverflow.Ellipsis | ||
) | ||
Text( | ||
text = artistName, | ||
style = MaterialTheme.typography.bodySmall | ||
.copy( | ||
fontWeight = FontWeight.Bold, | ||
color = lb_purple.copy(alpha = 0.7f) | ||
), | ||
maxLines = 1, | ||
overflow = TextOverflow.Ellipsis | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
private fun YimListenCardPreview() { | ||
ListenBrainzTheme { | ||
// Doesn't work due to glide | ||
YimListenCard(releaseName = "Release name", artistName = "Artist", coverArtUrl = "") | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
app/src/main/java/org/listenbrainz/android/ui/screens/yim23/Yim23DiscoveriesListScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package org.listenbrainz.android.ui.screens.yim23 | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
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.foundation.lazy.LazyColumn | ||
import androidx.compose.foundation.lazy.items | ||
import androidx.compose.foundation.lazy.rememberLazyListState | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.collectAsState | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.unit.dp | ||
import androidx.navigation.NavController | ||
import org.listenbrainz.android.model.yimdata.Yim23Screens | ||
import org.listenbrainz.android.model.yimdata.Yim23TopDiscoveries | ||
import org.listenbrainz.android.model.yimdata.Yim23Track | ||
import org.listenbrainz.android.ui.components.Yim23Footer | ||
import org.listenbrainz.android.ui.components.Yim23Header | ||
import org.listenbrainz.android.ui.components.Yim23ListenCard | ||
import org.listenbrainz.android.ui.components.Yim23ShareButton | ||
import org.listenbrainz.android.ui.theme.Yim23Theme | ||
import org.listenbrainz.android.viewmodel.Yim23ViewModel | ||
|
||
@Composable | ||
fun Yim23DiscoveriesListScreen ( | ||
viewModel: Yim23ViewModel, | ||
navController: NavController | ||
) { | ||
val username by viewModel.getUsernameFlow().collectAsState(initial = "") | ||
Yim23Theme(themeType = viewModel.themeType.value) { | ||
Column (modifier = Modifier | ||
.fillMaxSize() | ||
.background(MaterialTheme.colorScheme.onBackground), verticalArrangement = Arrangement.SpaceBetween) { | ||
Yim23Header(username = username, navController = navController, upperScreen = Yim23Screens.YimDiscoveriesScreen) | ||
Yim23Discoveries(viewModel = viewModel) | ||
Column (modifier = Modifier.fillMaxWidth().padding(top = 11.dp , end = 11.dp) , horizontalAlignment = Alignment.CenterHorizontally) { | ||
Yim23ShareButton() | ||
} | ||
Yim23Footer(footerText = "DISCOVERIES OF 2023", isUsername = false, navController = navController, downScreen = Yim23Screens.YimMissedSongsScreen) | ||
} | ||
} | ||
} | ||
|
||
|
||
@Composable | ||
private fun Yim23Discoveries (viewModel: Yim23ViewModel) { | ||
val topDiscoveries : List<Yim23Track> = viewModel.getTopDiscoveries().playlist.tracks.toList() | ||
Box (modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(start = 11.dp, end = 11.dp) | ||
.clip( | ||
RoundedCornerShape(10.dp) | ||
) | ||
.height(300.dp) | ||
.background( | ||
Color(0xFFe0e5de) | ||
) | ||
) { | ||
LazyColumn (state = rememberLazyListState()) { | ||
items(topDiscoveries) { | ||
Yim23ListenCard(releaseName = it.title, artistName = it.creator, caaId = it.extension.extensionData.additionalMetadata.caaId, caaReleaseMbid = it.extension.extensionData.additionalMetadata.caaReleaseMbid) | ||
} | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.