Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JetStream] Compose for tv beta migration #168

Merged
merged 20 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
e6a6c83
apply spotless
chikoski May 14, 2024
7803fb4
Update dependencies
chikoski May 14, 2024
98637d8
Update code to fix warnings
chikoski May 15, 2024
feced9e
Update the loading and error state message to place the message on ce…
chikoski May 15, 2024
cbae28a
Update code due to the rename of the ToogleableSurfaceDefaults object
chikoski May 15, 2024
23b18cc
Update the code due to the rename of StandardCardLayout component
chikoski May 15, 2024
7a83e69
Specified UserAvator's size and minor code cleanup
chikoski May 15, 2024
3d77121
Replace ImmersiveList with custom implementation as ImmersiveList is …
chikoski May 15, 2024
ceaa51a
spotlessApply
chikoski May 16, 2024
7154759
code cleanup
chikoski May 16, 2024
19b826c
Add OptIn annotation to the functions using experimental features
chikoski May 16, 2024
dca953e
Upgrade core compose version to 1.7.0-beta01 and remove tv-foundation…
chikoski May 16, 2024
32a5086
spotless Apply
chikoski May 17, 2024
119d63a
Update Kotlin version to 2.0.0-RC3 and the settings accordingly.
chikoski May 20, 2024
42d684f
Remove the indentation of the line for the URL of the license
chikoski May 20, 2024
b6d56bc
Mark MovieList and MovieCategoryList as deprecated. This is because s…
chikoski May 20, 2024
2643026
Changed to refer to strings.xml from the actual string values.
chikoski May 20, 2024
149466c
Remove redundant conditional branch
chikoski May 20, 2024
21ec05b
Add a todo comment
chikoski May 20, 2024
def415d
Fix a layout issue where the background image is not fully visible wh…
chikoski May 20, 2024
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
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
*
* https://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 @@ -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 @@ -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
*
* https://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 @@ -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
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"), "(^(?![\\/ ]\\*).*$)")
}
}
}
30 changes: 16 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 = "1.9.24"
kotlinx-serialization = "1.6.0"
ksp = "1.9.0-1.0.13"
lifecycle-runtime-ktx = "2.7.0"
ksp = "1.9.24-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 Down
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
8 changes: 5 additions & 3 deletions JetStreamCompose/jetstream/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ android {
buildConfig = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.0"
kotlinCompilerExtensionVersion = "1.5.14"
}
packaging {
resources {
Expand All @@ -90,11 +90,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 @@ -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
*
* https://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 @@ -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
*
* https://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
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
*
* https://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
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
*
* https://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
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
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
*
* https://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 @@ -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 @@ -21,4 +21,4 @@ import androidx.compose.runtime.Immutable
@Immutable
data class MovieList(
val value: List<Movie> = emptyList()
) : List<Movie> by value
chikoski marked this conversation as resolved.
Show resolved Hide resolved
) : List<Movie> by value
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
*
* https://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
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
*
* https://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
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
*
* https://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,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
*
* https://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
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())
}
}
Loading
Loading