diff --git a/lottie/src/main/java/com/airbnb/lottie/animation/content/ContentGroup.java b/lottie/src/main/java/com/airbnb/lottie/animation/content/ContentGroup.java index 166ee8b5f1..ebe2ad5509 100644 --- a/lottie/src/main/java/com/airbnb/lottie/animation/content/ContentGroup.java +++ b/lottie/src/main/java/com/airbnb/lottie/animation/content/ContentGroup.java @@ -221,7 +221,7 @@ private boolean hasTwoOrMoreDrawableContent() { @Override public void resolveKeyPath( KeyPath keyPath, int depth, List accumulator, KeyPath currentPartialKeyPath) { - if (!keyPath.matches(getName(), depth)) { + if (!keyPath.matches(getName(), depth) && !"__container".equals(getName())) { return; } diff --git a/lottie/src/main/java/com/airbnb/lottie/model/layer/BaseLayer.java b/lottie/src/main/java/com/airbnb/lottie/model/layer/BaseLayer.java index 71acea8c74..f2872996ae 100644 --- a/lottie/src/main/java/com/airbnb/lottie/model/layer/BaseLayer.java +++ b/lottie/src/main/java/com/airbnb/lottie/model/layer/BaseLayer.java @@ -592,6 +592,18 @@ public void setContents(List contentsBefore, List contentsAfte @Override public void resolveKeyPath( KeyPath keyPath, int depth, List accumulator, KeyPath currentPartialKeyPath) { + if (matteLayer != null) { + KeyPath matteCurrentPartialKeyPath = currentPartialKeyPath.addKey(matteLayer.getName()); + if (keyPath.fullyResolvesTo(matteLayer.getName(), depth)) { + accumulator.add(matteCurrentPartialKeyPath.resolve(matteLayer)); + } + + if (keyPath.propagateToChildren(getName(), depth)) { + int newDepth = depth + keyPath.incrementDepthBy(matteLayer.getName(), depth); + matteLayer.resolveChildKeyPath(keyPath, newDepth, accumulator, matteCurrentPartialKeyPath); + } + } + if (!keyPath.matches(getName(), depth)) { return; } diff --git a/sample/src/androidTest/java/com/airbnb/lottie/samples/LottieTest.kt b/sample/src/androidTest/java/com/airbnb/lottie/samples/LottieTest.kt index 5395a62d9a..64675c66b7 100644 --- a/sample/src/androidTest/java/com/airbnb/lottie/samples/LottieTest.kt +++ b/sample/src/androidTest/java/com/airbnb/lottie/samples/LottieTest.kt @@ -746,6 +746,11 @@ class LottieTest { { ScaleXY(-1.0f, 1.0f) }) } + withDrawable("Tests/TrackMattes.json", "Matte", "Matte property") { drawable -> + val keyPath = KeyPath("Shape Layer 1", "Rectangle 1", "Rectangle Path 1") + drawable.addValueCallback(keyPath, LottieProperty.RECTANGLE_SIZE, LottieValueCallback(PointF(50f, 50f))) + } + withDrawable("Tests/Text.json", "Text", "Text Fill (Blue -> Green)") { drawable -> val value = object : LottieValueCallback() { override fun getValue(frameInfo: LottieFrameInfo?) = Color.GREEN