From 486930a9d60523c615b08a73624ed3b2e4babb40 Mon Sep 17 00:00:00 2001 From: Gabriel Peal Date: Sun, 7 May 2023 11:23:47 -0700 Subject: [PATCH] Migrate to version catalogues, refreshVersions, and update dependencies (#2285) It has been a very long time since I've updated dependencies around the project. This revamps the dependency infra to use refreshVersions and updates a handful of libraries. --- .github/workflows/validate.yml | 8 +- .idea/kotlinc.xml | 2 +- build.gradle | 36 +- gradle.properties | 2 +- gradle/libs.versions.toml | 74 ++ gradle/wrapper/gradle-wrapper.properties | 2 +- issue-repro-compose/build.gradle | 28 +- .../src/main/AndroidManifest.xml | 4 +- issue-repro/build.gradle | 11 +- issue-repro/src/main/AndroidManifest.xml | 7 +- lint.xml | 20 + lottie-compose/build.gradle | 35 +- lottie-compose/src/main/AndroidManifest.xml | 2 - lottie/build.gradle | 30 +- lottie/src/main/AndroidManifest.xml | 4 +- sample-compose-benchmark/build.gradle | 19 +- .../src/main/AndroidManifest.xml | 3 +- sample-compose/build.gradle | 65 +- sample-compose/src/main/AndroidManifest.xml | 14 +- .../examples/DynamicPropertiesExamplesPage.kt | 4 +- .../compose/examples/ImagesExamplesPage.kt | 2 +- .../compose/examples/ViewPagerExample.kt | 35 +- .../sample/compose/player/PlayerPage.kt | 21 +- sample/build.gradle | 76 +- sample/lint-baseline.xml | 1 - sample/src/main/AndroidManifest.xml | 29 +- .../airbnb/lottie/samples/PlayerActivity.kt | 5 +- .../airbnb/lottie/samples/PlayerFragment.kt | 44 +- .../lottie/samples/utils/TypeExtensions.kt | 22 + .../samples/views/InterceptingFrameLayout.kt | 2 + .../main/res/layout/choose_asset_fragment.xml | 11 - .../layout/control_bar_player_controls.xml | 40 +- sample/src/main/res/layout/empty_fragment.xml | 4 - sample/src/main/res/layout/font_fragment.xml | 41 - .../main/res/layout/view_holder_grid_item.xml | 24 - .../main/res/layout/view_holder_letter.xml | 4 - .../main/res/layout/view_holder_warning.xml | 21 - .../src/main/res/layout/warnings_fragment.xml | 45 - sample/src/main/res/menu/bottom_bar.xml | 8 +- .../src/main/res/menu/fragment_animation.xml | 24 - sample/src/main/res/values/strings.xml | 7 - settings.gradle | 4 + snapshot-tests/build.gradle | 53 +- snapshot-tests/src/main/AndroidManifest.xml | 3 +- versions.properties | 1072 +++++++++++++++++ 45 files changed, 1493 insertions(+), 475 deletions(-) create mode 100644 gradle/libs.versions.toml create mode 100644 lint.xml delete mode 100644 lottie-compose/src/main/AndroidManifest.xml delete mode 100644 sample/src/main/res/layout/choose_asset_fragment.xml delete mode 100644 sample/src/main/res/layout/empty_fragment.xml delete mode 100644 sample/src/main/res/layout/font_fragment.xml delete mode 100644 sample/src/main/res/layout/view_holder_grid_item.xml delete mode 100644 sample/src/main/res/layout/view_holder_letter.xml delete mode 100644 sample/src/main/res/layout/view_holder_warning.xml delete mode 100644 sample/src/main/res/layout/warnings_fragment.xml delete mode 100644 sample/src/main/res/menu/fragment_animation.xml create mode 100644 versions.properties diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index e0d83dbf6..0862a240a 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -21,7 +21,7 @@ jobs: uses: actions/setup-java@v2 with: distribution: 'zulu' - java-version: 11 + java-version: 17 cache: 'gradle' - name: Run Lint run: ./gradlew lintDebug --no-daemon @@ -43,7 +43,7 @@ jobs: uses: actions/setup-java@v2 with: distribution: 'zulu' - java-version: 11 + java-version: 17 cache: 'gradle' - name: Run Unit Tests run: ./gradlew testDebugUnitTest --no-daemon @@ -72,7 +72,7 @@ jobs: uses: actions/setup-java@v2 with: distribution: 'zulu' - java-version: 11 + java-version: 17 cache: 'gradle' - name: Build app run: ./gradlew snapshot-tests:assembleDebug snapshot-tests:assembleDebugAndroidTest --no-daemon @@ -109,7 +109,7 @@ jobs: uses: actions/setup-java@v2 with: distribution: 'zulu' - java-version: 11 + java-version: 17 cache: 'gradle' - name: "Deploy Snapshot" env: diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml index 4515aa32f..217e5c51f 100644 --- a/.idea/kotlinc.xml +++ b/.idea/kotlinc.xml @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/build.gradle b/build.gradle index 7fa614c8f..992b3a112 100644 --- a/build.gradle +++ b/build.gradle @@ -1,42 +1,22 @@ import org.ajoberstar.grgit.Grgit buildscript { - ext { - coroutinesVersion = '1.6.2' - coreVersion = '1.6.0' - appcompatVersion = '1.3.1' - activityVersion = '1.3.1' - lifecycleVersion = '2.3.1' - composeVersion = '1.1.1' - kotlinVersion = '1.6.10' - daggerVersion = '2.38.1' - awsVersion = '2.8.3' - mockitoVersion = '3.12.4' - robolectricVersion = '4.6.1' - retrofitVersion = '2.9.0' - materialVersion = '1.4.0' - epoxyVersion = '4.6.4' - junitVersion = '4.13.2' - extJunitVersion = '1.1.3' - espressoVersion = '3.3.0' - startupVersion = '1.2.0-alpha01' - } - repositories { google() mavenCentral() } dependencies { - classpath 'org.ajoberstar.grgit:grgit-gradle:4.1.1' - classpath 'com.android.tools.build:gradle:7.1.3' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" - classpath 'com.vanniktech:gradle-maven-publish-plugin:0.24.0' - classpath 'org.jetbrains.dokka:dokka-gradle-plugin:1.5.30' + classpath libs.grgit.plugin + classpath libs.android.gradle.plugin + classpath libs.kotlin.gradle.plugin + classpath libs.gradle.maven.publish.plugin + classpath libs.dokka.gradle.plugin } } plugins { - id 'net.ltgt.errorprone' version '3.0.1' apply false + id 'net.ltgt.errorprone' apply false + id "com.google.devtools.ksp" apply false } allprojects { @@ -53,6 +33,6 @@ ext { gitBranch = git.branch.current().name } -task clean(type: Delete) { +tasks.register('clean', Delete) { delete rootProject.buildDir } diff --git a/gradle.properties b/gradle.properties index 5dd110580..09a5e6fd8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,7 +15,7 @@ POM_DEVELOPER_EMAIL=lottie@airbnb.com POM_INCEPTION_YEAR=2017 android.useAndroidX=true -android.enableJetifier=true +android.enableJetifier=false org.gradle.caching=true org.gradle.jvmargs=-Xmx4g -XX:+UseParallelGC -Dfile.encoding=UTF-8 org.gradle.daemon=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 000000000..d52d9585e --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,74 @@ +[libraries] +android-gradle-plugin = "com.android.tools.build:gradle:_" +androidx-activity-compose = "androidx.activity:activity-compose:_" +androidx-appcompat = "androidx.appcompat:appcompat:_" +androidx-browser = "androidx.browser:browser:_" +androidx-cardview = "androidx.cardview:cardview:_" +androidx-collection-ktx = "androidx.collection:collection:_" +androidx-constraintlayout = "androidx.constraintlayout:constraintlayout:_" +androidx-core-ktx = "androidx.core:core-ktx:_" +androidx-fragment-testing = "androidx.fragment:fragment-testing:_" +androidx-multidex = "androidx.multidex:multidex:_" +androidx-navigation-compose = "androidx.navigation:navigation-compose:_" +androidx-navigation-ui = "androidx.navigation:navigation-ui-ktx:_" +androidx-paging-runtime-ktx = "androidx.paging:paging-runtime-ktx:_" +androidx-recyclerview = "androidx.recyclerview:recyclerview:_" +androidx-test-core = "androidx.test:core:_" +androidx-test-espresso = "androidx.test.espresso:espresso-core:_" +androidx-test-espresso-idling = "androidx.test.espresso:espresso-idling-resource:_" +androidx-test-junit = "androidx.test.ext:junit:_" +androidx-test-rules = "androidx.test:rules:_" +androidx-viewmodel-ktx = "androidx.lifecycle:lifecycle-viewmodel-ktx:_" +aws-android-sdk-auth-userpools = "com.amazonaws:aws-android-sdk-auth-userpools:_" +aws-android-sdk-mobile-client = "com.amazonaws:aws-android-sdk-mobile-client:_" +aws-android-sdk-s3 = "com.amazonaws:aws-android-sdk-s3:_" +coil-compose = "io.coil-kt:coil-compose:_" +compose-bom = "androidx.compose:compose-bom:_" +# Compose deps need the group/name structure without version because version is pulled from the bom. +compose-foundation = { group = "androidx.compose.foundation", name = "foundation" } +compose-material = { group = "androidx.compose.material", name = "material" } +compose-material-icons-extended = { group = "androidx.compose.material", name = "material-icons-extended" } +compose-ui = { group = "androidx.compose.ui", name = "ui" } +compose-ui-test-junit = "androidx.compose.ui:ui-test-junit4:_" +compose-ui-test-manifest = "androidx.compose.ui:ui-test-manifest:_" +compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" } +dagger = "com.google.dagger:dagger:_" +dagger-compiler = "com.google.dagger:dagger-compiler:_" +dokka-gradle-plugin = "org.jetbrains.dokka:dokka-gradle-plugin:_" +epoxy = "com.airbnb.android:epoxy:_" +epoxy-processor = "com.airbnb.android:epoxy-processor:_" +errorprone-core = "com.google.errorprone:error_prone_core:_" +errorprone-javac = "com.google.errorprone:javac:_" +glide = "com.github.bumptech.glide:glide:_" +google-material = "com.google.android.material:material:_" +gradle-maven-publish-plugin = "com.vanniktech:gradle-maven-publish-plugin:_" +grgit-plugin = "org.ajoberstar.grgit:grgit-gradle:_" +gson = "com.google.code.gson:gson:_" +javac = "com.google.errorprone:javac:_" +jjwt = "io.jsonwebtoken:jjwt:_" +junit4 = "junit:junit:_" +kotlin-annotation-processing-gradle = "org.jetbrains.kotlin:kotlin-annotation-processing-gradle:_" +kotlin-gradle-plugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:_" +kotlin-parcelize-compiler = "org.jetbrains.kotlin:kotlin-parcelize-compiler:_" +kotlin-parcelize-runtime = "org.jetbrains.kotlin:kotlin-parcelize-runtime:_" +kotlinx-coroutines-android = "org.jetbrains.kotlinx:kotlinx-coroutines-android:_" +kotlinx-coroutines-test = "org.jetbrains.kotlinx:kotlinx-coroutines-test:_" +mavericks = "com.airbnb.android:mavericks:_" +mavericks-compose = "com.airbnb.android:mavericks-compose:_" +mockito-android = "com.nhaarman.mockitokotlin2:mockito-kotlin:_" +mockito-core = "org.mockito:mockito-core:_" +mockito-kotlin = "org.mockito:mockito-android:_" +mpandroidchart = "com.github.PhilJay:MPAndroidChart:_" +mvrx = "com.airbnb.android:mvrx:_" +nullaway = "com.uber.nullaway:nullaway:_" +okhttp = "com.squareup.okhttp3:okhttp:_" +okio = "com.squareup.okio:okio:_" +org-jacoco-ant = "org.jacoco:org.jacoco.ant:_" +profileinstaller = "androidx.profileinstaller:profileinstaller:_" +qrcodereaderview = "com.dlazaro66.qrcodereaderview:qrcodereaderview:_" +retrofit = "com.squareup.retrofit2:retrofit:_" +retrofit-gson = "com.squareup.retrofit2:converter-gson:_" +retrofit-moshi = "com.squareup.retrofit2:converter-moshi:_" +retrofit-rxjava = "com.squareup.retrofit2:adapter-rxjava2:_" +robolectric = "org.robolectric:robolectric:_" +viewbinding = "androidx.databinding:viewbinding:_" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e750102e0..fae08049a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/issue-repro-compose/build.gradle b/issue-repro-compose/build.gradle index d3e20bcfa..129022ba3 100755 --- a/issue-repro-compose/build.gradle +++ b/issue-repro-compose/build.gradle @@ -1,38 +1,42 @@ +import static de.fayard.refreshVersions.core.Versions.versionFor + plugins { id 'com.android.application' id "kotlin-android" } android { - compileSdk 31 + namespace 'com.airbnb.lottie.issues.compose' + compileSdk 33 defaultConfig { applicationId "com.airbnb.lottie.issues.compose" minSdk 21 - targetSdk 30 + targetSdk 33 versionCode 1 versionName "1.0" } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = JavaVersion.VERSION_1_8.toString() + jvmTarget = JavaVersion.VERSION_17.toString() } buildFeatures { compose true } composeOptions { - kotlinCompilerExtensionVersion composeVersion + kotlinCompilerExtensionVersion = versionFor(project, AndroidX.compose.compiler) } } dependencies { implementation project(':lottie-compose') - implementation "androidx.appcompat:appcompat:$appcompatVersion" - implementation "androidx.activity:activity-compose:$activityVersion" - implementation "androidx.compose.ui:ui:$composeVersion" - implementation "androidx.compose.material:material:$composeVersion" - implementation "androidx.compose.material:material-icons-extended:$composeVersion" - implementation "androidx.compose.ui:ui-tooling:$composeVersion" + implementation libs.androidx.appcompat + implementation libs.androidx.activity.compose + implementation platform(libs.compose.bom) + implementation libs.compose.ui + implementation libs.compose.material + implementation libs.compose.material.icons.extended + implementation libs.compose.ui.tooling } diff --git a/issue-repro-compose/src/main/AndroidManifest.xml b/issue-repro-compose/src/main/AndroidManifest.xml index 3a75e49f8..9ca497e32 100755 --- a/issue-repro-compose/src/main/AndroidManifest.xml +++ b/issue-repro-compose/src/main/AndroidManifest.xml @@ -6,7 +6,9 @@ android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/Theme.AppCompat.Light.NoActionBar"> - + diff --git a/issue-repro/build.gradle b/issue-repro/build.gradle index 474f65119..c5eaa3539 100755 --- a/issue-repro/build.gradle +++ b/issue-repro/build.gradle @@ -4,17 +4,18 @@ plugins { } android { - compileSdk 31 + namespace 'com.airbnb.lottie.issues' + compileSdk 33 defaultConfig { applicationId "com.airbnb.lottie.issues" minSdk 16 - targetSdk 30 + targetSdk 33 versionCode 1 versionName "1.0" } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } buildFeatures { viewBinding true @@ -23,5 +24,5 @@ android { dependencies { implementation project(':lottie') - implementation "androidx.appcompat:appcompat:$appcompatVersion" + implementation libs.androidx.appcompat } diff --git a/issue-repro/src/main/AndroidManifest.xml b/issue-repro/src/main/AndroidManifest.xml index 68264122f..10a59c4a5 100755 --- a/issue-repro/src/main/AndroidManifest.xml +++ b/issue-repro/src/main/AndroidManifest.xml @@ -1,12 +1,13 @@ - + - + diff --git a/lint.xml b/lint.xml new file mode 100644 index 000000000..fa26a5a1d --- /dev/null +++ b/lint.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/lottie-compose/build.gradle b/lottie-compose/build.gradle index e4cb06713..14d645005 100644 --- a/lottie-compose/build.gradle +++ b/lottie-compose/build.gradle @@ -1,4 +1,5 @@ import com.vanniktech.maven.publish.SonatypeHost +import static de.fayard.refreshVersions.core.Versions.versionFor plugins { id 'com.android.library' @@ -7,10 +8,11 @@ plugins { } android { - compileSdk 31 + namespace 'com.airbnb.lottie.compose' + compileSdk 33 defaultConfig { minSdk 21 - targetSdk 30 + targetSdk 33 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { @@ -19,22 +21,20 @@ android { } } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = JavaVersion.VERSION_1_8.toString() + jvmTarget = JavaVersion.VERSION_17.toString() freeCompilerArgs += [ - "-Xallow-jvm-ir-dependencies", - "-Xskip-prerelease-check", - "-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi", + "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", ] } buildFeatures { compose true } composeOptions { - kotlinCompilerExtensionVersion composeVersion + kotlinCompilerExtensionVersion = versionFor(project, AndroidX.compose.compiler) } } @@ -45,13 +45,14 @@ mavenPublishing { dependencies { api project(':lottie') - implementation "androidx.compose.foundation:foundation:$composeVersion" - implementation "androidx.compose.ui:ui:$composeVersion" + implementation platform(libs.compose.bom) + implementation libs.compose.foundation + implementation libs.compose.ui - testImplementation "org.robolectric:robolectric:$robolectricVersion" - testImplementation 'androidx.collection:collection-ktx:1.1.0' - testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion" - testImplementation "junit:junit:$junitVersion" - androidTestImplementation "androidx.test.ext:junit:$extJunitVersion" - androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion" + testImplementation libs.robolectric + testImplementation libs.androidx.collection.ktx + testImplementation libs.kotlinx.coroutines.test + testImplementation libs.junit4 + androidTestImplementation libs.androidx.test.junit + androidTestImplementation libs.androidx.test.espresso } \ No newline at end of file diff --git a/lottie-compose/src/main/AndroidManifest.xml b/lottie-compose/src/main/AndroidManifest.xml deleted file mode 100644 index aca44676d..000000000 --- a/lottie-compose/src/main/AndroidManifest.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/lottie/build.gradle b/lottie/build.gradle index 2cc26bae2..c02c42991 100644 --- a/lottie/build.gradle +++ b/lottie/build.gradle @@ -8,11 +8,12 @@ plugins { } android { + namespace 'com.airbnb.lottie' resourcePrefix 'lottie_' - compileSdk 31 + compileSdk 33 defaultConfig { minSdk 16 - targetSdk 30 + targetSdk 33 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } lintOptions { @@ -21,8 +22,8 @@ android { textOutput 'stdout' } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } testOptions { unitTests { @@ -37,21 +38,20 @@ mavenPublishing { } dependencies { - implementation "androidx.appcompat:appcompat:$appcompatVersion" + implementation libs.androidx.appcompat // Do not upgrade to 2.0 because it will bring in Kotlin as a transitive dependency. //noinspection GradleDependency - implementation("com.squareup.okio:okio:1.17.4") + implementation libs.okio - annotationProcessor "com.uber.nullaway:nullaway:0.9.2" - errorprone "com.google.errorprone:error_prone_core:2.9.0" - //noinspection GradleDynamicVersion - errorproneJavac "com.google.errorprone:javac:9+181-r4173-1" + annotationProcessor libs.nullaway + errorprone libs.errorprone.core + errorproneJavac libs.errorprone.javac - testImplementation "org.mockito:mockito-core:$mockitoVersion" - testImplementation "org.robolectric:robolectric:$robolectricVersion" - testImplementation "junit:junit:$junitVersion" - androidTestImplementation "androidx.test.ext:junit:$extJunitVersion" - androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion" + testImplementation libs.mockito.core + testImplementation libs.robolectric + testImplementation libs.junit4 + androidTestImplementation libs.androidx.test.junit + androidTestImplementation libs.androidx.test.espresso } task sourcesJar(type: Jar) { diff --git a/lottie/src/main/AndroidManifest.xml b/lottie/src/main/AndroidManifest.xml index f2b05f445..486520569 100644 --- a/lottie/src/main/AndroidManifest.xml +++ b/lottie/src/main/AndroidManifest.xml @@ -1,5 +1,3 @@ - - + - diff --git a/sample-compose-benchmark/build.gradle b/sample-compose-benchmark/build.gradle index 742600ed8..99a24cab6 100644 --- a/sample-compose-benchmark/build.gradle +++ b/sample-compose-benchmark/build.gradle @@ -4,21 +4,22 @@ plugins { } android { - compileSdk 31 + namespace 'com.airbnb.lottie.sample.compose.benchmark' + compileSdk 33 compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = "1.8" + jvmTarget = JavaVersion.VERSION_17.toString() freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn" } defaultConfig { minSdk 30 - targetSdk 31 + targetSdk 33 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } @@ -35,10 +36,10 @@ android { } dependencies { - implementation 'androidx.test.ext:junit:1.1.3' - implementation 'androidx.test.espresso:espresso-core:3.4.0' - implementation 'androidx.test.uiautomator:uiautomator:2.2.0' - implementation 'androidx.benchmark:benchmark-macro-junit4:1.1.0-beta01' + implementation AndroidX.test.ext.junit + implementation AndroidX.test.espresso.core + implementation AndroidX.test.uiAutomator + implementation AndroidX.benchmark.macroJunit4 } androidComponents { diff --git a/sample-compose-benchmark/src/main/AndroidManifest.xml b/sample-compose-benchmark/src/main/AndroidManifest.xml index 4029f812d..16687dab8 100644 --- a/sample-compose-benchmark/src/main/AndroidManifest.xml +++ b/sample-compose-benchmark/src/main/AndroidManifest.xml @@ -1,7 +1,6 @@ + xmlns:tools="http://schemas.android.com/tools"> diff --git a/sample-compose/build.gradle b/sample-compose/build.gradle index c2f6061b7..f3c3698c2 100644 --- a/sample-compose/build.gradle +++ b/sample-compose/build.gradle @@ -1,3 +1,5 @@ +import static de.fayard.refreshVersions.core.Versions.versionFor + plugins { id 'com.android.application' id "kotlin-android" @@ -5,11 +7,12 @@ plugins { } android { - compileSdk 31 + namespace 'com.airbnb.lottie.sample.compose' + compileSdk 33 defaultConfig { applicationId "com.airbnb.lottie.sample.compose" minSdk 21 - targetSdk 30 + targetSdk 33 versionCode 1 versionName VERSION_NAME testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -22,26 +25,27 @@ android { } } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = JavaVersion.VERSION_1_8.toString() + jvmTarget = '17' freeCompilerArgs += [ "-Xallow-jvm-ir-dependencies", "-Xskip-prerelease-check", "-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi", "-Xuse-experimental=androidx.compose.animation.ExperimentalAnimationApi", + "-opt-in=androidx.compose.foundation.ExperimentalFoundationApi", "-Xopt-in=androidx.compose.material.ExperimentalMaterialApi", - "-Xopt-in=com.google.accompanist.pager.ExperimentalPagerApi", "-Xopt-in=kotlin.RequiresOptIn", ] } buildFeatures { compose true + buildConfig true } composeOptions { - kotlinCompilerExtensionVersion composeVersion + kotlinCompilerExtensionVersion = versionFor(project, AndroidX.compose.compiler) } packagingOptions { exclude 'META-INF/AL2.0' @@ -55,34 +59,35 @@ kapt { dependencies { implementation project(':lottie-compose') - implementation "androidx.core:core-ktx:$coreVersion" - implementation "androidx.activity:activity-compose:$activityVersion" - implementation 'androidx.appcompat:appcompat:1.4.0-beta01' - implementation "com.google.android.material:material:$materialVersion" - implementation "androidx.compose.ui:ui:$composeVersion" - implementation "androidx.compose.material:material:$composeVersion" - implementation "androidx.compose.material:material-icons-extended:$composeVersion" - implementation "androidx.compose.ui:ui-tooling:$composeVersion" - implementation "androidx.navigation:navigation-compose:2.4.0-alpha10" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion" + implementation libs.androidx.appcompat + implementation libs.androidx.core.ktx + implementation libs.androidx.activity.compose + implementation libs.google.material + implementation platform(libs.compose.bom) + implementation libs.compose.ui + implementation libs.compose.foundation + implementation libs.compose.material + implementation libs.compose.material.icons.extended + implementation libs.compose.ui.tooling + implementation libs.androidx.navigation.ui + implementation libs.androidx.navigation.compose + implementation libs.androidx.viewmodel.ktx // Need this to side load a Baseline Profile when Benchmarking - implementation "androidx.profileinstaller:profileinstaller:$startupVersion" + implementation libs.profileinstaller - implementation "androidx.navigation:navigation-ui-ktx:2.3.5" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion" + implementation libs.kotlinx.coroutines.android - implementation "com.google.dagger:dagger:$daggerVersion" - kapt "com.google.dagger:dagger-compiler:$daggerVersion" + implementation libs.dagger + kapt libs.dagger.compiler - implementation "com.squareup.retrofit2:retrofit:$retrofitVersion" - implementation "com.squareup.retrofit2:converter-moshi:$retrofitVersion" - implementation "com.google.accompanist:accompanist-coil:0.15.0" - implementation "com.google.accompanist:accompanist-pager-indicators:0.18.0" - implementation 'com.airbnb.android:mavericks:2.3.0' - implementation 'com.airbnb.android:mavericks-compose:2.1.0-alpha02' + implementation libs.retrofit + implementation libs.retrofit.moshi + implementation libs.coil.compose + implementation libs.mavericks + implementation libs.mavericks.compose - debugImplementation "androidx.compose.ui:ui-test-manifest:$composeVersion" + debugImplementation libs.compose.ui.test.manifest - androidTestImplementation "androidx.compose.ui:ui-test-junit4:$composeVersion" + androidTestImplementation libs.compose.ui.test.junit } diff --git a/sample-compose/src/main/AndroidManifest.xml b/sample-compose/src/main/AndroidManifest.xml index 139b4a3b9..e0557ace9 100644 --- a/sample-compose/src/main/AndroidManifest.xml +++ b/sample-compose/src/main/AndroidManifest.xml @@ -1,22 +1,18 @@ - - - + - - @@ -25,6 +21,10 @@ + + + + diff --git a/sample-compose/src/main/java/com/airbnb/lottie/sample/compose/examples/DynamicPropertiesExamplesPage.kt b/sample-compose/src/main/java/com/airbnb/lottie/sample/compose/examples/DynamicPropertiesExamplesPage.kt index 47723188e..5d6934c42 100644 --- a/sample-compose/src/main/java/com/airbnb/lottie/sample/compose/examples/DynamicPropertiesExamplesPage.kt +++ b/sample-compose/src/main/java/com/airbnb/lottie/sample/compose/examples/DynamicPropertiesExamplesPage.kt @@ -60,7 +60,7 @@ private fun HeartColor() { ) } var colorIndex by remember { mutableStateOf(0) } - val color by derivedStateOf { colors[colorIndex] } + val color by remember { derivedStateOf { colors[colorIndex] } } val blurRadius = with(LocalDensity.current) { 12.dp.toPx() } val dynamicProperties = rememberLottieDynamicProperties( @@ -100,7 +100,7 @@ private fun JumpHeight() { val composition by rememberLottieComposition(LottieCompositionSpec.Asset("AndroidWave.json")) val extraJumpHeights = remember { listOf(0.dp, 24.dp, 48.dp, 128.dp) } var extraJumpIndex by remember { mutableStateOf(0) } - val extraJumpHeight by derivedStateOf { extraJumpHeights[extraJumpIndex] } + val extraJumpHeight by remember { derivedStateOf { extraJumpHeights[extraJumpIndex] } } val extraJumpHeightPx = with(LocalDensity.current) { extraJumpHeight.toPx() } val point = remember { PointF() } diff --git a/sample-compose/src/main/java/com/airbnb/lottie/sample/compose/examples/ImagesExamplesPage.kt b/sample-compose/src/main/java/com/airbnb/lottie/sample/compose/examples/ImagesExamplesPage.kt index 0bedae94f..b9d5129a1 100644 --- a/sample-compose/src/main/java/com/airbnb/lottie/sample/compose/examples/ImagesExamplesPage.kt +++ b/sample-compose/src/main/java/com/airbnb/lottie/sample/compose/examples/ImagesExamplesPage.kt @@ -106,7 +106,7 @@ fun StoredOnImageAsset() { LottieCompositionSpec.RawRes(R.raw.we_accept), cacheKey = null, ) - val imageAsset by derivedStateOf { composition?.images?.get("image_0") } + val imageAsset by remember { derivedStateOf { composition?.images?.get("image_0") } } val bitmap = rememberBitmapFromAssets("Images/android.png") LaunchedEffect(imageAsset, bitmap) { if (imageAsset != null && bitmap != null) { diff --git a/sample-compose/src/main/java/com/airbnb/lottie/sample/compose/examples/ViewPagerExample.kt b/sample-compose/src/main/java/com/airbnb/lottie/sample/compose/examples/ViewPagerExample.kt index 79945beff..c05b47a15 100644 --- a/sample-compose/src/main/java/com/airbnb/lottie/sample/compose/examples/ViewPagerExample.kt +++ b/sample-compose/src/main/java/com/airbnb/lottie/sample/compose/examples/ViewPagerExample.kt @@ -1,41 +1,33 @@ package com.airbnb.lottie.sample.compose.examples -import androidx.compose.animation.core.exponentialDecay import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.pager.HorizontalPager +import androidx.compose.foundation.pager.PagerState +import androidx.compose.foundation.pager.rememberPagerState import androidx.compose.runtime.Composable import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue -import androidx.compose.ui.Alignment +import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color -import androidx.compose.ui.unit.dp import com.airbnb.lottie.compose.LottieAnimation import com.airbnb.lottie.compose.LottieCompositionSpec import com.airbnb.lottie.compose.rememberLottieComposition import com.airbnb.lottie.sample.compose.R -import com.google.accompanist.pager.HorizontalPager -import com.google.accompanist.pager.HorizontalPagerIndicator -import com.google.accompanist.pager.PagerDefaults -import com.google.accompanist.pager.PagerState -import com.google.accompanist.pager.rememberPagerState @Composable fun ViewPagerExamplePage() { val colors = listOf(Color.Red, Color.Green, Color.Blue, Color.Magenta) - val pagerState = rememberPagerState(pageCount = colors.size) + val pagerState = rememberPagerState() Box( modifier = Modifier .fillMaxSize() ) { HorizontalPager( - pagerState, - flingBehavior = PagerDefaults.rememberPagerFlingConfig( - pagerState, - decayAnimationSpec = exponentialDecay(frictionMultiplier = 0.05f) - ) + colors.size, + state = pagerState ) { page -> Box( modifier = Modifier @@ -43,21 +35,14 @@ fun ViewPagerExamplePage() { .background(colors[page]) ) } - WalkthroughAnimation(pagerState) - HorizontalPagerIndicator( - pagerState, - modifier = Modifier - .align(Alignment.BottomCenter) - .padding(bottom = 32.dp) - ) - + WalkthroughAnimation(pagerState, colors.size) } } @Composable -private fun WalkthroughAnimation(pagerState: PagerState) { +private fun WalkthroughAnimation(pagerState: PagerState, size: Int) { val composition by rememberLottieComposition(LottieCompositionSpec.RawRes(R.raw.walkthrough)) - val progress by derivedStateOf { (pagerState.currentPage + pagerState.currentPageOffset) / (pagerState.pageCount - 1f) } + val progress by remember { derivedStateOf { (pagerState.currentPage + pagerState.currentPageOffsetFraction) / (size - 1f) } } LottieAnimation( composition, { progress }, diff --git a/sample-compose/src/main/java/com/airbnb/lottie/sample/compose/player/PlayerPage.kt b/sample-compose/src/main/java/com/airbnb/lottie/sample/compose/player/PlayerPage.kt index 3a640f272..f53464a45 100644 --- a/sample-compose/src/main/java/com/airbnb/lottie/sample/compose/player/PlayerPage.kt +++ b/sample-compose/src/main/java/com/airbnb/lottie/sample/compose/player/PlayerPage.kt @@ -134,13 +134,18 @@ fun PlayerPage( Scaffold( scaffoldState = scaffoldState, topBar = { PlayerPageTopAppBar(state, compositionResult.value) }, - ) { - PlayerPageContent( - state, - compositionResult.value, - compositionResult.isLoading, - animationBackgroundColor, - ) + ) { padding -> + Box( + modifier = Modifier + .padding(padding) + ) { + PlayerPageContent( + state, + compositionResult.value, + compositionResult.isLoading, + animationBackgroundColor, + ) + } } if (state.showWarningsDialog) { @@ -306,7 +311,7 @@ private fun PlayerControlsRow( state: PlayerPageState, composition: LottieComposition?, ) { - val totalTime = ((composition?.duration ?: 0L / state.animatable.speed) / 1000.0) + val totalTime = (((composition?.duration ?: (0L / state.animatable.speed)) / 1000.0)) val totalTimeFormatted = ("%.1f").format(totalTime) val progressFormatted = ("%.1f").format(state.animatable.progress * totalTime) diff --git a/sample/build.gradle b/sample/build.gradle index bf60f181f..869b0ab20 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -1,16 +1,17 @@ plugins { id 'com.android.application' id "kotlin-android" - id 'kotlin-kapt' id 'kotlin-parcelize' + id 'com.google.devtools.ksp' } android { - compileSdk 31 + namespace 'com.airbnb.lottie.samples' + compileSdk 33 defaultConfig { applicationId "com.airbnb.lottie" minSdk 16 - targetSdk 30 + targetSdk 33 versionCode 70 versionName VERSION_NAME multiDexEnabled true @@ -21,6 +22,7 @@ android { } buildFeatures { viewBinding true + buildConfig true } buildTypes { debug { @@ -39,12 +41,12 @@ android { baseline file("lint-baseline.xml") } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = JavaVersion.VERSION_1_8.toString() - freeCompilerArgs += ["-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi"] + jvmTarget = JavaVersion.VERSION_17.toString() + freeCompilerArgs += ["-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi"] } sourceSets { main.java.srcDirs += 'src/main/kotlin' @@ -59,39 +61,39 @@ android { dependencies { implementation project(':lottie') - implementation 'androidx.multidex:multidex:2.0.1' + implementation libs.androidx.multidex - implementation "androidx.appcompat:appcompat:$appcompatVersion" - implementation "androidx.recyclerview:recyclerview:1.2.1" - implementation "androidx.paging:paging-runtime-ktx:3.0.1" - implementation "androidx.cardview:cardview:1.0.0" - implementation "androidx.core:core-ktx:$coreVersion" - implementation 'androidx.constraintlayout:constraintlayout:2.1.1' - implementation "androidx.browser:browser:1.3.0" - implementation "com.google.android.material:material:$materialVersion" + implementation libs.androidx.appcompat + implementation libs.androidx.recyclerview + implementation libs.androidx.paging.runtime.ktx + implementation libs.androidx.cardview + implementation libs.androidx.core.ktx + implementation libs.androidx.constraintlayout + implementation libs.androidx.browser + implementation libs.google.material - implementation "com.airbnb.android:epoxy:$epoxyVersion" - kapt "com.airbnb.android:epoxy-processor:$epoxyVersion" - implementation 'com.airbnb.android:mvrx:1.5.1' + implementation libs.epoxy + ksp libs.epoxy.processor + implementation libs.mvrx - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion" - implementation 'com.dlazaro66.qrcodereaderview:qrcodereaderview:2.0.2' - implementation 'com.github.PhilJay:MPAndroidChart:3.1.0' - implementation 'com.google.code.gson:gson:2.8.8' - implementation 'com.squareup.okhttp3:okhttp:4.9.1' - implementation "com.squareup.retrofit2:retrofit:$retrofitVersion" - implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion" - implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion" - implementation 'com.github.bumptech.glide:glide:4.12.0' + implementation libs.kotlinx.coroutines.android + implementation libs.qrcodereaderview + implementation libs.mpandroidchart + implementation libs.gson + implementation libs.okhttp + implementation libs.retrofit + implementation libs.retrofit.rxjava + implementation libs.retrofit.gson + implementation libs.glide - debugImplementation 'androidx.fragment:fragment-testing:1.3.6' + debugImplementation libs.androidx.fragment.testing - testImplementation "junit:junit:$junitVersion" - androidTestImplementation "androidx.test.ext:junit:$extJunitVersion" - androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion" - androidTestImplementation "androidx.test.espresso:espresso-idling-resource:$espressoVersion" - androidTestImplementation 'androidx.test:core:1.3.0' - androidTestImplementation 'androidx.test:rules:1.4.0' - androidTestImplementation "org.mockito:mockito-android:$mockitoVersion" - androidTestImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0" + testImplementation libs.junit4 + androidTestImplementation libs.androidx.test.junit + androidTestImplementation libs.androidx.test.espresso + androidTestImplementation libs.androidx.test.espresso.idling + androidTestImplementation libs.androidx.test.core + androidTestImplementation libs.androidx.test.rules + androidTestImplementation libs.mockito.android + androidTestImplementation libs.mockito.kotlin } diff --git a/sample/lint-baseline.xml b/sample/lint-baseline.xml index a7149f3f3..da9ad55b9 100644 --- a/sample/lint-baseline.xml +++ b/sample/lint-baseline.xml @@ -1639,5 +1639,4 @@ line="39" column="33"/> - diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml index f57a13dac..7727cfa03 100644 --- a/sample/src/main/AndroidManifest.xml +++ b/sample/src/main/AndroidManifest.xml @@ -1,22 +1,26 @@ - + + + - + + @@ -30,17 +34,21 @@ @@ -55,14 +63,19 @@ android:scheme="content" /> - - + + - + - \ No newline at end of file diff --git a/sample/src/main/kotlin/com/airbnb/lottie/samples/PlayerActivity.kt b/sample/src/main/kotlin/com/airbnb/lottie/samples/PlayerActivity.kt index 3059b4c9b..b91c9544d 100644 --- a/sample/src/main/kotlin/com/airbnb/lottie/samples/PlayerActivity.kt +++ b/sample/src/main/kotlin/com/airbnb/lottie/samples/PlayerActivity.kt @@ -5,6 +5,7 @@ import android.content.Intent import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import com.airbnb.lottie.samples.model.CompositionArgs +import com.airbnb.lottie.samples.utils.getParcelableExtraCompat class PlayerActivity : AppCompatActivity(R.layout.player_activity) { @@ -12,7 +13,9 @@ class PlayerActivity : AppCompatActivity(R.layout.player_activity) { super.onCreate(savedInstanceState) if (savedInstanceState == null) { - val args = intent.getParcelableExtra(PlayerFragment.EXTRA_ANIMATION_ARGS) ?: CompositionArgs(fileUri = intent.data) + val args = + intent.getParcelableExtraCompat(PlayerFragment.EXTRA_ANIMATION_ARGS, CompositionArgs::class.java) + ?: CompositionArgs(fileUri = intent.data) supportFragmentManager.beginTransaction() .add(R.id.content, PlayerFragment.forAsset(args)) .commit() diff --git a/sample/src/main/kotlin/com/airbnb/lottie/samples/PlayerFragment.kt b/sample/src/main/kotlin/com/airbnb/lottie/samples/PlayerFragment.kt index b2f10cf9b..ed279ae97 100644 --- a/sample/src/main/kotlin/com/airbnb/lottie/samples/PlayerFragment.kt +++ b/sample/src/main/kotlin/com/airbnb/lottie/samples/PlayerFragment.kt @@ -14,6 +14,8 @@ import android.view.View import android.widget.EditText import androidx.appcompat.app.AppCompatActivity import androidx.core.content.ContextCompat +import androidx.core.view.MenuHost +import androidx.core.view.MenuProvider import androidx.core.view.children import androidx.core.view.isVisible import androidx.fragment.app.Fragment @@ -30,6 +32,7 @@ import com.airbnb.lottie.RenderMode import com.airbnb.lottie.model.KeyPath import com.airbnb.lottie.samples.databinding.PlayerFragmentBinding import com.airbnb.lottie.samples.model.CompositionArgs +import com.airbnb.lottie.samples.utils.getParcelableCompat import com.airbnb.lottie.samples.utils.viewBinding import com.airbnb.lottie.samples.views.BottomSheetItemView import com.airbnb.lottie.samples.views.BottomSheetItemViewModel_ @@ -100,7 +103,25 @@ class PlayerFragment : BaseMvRxFragment(R.layout.player_fragment) { super.onViewCreated(view, savedInstanceState) (requireActivity() as AppCompatActivity).setSupportActionBar(binding.toolbar) (requireActivity() as AppCompatActivity).supportActionBar?.setDisplayShowTitleEnabled(false) - setHasOptionsMenu(true) + (requireActivity() as MenuHost).addMenuProvider(object : MenuProvider { + + override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) { + menuInflater.inflate(R.menu.fragment_player, menu) + } + + override fun onMenuItemSelected(item: MenuItem): Boolean { + if (item.isCheckable) item.isChecked = !item.isChecked + when (item.itemId) { + android.R.id.home -> requireActivity().finish() + R.id.visibility -> { + viewModel.setDistractionFree(item.isChecked) + val menuIcon = if (item.isChecked) R.drawable.ic_eye_teal else R.drawable.ic_eye_selector + item.icon = ContextCompat.getDrawable(requireContext(), menuIcon) + } + } + return true + } + }, viewLifecycleOwner, Lifecycle.State.RESUMED) binding.controlBarPlayerControls.lottieVersionView.text = getString(R.string.lottie_version, BuildConfig.VERSION_NAME) @@ -110,7 +131,7 @@ class PlayerFragment : BaseMvRxFragment(R.layout.player_fragment) { } }) - val args = arguments?.getParcelable(EXTRA_ANIMATION_ARGS) + val args = arguments?.getParcelableCompat(EXTRA_ANIMATION_ARGS, CompositionArgs::class.java) ?: throw IllegalArgumentException("No composition args specified") args.animationData?.bgColorInt?.let { binding.controlBarBackgroundColor.backgroundButton1.setBackgroundColor(it) @@ -394,25 +415,6 @@ class PlayerFragment : BaseMvRxFragment(R.layout.player_fragment) { super.onDestroyView() } - override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { - inflater.inflate(R.menu.fragment_player, menu) - super.onCreateOptionsMenu(menu, inflater) - } - - override fun onOptionsItemSelected(item: MenuItem): Boolean { - if (item.isCheckable) item.isChecked = !item.isChecked - when (item.itemId) { - android.R.id.home -> requireActivity().finish() - R.id.info -> Unit - R.id.visibility -> { - viewModel.setDistractionFree(item.isChecked) - val menuIcon = if (item.isChecked) R.drawable.ic_eye_teal else R.drawable.ic_eye_selector - item.icon = ContextCompat.getDrawable(requireContext(), menuIcon) - } - } - return true - } - private fun onCompositionLoaded(composition: LottieComposition?) { composition ?: return diff --git a/sample/src/main/kotlin/com/airbnb/lottie/samples/utils/TypeExtensions.kt b/sample/src/main/kotlin/com/airbnb/lottie/samples/utils/TypeExtensions.kt index 4c7a66099..66d70b0a2 100644 --- a/sample/src/main/kotlin/com/airbnb/lottie/samples/utils/TypeExtensions.kt +++ b/sample/src/main/kotlin/com/airbnb/lottie/samples/utils/TypeExtensions.kt @@ -7,6 +7,8 @@ import android.content.pm.PackageManager import android.graphics.Color import android.net.Uri import android.os.Build +import android.os.Bundle +import android.os.Parcelable import android.os.VibrationEffect import android.os.Vibrator import android.util.Log @@ -94,12 +96,14 @@ fun String?.toColorIntSafe(): Int { bgColor[2], bgColor[2], bgColor[3], bgColor[3] ) + 5 -> "#%c%c%c%c%c%c%c%c".format( bgColor[1], bgColor[1], bgColor[2], bgColor[2], bgColor[3], bgColor[3], bgColor[4], bgColor[4] ) + else -> bgColor }.toColorInt() } catch (e: IllegalArgumentException) { @@ -111,4 +115,22 @@ fun String?.toColorIntSafe(): Int { fun Context.hideKeyboard() { val inputMethodManager = getSystemService()!! inputMethodManager.hideSoftInputFromWindow((this as Activity).currentFocus?.windowToken, 0) +} + +fun Intent.getParcelableExtraCompat(key: String, klass: Class): T? { + return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + getParcelableExtra(key, klass) + } else { + @Suppress("DEPRECATION") + getParcelableExtra(key) + } +} + +fun Bundle.getParcelableCompat(key: String, klass: Class): T? { + return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + getParcelable(key, klass) + } else { + @Suppress("DEPRECATION") + getParcelable(key) + } } \ No newline at end of file diff --git a/sample/src/main/kotlin/com/airbnb/lottie/samples/views/InterceptingFrameLayout.kt b/sample/src/main/kotlin/com/airbnb/lottie/samples/views/InterceptingFrameLayout.kt index d078e4e80..2dd5caa17 100644 --- a/sample/src/main/kotlin/com/airbnb/lottie/samples/views/InterceptingFrameLayout.kt +++ b/sample/src/main/kotlin/com/airbnb/lottie/samples/views/InterceptingFrameLayout.kt @@ -1,5 +1,6 @@ package com.airbnb.lottie.samples.views +import android.annotation.SuppressLint import android.content.Context import android.util.AttributeSet import android.view.MotionEvent @@ -19,6 +20,7 @@ class InterceptingFrameLayout @JvmOverloads constructor( return super.onInterceptTouchEvent(ev) } + @SuppressLint("ClickableViewAccessibility") override fun onTouchEvent(event: MotionEvent): Boolean { viewDragHelper?.processTouchEvent(event) return true diff --git a/sample/src/main/res/layout/choose_asset_fragment.xml b/sample/src/main/res/layout/choose_asset_fragment.xml deleted file mode 100644 index 2b6b6e45c..000000000 --- a/sample/src/main/res/layout/choose_asset_fragment.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - \ No newline at end of file diff --git a/sample/src/main/res/layout/control_bar_player_controls.xml b/sample/src/main/res/layout/control_bar_player_controls.xml index 37977ec31..96b8e866a 100644 --- a/sample/src/main/res/layout/control_bar_player_controls.xml +++ b/sample/src/main/res/layout/control_bar_player_controls.xml @@ -1,7 +1,7 @@ - @@ -20,25 +20,32 @@ android:layout_marginLeft="16dp" android:gravity="center_horizontal" android:text="@string/ms" - android:textSize="12sp"/> + android:textSize="12sp" /> + android:layout_marginRight="64dp" /> + + + app:srcCompat="@drawable/ic_play_pause" /> + android:textSize="10sp" + tools:ignore="SmallSp" /> - - + android:layout_weight="1" /> + android:visibility="gone" + tools:ignore="SmallSp" /> + android:textSize="10sp" + tools:ignore="SmallSp" /> + android:background="@color/divider" /> diff --git a/sample/src/main/res/layout/empty_fragment.xml b/sample/src/main/res/layout/empty_fragment.xml deleted file mode 100644 index e54d18855..000000000 --- a/sample/src/main/res/layout/empty_fragment.xml +++ /dev/null @@ -1,4 +0,0 @@ - \ No newline at end of file diff --git a/sample/src/main/res/layout/font_fragment.xml b/sample/src/main/res/layout/font_fragment.xml deleted file mode 100644 index 71ed6fac0..000000000 --- a/sample/src/main/res/layout/font_fragment.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/sample/src/main/res/layout/view_holder_grid_item.xml b/sample/src/main/res/layout/view_holder_grid_item.xml deleted file mode 100644 index d7a773694..000000000 --- a/sample/src/main/res/layout/view_holder_grid_item.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/sample/src/main/res/layout/view_holder_letter.xml b/sample/src/main/res/layout/view_holder_letter.xml deleted file mode 100644 index 6dcd1c5c2..000000000 --- a/sample/src/main/res/layout/view_holder_letter.xml +++ /dev/null @@ -1,4 +0,0 @@ - - \ No newline at end of file diff --git a/sample/src/main/res/layout/view_holder_warning.xml b/sample/src/main/res/layout/view_holder_warning.xml deleted file mode 100644 index 37c983f85..000000000 --- a/sample/src/main/res/layout/view_holder_warning.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/sample/src/main/res/layout/warnings_fragment.xml b/sample/src/main/res/layout/warnings_fragment.xml deleted file mode 100644 index b90f48a96..000000000 --- a/sample/src/main/res/layout/warnings_fragment.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - -