diff --git a/build-logic/plugins/src/main/java/ch/srgssr/pillarbox/gradle/internal/AppConfig.kt b/build-logic/plugins/src/main/java/ch/srgssr/pillarbox/gradle/internal/AppConfig.kt index 2b6d9e4b2..ca476c839 100644 --- a/build-logic/plugins/src/main/java/ch/srgssr/pillarbox/gradle/internal/AppConfig.kt +++ b/build-logic/plugins/src/main/java/ch/srgssr/pillarbox/gradle/internal/AppConfig.kt @@ -10,7 +10,7 @@ internal object AppConfig { internal const val minSdk = 21 internal const val targetSdk = 34 internal const val compileSdk = 34 - internal const val androidXComposeCompiler = "1.5.11" + internal const val androidXComposeCompiler = "1.5.12" // When changing this value, don't forget to also update the Detekt config in the root `build.gradle.kts` file internal val javaVersion = JavaVersion.VERSION_17 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9f6a0ff8c..09ceae463 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,10 +1,10 @@ [versions] accompanist = "0.34.0" android-gradle-plugin = "8.3.2" -androidx-activity = "1.8.2" +androidx-activity = "1.9.0" androidx-annotation = "1.7.1" -androidx-compose = "2024.04.00" -androidx-core = "1.12.0" +androidx-compose = "2024.04.01" +androidx-core = "1.13.0" androidx-fragment = "1.6.2" androidx-leanback = "1.0.0" androidx-lifecycle = "2.7.0" @@ -42,7 +42,6 @@ accompanist-navigation-material = { module = "com.google.accompanist:accompanist android-gradle-api = { module = "com.android.tools.build:gradle-api", version.ref = "android-gradle-plugin" } androidx-activity = { module = "androidx.activity:activity", version.ref = "androidx-activity" } androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity" } -androidx-activity-ktx = { module = "androidx.activity:activity-ktx", version.ref = "androidx-activity" } androidx-annotation = { module = "androidx.annotation:annotation", version.ref = "androidx-annotation" } androidx-core = { module = "androidx.core:core", version.ref = "androidx-core" } androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "androidx-core" } diff --git a/pillarbox-demo-tv/build.gradle.kts b/pillarbox-demo-tv/build.gradle.kts index e0793358e..bc1ed2263 100644 --- a/pillarbox-demo-tv/build.gradle.kts +++ b/pillarbox-demo-tv/build.gradle.kts @@ -29,6 +29,7 @@ dependencies { implementation(libs.androidx.compose.ui.tooling.preview) implementation(libs.androidx.compose.ui.unit) implementation(libs.androidx.compose.ui.util) + implementation(libs.androidx.core) implementation(libs.androidx.fragment) implementation(libs.androidx.lifecycle.common) implementation(libs.androidx.lifecycle.runtime.ktx) diff --git a/pillarbox-demo-tv/src/main/java/ch/srgssr/pillarbox/demo/tv/ui/player/PlayerActivity.kt b/pillarbox-demo-tv/src/main/java/ch/srgssr/pillarbox/demo/tv/ui/player/PlayerActivity.kt index a6085b278..676d5563c 100644 --- a/pillarbox-demo-tv/src/main/java/ch/srgssr/pillarbox/demo/tv/ui/player/PlayerActivity.kt +++ b/pillarbox-demo-tv/src/main/java/ch/srgssr/pillarbox/demo/tv/ui/player/PlayerActivity.kt @@ -6,12 +6,12 @@ package ch.srgssr.pillarbox.demo.tv.ui.player import android.content.Context import android.content.Intent -import android.os.Build import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.ui.Modifier +import androidx.core.content.IntentCompat import ch.srgssr.pillarbox.demo.shared.data.DemoItem import ch.srgssr.pillarbox.demo.shared.di.PlayerModule import ch.srgssr.pillarbox.demo.tv.ui.player.compose.PlayerView @@ -33,11 +33,7 @@ class PlayerActivity : ComponentActivity() { player = PlayerModule.provideDefaultPlayer(this) mediaSession = PillarboxMediaSession.Builder(this, player) .build() - val demoItem = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - intent.getSerializableExtra(ARG_ITEM, DemoItem::class.java) - } else { - intent.getSerializableExtra(ARG_ITEM) as DemoItem? - } + val demoItem = IntentCompat.getSerializableExtra(intent, ARG_ITEM, DemoItem::class.java) demoItem?.let { player.setMediaItem(it.toMediaItem()) } diff --git a/pillarbox-demo-tv/src/main/java/ch/srgssr/pillarbox/demo/tv/ui/player/leanback/LeanbackPlayerActivity.kt b/pillarbox-demo-tv/src/main/java/ch/srgssr/pillarbox/demo/tv/ui/player/leanback/LeanbackPlayerActivity.kt index 87c2e9189..5a81df361 100644 --- a/pillarbox-demo-tv/src/main/java/ch/srgssr/pillarbox/demo/tv/ui/player/leanback/LeanbackPlayerActivity.kt +++ b/pillarbox-demo-tv/src/main/java/ch/srgssr/pillarbox/demo/tv/ui/player/leanback/LeanbackPlayerActivity.kt @@ -6,8 +6,8 @@ package ch.srgssr.pillarbox.demo.tv.ui.player.leanback import android.app.Activity import android.content.Intent -import android.os.Build import android.os.Bundle +import androidx.core.content.IntentCompat import androidx.fragment.app.FragmentActivity import ch.srgssr.pillarbox.demo.shared.data.DemoItem import ch.srgssr.pillarbox.demo.tv.R @@ -26,11 +26,7 @@ class LeanbackPlayerActivity : FragmentActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.activity_leanback_player) leanbackPlayerFragment = supportFragmentManager.findFragmentById(R.id.fragment_container) as LeanbackPlayerFragment - val demoItem = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - intent.getSerializableExtra(ARG_ITEM, DemoItem::class.java) - } else { - intent.getSerializableExtra(ARG_ITEM) as DemoItem? - } + val demoItem = IntentCompat.getSerializableExtra(intent, ARG_ITEM, DemoItem::class.java) demoItem?.let { leanbackPlayerFragment.setDemoItem(it) } diff --git a/pillarbox-demo/build.gradle.kts b/pillarbox-demo/build.gradle.kts index 7afb11ee3..21e07bf98 100644 --- a/pillarbox-demo/build.gradle.kts +++ b/pillarbox-demo/build.gradle.kts @@ -51,7 +51,6 @@ dependencies { implementation(libs.accompanist.navigation.material) implementation(libs.androidx.activity) implementation(libs.androidx.activity.compose) - implementation(libs.androidx.activity.ktx) implementation(libs.androidx.annotation) implementation(libs.androidx.compose.animation) implementation(libs.androidx.compose.animation.core) diff --git a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/SimplePlayerActivity.kt b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/SimplePlayerActivity.kt index b284367ea..1adfc130c 100644 --- a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/SimplePlayerActivity.kt +++ b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/player/SimplePlayerActivity.kt @@ -23,6 +23,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier +import androidx.core.content.IntentCompat import androidx.lifecycle.Lifecycle import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.flowWithLifecycle @@ -56,20 +57,15 @@ class SimplePlayerActivity : ComponentActivity(), ServiceConnection { private var layoutStyle: Int = LAYOUT_PLAYLIST private fun readIntent(intent: Intent) { - intent.extras?.let { - layoutStyle = it.getInt(ARG_LAYOUT) - val playlist: Playlist = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - it.getSerializable(ARG_PLAYLIST, Playlist::class.java)!! - } else { - it.getSerializable(ARG_PLAYLIST) as Playlist - } - playerViewModel.playUri(playlist.items) - } + layoutStyle = intent.getIntExtra(ARG_LAYOUT, LAYOUT_PLAYLIST) + + val playlist = IntentCompat.getSerializableExtra(intent, ARG_PLAYLIST, Playlist::class.java) + playlist?.let { playerViewModel.playUri(it.items) } } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - val ilHost = (intent.extras?.getSerializable(ARG_IL_HOST) as URL?) ?: IlHost.DEFAULT + val ilHost = IntentCompat.getSerializableExtra(intent, ARG_IL_HOST, URL::class.java) ?: IlHost.DEFAULT playerViewModel = ViewModelProvider(this, factory = SimplePlayerViewModel.Factory(application, ilHost))[SimplePlayerViewModel::class.java] readIntent(intent) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { @@ -110,11 +106,9 @@ class SimplePlayerActivity : ComponentActivity(), ServiceConnection { ) } - override fun onNewIntent(intent: Intent?) { + override fun onNewIntent(intent: Intent) { super.onNewIntent(intent) - intent?.let { - readIntent(it) - } + readIntent(intent) } override fun onServiceConnected(name: ComponentName?, service: IBinder?) {