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
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.listenbrainz.android.di

import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import org.listenbrainz.android.repository.explore.ExploreRepository
import org.listenbrainz.android.repository.explore.ExploreRepositoryImpl

@Module
@InstallIn(SingletonComponent::class)
abstract class ExploreRepositoryModule {

@Binds
abstract fun bindsExploreRepository(repository: ExploreRepositoryImpl): ExploreRepository
}
11 changes: 9 additions & 2 deletions app/src/main/java/org/listenbrainz/android/di/ServiceModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import org.listenbrainz.android.service.AlbumService
import org.listenbrainz.android.service.ArtistService
import org.listenbrainz.android.service.BlogService
import org.listenbrainz.android.service.CBService
import org.listenbrainz.android.service.ExploreService
import org.listenbrainz.android.service.FeedService
import org.listenbrainz.android.service.ListensService
import org.listenbrainz.android.service.MBService
Expand Down Expand Up @@ -78,8 +79,14 @@ class ServiceModule {
fun providesListensService(appPreferences: AppPreferences): ListensService =
constructRetrofit(appPreferences)
.create(ListensService::class.java)



@Singleton
@Provides
fun providesExploreService(appPreferences: AppPreferences): ExploreService =
constructRetrofit(appPreferences)
.create(ExploreService::class.java)


@Singleton
@Provides
fun providesSocialService(appPreferences: AppPreferences): SocialService =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ sealed class AppNavigationItem(val route: String, @DrawableRes val iconUnselecte
object Artist: AppNavigationItem("artist", R.drawable.ic_artist, R.drawable.ic_artist,"Artist")
object Album: AppNavigationItem("album", R.drawable.ic_album, R.drawable.ic_album, "Artist > Album")
object PlaylistScreen: AppNavigationItem("playlist", R.drawable.ic_queue_music, R.drawable.ic_queue_music, "Playlist")
object HueSound: AppNavigationItem("HueSound", R.drawable.ic_album, R.drawable.ic_album, "HueSound")
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.listenbrainz.android.model.explore

import com.google.gson.annotations.SerializedName
import org.listenbrainz.android.model.TrackMetadata

data class HueSoundPayload(
val payload: HueSoundPayloadData
)

data class HueSoundPayloadData(
val releases: List<Release>
)

data class Release(
@SerializedName("artist_name") val artistName: String = "",
@SerializedName("release_name") val releaseName: String = "",
@SerializedName("release_mbid") val releaseId: String = "",
@SerializedName("caa_id") val caaId: Long = 0,
val recordings: List<Recording> = listOf()
)

data class Recording(
@SerializedName("track_metadata") val trackMetadata: TrackMetadata
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.listenbrainz.android.repository.explore

import org.listenbrainz.android.model.explore.HueSoundPayload
import org.listenbrainz.android.util.Resource

interface ExploreRepository {

suspend fun getReleasesFromColor(color: String): Resource<HueSoundPayload>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.listenbrainz.android.repository.explore

import javax.inject.Inject
import org.listenbrainz.android.model.explore.HueSoundPayload
import org.listenbrainz.android.service.ExploreService
import org.listenbrainz.android.util.Resource
import org.listenbrainz.android.util.Utils.parseResponse


class ExploreRepositoryImpl @Inject constructor(
private val exploreService: ExploreService
) : ExploreRepository {
override suspend fun getReleasesFromColor(color: String): Resource<HueSoundPayload> =
parseResponse { exploreService.getReleasesFromColor(color) }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.listenbrainz.android.service

import org.listenbrainz.android.model.explore.HueSoundPayload
import retrofit2.Response
import retrofit2.http.GET
import retrofit2.http.Path

interface ExploreService {

@GET("explore/color/{hexCode}")
suspend fun getReleasesFromColor(@Path("hexCode") colorHex: String): Response<HueSoundPayload>
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import org.listenbrainz.android.ui.screens.album.AlbumScreen
import org.listenbrainz.android.ui.screens.artist.ArtistScreen
import org.listenbrainz.android.ui.screens.brainzplayer.BrainzPlayerScreen
import org.listenbrainz.android.ui.screens.explore.ExploreScreen
import org.listenbrainz.android.ui.screens.explore.HueSoundScreen
import org.listenbrainz.android.ui.screens.feed.FeedScreen
import org.listenbrainz.android.ui.screens.playlist.PlaylistDetailScreen
import org.listenbrainz.android.ui.screens.profile.LoginScreen
Expand Down Expand Up @@ -81,6 +82,13 @@ fun AppNavigation(
}
}

fun goToHueSound() {
navController.navigate(AppNavigationItem.HueSound.route) {
launchSingleTop = true
restoreState = true
}
}


NavHost(
navController = navController as NavHostController,
Expand All @@ -103,7 +111,8 @@ fun AppNavigation(
}
appComposable(route = AppNavigationItem.Explore.route) {
ExploreScreen(
topAppBarActions
goToHueSoundScreen = ::goToHueSound,
topBarActions = topAppBarActions
)
}
appComposable(
Expand Down Expand Up @@ -222,6 +231,14 @@ fun AppNavigation(
)
}
}

appComposable(route = AppNavigationItem.HueSound.route) {
HueSoundScreen(
snackbarState = snackbarState,
topBarActions = topAppBarActions,
goToArtistPage = ::goToArtistPage
)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ import org.listenbrainz.android.ui.theme.ListenBrainzTheme

@Composable
fun ExploreScreen(
topBarActions: TopBarActions
topBarActions: TopBarActions,
goToHueSoundScreen: () -> Unit = {}
) {
Surface(
modifier = Modifier.fillMaxSize(),
Expand All @@ -57,6 +58,16 @@ fun ExploreScreen(
modifier = Modifier
.fillMaxWidth()
) {
//HueSound
item {
ExploreScreenCard(
nextActivity = null,
iconId = R.drawable.huesound_cover,
title = "HueSound",
subTitle = stringResource(id = R.string.discover),
nextScreen = goToHueSoundScreen
)
}
item {
ExploreScreenCard(
nextActivity = YearInMusic23Activity::class.java,
Expand Down Expand Up @@ -91,13 +102,24 @@ fun ExploreScreen(
}
}

/**
* Card used in the Explore screen.
*
* @param nextActivity Activity class to launch when the card is clicked.
* If non-null, clicking the card will start this activity and [nextScreen]
* will not be invoked.
* If `null`, no activity will be started and [nextScreen] will be called
* instead. In that case, callers are expected to provide a suitable
* navigation lambda via [nextScreen].
*/
@Composable
private fun ExploreScreenCard(
nextActivity: Class<out ComponentActivity>,
nextActivity: Class<out ComponentActivity>?,
iconId: Int,
title: String,
subTitle: String,
context: Context = LocalContext.current
context: Context = LocalContext.current,
nextScreen: () -> Unit = {}
) {
Surface(
modifier = Modifier
Expand All @@ -107,12 +129,16 @@ private fun ExploreScreenCard(
vertical = 10.dp
)
.clickable {
context.startActivity(
Intent(
context,
nextActivity
if (nextActivity != null)
context.startActivity(
Intent(
context,
nextActivity
)
)
)
else {
nextScreen()
}
},
color = ListenBrainzTheme.colorScheme.level1,
elevation = 6.dp,
Expand Down
Loading
Loading