Skip to content

Commit

Permalink
Merge pull request #5 from RLD-JL/version-1.0.2
Browse files Browse the repository at this point in the history
Version 1.0.2
  • Loading branch information
RLD-JL committed May 29, 2022
2 parents b0098a9 + e153d9f commit 5270ee6
Show file tree
Hide file tree
Showing 21 changed files with 472 additions and 368 deletions.
30 changes: 15 additions & 15 deletions androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,37 @@ dependencies {
implementation("androidx.appcompat:appcompat:1.4.1")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.4.1")
implementation ("androidx.lifecycle:lifecycle-viewmodel-compose:2.5.0-rc01")
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.5.0-rc01")
implementation("androidx.activity:activity-compose:1.4.0")
implementation ("androidx.palette:palette-ktx:1.0.0")
implementation("androidx.palette:palette-ktx:1.0.0")

implementation ("androidx.compose.ui:ui-util:1.2.0-beta02")
implementation("androidx.compose.ui:ui-util:1.2.0-beta02")
implementation("androidx.compose.animation:animation:1.1.1")
implementation("androidx.compose.ui:ui:1.2.0-beta02")
debugImplementation ("androidx.compose.ui:ui-tooling:1.1.1")
implementation ("androidx.compose.ui:ui-tooling-preview:1.1.1")
debugImplementation("androidx.compose.ui:ui-tooling:1.1.1")
implementation("androidx.compose.ui:ui-tooling-preview:1.1.1")
implementation("androidx.compose.material:material:1.2.0-beta02")

implementation ("com.google.android.exoplayer:exoplayer:2.17.1")
implementation ("com.google.android.exoplayer:extension-mediasession:2.17.1")
implementation ("com.google.android.exoplayer:extension-cast:2.17.1")
implementation("com.google.android.exoplayer:exoplayer:2.17.1")
implementation("com.google.android.exoplayer:extension-mediasession:2.17.1")
implementation("com.google.android.exoplayer:extension-cast:2.17.1")


implementation("androidx.lifecycle:lifecycle-process:2.4.1")
implementation("io.coil-kt:coil-compose:2.0.0")
implementation("io.coil-kt:coil-compose:2.1.0")
implementation("com.google.dagger:hilt-android:2.38.1")
kapt("com.google.dagger:hilt-android-compiler:2.38.1")
implementation ("com.github.bumptech.glide:glide:4.12.0")
annotationProcessor ("com.github.bumptech.glide:compiler:4.12.0")
implementation("com.github.bumptech.glide:glide:4.13.2")
annotationProcessor("com.github.bumptech.glide:compiler:4.13.2")

implementation ("com.google.accompanist:accompanist-swiperefresh:0.24.1-alpha")
implementation("com.google.accompanist:accompanist-swiperefresh:0.24.1-alpha")
implementation("androidx.core:core-splashscreen:1.0.0-rc01")



androidTestImplementation("androidx.compose.ui:ui-test-junit4:${rootProject.extra["compose_version"]}")
debugImplementation("androidx.compose.ui:ui-tooling:${rootProject.extra["compose_version"]}")
debugImplementation ("com.squareup.leakcanary:leakcanary-android:2.7")
debugImplementation("com.squareup.leakcanary:leakcanary-android:2.7")
}

