Update Compose API docs
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index cccd6bb..601ecd9 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -1,6 +1,7 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
+ <inspection_tool class="DeprecatedCallableAddReplaceWith" enabled="false" level="INFO" enabled_by_default="false" />
<inspection_tool class="EqualsReplaceableByObjectsCall" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="ForCanBeForeach" enabled="false" level="WARNING" enabled_by_default="false">
<option name="REPORT_INDEXED_LOOP" value="false" />
@@ -8,20 +9,34 @@
</inspection_tool>
<inspection_tool class="IfStatementWithIdenticalBranches" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="PreviewAnnotationInFunctionWithParameters" enabled="true" level="ERROR" enabled_by_default="true">
+ <option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewDimensionRespectsLimit" enabled="true" level="WARNING" enabled_by_default="true">
+ <option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
+ <inspection_tool class="PreviewFontScaleMustBeGreaterThanZero" enabled="true" level="ERROR" enabled_by_default="true">
+ <option name="composableFile" value="true" />
+ </inspection_tool>
<inspection_tool class="PreviewMultipleParameterProviders" enabled="true" level="ERROR" enabled_by_default="true">
+ <option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewMustBeTopLevelFunction" enabled="true" level="ERROR" enabled_by_default="true">
+ <option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewNeedsComposableAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
+ <option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
+ <inspection_tool class="PreviewNotSupportedInUnitTestFiles" enabled="true" level="ERROR" enabled_by_default="true">
+ <option name="composableFile" value="true" />
+ </inspection_tool>
+ <inspection_tool class="PreviewPickerAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
+ <option name="composableFile" value="true" />
+ </inspection_tool>
<inspection_tool class="SameParameterValue" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="SwitchStatementWithTooFewBranches" enabled="false" level="WARNING" enabled_by_default="false">
<option name="m_limit" value="2" />
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e24dfa2..6a44941 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+# 5.2.0
+### Bugs Fixed
+* De-dupe gradient stops. On pre-Oreo devices, if you had color and opacity stops in the same place and used hardware acceleration, you may have seen artifacts at the stop positions as of 5.1.1 [#20814](https://github.com/airbnb/lottie-android/pull/2081)
+
# 5.1.1
### New Features
* Added support for gradient opacity stops at different points than color stops ([#2062](https://github.com/airbnb/lottie-android/pull/2062))
diff --git a/CHANGELOG_COMPOSE.md b/CHANGELOG_COMPOSE.md
index 98451df..1b61124 100644
--- a/CHANGELOG_COMPOSE.md
+++ b/CHANGELOG_COMPOSE.md
@@ -1,3 +1,6 @@
+# 5.2.0
+* [BREAKING CHANGE] LottieAnimation now takes progress as a `() -> Float` rather than a `Float`. This allows Lottie to redraw without triggering a recomposition every time progress updates. For more information, refer to the Compose [phase docs](https://developer.android.com/jetpack/compose/phases). The existing API will exist as deprecated for one more release but will then be removed. [#2078](https://github.com/airbnb/lottie-android/pull/2078).
+
# 5.1.1
* Add support for completable animations in tests ([#2051](https://github.com/airbnb/lottie-android/pull/2051))
diff --git a/build.gradle b/build.gradle
index a54430f..5bfee23 100644
--- a/build.gradle
+++ b/build.gradle
@@ -2,13 +2,13 @@
buildscript {
ext {
- coroutinesVersion = '1.5.2'
+ coroutinesVersion = '1.6.2'
coreVersion = '1.6.0'
appcompatVersion = '1.3.1'
activityVersion = '1.3.1'
lifecycleVersion = '2.3.1'
- composeVersion = '1.0.3'
- kotlinVersion = '1.5.30'
+ composeVersion = '1.1.1'
+ kotlinVersion = '1.6.10'
daggerVersion = '2.38.1'
awsVersion = '2.8.3'
mockitoVersion = '3.12.4'
diff --git a/issue-repro-compose/src/main/java/com/airbnb/lottie/issues/compose/ComposeIssueReproActivity.kt b/issue-repro-compose/src/main/java/com/airbnb/lottie/issues/compose/ComposeIssueReproActivity.kt
index aeecf2f..abf6dc2 100755
--- a/issue-repro-compose/src/main/java/com/airbnb/lottie/issues/compose/ComposeIssueReproActivity.kt
+++ b/issue-repro-compose/src/main/java/com/airbnb/lottie/issues/compose/ComposeIssueReproActivity.kt
@@ -7,6 +7,7 @@
import androidx.compose.runtime.getValue
import com.airbnb.lottie.compose.LottieAnimation
import com.airbnb.lottie.compose.LottieCompositionSpec
+import com.airbnb.lottie.compose.LottieConstants
import com.airbnb.lottie.compose.animateLottieCompositionAsState
import com.airbnb.lottie.compose.rememberLottieComposition
@@ -21,7 +22,7 @@
@Composable
fun Content() {
val composition by rememberLottieComposition(LottieCompositionSpec.RawRes(R.raw.heart))
- val progress by animateLottieCompositionAsState(composition)
+ val progress by animateLottieCompositionAsState(composition, iterations = LottieConstants.IterateForever)
LottieAnimation(composition, { progress })
}
}
diff --git a/lottie-compose/src/main/java/com/airbnb/lottie/compose/LottieAnimation.kt b/lottie-compose/src/main/java/com/airbnb/lottie/compose/LottieAnimation.kt
index 0101abd..fb9edec 100644
--- a/lottie-compose/src/main/java/com/airbnb/lottie/compose/LottieAnimation.kt
+++ b/lottie-compose/src/main/java/com/airbnb/lottie/compose/LottieAnimation.kt
@@ -32,7 +32,7 @@
*
* @param composition The composition that will be rendered. To generate a [LottieComposition], you can use
* [rememberLottieComposition].
- * @param progressProvider A provider for the progress (between 0 and 1) that should be rendered. If you want to render a
+ * @param progress A provider for the progress (between 0 and 1) that should be rendered. If you want to render a
* specific frame, you can use [LottieComposition.getFrameForProgress]. In most cases, you will want
* to use one of the overloaded LottieAnimation composables that drives the animation for you.
* The overloads that have isPlaying as a parameter instead of progress will drive the
@@ -69,7 +69,7 @@
@Composable
fun LottieAnimation(
composition: LottieComposition?,
- progressProvider: () -> Float,
+ progress: () -> Float,
modifier: Modifier = Modifier,
outlineMasksAndMattes: Boolean = false,
applyOpacityToLayers: Boolean = false,
@@ -114,7 +114,7 @@
drawable.isApplyingOpacityToLayersEnabled = applyOpacityToLayers
drawable.maintainOriginalImageBounds = maintainOriginalImageBounds
drawable.clipToCompositionBounds = clipToCompositionBounds
- drawable.progress = progressProvider()
+ drawable.progress = progress()
drawable.setBounds(0, 0, composition.bounds.width(), composition.bounds.height())
drawable.draw(canvas.nativeCanvas, matrix)
}
@@ -127,6 +127,7 @@
* @see LottieAnimation
*/
@Composable
+@Deprecated("Pass progress as a lambda instead of a float. This overload will be removed in the next release.")
fun LottieAnimation(
composition: LottieComposition?,
@FloatRange(from = 0.0, to = 1.0) progress: Float,
@@ -192,18 +193,18 @@
iterations,
)
LottieAnimation(
- composition,
- { progress },
- modifier,
- outlineMasksAndMattes,
- applyOpacityToLayers,
- enableMergePaths,
- renderMode,
- maintainOriginalImageBounds,
- dynamicProperties,
- alignment,
- contentScale,
- clipToCompositionBounds,
+ composition = composition,
+ progress = { progress },
+ modifier = modifier,
+ outlineMasksAndMattes = outlineMasksAndMattes,
+ applyOpacityToLayers = applyOpacityToLayers,
+ enableMergePaths = enableMergePaths,
+ renderMode = renderMode,
+ maintainOriginalImageBounds = maintainOriginalImageBounds,
+ dynamicProperties = dynamicProperties,
+ alignment = alignment,
+ contentScale = contentScale,
+ clipToCompositionBounds = clipToCompositionBounds,
)
}