Skip to content

Commit

Permalink
Merge pull request #168 from chikoski/compose-for-tv-beta-migration
Browse files Browse the repository at this point in the history
[JetStream] Compose for tv beta migration
  • Loading branch information
chikoski authored May 20, 2024
2 parents fc5dcc0 + def415d commit dba6602
Show file tree
Hide file tree
Showing 79 changed files with 1,070 additions and 936 deletions.
2 changes: 1 addition & 1 deletion JetStreamCompose/benchmark/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
plugins {
alias(libs.plugins.android.test)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.compose.compiler)
}

android {
Expand Down Expand Up @@ -51,7 +52,6 @@ android {
}

targetProjectPath = ":jetstream"
experimentalProperties["android.experimental.self-instrumenting"] = true
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class BaselineProfileGenerator {
waitForIdle()
repeat(2) { pressDPadRight(); waitForIdle() }


// Navigate to Movies tab
pressDPadUp()
waitForIdle()
Expand Down Expand Up @@ -127,7 +126,6 @@ class BaselineProfileGenerator {
pressDPadRight()
waitForIdle()


// Navigate to Search tab
repeat(3) { pressDPadUp(); waitForIdle() }
pressDPadRight()
Expand Down Expand Up @@ -188,7 +186,6 @@ class BaselineProfileGenerator {
}
}


private const val JETSTREAM_PACKAGE_NAME = "com.google.jetstream"

private const val INITIAL_WAIT_TIMEOUT = 2000L
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ class StartupBenchmark {
}

private const val JETSTREAM_PACKAGE_NAME = "com.google.jetstream"
private const val STARTUP_TEST_ITERATIONS = 5
private const val STARTUP_TEST_ITERATIONS = 5
11 changes: 6 additions & 5 deletions JetStreamCompose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
https://youtrack.jetbrains.com/issue/KTIJ-19369/
*/
plugins {
alias(libs.plugins.android.application) apply(false)
alias(libs.plugins.kotlin.android) apply(false)
alias(libs.plugins.kotlin.serialization) apply(false)
alias(libs.plugins.android.test) apply(false)
alias(libs.plugins.hilt) apply(false)
alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.serialization) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.android.test) apply false
alias(libs.plugins.hilt) apply false
alias(libs.plugins.ksp) apply false
}
72 changes: 72 additions & 0 deletions JetStreamCompose/buildscripts/init.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

val ktlintVersion = "0.46.1"

initscript {
val spotlessVersion = "6.10.0"

repositories {
mavenCentral()
}

dependencies {
classpath("com.diffplug.spotless:spotless-plugin-gradle:$spotlessVersion")
}
}

allprojects {
if (this == rootProject) {
return@allprojects
}
apply<com.diffplug.gradle.spotless.SpotlessPlugin>()
extensions.configure<com.diffplug.gradle.spotless.SpotlessExtension> {
kotlin {
target("**/*.kt")
targetExclude("**/build/**/*.kt")
ktlint(ktlintVersion).editorConfigOverride(
mapOf(
"ktlint_code_style" to "android",
"ij_kotlin_allow_trailing_comma" to true,
// These rules were introduced in ktlint 0.46.0 and should not be
// enabled without further discussion. They are disabled for now.
// See: https://github.com/pinterest/ktlint/releases/tag/0.46.0
"disabled_rules" to
"filename," +
"annotation,annotation-spacing," +
"argument-list-wrapping," +
"double-colon-spacing," +
"enum-entry-name-case," +
"multiline-if-else," +
"no-empty-first-line-in-method-block," +
"package-name," +
"trailing-comma," +
"spacing-around-angle-brackets," +
"spacing-between-declarations-with-annotations," +
"spacing-between-declarations-with-comments," +
"unary-op-spacing"
)
)
licenseHeaderFile(rootProject.file("spotless/copyright.kt"))
}
format("kts") {
target("**/*.kts")
targetExclude("**/build/**/*.kts")
// Look for the first line that doesn't have a block comment (assumed to be the license)
licenseHeaderFile(rootProject.file("spotless/copyright.kt"), "(^(?![\\/ ]\\*).*$)")
}
}
}
31 changes: 17 additions & 14 deletions JetStreamCompose/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
[versions]
activity-compose = "1.9.0"
android-gradle-plugin = "8.3.2"
android-test-plugin = "8.3.2"
android-gradle-plugin = "8.4.0"
android-test-plugin = "8.4.0"
benchmark-macro-junit4 = "1.2.4"
coil-compose = "2.6.0"
compose-bom = "2024.04.01"
compose-for-tv = "1.0.0-alpha10"
core-ktx = "1.13.0"
compose-bom = "2024.05.00"
compose-foundation = "1.7.0-beta01"
compose-ui = "1.7.0-beta01"
tv-material = "1.0.0-beta01"
core-ktx = "1.13.1"
core-splashscreen = "1.0.1"
hilt-navigation-compose = "1.2.0"
hilt-android = "2.51"
hilt-android = "2.51.1"
junit = "1.1.5"
kotlin-android = "1.9.0"
kotlin-android = "2.0.0-RC3"
kotlinx-serialization = "1.6.0"
ksp = "1.9.0-1.0.13"
lifecycle-runtime-ktx = "2.7.0"
ksp = "2.0.0-RC3-1.0.20"
lifecycle-runtime-ktx = "2.8.0"
media3-ui = "1.3.1"
media3-exoplayer = "1.3.1"
navigation-compose = "2.7.7"
Expand All @@ -25,9 +27,10 @@ uiautomator = "2.3.0"
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activity-compose" }
androidx-benchmark-macro-junit4 = { module = "androidx.benchmark:benchmark-macro-junit4", version.ref = "benchmark-macro-junit4" }
androidx-compose-bom = { module = "androidx.compose:compose-bom", version.ref = "compose-bom" }
androidx-compose-ui-base = { module = "androidx.compose.ui:ui" }
androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" }
androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" }
androidx-compose-foundation-base = { module = "androidx.compose.foundation:foundation", version.ref = "compose-foundation"}
androidx-compose-ui-base = { module = "androidx.compose.ui:ui", version.ref = "compose-ui" }
androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose-ui" }
androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose-ui" }
androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "core-ktx" }
androidx-core-splashscreen = { module = "androidx.core:core-splashscreen", version.ref = "core-splashscreen" }
androidx-hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", version.ref = "hilt-navigation-compose" }
Expand All @@ -40,8 +43,7 @@ androidx-media3-ui = { module = "androidx.media3:media3-ui", version.ref = "medi
androidx-media3-exoplayer = { module = "androidx.media3:media3-exoplayer", version.ref = "media3-exoplayer" }
androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "navigation-compose" }
androidx-profileinstaller = { module = "androidx.profileinstaller:profileinstaller", version.ref = "profileinstaller" }
androidx-tv-foundation = { module = "androidx.tv:tv-foundation", version.ref = "compose-for-tv" }
androidx-tv-material = { module = "androidx.tv:tv-material", version.ref = "compose-for-tv" }
androidx-tv-material = { module = "androidx.tv:tv-material", version.ref = "tv-material" }
androidx-uiautomator = { module = "androidx.test.uiautomator:uiautomator", version.ref = "uiautomator" }
coil-compose = { module = "io.coil-kt:coil-compose", version.ref = "coil-compose" }
hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "hilt-android" }
Expand All @@ -53,5 +55,6 @@ android-application = { id = "com.android.application", version.ref = "android-g
android-test = { id = "com.android.test", version.ref = "android-test-plugin" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin-android" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin-android" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin-android" }
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt-android" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
2 changes: 1 addition & 1 deletion JetStreamCompose/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
15 changes: 10 additions & 5 deletions JetStreamCompose/jetstream/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.hilt)
alias(libs.plugins.ksp)
}
Expand All @@ -27,6 +28,10 @@ kotlin {
jvmToolchain(17)
}

composeCompiler {
enableStrongSkippingMode = true
}

android {
namespace = "com.google.jetstream"
// Needed for latest androidx snapshot build
Expand Down Expand Up @@ -69,9 +74,7 @@ android {
compose = true
buildConfig = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.0"
}

packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
Expand All @@ -90,11 +93,13 @@ dependencies {
implementation(libs.androidx.compose.ui.base)
implementation(libs.androidx.compose.ui.tooling.preview)

// Compose foundation library to replace tv-foundation
implementation(libs.androidx.compose.foundation.base)

// extra material icons
implementation(libs.androidx.material.icons.extended)

// TV Compose
implementation(libs.androidx.tv.foundation)
// Material components optimized for TV apps
implementation(libs.androidx.tv.material)

// ViewModel in Compose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -36,5 +36,4 @@ abstract class MovieRepositoryModule {
abstract fun bindMovieRepository(
movieRepositoryImpl: MovieRepositoryImpl
): MovieRepository

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.jetstream

import android.os.Bundle
Expand Down Expand Up @@ -40,4 +56,3 @@ class MainActivity : ComponentActivity() {
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ fun MoviesResponseItem.toMovie(thumbnailType: ThumbnailType = ThumbnailType.Stan
enum class ThumbnailType {
Standard,
Long
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -18,6 +18,7 @@ package com.google.jetstream.data.entities

import androidx.compose.runtime.Immutable

@Deprecated("This data class is deprecated as strong skip mode is enabled.")
@Immutable
data class MovieCategoryList(
val value: List<MovieCategory> = emptyList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ data class MovieDetails(
val originalLanguage: String,
val budget: String,
val revenue: String,
val similarMovies: List<Movie>,
val similarMovies: MovieList,
val reviewsAndRatings: List<MovieReviewsAndRatings>
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -18,7 +18,8 @@ package com.google.jetstream.data.entities

import androidx.compose.runtime.Immutable

@Deprecated("This data class is deprecated as strong skip mode is enabled.")
@Immutable
data class MovieList(
val value: List<Movie> = emptyList()
) : List<Movie> by value
) : List<Movie> by value
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package com.google.jetstream.data.models

import kotlinx.serialization.Serializable


@Serializable
data class MovieCategoriesResponseItem(
val id: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -72,4 +72,4 @@ internal suspend fun readMovieCategoryData(
assetsReader.getJsonDataFromAsset(resourceId).map {
Json.decodeFromString<List<MovieCategoriesResponseItem>>(it)
}.getOrDefault(emptyList())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -32,6 +32,4 @@ class MovieCastDataSource @Inject constructor(
}

suspend fun getMovieCastList() = movieCastDataReader.read()


}
}
Loading

0 comments on commit dba6602

Please sign in to comment.