Merge remote-tracking branch 'origin/master' into gpeal/telegraph-alpha-compat
diff --git a/LottieSample/src/main/assets/Tests/ TelegramAlphaCompat.json b/LottieSample/src/main/assets/Tests/ TelegramAlphaCompat.json
new file mode 100644
index 0000000..fd96baa
--- /dev/null
+++ b/LottieSample/src/main/assets/Tests/ TelegramAlphaCompat.json
@@ -0,0 +1,185 @@
+{
+ "v": "5.5.7",
+ "meta": {
+ "g": "LottieFiles AE 0.1.14",
+ "a": "",
+ "k": "",
+ "d": "",
+ "tc": ""
+ },
+ "fr": 60,
+ "ip": 0,
+ "op": 180,
+ "w": 300,
+ "h": 300,
+ "nm": " Square",
+ "ddd": 0,
+ "assets": [],
+ "layers": [
+ {
+ "ddd": 0,
+ "ind": 1,
+ "ty": 4,
+ "nm": "Shape Layer 1",
+ "sr": 1,
+ "ks": {
+ "o": {
+ "a": 0,
+ "k": 100,
+ "ix": 11
+ },
+ "r": {
+ "a": 0,
+ "k": 0,
+ "ix": 10
+ },
+ "p": {
+ "a": 0,
+ "k": [
+ 150,
+ 150,
+ 0
+ ],
+ "ix": 2
+ },
+ "a": {
+ "a": 0,
+ "k": [
+ 0,
+ 0,
+ 0
+ ],
+ "ix": 1
+ },
+ "s": {
+ "a": 0,
+ "k": [
+ 100,
+ 100,
+ 100
+ ],
+ "ix": 6
+ }
+ },
+ "ao": 0,
+ "shapes": [
+ {
+ "ty": "gr",
+ "it": [
+ {
+ "ty": "rc",
+ "d": 1,
+ "s": {
+ "a": 0,
+ "k": [
+ 182.992,
+ 182.992
+ ],
+ "ix": 2
+ },
+ "p": {
+ "a": 0,
+ "k": [
+ 0,
+ 0
+ ],
+ "ix": 3
+ },
+ "r": {
+ "a": 0,
+ "k": 0,
+ "ix": 4
+ },
+ "nm": "Rectangle Path 1",
+ "mn": "ADBE Vector Shape - Rect",
+ "hd": false
+ },
+ {
+ "ty": "fl",
+ "c": {
+ "a": 0,
+ "k": [
+ 1,
+ 0,
+ 0,
+ 255
+ ],
+ "ix": 4
+ },
+ "o": {
+ "a": 0,
+ "k": 100,
+ "ix": 5
+ },
+ "r": 1,
+ "bm": 0,
+ "nm": "Fill 1",
+ "mn": "ADBE Vector Graphic - Fill",
+ "hd": false
+ },
+ {
+ "ty": "tr",
+ "p": {
+ "a": 0,
+ "k": [
+ -8.504,
+ 1.496
+ ],
+ "ix": 2
+ },
+ "a": {
+ "a": 0,
+ "k": [
+ 0,
+ 0
+ ],
+ "ix": 1
+ },
+ "s": {
+ "a": 0,
+ "k": [
+ 100,
+ 100
+ ],
+ "ix": 3
+ },
+ "r": {
+ "a": 0,
+ "k": 0,
+ "ix": 6
+ },
+ "o": {
+ "a": 0,
+ "k": 100,
+ "ix": 7
+ },
+ "sk": {
+ "a": 0,
+ "k": 0,
+ "ix": 4
+ },
+ "sa": {
+ "a": 0,
+ "k": 0,
+ "ix": 5
+ },
+ "nm": "Transform"
+ }
+ ],
+ "nm": "Rectangle 1",
+ "np": 2,
+ "cix": 2,
+ "bm": 0,
+ "ix": 1,
+ "mn": "ADBE Vector Group",
+ "hd": false
+ }
+ ],
+ "ip": 0,
+ "op": 180,
+ "st": 0,
+ "bm": 0
+ }
+ ],
+ "markers": []
+}
\ No newline at end of file
diff --git a/lottie/src/main/java/com/airbnb/lottie/parser/ColorParser.java b/lottie/src/main/java/com/airbnb/lottie/parser/ColorParser.java
index 6f61119..fa4f1b4 100644
--- a/lottie/src/main/java/com/airbnb/lottie/parser/ColorParser.java
+++ b/lottie/src/main/java/com/airbnb/lottie/parser/ColorParser.java
@@ -25,11 +25,14 @@
reader.endArray();
}
- if (r <= 1 && g <= 1 && b <= 1 && a <= 1) {
+ if (r <= 1 && g <= 1 && b <= 1) {
r *= 255;
g *= 255;
b *= 255;
- a *= 255;
+ // It appears as if sometimes, Telegram Lottie stickers are exported with rgb [0,1] and a [0,255].
+ // This shouldn't happen but we can gracefully handle it when it does.
+ // https://github.com/airbnb/lottie-android/issues/1478
+ if (a <= 1) a *= 255;
}
return Color.argb((int) a, (int) r, (int) g, (int) b);