kapt {
Expand All @@ -55,8 +55,8 @@ android {
applicationId = "com.rld.justlisten.android"
minSdk = 21
targetSdk = 31
versionCode = 13
versionName = "1.0.1"
versionCode = 14
versionName = "1.0.2"
vectorDrawables {
useSupportLibrary = true
}
Expand Down
11 changes: 11 additions & 0 deletions androidApp/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,14 @@
# @Serializable and @Polymorphic are used at runtime for polymorphic serialization.
-keepattributes RuntimeVisibleAnnotations,AnnotationDefault

-keep public class * implements com.bumptech.glide.module.GlideModule
-keep class * extends com.bumptech.glide.module.AppGlideModule {
<init>(...);
}
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
**[] $VALUES;
public *;
}
-keep class com.bumptech.glide.load.data.ParcelFileDescriptorRewinder$InternalRewinder {
*** rewind();
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.graphics.toArgb
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import com.rld.justlisten.android.ui.MainComposable
import com.rld.justlisten.android.ui.theme.JustListenTheme
import com.rld.justlisten.android.ui.theme.ColorPallet
import com.rld.justlisten.android.ui.theme.JustListenTheme
import com.rld.justlisten.android.ui.utils.getColorPallet
import com.rld.justlisten.datalayer.datacalls.settings.getSettingsInfo

Expand All @@ -31,15 +31,24 @@ class MainActivity : ComponentActivity() {
darkTheme = settingsInfo.value.isDarkThemeOn,
colorPallet = getColorPallet(settingsInfo.value.palletColor)
) {
window.statusBarColor = if (getColorPallet(settingsInfo.value.palletColor) == ColorPallet.Dark) MaterialTheme.colors.background.toArgb()
else MaterialTheme.colors.primary.toArgb()
window.navigationBarColor = if (getColorPallet(settingsInfo.value.palletColor) == ColorPallet.Dark)
MaterialTheme.colors.background.toArgb() else MaterialTheme.colors.primary.toArgb()
val statusBarColor =
if (getColorPallet(settingsInfo.value.palletColor) == ColorPallet.Dark) MaterialTheme.colors.background.toArgb()
else MaterialTheme.colors.primary.toArgb()
window.statusBarColor = statusBarColor
window.navigationBarColor =
if (getColorPallet(settingsInfo.value.palletColor) == ColorPallet.Dark)
MaterialTheme.colors.background.toArgb() else MaterialTheme.colors.primary.toArgb()
MainComposable(
model, musicServiceConnection, settingsUpdated = {
settingsInfo.value = model.repository.getSettingsInfo()
},
hasNavigationDonationOn = settingsInfo.value.hasNavigationDonationOn
hasNavigationDonationOn = settingsInfo.value.hasNavigationDonationOn,
updateStatusBarColor = { color, extended ->
if (extended)
window.statusBarColor = color
else
window.statusBarColor = statusBarColor
}
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,26 @@ package com.rld.justlisten.android.di
import android.content.Context
import com.google.android.exoplayer2.C
import com.google.android.exoplayer2.ExoPlayer
import com.google.android.exoplayer2.RenderersFactory
import com.google.android.exoplayer2.audio.AudioAttributes
import com.google.android.exoplayer2.audio.MediaCodecAudioRenderer
import com.google.android.exoplayer2.database.DatabaseProvider
import com.google.android.exoplayer2.database.StandaloneDatabaseProvider
import com.google.android.exoplayer2.mediacodec.MediaCodecSelector
import com.google.android.exoplayer2.source.DefaultMediaSourceFactory
import com.google.android.exoplayer2.upstream.DefaultHttpDataSource
import com.google.android.exoplayer2.upstream.HttpDataSource
import com.google.android.exoplayer2.upstream.cache.CacheDataSource
import com.google.android.exoplayer2.upstream.cache.LeastRecentlyUsedCacheEvictor
import com.google.android.exoplayer2.upstream.cache.SimpleCache
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ServiceComponent
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.android.scopes.ServiceScoped
import java.io.File


@Module
@InstallIn(ServiceComponent::class)
Expand All @@ -21,7 +34,10 @@ object ServiceModule {
fun provideExoPlayer(
@ApplicationContext context: Context,
audioAttributes: AudioAttributes,
) = ExoPlayer.Builder(context).build().apply {
renderersFactory: RenderersFactory,
cacheDataSourceFactory: CacheDataSource.Factory
) = ExoPlayer.Builder(context, renderersFactory)
.setMediaSourceFactory(DefaultMediaSourceFactory(cacheDataSourceFactory)).build().apply {
setAudioAttributes(audioAttributes, true)
setHandleAudioBecomingNoisy(true)
}
Expand All @@ -32,4 +48,31 @@ object ServiceModule {
.setContentType(C.CONTENT_TYPE_MUSIC)
.setUsage(C.USAGE_MEDIA)
.build()

@Provides
@ServiceScoped
fun provideRenderFactory(@ApplicationContext context: Context) =
RenderersFactory { handler, _, audioListener, _, _ ->
arrayOf(
MediaCodecAudioRenderer(
context, MediaCodecSelector.DEFAULT, handler, audioListener
)
)
}

@Provides
@ServiceScoped
fun provideCacheFactory(@ApplicationContext context: Context): CacheDataSource.Factory {

val httpDataSourceFactory: HttpDataSource.Factory =
DefaultHttpDataSource.Factory()

val evictor = LeastRecentlyUsedCacheEvictor((50 * 1024 * 1024).toLong())
val databaseProvider: DatabaseProvider = StandaloneDatabaseProvider(context)

val simpleCache = SimpleCache(File(context.cacheDir, "media"), evictor, databaseProvider)

return CacheDataSource.Factory().setCache(simpleCache)
.setUpstreamDataSourceFactory(httpDataSourceFactory)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import android.support.v4.media.session.MediaSessionCompat
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.request.RequestOptions
import com.google.android.exoplayer2.Player
import com.google.android.exoplayer2.ui.PlayerNotificationManager
import com.rld.justlisten.android.R
import com.rld.justlisten.android.exoplayer.utils.Constants.NOTIFICATION_CHANNEL_ID
import com.rld.justlisten.android.exoplayer.utils.Constants.NOTIFICATION_ID
import com.google.android.exoplayer2.Player
import com.google.android.exoplayer2.ui.PlayerNotificationManager
import kotlinx.coroutines.*

class MusicNotificationManager(
Expand Down Expand Up @@ -97,19 +97,14 @@ class MusicNotificationManager(
}

private suspend fun resolveUriAsBitmap(uri: Uri): Bitmap? {
withContext(Dispatchers.IO) {
return withContext(Dispatchers.IO) {
// Block on downloading artwork.
return@withContext try {
Glide.with(context).applyDefaultRequestOptions(glideOptions)
.asBitmap()
.load(uri)
.submit(NOTIFICATION_LARGE_ICON_SIZE, NOTIFICATION_LARGE_ICON_SIZE)
.get()
} catch (e: Exception) {
return@withContext null
}
Glide.with(context).applyDefaultRequestOptions(glideOptions)
.asBitmap()
.load(uri)
.submit(NOTIFICATION_LARGE_ICON_SIZE, NOTIFICATION_LARGE_ICON_SIZE)
.get()
}
return null
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.support.v4.media.MediaMetadataCompat
import com.rld.justlisten.android.exoplayer.State.*
import com.rld.justlisten.android.exoplayer.library.extension.*
import com.rld.justlisten.datalayer.utils.Constants.BASEURL
import com.rld.justlisten.datalayer.utils.Constants.appName
import com.rld.justlisten.viewmodel.interfaces.Item

class MusicSource {
Expand Down Expand Up @@ -75,7 +76,7 @@ class MusicSource {
}

private fun setSongUrl(songId: String): String {
return "${BASEURL}/v1/tracks/${songId}/stream?app_name=EXAMPLEAPP"
return "${BASEURL}/v1/tracks/${songId}/stream?app_name=$appName"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ fun MainComposable(
model: JustListenViewModel,
musicServiceConnection: MusicServiceConnection,
settingsUpdated: () -> Unit,
hasNavigationDonationOn: Boolean
hasNavigationDonationOn: Boolean,
updateStatusBarColor: (Int, Boolean) -> Unit
) {
val appState by model.stateFlow.collectAsState()
val justlistenNav = appState.getNavigation(model = model)
justlistenNav.Router(musicServiceConnection, settingsUpdated = settingsUpdated, hasNavigationDonationOn)
justlistenNav.Router(musicServiceConnection, settingsUpdated = settingsUpdated, hasNavigationDonationOn,
updateStatusBarColor)
}
Loading

0 comments on commit 5270ee6

Please sign in to comment.