Initial commit
This commit is contained in:
35
sources/androidx/core/graphics/ColorUtils.java
Normal file
35
sources/androidx/core/graphics/ColorUtils.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package androidx.core.graphics;
|
||||
|
||||
import android.graphics.Color;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class ColorUtils {
|
||||
static {
|
||||
new ThreadLocal();
|
||||
}
|
||||
|
||||
private static int a(int i, int i2) {
|
||||
return 255 - (((255 - i2) * (255 - i)) / 255);
|
||||
}
|
||||
|
||||
public static int b(int i, int i2) {
|
||||
int alpha = Color.alpha(i2);
|
||||
int alpha2 = Color.alpha(i);
|
||||
int a = a(alpha2, alpha);
|
||||
return Color.argb(a, a(Color.red(i), alpha2, Color.red(i2), alpha, a), a(Color.green(i), alpha2, Color.green(i2), alpha, a), a(Color.blue(i), alpha2, Color.blue(i2), alpha, a));
|
||||
}
|
||||
|
||||
public static int c(int i, int i2) {
|
||||
if (i2 < 0 || i2 > 255) {
|
||||
throw new IllegalArgumentException("alpha must be between 0 and 255.");
|
||||
}
|
||||
return (i & 16777215) | (i2 << 24);
|
||||
}
|
||||
|
||||
private static int a(int i, int i2, int i3, int i4, int i5) {
|
||||
if (i5 == 0) {
|
||||
return 0;
|
||||
}
|
||||
return (((i * 255) * i2) + ((i3 * i4) * (255 - i2))) / (i5 * 255);
|
||||
}
|
||||
}
|
636
sources/androidx/core/graphics/PathParser.java
Normal file
636
sources/androidx/core/graphics/PathParser.java
Normal file
@@ -0,0 +1,636 @@
|
||||
package androidx.core.graphics;
|
||||
|
||||
import android.graphics.Path;
|
||||
import android.util.Log;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class PathParser {
|
||||
|
||||
private static class ExtractFloatResult {
|
||||
int a;
|
||||
boolean b;
|
||||
|
||||
ExtractFloatResult() {
|
||||
}
|
||||
}
|
||||
|
||||
static float[] a(float[] fArr, int i, int i2) {
|
||||
if (i > i2) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
int length = fArr.length;
|
||||
if (i < 0 || i > length) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
int i3 = i2 - i;
|
||||
int min = Math.min(i3, length - i);
|
||||
float[] fArr2 = new float[i3];
|
||||
System.arraycopy(fArr, i, fArr2, 0, min);
|
||||
return fArr2;
|
||||
}
|
||||
|
||||
public static Path b(String str) {
|
||||
Path path = new Path();
|
||||
PathDataNode[] a = a(str);
|
||||
if (a == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
PathDataNode.a(a, path);
|
||||
return path;
|
||||
} catch (RuntimeException e) {
|
||||
throw new RuntimeException("Error in parsing " + str, e);
|
||||
}
|
||||
}
|
||||
|
||||
private static float[] c(String str) {
|
||||
if (str.charAt(0) == 'z' || str.charAt(0) == 'Z') {
|
||||
return new float[0];
|
||||
}
|
||||
try {
|
||||
float[] fArr = new float[str.length()];
|
||||
ExtractFloatResult extractFloatResult = new ExtractFloatResult();
|
||||
int length = str.length();
|
||||
int i = 1;
|
||||
int i2 = 0;
|
||||
while (i < length) {
|
||||
a(str, i, extractFloatResult);
|
||||
int i3 = extractFloatResult.a;
|
||||
if (i < i3) {
|
||||
fArr[i2] = Float.parseFloat(str.substring(i, i3));
|
||||
i2++;
|
||||
}
|
||||
i = extractFloatResult.b ? i3 : i3 + 1;
|
||||
}
|
||||
return a(fArr, 0, i2);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new RuntimeException("error in parsing \"" + str + "\"", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static class PathDataNode {
|
||||
public char a;
|
||||
public float[] b;
|
||||
|
||||
PathDataNode(char c, float[] fArr) {
|
||||
this.a = c;
|
||||
this.b = fArr;
|
||||
}
|
||||
|
||||
public static void a(PathDataNode[] pathDataNodeArr, Path path) {
|
||||
float[] fArr = new float[6];
|
||||
char c = 'm';
|
||||
for (int i = 0; i < pathDataNodeArr.length; i++) {
|
||||
a(path, fArr, c, pathDataNodeArr[i].a, pathDataNodeArr[i].b);
|
||||
c = pathDataNodeArr[i].a;
|
||||
}
|
||||
}
|
||||
|
||||
PathDataNode(PathDataNode pathDataNode) {
|
||||
this.a = pathDataNode.a;
|
||||
float[] fArr = pathDataNode.b;
|
||||
this.b = PathParser.a(fArr, 0, fArr.length);
|
||||
}
|
||||
|
||||
public void a(PathDataNode pathDataNode, PathDataNode pathDataNode2, float f) {
|
||||
int i = 0;
|
||||
while (true) {
|
||||
float[] fArr = pathDataNode.b;
|
||||
if (i >= fArr.length) {
|
||||
return;
|
||||
}
|
||||
this.b[i] = (fArr[i] * (1.0f - f)) + (pathDataNode2.b[i] * f);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
|
||||
private static void a(Path path, float[] fArr, char c, char c2, float[] fArr2) {
|
||||
int i;
|
||||
int i2;
|
||||
float f;
|
||||
float f2;
|
||||
float f3;
|
||||
float f4;
|
||||
float f5;
|
||||
float f6;
|
||||
float f7;
|
||||
float f8;
|
||||
char c3 = c2;
|
||||
float f9 = fArr[0];
|
||||
float f10 = fArr[1];
|
||||
float f11 = fArr[2];
|
||||
float f12 = fArr[3];
|
||||
float f13 = fArr[4];
|
||||
float f14 = fArr[5];
|
||||
switch (c3) {
|
||||
case 'A':
|
||||
case 'a':
|
||||
i = 7;
|
||||
break;
|
||||
case 'C':
|
||||
case 'c':
|
||||
i = 6;
|
||||
break;
|
||||
case 'H':
|
||||
case 'V':
|
||||
case 'h':
|
||||
case 'v':
|
||||
i = 1;
|
||||
break;
|
||||
case 'L':
|
||||
case 'M':
|
||||
case 'T':
|
||||
case 'l':
|
||||
case 'm':
|
||||
case 't':
|
||||
default:
|
||||
i = 2;
|
||||
break;
|
||||
case 'Q':
|
||||
case 'S':
|
||||
case 'q':
|
||||
case 's':
|
||||
i = 4;
|
||||
break;
|
||||
case 'Z':
|
||||
case 'z':
|
||||
path.close();
|
||||
path.moveTo(f13, f14);
|
||||
f9 = f13;
|
||||
f11 = f9;
|
||||
f10 = f14;
|
||||
f12 = f10;
|
||||
i = 2;
|
||||
break;
|
||||
}
|
||||
float f15 = f9;
|
||||
float f16 = f10;
|
||||
float f17 = f13;
|
||||
float f18 = f14;
|
||||
int i3 = 0;
|
||||
char c4 = c;
|
||||
while (i3 < fArr2.length) {
|
||||
if (c3 != 'A') {
|
||||
if (c3 == 'C') {
|
||||
i2 = i3;
|
||||
int i4 = i2 + 2;
|
||||
int i5 = i2 + 3;
|
||||
int i6 = i2 + 4;
|
||||
int i7 = i2 + 5;
|
||||
path.cubicTo(fArr2[i2 + 0], fArr2[i2 + 1], fArr2[i4], fArr2[i5], fArr2[i6], fArr2[i7]);
|
||||
f15 = fArr2[i6];
|
||||
float f19 = fArr2[i7];
|
||||
float f20 = fArr2[i4];
|
||||
float f21 = fArr2[i5];
|
||||
f16 = f19;
|
||||
f12 = f21;
|
||||
f11 = f20;
|
||||
} else if (c3 == 'H') {
|
||||
i2 = i3;
|
||||
int i8 = i2 + 0;
|
||||
path.lineTo(fArr2[i8], f16);
|
||||
f15 = fArr2[i8];
|
||||
} else if (c3 == 'Q') {
|
||||
i2 = i3;
|
||||
int i9 = i2 + 0;
|
||||
int i10 = i2 + 1;
|
||||
int i11 = i2 + 2;
|
||||
int i12 = i2 + 3;
|
||||
path.quadTo(fArr2[i9], fArr2[i10], fArr2[i11], fArr2[i12]);
|
||||
float f22 = fArr2[i9];
|
||||
float f23 = fArr2[i10];
|
||||
f15 = fArr2[i11];
|
||||
f16 = fArr2[i12];
|
||||
f11 = f22;
|
||||
f12 = f23;
|
||||
} else if (c3 == 'V') {
|
||||
i2 = i3;
|
||||
int i13 = i2 + 0;
|
||||
path.lineTo(f15, fArr2[i13]);
|
||||
f16 = fArr2[i13];
|
||||
} else if (c3 != 'a') {
|
||||
if (c3 != 'c') {
|
||||
if (c3 == 'h') {
|
||||
int i14 = i3 + 0;
|
||||
path.rLineTo(fArr2[i14], 0.0f);
|
||||
f15 += fArr2[i14];
|
||||
} else if (c3 != 'q') {
|
||||
if (c3 == 'v') {
|
||||
int i15 = i3 + 0;
|
||||
path.rLineTo(0.0f, fArr2[i15]);
|
||||
f4 = fArr2[i15];
|
||||
} else if (c3 == 'L') {
|
||||
int i16 = i3 + 0;
|
||||
int i17 = i3 + 1;
|
||||
path.lineTo(fArr2[i16], fArr2[i17]);
|
||||
f15 = fArr2[i16];
|
||||
f16 = fArr2[i17];
|
||||
} else if (c3 == 'M') {
|
||||
int i18 = i3 + 0;
|
||||
f15 = fArr2[i18];
|
||||
int i19 = i3 + 1;
|
||||
f16 = fArr2[i19];
|
||||
if (i3 > 0) {
|
||||
path.lineTo(fArr2[i18], fArr2[i19]);
|
||||
} else {
|
||||
path.moveTo(fArr2[i18], fArr2[i19]);
|
||||
f18 = f16;
|
||||
f17 = f15;
|
||||
}
|
||||
} else if (c3 == 'S') {
|
||||
if (c4 == 'c' || c4 == 's' || c4 == 'C' || c4 == 'S') {
|
||||
f15 = (f15 * 2.0f) - f11;
|
||||
f16 = (f16 * 2.0f) - f12;
|
||||
}
|
||||
float f24 = f16;
|
||||
int i20 = i3 + 0;
|
||||
int i21 = i3 + 1;
|
||||
int i22 = i3 + 2;
|
||||
int i23 = i3 + 3;
|
||||
path.cubicTo(f15, f24, fArr2[i20], fArr2[i21], fArr2[i22], fArr2[i23]);
|
||||
f = fArr2[i20];
|
||||
f2 = fArr2[i21];
|
||||
f15 = fArr2[i22];
|
||||
f16 = fArr2[i23];
|
||||
f11 = f;
|
||||
f12 = f2;
|
||||
} else if (c3 == 'T') {
|
||||
if (c4 == 'q' || c4 == 't' || c4 == 'Q' || c4 == 'T') {
|
||||
f15 = (f15 * 2.0f) - f11;
|
||||
f16 = (f16 * 2.0f) - f12;
|
||||
}
|
||||
int i24 = i3 + 0;
|
||||
int i25 = i3 + 1;
|
||||
path.quadTo(f15, f16, fArr2[i24], fArr2[i25]);
|
||||
float f25 = fArr2[i24];
|
||||
float f26 = fArr2[i25];
|
||||
f12 = f16;
|
||||
f11 = f15;
|
||||
i2 = i3;
|
||||
f15 = f25;
|
||||
f16 = f26;
|
||||
} else if (c3 == 'l') {
|
||||
int i26 = i3 + 0;
|
||||
int i27 = i3 + 1;
|
||||
path.rLineTo(fArr2[i26], fArr2[i27]);
|
||||
f15 += fArr2[i26];
|
||||
f4 = fArr2[i27];
|
||||
} else if (c3 == 'm') {
|
||||
int i28 = i3 + 0;
|
||||
f15 += fArr2[i28];
|
||||
int i29 = i3 + 1;
|
||||
f16 += fArr2[i29];
|
||||
if (i3 > 0) {
|
||||
path.rLineTo(fArr2[i28], fArr2[i29]);
|
||||
} else {
|
||||
path.rMoveTo(fArr2[i28], fArr2[i29]);
|
||||
f18 = f16;
|
||||
f17 = f15;
|
||||
}
|
||||
} else if (c3 == 's') {
|
||||
if (c4 == 'c' || c4 == 's' || c4 == 'C' || c4 == 'S') {
|
||||
float f27 = f15 - f11;
|
||||
f5 = f16 - f12;
|
||||
f6 = f27;
|
||||
} else {
|
||||
f6 = 0.0f;
|
||||
f5 = 0.0f;
|
||||
}
|
||||
int i30 = i3 + 0;
|
||||
int i31 = i3 + 1;
|
||||
int i32 = i3 + 2;
|
||||
int i33 = i3 + 3;
|
||||
path.rCubicTo(f6, f5, fArr2[i30], fArr2[i31], fArr2[i32], fArr2[i33]);
|
||||
f = fArr2[i30] + f15;
|
||||
f2 = fArr2[i31] + f16;
|
||||
f15 += fArr2[i32];
|
||||
f3 = fArr2[i33];
|
||||
} else if (c3 == 't') {
|
||||
if (c4 == 'q' || c4 == 't' || c4 == 'Q' || c4 == 'T') {
|
||||
f7 = f15 - f11;
|
||||
f8 = f16 - f12;
|
||||
} else {
|
||||
f8 = 0.0f;
|
||||
f7 = 0.0f;
|
||||
}
|
||||
int i34 = i3 + 0;
|
||||
int i35 = i3 + 1;
|
||||
path.rQuadTo(f7, f8, fArr2[i34], fArr2[i35]);
|
||||
float f28 = f7 + f15;
|
||||
float f29 = f8 + f16;
|
||||
f15 += fArr2[i34];
|
||||
f16 += fArr2[i35];
|
||||
f12 = f29;
|
||||
f11 = f28;
|
||||
}
|
||||
f16 += f4;
|
||||
} else {
|
||||
int i36 = i3 + 0;
|
||||
int i37 = i3 + 1;
|
||||
int i38 = i3 + 2;
|
||||
int i39 = i3 + 3;
|
||||
path.rQuadTo(fArr2[i36], fArr2[i37], fArr2[i38], fArr2[i39]);
|
||||
f = fArr2[i36] + f15;
|
||||
f2 = fArr2[i37] + f16;
|
||||
f15 += fArr2[i38];
|
||||
f3 = fArr2[i39];
|
||||
}
|
||||
i2 = i3;
|
||||
} else {
|
||||
int i40 = i3 + 2;
|
||||
int i41 = i3 + 3;
|
||||
int i42 = i3 + 4;
|
||||
int i43 = i3 + 5;
|
||||
path.rCubicTo(fArr2[i3 + 0], fArr2[i3 + 1], fArr2[i40], fArr2[i41], fArr2[i42], fArr2[i43]);
|
||||
f = fArr2[i40] + f15;
|
||||
f2 = fArr2[i41] + f16;
|
||||
f15 += fArr2[i42];
|
||||
f3 = fArr2[i43];
|
||||
}
|
||||
f16 += f3;
|
||||
f11 = f;
|
||||
f12 = f2;
|
||||
i2 = i3;
|
||||
} else {
|
||||
int i44 = i3 + 5;
|
||||
float f30 = fArr2[i44] + f15;
|
||||
int i45 = i3 + 6;
|
||||
float f31 = fArr2[i45] + f16;
|
||||
float f32 = fArr2[i3 + 0];
|
||||
float f33 = fArr2[i3 + 1];
|
||||
float f34 = fArr2[i3 + 2];
|
||||
float f35 = f15;
|
||||
boolean z = fArr2[i3 + 3] != 0.0f;
|
||||
i2 = i3;
|
||||
a(path, f15, f16, f30, f31, f32, f33, f34, z, fArr2[i3 + 4] != 0.0f);
|
||||
f15 = f35 + fArr2[i44];
|
||||
f16 += fArr2[i45];
|
||||
}
|
||||
i3 = i2 + i;
|
||||
c4 = c2;
|
||||
c3 = c4;
|
||||
} else {
|
||||
i2 = i3;
|
||||
int i46 = i2 + 5;
|
||||
int i47 = i2 + 6;
|
||||
a(path, f15, f16, fArr2[i46], fArr2[i47], fArr2[i2 + 0], fArr2[i2 + 1], fArr2[i2 + 2], fArr2[i2 + 3] != 0.0f, fArr2[i2 + 4] != 0.0f);
|
||||
f15 = fArr2[i46];
|
||||
f16 = fArr2[i47];
|
||||
}
|
||||
f12 = f16;
|
||||
f11 = f15;
|
||||
i3 = i2 + i;
|
||||
c4 = c2;
|
||||
c3 = c4;
|
||||
}
|
||||
fArr[0] = f15;
|
||||
fArr[1] = f16;
|
||||
fArr[2] = f11;
|
||||
fArr[3] = f12;
|
||||
fArr[4] = f17;
|
||||
fArr[5] = f18;
|
||||
}
|
||||
|
||||
private static void a(Path path, float f, float f2, float f3, float f4, float f5, float f6, float f7, boolean z, boolean z2) {
|
||||
double d;
|
||||
double d2;
|
||||
double radians = Math.toRadians(f7);
|
||||
double cos = Math.cos(radians);
|
||||
double sin = Math.sin(radians);
|
||||
double d3 = f;
|
||||
double d4 = d3 * cos;
|
||||
double d5 = f2;
|
||||
double d6 = f5;
|
||||
double d7 = (d4 + (d5 * sin)) / d6;
|
||||
double d8 = ((-f) * sin) + (d5 * cos);
|
||||
double d9 = f6;
|
||||
double d10 = d8 / d9;
|
||||
double d11 = f4;
|
||||
double d12 = ((f3 * cos) + (d11 * sin)) / d6;
|
||||
double d13 = (((-f3) * sin) + (d11 * cos)) / d9;
|
||||
double d14 = d7 - d12;
|
||||
double d15 = d10 - d13;
|
||||
double d16 = (d7 + d12) / 2.0d;
|
||||
double d17 = (d10 + d13) / 2.0d;
|
||||
double d18 = (d14 * d14) + (d15 * d15);
|
||||
if (d18 == 0.0d) {
|
||||
Log.w("PathParser", " Points are coincident");
|
||||
return;
|
||||
}
|
||||
double d19 = (1.0d / d18) - 0.25d;
|
||||
if (d19 < 0.0d) {
|
||||
Log.w("PathParser", "Points are too far apart " + d18);
|
||||
float sqrt = (float) (Math.sqrt(d18) / 1.99999d);
|
||||
a(path, f, f2, f3, f4, f5 * sqrt, f6 * sqrt, f7, z, z2);
|
||||
return;
|
||||
}
|
||||
double sqrt2 = Math.sqrt(d19);
|
||||
double d20 = d14 * sqrt2;
|
||||
double d21 = sqrt2 * d15;
|
||||
if (z == z2) {
|
||||
d = d16 - d21;
|
||||
d2 = d17 + d20;
|
||||
} else {
|
||||
d = d16 + d21;
|
||||
d2 = d17 - d20;
|
||||
}
|
||||
double atan2 = Math.atan2(d10 - d2, d7 - d);
|
||||
double atan22 = Math.atan2(d13 - d2, d12 - d) - atan2;
|
||||
if (z2 != (atan22 >= 0.0d)) {
|
||||
atan22 = atan22 > 0.0d ? atan22 - 6.283185307179586d : atan22 + 6.283185307179586d;
|
||||
}
|
||||
double d22 = d * d6;
|
||||
double d23 = d2 * d9;
|
||||
a(path, (d22 * cos) - (d23 * sin), (d22 * sin) + (d23 * cos), d6, d9, d3, d5, radians, atan2, atan22);
|
||||
}
|
||||
|
||||
private static void a(Path path, double d, double d2, double d3, double d4, double d5, double d6, double d7, double d8, double d9) {
|
||||
double d10 = d3;
|
||||
int ceil = (int) Math.ceil(Math.abs((d9 * 4.0d) / 3.141592653589793d));
|
||||
double cos = Math.cos(d7);
|
||||
double sin = Math.sin(d7);
|
||||
double cos2 = Math.cos(d8);
|
||||
double sin2 = Math.sin(d8);
|
||||
double d11 = -d10;
|
||||
double d12 = d11 * cos;
|
||||
double d13 = d4 * sin;
|
||||
double d14 = (d12 * sin2) - (d13 * cos2);
|
||||
double d15 = d11 * sin;
|
||||
double d16 = d4 * cos;
|
||||
double d17 = (sin2 * d15) + (cos2 * d16);
|
||||
double d18 = d9 / ceil;
|
||||
double d19 = d5;
|
||||
double d20 = d6;
|
||||
double d21 = d17;
|
||||
double d22 = d14;
|
||||
int i = 0;
|
||||
double d23 = d8;
|
||||
while (i < ceil) {
|
||||
double d24 = d23 + d18;
|
||||
double sin3 = Math.sin(d24);
|
||||
double cos3 = Math.cos(d24);
|
||||
double d25 = (d + ((d10 * cos) * cos3)) - (d13 * sin3);
|
||||
double d26 = d2 + (d10 * sin * cos3) + (d16 * sin3);
|
||||
double d27 = (d12 * sin3) - (d13 * cos3);
|
||||
double d28 = (sin3 * d15) + (cos3 * d16);
|
||||
double d29 = d24 - d23;
|
||||
double tan = Math.tan(d29 / 2.0d);
|
||||
double sin4 = (Math.sin(d29) * (Math.sqrt(((tan * 3.0d) * tan) + 4.0d) - 1.0d)) / 3.0d;
|
||||
path.rLineTo(0.0f, 0.0f);
|
||||
path.cubicTo((float) (d19 + (d22 * sin4)), (float) (d20 + (d21 * sin4)), (float) (d25 - (sin4 * d27)), (float) (d26 - (sin4 * d28)), (float) d25, (float) d26);
|
||||
i++;
|
||||
d18 = d18;
|
||||
ceil = ceil;
|
||||
sin = sin;
|
||||
d20 = d26;
|
||||
d15 = d15;
|
||||
d23 = d24;
|
||||
d21 = d28;
|
||||
d22 = d27;
|
||||
cos = cos;
|
||||
d10 = d3;
|
||||
d19 = d25;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void b(PathDataNode[] pathDataNodeArr, PathDataNode[] pathDataNodeArr2) {
|
||||
for (int i = 0; i < pathDataNodeArr2.length; i++) {
|
||||
pathDataNodeArr[i].a = pathDataNodeArr2[i].a;
|
||||
for (int i2 = 0; i2 < pathDataNodeArr2[i].b.length; i2++) {
|
||||
pathDataNodeArr[i].b[i2] = pathDataNodeArr2[i].b[i2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static PathDataNode[] a(String str) {
|
||||
if (str == null) {
|
||||
return null;
|
||||
}
|
||||
ArrayList arrayList = new ArrayList();
|
||||
int i = 1;
|
||||
int i2 = 0;
|
||||
while (i < str.length()) {
|
||||
int a = a(str, i);
|
||||
String trim = str.substring(i2, a).trim();
|
||||
if (trim.length() > 0) {
|
||||
a((ArrayList<PathDataNode>) arrayList, trim.charAt(0), c(trim));
|
||||
}
|
||||
i2 = a;
|
||||
i = a + 1;
|
||||
}
|
||||
if (i - i2 == 1 && i2 < str.length()) {
|
||||
a((ArrayList<PathDataNode>) arrayList, str.charAt(i2), new float[0]);
|
||||
}
|
||||
return (PathDataNode[]) arrayList.toArray(new PathDataNode[arrayList.size()]);
|
||||
}
|
||||
|
||||
public static PathDataNode[] a(PathDataNode[] pathDataNodeArr) {
|
||||
if (pathDataNodeArr == null) {
|
||||
return null;
|
||||
}
|
||||
PathDataNode[] pathDataNodeArr2 = new PathDataNode[pathDataNodeArr.length];
|
||||
for (int i = 0; i < pathDataNodeArr.length; i++) {
|
||||
pathDataNodeArr2[i] = new PathDataNode(pathDataNodeArr[i]);
|
||||
}
|
||||
return pathDataNodeArr2;
|
||||
}
|
||||
|
||||
public static boolean a(PathDataNode[] pathDataNodeArr, PathDataNode[] pathDataNodeArr2) {
|
||||
if (pathDataNodeArr == null || pathDataNodeArr2 == null || pathDataNodeArr.length != pathDataNodeArr2.length) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < pathDataNodeArr.length; i++) {
|
||||
if (pathDataNodeArr[i].a != pathDataNodeArr2[i].a || pathDataNodeArr[i].b.length != pathDataNodeArr2[i].b.length) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static int a(String str, int i) {
|
||||
while (i < str.length()) {
|
||||
char charAt = str.charAt(i);
|
||||
if (((charAt - 'A') * (charAt - 'Z') <= 0 || (charAt - 'a') * (charAt - 'z') <= 0) && charAt != 'e' && charAt != 'E') {
|
||||
return i;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
private static void a(ArrayList<PathDataNode> arrayList, char c, float[] fArr) {
|
||||
arrayList.add(new PathDataNode(c, fArr));
|
||||
}
|
||||
|
||||
/* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
|
||||
/* JADX WARN: Removed duplicated region for block: B:14:0x003a A[LOOP:0: B:2:0x0007->B:14:0x003a, LOOP_END] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:15:0x003d A[SYNTHETIC] */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
private static void a(java.lang.String r8, int r9, androidx.core.graphics.PathParser.ExtractFloatResult r10) {
|
||||
/*
|
||||
r0 = 0
|
||||
r10.b = r0
|
||||
r1 = r9
|
||||
r2 = 0
|
||||
r3 = 0
|
||||
r4 = 0
|
||||
L7:
|
||||
int r5 = r8.length()
|
||||
if (r1 >= r5) goto L3d
|
||||
char r5 = r8.charAt(r1)
|
||||
r6 = 32
|
||||
r7 = 1
|
||||
if (r5 == r6) goto L35
|
||||
r6 = 69
|
||||
if (r5 == r6) goto L33
|
||||
r6 = 101(0x65, float:1.42E-43)
|
||||
if (r5 == r6) goto L33
|
||||
switch(r5) {
|
||||
case 44: goto L35;
|
||||
case 45: goto L2a;
|
||||
case 46: goto L22;
|
||||
default: goto L21;
|
||||
}
|
||||
L21:
|
||||
goto L31
|
||||
L22:
|
||||
if (r3 != 0) goto L27
|
||||
r2 = 0
|
||||
r3 = 1
|
||||
goto L37
|
||||
L27:
|
||||
r10.b = r7
|
||||
goto L35
|
||||
L2a:
|
||||
if (r1 == r9) goto L31
|
||||
if (r2 != 0) goto L31
|
||||
r10.b = r7
|
||||
goto L35
|
||||
L31:
|
||||
r2 = 0
|
||||
goto L37
|
||||
L33:
|
||||
r2 = 1
|
||||
goto L37
|
||||
L35:
|
||||
r2 = 0
|
||||
r4 = 1
|
||||
L37:
|
||||
if (r4 == 0) goto L3a
|
||||
goto L3d
|
||||
L3a:
|
||||
int r1 = r1 + 1
|
||||
goto L7
|
||||
L3d:
|
||||
r10.a = r1
|
||||
return
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: androidx.core.graphics.PathParser.a(java.lang.String, int, androidx.core.graphics.PathParser$ExtractFloatResult):void");
|
||||
}
|
||||
}
|
79
sources/androidx/core/graphics/TypefaceCompat.java
Normal file
79
sources/androidx/core/graphics/TypefaceCompat.java
Normal file
@@ -0,0 +1,79 @@
|
||||
package androidx.core.graphics;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Build;
|
||||
import android.os.CancellationSignal;
|
||||
import android.os.Handler;
|
||||
import androidx.collection.LruCache;
|
||||
import androidx.core.content.res.FontResourcesParserCompat;
|
||||
import androidx.core.content.res.ResourcesCompat;
|
||||
import androidx.core.provider.FontsContractCompat;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class TypefaceCompat {
|
||||
private static final TypefaceCompatBaseImpl a;
|
||||
private static final LruCache<String, Typeface> b;
|
||||
|
||||
static {
|
||||
int i = Build.VERSION.SDK_INT;
|
||||
if (i >= 28) {
|
||||
a = new TypefaceCompatApi28Impl();
|
||||
} else if (i >= 26) {
|
||||
a = new TypefaceCompatApi26Impl();
|
||||
} else if (i >= 24 && TypefaceCompatApi24Impl.a()) {
|
||||
a = new TypefaceCompatApi24Impl();
|
||||
} else if (Build.VERSION.SDK_INT >= 21) {
|
||||
a = new TypefaceCompatApi21Impl();
|
||||
} else {
|
||||
a = new TypefaceCompatBaseImpl();
|
||||
}
|
||||
b = new LruCache<>(16);
|
||||
}
|
||||
|
||||
private static String a(Resources resources, int i, int i2) {
|
||||
return resources.getResourcePackageName(i) + "-" + i + "-" + i2;
|
||||
}
|
||||
|
||||
public static Typeface b(Resources resources, int i, int i2) {
|
||||
return b.b(a(resources, i, i2));
|
||||
}
|
||||
|
||||
public static Typeface a(Context context, FontResourcesParserCompat.FamilyResourceEntry familyResourceEntry, Resources resources, int i, int i2, ResourcesCompat.FontCallback fontCallback, Handler handler, boolean z) {
|
||||
Typeface a2;
|
||||
if (familyResourceEntry instanceof FontResourcesParserCompat.ProviderResourceEntry) {
|
||||
FontResourcesParserCompat.ProviderResourceEntry providerResourceEntry = (FontResourcesParserCompat.ProviderResourceEntry) familyResourceEntry;
|
||||
boolean z2 = false;
|
||||
if (!z ? fontCallback == null : providerResourceEntry.a() == 0) {
|
||||
z2 = true;
|
||||
}
|
||||
a2 = FontsContractCompat.a(context, providerResourceEntry.b(), fontCallback, handler, z2, z ? providerResourceEntry.c() : -1, i2);
|
||||
} else {
|
||||
a2 = a.a(context, (FontResourcesParserCompat.FontFamilyFilesResourceEntry) familyResourceEntry, resources, i2);
|
||||
if (fontCallback != null) {
|
||||
if (a2 != null) {
|
||||
fontCallback.a(a2, handler);
|
||||
} else {
|
||||
fontCallback.a(-3, handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (a2 != null) {
|
||||
b.a(a(resources, i, i2), a2);
|
||||
}
|
||||
return a2;
|
||||
}
|
||||
|
||||
public static Typeface a(Context context, Resources resources, int i, String str, int i2) {
|
||||
Typeface a2 = a.a(context, resources, i, str, i2);
|
||||
if (a2 != null) {
|
||||
b.a(a(resources, i, i2), a2);
|
||||
}
|
||||
return a2;
|
||||
}
|
||||
|
||||
public static Typeface a(Context context, CancellationSignal cancellationSignal, FontsContractCompat.FontInfo[] fontInfoArr, int i) {
|
||||
return a.a(context, cancellationSignal, fontInfoArr, i);
|
||||
}
|
||||
}
|
64
sources/androidx/core/graphics/TypefaceCompatApi21Impl.java
Normal file
64
sources/androidx/core/graphics/TypefaceCompatApi21Impl.java
Normal file
@@ -0,0 +1,64 @@
|
||||
package androidx.core.graphics;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.CancellationSignal;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.system.ErrnoException;
|
||||
import android.system.Os;
|
||||
import android.system.OsConstants;
|
||||
import androidx.core.provider.FontsContractCompat;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class TypefaceCompatApi21Impl extends TypefaceCompatBaseImpl {
|
||||
TypefaceCompatApi21Impl() {
|
||||
}
|
||||
|
||||
private File a(ParcelFileDescriptor parcelFileDescriptor) {
|
||||
try {
|
||||
String readlink = Os.readlink("/proc/self/fd/" + parcelFileDescriptor.getFd());
|
||||
if (OsConstants.S_ISREG(Os.stat(readlink).st_mode)) {
|
||||
return new File(readlink);
|
||||
}
|
||||
} catch (ErrnoException unused) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // androidx.core.graphics.TypefaceCompatBaseImpl
|
||||
public Typeface a(Context context, CancellationSignal cancellationSignal, FontsContractCompat.FontInfo[] fontInfoArr, int i) {
|
||||
if (fontInfoArr.length < 1) {
|
||||
return null;
|
||||
}
|
||||
FontsContractCompat.FontInfo a = a(fontInfoArr, i);
|
||||
try {
|
||||
ParcelFileDescriptor openFileDescriptor = context.getContentResolver().openFileDescriptor(a.c(), "r", cancellationSignal);
|
||||
try {
|
||||
File a2 = a(openFileDescriptor);
|
||||
if (a2 != null && a2.canRead()) {
|
||||
Typeface createFromFile = Typeface.createFromFile(a2);
|
||||
if (openFileDescriptor != null) {
|
||||
openFileDescriptor.close();
|
||||
}
|
||||
return createFromFile;
|
||||
}
|
||||
FileInputStream fileInputStream = new FileInputStream(openFileDescriptor.getFileDescriptor());
|
||||
try {
|
||||
Typeface a3 = super.a(context, fileInputStream);
|
||||
fileInputStream.close();
|
||||
if (openFileDescriptor != null) {
|
||||
openFileDescriptor.close();
|
||||
}
|
||||
return a3;
|
||||
} finally {
|
||||
}
|
||||
} finally {
|
||||
}
|
||||
} catch (IOException unused) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
114
sources/androidx/core/graphics/TypefaceCompatApi24Impl.java
Normal file
114
sources/androidx/core/graphics/TypefaceCompatApi24Impl.java
Normal file
@@ -0,0 +1,114 @@
|
||||
package androidx.core.graphics;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Typeface;
|
||||
import android.net.Uri;
|
||||
import android.os.CancellationSignal;
|
||||
import android.util.Log;
|
||||
import androidx.collection.SimpleArrayMap;
|
||||
import androidx.core.content.res.FontResourcesParserCompat;
|
||||
import androidx.core.provider.FontsContractCompat;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class TypefaceCompatApi24Impl extends TypefaceCompatBaseImpl {
|
||||
private static final Class a;
|
||||
private static final Constructor b;
|
||||
private static final Method c;
|
||||
private static final Method d;
|
||||
|
||||
static {
|
||||
Class<?> cls;
|
||||
Method method;
|
||||
Method method2;
|
||||
Constructor<?> constructor = null;
|
||||
try {
|
||||
cls = Class.forName("android.graphics.FontFamily");
|
||||
Constructor<?> constructor2 = cls.getConstructor(new Class[0]);
|
||||
method2 = cls.getMethod("addFontWeightStyle", ByteBuffer.class, Integer.TYPE, List.class, Integer.TYPE, Boolean.TYPE);
|
||||
method = Typeface.class.getMethod("createFromFamiliesWithDefault", Array.newInstance(cls, 1).getClass());
|
||||
constructor = constructor2;
|
||||
} catch (ClassNotFoundException | NoSuchMethodException e) {
|
||||
Log.e("TypefaceCompatApi24Impl", e.getClass().getName(), e);
|
||||
cls = null;
|
||||
method = null;
|
||||
method2 = null;
|
||||
}
|
||||
b = constructor;
|
||||
a = cls;
|
||||
c = method2;
|
||||
d = method;
|
||||
}
|
||||
|
||||
TypefaceCompatApi24Impl() {
|
||||
}
|
||||
|
||||
public static boolean a() {
|
||||
if (c == null) {
|
||||
Log.w("TypefaceCompatApi24Impl", "Unable to collect necessary private methods.Fallback to legacy implementation.");
|
||||
}
|
||||
return c != null;
|
||||
}
|
||||
|
||||
private static Object b() {
|
||||
try {
|
||||
return b.newInstance(new Object[0]);
|
||||
} catch (IllegalAccessException | InstantiationException | InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean a(Object obj, ByteBuffer byteBuffer, int i, int i2, boolean z) {
|
||||
try {
|
||||
return ((Boolean) c.invoke(obj, byteBuffer, Integer.valueOf(i), null, Integer.valueOf(i2), Boolean.valueOf(z))).booleanValue();
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static Typeface a(Object obj) {
|
||||
try {
|
||||
Object newInstance = Array.newInstance((Class<?>) a, 1);
|
||||
Array.set(newInstance, 0, obj);
|
||||
return (Typeface) d.invoke(null, newInstance);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.core.graphics.TypefaceCompatBaseImpl
|
||||
public Typeface a(Context context, CancellationSignal cancellationSignal, FontsContractCompat.FontInfo[] fontInfoArr, int i) {
|
||||
Object b2 = b();
|
||||
SimpleArrayMap simpleArrayMap = new SimpleArrayMap();
|
||||
for (FontsContractCompat.FontInfo fontInfo : fontInfoArr) {
|
||||
Uri c2 = fontInfo.c();
|
||||
ByteBuffer byteBuffer = (ByteBuffer) simpleArrayMap.get(c2);
|
||||
if (byteBuffer == null) {
|
||||
byteBuffer = TypefaceCompatUtil.a(context, cancellationSignal, c2);
|
||||
simpleArrayMap.put(c2, byteBuffer);
|
||||
}
|
||||
if (!a(b2, byteBuffer, fontInfo.b(), fontInfo.d(), fontInfo.e())) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return Typeface.create(a(b2), i);
|
||||
}
|
||||
|
||||
@Override // androidx.core.graphics.TypefaceCompatBaseImpl
|
||||
public Typeface a(Context context, FontResourcesParserCompat.FontFamilyFilesResourceEntry fontFamilyFilesResourceEntry, Resources resources, int i) {
|
||||
Object b2 = b();
|
||||
for (FontResourcesParserCompat.FontFileResourceEntry fontFileResourceEntry : fontFamilyFilesResourceEntry.a()) {
|
||||
ByteBuffer a2 = TypefaceCompatUtil.a(context, resources, fontFileResourceEntry.b());
|
||||
if (a2 == null || !a(b2, a2, fontFileResourceEntry.c(), fontFileResourceEntry.e(), fontFileResourceEntry.f())) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return a(b2);
|
||||
}
|
||||
}
|
241
sources/androidx/core/graphics/TypefaceCompatApi26Impl.java
Normal file
241
sources/androidx/core/graphics/TypefaceCompatApi26Impl.java
Normal file
@@ -0,0 +1,241 @@
|
||||
package androidx.core.graphics;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.AssetManager;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.fonts.FontVariationAxis;
|
||||
import android.net.Uri;
|
||||
import android.os.CancellationSignal;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.util.Log;
|
||||
import androidx.core.content.res.FontResourcesParserCompat;
|
||||
import androidx.core.provider.FontsContractCompat;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class TypefaceCompatApi26Impl extends TypefaceCompatApi21Impl {
|
||||
protected final Class a;
|
||||
protected final Constructor b;
|
||||
protected final Method c;
|
||||
protected final Method d;
|
||||
protected final Method e;
|
||||
protected final Method f;
|
||||
protected final Method g;
|
||||
|
||||
public TypefaceCompatApi26Impl() {
|
||||
Method method;
|
||||
Constructor constructor;
|
||||
Method method2;
|
||||
Method method3;
|
||||
Method method4;
|
||||
Method method5;
|
||||
Class cls = null;
|
||||
try {
|
||||
Class a = a();
|
||||
constructor = e(a);
|
||||
method2 = b(a);
|
||||
method3 = c(a);
|
||||
method4 = f(a);
|
||||
method5 = a(a);
|
||||
method = d(a);
|
||||
cls = a;
|
||||
} catch (ClassNotFoundException | NoSuchMethodException e) {
|
||||
Log.e("TypefaceCompatApi26Impl", "Unable to collect necessary methods for class " + e.getClass().getName(), e);
|
||||
method = null;
|
||||
constructor = null;
|
||||
method2 = null;
|
||||
method3 = null;
|
||||
method4 = null;
|
||||
method5 = null;
|
||||
}
|
||||
this.a = cls;
|
||||
this.b = constructor;
|
||||
this.c = method2;
|
||||
this.d = method3;
|
||||
this.e = method4;
|
||||
this.f = method5;
|
||||
this.g = method;
|
||||
}
|
||||
|
||||
private boolean a(Context context, Object obj, String str, int i, int i2, int i3, FontVariationAxis[] fontVariationAxisArr) {
|
||||
try {
|
||||
return ((Boolean) this.c.invoke(obj, context.getAssets(), str, 0, false, Integer.valueOf(i), Integer.valueOf(i2), Integer.valueOf(i3), fontVariationAxisArr)).booleanValue();
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean b() {
|
||||
if (this.c == null) {
|
||||
Log.w("TypefaceCompatApi26Impl", "Unable to collect necessary private methods. Fallback to legacy implementation.");
|
||||
}
|
||||
return this.c != null;
|
||||
}
|
||||
|
||||
private Object c() {
|
||||
try {
|
||||
return this.b.newInstance(new Object[0]);
|
||||
} catch (IllegalAccessException | InstantiationException | InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected Method d(Class cls) throws NoSuchMethodException {
|
||||
Class cls2 = Integer.TYPE;
|
||||
Method declaredMethod = Typeface.class.getDeclaredMethod("createFromFamiliesWithDefault", Array.newInstance((Class<?>) cls, 1).getClass(), cls2, cls2);
|
||||
declaredMethod.setAccessible(true);
|
||||
return declaredMethod;
|
||||
}
|
||||
|
||||
protected Constructor e(Class cls) throws NoSuchMethodException {
|
||||
return cls.getConstructor(new Class[0]);
|
||||
}
|
||||
|
||||
protected Method f(Class cls) throws NoSuchMethodException {
|
||||
return cls.getMethod("freeze", new Class[0]);
|
||||
}
|
||||
|
||||
private boolean c(Object obj) {
|
||||
try {
|
||||
return ((Boolean) this.e.invoke(obj, new Object[0])).booleanValue();
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void b(Object obj) {
|
||||
try {
|
||||
this.f.invoke(obj, new Object[0]);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected Method b(Class cls) throws NoSuchMethodException {
|
||||
Class<?> cls2 = Integer.TYPE;
|
||||
return cls.getMethod("addFontFromAssetManager", AssetManager.class, String.class, Integer.TYPE, Boolean.TYPE, cls2, cls2, cls2, FontVariationAxis[].class);
|
||||
}
|
||||
|
||||
protected Method c(Class cls) throws NoSuchMethodException {
|
||||
Class<?> cls2 = Integer.TYPE;
|
||||
return cls.getMethod("addFontFromBuffer", ByteBuffer.class, cls2, FontVariationAxis[].class, cls2, cls2);
|
||||
}
|
||||
|
||||
private boolean a(Object obj, ByteBuffer byteBuffer, int i, int i2, int i3) {
|
||||
try {
|
||||
return ((Boolean) this.d.invoke(obj, byteBuffer, Integer.valueOf(i), null, Integer.valueOf(i2), Integer.valueOf(i3))).booleanValue();
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected Typeface a(Object obj) {
|
||||
try {
|
||||
Object newInstance = Array.newInstance((Class<?>) this.a, 1);
|
||||
Array.set(newInstance, 0, obj);
|
||||
return (Typeface) this.g.invoke(null, newInstance, -1, -1);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.core.graphics.TypefaceCompatBaseImpl
|
||||
public Typeface a(Context context, FontResourcesParserCompat.FontFamilyFilesResourceEntry fontFamilyFilesResourceEntry, Resources resources, int i) {
|
||||
if (!b()) {
|
||||
return super.a(context, fontFamilyFilesResourceEntry, resources, i);
|
||||
}
|
||||
Object c = c();
|
||||
for (FontResourcesParserCompat.FontFileResourceEntry fontFileResourceEntry : fontFamilyFilesResourceEntry.a()) {
|
||||
if (!a(context, c, fontFileResourceEntry.a(), fontFileResourceEntry.c(), fontFileResourceEntry.e(), fontFileResourceEntry.f() ? 1 : 0, FontVariationAxis.fromFontVariationSettings(fontFileResourceEntry.d()))) {
|
||||
b(c);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (c(c)) {
|
||||
return a(c);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // androidx.core.graphics.TypefaceCompatApi21Impl, androidx.core.graphics.TypefaceCompatBaseImpl
|
||||
public Typeface a(Context context, CancellationSignal cancellationSignal, FontsContractCompat.FontInfo[] fontInfoArr, int i) {
|
||||
if (fontInfoArr.length < 1) {
|
||||
return null;
|
||||
}
|
||||
if (!b()) {
|
||||
FontsContractCompat.FontInfo a = a(fontInfoArr, i);
|
||||
try {
|
||||
ParcelFileDescriptor openFileDescriptor = context.getContentResolver().openFileDescriptor(a.c(), "r", cancellationSignal);
|
||||
if (openFileDescriptor == null) {
|
||||
if (openFileDescriptor != null) {
|
||||
openFileDescriptor.close();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
Typeface build = new Typeface.Builder(openFileDescriptor.getFileDescriptor()).setWeight(a.d()).setItalic(a.e()).build();
|
||||
if (openFileDescriptor != null) {
|
||||
openFileDescriptor.close();
|
||||
}
|
||||
return build;
|
||||
} finally {
|
||||
}
|
||||
} catch (IOException unused) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
Map<Uri, ByteBuffer> a2 = FontsContractCompat.a(context, fontInfoArr, cancellationSignal);
|
||||
Object c = c();
|
||||
boolean z = false;
|
||||
for (FontsContractCompat.FontInfo fontInfo : fontInfoArr) {
|
||||
ByteBuffer byteBuffer = a2.get(fontInfo.c());
|
||||
if (byteBuffer != null) {
|
||||
if (!a(c, byteBuffer, fontInfo.b(), fontInfo.d(), fontInfo.e() ? 1 : 0)) {
|
||||
b(c);
|
||||
return null;
|
||||
}
|
||||
z = true;
|
||||
}
|
||||
}
|
||||
if (!z) {
|
||||
b(c);
|
||||
return null;
|
||||
}
|
||||
if (c(c)) {
|
||||
return Typeface.create(a(c), i);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.core.graphics.TypefaceCompatBaseImpl
|
||||
public Typeface a(Context context, Resources resources, int i, String str, int i2) {
|
||||
if (!b()) {
|
||||
return super.a(context, resources, i, str, i2);
|
||||
}
|
||||
Object c = c();
|
||||
if (!a(context, c, str, 0, -1, -1, null)) {
|
||||
b(c);
|
||||
return null;
|
||||
}
|
||||
if (c(c)) {
|
||||
return a(c);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Class a() throws ClassNotFoundException {
|
||||
return Class.forName("android.graphics.FontFamily");
|
||||
}
|
||||
|
||||
protected Method a(Class cls) throws NoSuchMethodException {
|
||||
return cls.getMethod("abortCreation", new Class[0]);
|
||||
}
|
||||
}
|
28
sources/androidx/core/graphics/TypefaceCompatApi28Impl.java
Normal file
28
sources/androidx/core/graphics/TypefaceCompatApi28Impl.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package androidx.core.graphics;
|
||||
|
||||
import android.graphics.Typeface;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class TypefaceCompatApi28Impl extends TypefaceCompatApi26Impl {
|
||||
@Override // androidx.core.graphics.TypefaceCompatApi26Impl
|
||||
protected Typeface a(Object obj) {
|
||||
try {
|
||||
Object newInstance = Array.newInstance((Class<?>) this.a, 1);
|
||||
Array.set(newInstance, 0, obj);
|
||||
return (Typeface) this.g.invoke(null, newInstance, "sans-serif", -1, -1);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.core.graphics.TypefaceCompatApi26Impl
|
||||
protected Method d(Class cls) throws NoSuchMethodException {
|
||||
Class cls2 = Integer.TYPE;
|
||||
Method declaredMethod = Typeface.class.getDeclaredMethod("createFromFamiliesWithDefault", Array.newInstance((Class<?>) cls, 1).getClass(), String.class, cls2, cls2);
|
||||
declaredMethod.setAccessible(true);
|
||||
return declaredMethod;
|
||||
}
|
||||
}
|
138
sources/androidx/core/graphics/TypefaceCompatBaseImpl.java
Normal file
138
sources/androidx/core/graphics/TypefaceCompatBaseImpl.java
Normal file
@@ -0,0 +1,138 @@
|
||||
package androidx.core.graphics;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.CancellationSignal;
|
||||
import androidx.core.content.res.FontResourcesParserCompat;
|
||||
import androidx.core.provider.FontsContractCompat;
|
||||
import com.baidu.cloud.media.player.IMediaPlayer;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class TypefaceCompatBaseImpl {
|
||||
|
||||
private interface StyleExtractor<T> {
|
||||
int a(T t);
|
||||
|
||||
boolean b(T t);
|
||||
}
|
||||
|
||||
TypefaceCompatBaseImpl() {
|
||||
}
|
||||
|
||||
private static <T> T a(T[] tArr, int i, StyleExtractor<T> styleExtractor) {
|
||||
int i2 = (i & 1) == 0 ? 400 : IMediaPlayer.MEDIA_INFO_VIDEO_TRACK_LAGGING;
|
||||
boolean z = (i & 2) != 0;
|
||||
T t = null;
|
||||
int i3 = Integer.MAX_VALUE;
|
||||
for (T t2 : tArr) {
|
||||
int abs = (Math.abs(styleExtractor.a(t2) - i2) * 2) + (styleExtractor.b(t2) == z ? 0 : 1);
|
||||
if (t == null || i3 > abs) {
|
||||
t = t2;
|
||||
i3 = abs;
|
||||
}
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
protected FontsContractCompat.FontInfo a(FontsContractCompat.FontInfo[] fontInfoArr, int i) {
|
||||
return (FontsContractCompat.FontInfo) a(fontInfoArr, i, new StyleExtractor<FontsContractCompat.FontInfo>(this) { // from class: androidx.core.graphics.TypefaceCompatBaseImpl.1
|
||||
@Override // androidx.core.graphics.TypefaceCompatBaseImpl.StyleExtractor
|
||||
public int a(FontsContractCompat.FontInfo fontInfo) {
|
||||
return fontInfo.d();
|
||||
}
|
||||
|
||||
@Override // androidx.core.graphics.TypefaceCompatBaseImpl.StyleExtractor
|
||||
public boolean b(FontsContractCompat.FontInfo fontInfo) {
|
||||
return fontInfo.e();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected Typeface a(Context context, InputStream inputStream) {
|
||||
File a = TypefaceCompatUtil.a(context);
|
||||
if (a == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
if (TypefaceCompatUtil.a(a, inputStream)) {
|
||||
return Typeface.createFromFile(a.getPath());
|
||||
}
|
||||
return null;
|
||||
} catch (RuntimeException unused) {
|
||||
return null;
|
||||
} finally {
|
||||
a.delete();
|
||||
}
|
||||
}
|
||||
|
||||
public Typeface a(Context context, CancellationSignal cancellationSignal, FontsContractCompat.FontInfo[] fontInfoArr, int i) {
|
||||
InputStream inputStream;
|
||||
InputStream inputStream2 = null;
|
||||
if (fontInfoArr.length < 1) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
inputStream = context.getContentResolver().openInputStream(a(fontInfoArr, i).c());
|
||||
try {
|
||||
Typeface a = a(context, inputStream);
|
||||
TypefaceCompatUtil.a(inputStream);
|
||||
return a;
|
||||
} catch (IOException unused) {
|
||||
TypefaceCompatUtil.a(inputStream);
|
||||
return null;
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
inputStream2 = inputStream;
|
||||
TypefaceCompatUtil.a(inputStream2);
|
||||
throw th;
|
||||
}
|
||||
} catch (IOException unused2) {
|
||||
inputStream = null;
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
}
|
||||
}
|
||||
|
||||
private FontResourcesParserCompat.FontFileResourceEntry a(FontResourcesParserCompat.FontFamilyFilesResourceEntry fontFamilyFilesResourceEntry, int i) {
|
||||
return (FontResourcesParserCompat.FontFileResourceEntry) a(fontFamilyFilesResourceEntry.a(), i, new StyleExtractor<FontResourcesParserCompat.FontFileResourceEntry>(this) { // from class: androidx.core.graphics.TypefaceCompatBaseImpl.2
|
||||
@Override // androidx.core.graphics.TypefaceCompatBaseImpl.StyleExtractor
|
||||
public int a(FontResourcesParserCompat.FontFileResourceEntry fontFileResourceEntry) {
|
||||
return fontFileResourceEntry.e();
|
||||
}
|
||||
|
||||
@Override // androidx.core.graphics.TypefaceCompatBaseImpl.StyleExtractor
|
||||
public boolean b(FontResourcesParserCompat.FontFileResourceEntry fontFileResourceEntry) {
|
||||
return fontFileResourceEntry.f();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Typeface a(Context context, FontResourcesParserCompat.FontFamilyFilesResourceEntry fontFamilyFilesResourceEntry, Resources resources, int i) {
|
||||
FontResourcesParserCompat.FontFileResourceEntry a = a(fontFamilyFilesResourceEntry, i);
|
||||
if (a == null) {
|
||||
return null;
|
||||
}
|
||||
return TypefaceCompat.a(context, resources, a.b(), a.a(), i);
|
||||
}
|
||||
|
||||
public Typeface a(Context context, Resources resources, int i, String str, int i2) {
|
||||
File a = TypefaceCompatUtil.a(context);
|
||||
if (a == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
if (TypefaceCompatUtil.a(a, resources, i)) {
|
||||
return Typeface.createFromFile(a.getPath());
|
||||
}
|
||||
return null;
|
||||
} catch (RuntimeException unused) {
|
||||
return null;
|
||||
} finally {
|
||||
a.delete();
|
||||
}
|
||||
}
|
||||
}
|
160
sources/androidx/core/graphics/TypefaceCompatUtil.java
Normal file
160
sources/androidx/core/graphics/TypefaceCompatUtil.java
Normal file
@@ -0,0 +1,160 @@
|
||||
package androidx.core.graphics;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.os.CancellationSignal;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.os.Process;
|
||||
import android.os.StrictMode;
|
||||
import android.util.Log;
|
||||
import com.ijm.dataencryption.de.DataDecryptTool;
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.MappedByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class TypefaceCompatUtil {
|
||||
public static File a(Context context) {
|
||||
String str = ".font" + Process.myPid() + "-" + Process.myTid() + "-";
|
||||
for (int i = 0; i < 100; i++) {
|
||||
File file = new File(context.getCacheDir(), str + i);
|
||||
if (file.createNewFile()) {
|
||||
return file;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static ByteBuffer a(File file) {
|
||||
try {
|
||||
FileInputStream fileInputStream = new FileInputStream(file);
|
||||
try {
|
||||
FileChannel channel = fileInputStream.getChannel();
|
||||
MappedByteBuffer map = channel.map(FileChannel.MapMode.READ_ONLY, 0L, channel.size());
|
||||
fileInputStream.close();
|
||||
return map;
|
||||
} finally {
|
||||
}
|
||||
} catch (IOException unused) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static ByteBuffer a(Context context, CancellationSignal cancellationSignal, Uri uri) {
|
||||
try {
|
||||
ParcelFileDescriptor openFileDescriptor = context.getContentResolver().openFileDescriptor(uri, "r", cancellationSignal);
|
||||
if (openFileDescriptor == null) {
|
||||
if (openFileDescriptor != null) {
|
||||
openFileDescriptor.close();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
FileInputStream fileInputStream = new FileInputStream(openFileDescriptor.getFileDescriptor());
|
||||
try {
|
||||
FileChannel channel = fileInputStream.getChannel();
|
||||
MappedByteBuffer map = channel.map(FileChannel.MapMode.READ_ONLY, 0L, channel.size());
|
||||
fileInputStream.close();
|
||||
if (openFileDescriptor != null) {
|
||||
openFileDescriptor.close();
|
||||
}
|
||||
return map;
|
||||
} finally {
|
||||
}
|
||||
} finally {
|
||||
}
|
||||
} catch (IOException unused) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static ByteBuffer a(Context context, Resources resources, int i) {
|
||||
File a = a(context);
|
||||
if (a == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
if (a(a, resources, i)) {
|
||||
return a(a);
|
||||
}
|
||||
return null;
|
||||
} finally {
|
||||
a.delete();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean a(File file, InputStream inputStream) {
|
||||
StrictMode.ThreadPolicy allowThreadDiskWrites = StrictMode.allowThreadDiskWrites();
|
||||
FileOutputStream fileOutputStream = null;
|
||||
try {
|
||||
try {
|
||||
FileOutputStream fileOutputStream2 = new FileOutputStream(file, false);
|
||||
try {
|
||||
byte[] bArr = new byte[DataDecryptTool.DECRYPT_SP_FILE];
|
||||
while (true) {
|
||||
int read = inputStream.read(bArr);
|
||||
if (read != -1) {
|
||||
fileOutputStream2.write(bArr, 0, read);
|
||||
} else {
|
||||
a(fileOutputStream2);
|
||||
StrictMode.setThreadPolicy(allowThreadDiskWrites);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e = e;
|
||||
fileOutputStream = fileOutputStream2;
|
||||
Log.e("TypefaceCompatUtil", "Error copying resource contents to temp file: " + e.getMessage());
|
||||
a(fileOutputStream);
|
||||
StrictMode.setThreadPolicy(allowThreadDiskWrites);
|
||||
return false;
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
fileOutputStream = fileOutputStream2;
|
||||
a(fileOutputStream);
|
||||
StrictMode.setThreadPolicy(allowThreadDiskWrites);
|
||||
throw th;
|
||||
}
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
}
|
||||
} catch (IOException e2) {
|
||||
e = e2;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean a(File file, Resources resources, int i) {
|
||||
InputStream inputStream;
|
||||
try {
|
||||
inputStream = resources.openRawResource(i);
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
inputStream = null;
|
||||
}
|
||||
try {
|
||||
boolean a = a(file, inputStream);
|
||||
a(inputStream);
|
||||
return a;
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
a(inputStream);
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
|
||||
public static void a(Closeable closeable) {
|
||||
if (closeable != null) {
|
||||
try {
|
||||
closeable.close();
|
||||
} catch (IOException unused) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
211
sources/androidx/core/graphics/drawable/DrawableCompat.java
Normal file
211
sources/androidx/core/graphics/drawable/DrawableCompat.java
Normal file
@@ -0,0 +1,211 @@
|
||||
package androidx.core.graphics.drawable;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.DrawableContainer;
|
||||
import android.graphics.drawable.InsetDrawable;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class DrawableCompat {
|
||||
private static Method a;
|
||||
private static boolean b;
|
||||
private static Method c;
|
||||
private static boolean d;
|
||||
|
||||
public static void a(Drawable drawable, boolean z) {
|
||||
if (Build.VERSION.SDK_INT >= 19) {
|
||||
drawable.setAutoMirrored(z);
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
public static void b(Drawable drawable, int i) {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
drawable.setTint(i);
|
||||
} else if (drawable instanceof TintAwareDrawable) {
|
||||
((TintAwareDrawable) drawable).setTint(i);
|
||||
}
|
||||
}
|
||||
|
||||
public static int c(Drawable drawable) {
|
||||
if (Build.VERSION.SDK_INT >= 19) {
|
||||
return drawable.getAlpha();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static ColorFilter d(Drawable drawable) {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
return drawable.getColorFilter();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int e(Drawable drawable) {
|
||||
int i = Build.VERSION.SDK_INT;
|
||||
if (i >= 23) {
|
||||
return drawable.getLayoutDirection();
|
||||
}
|
||||
if (i >= 17) {
|
||||
if (!d) {
|
||||
try {
|
||||
c = Drawable.class.getDeclaredMethod("getLayoutDirection", new Class[0]);
|
||||
c.setAccessible(true);
|
||||
} catch (NoSuchMethodException e) {
|
||||
Log.i("DrawableCompat", "Failed to retrieve getLayoutDirection() method", e);
|
||||
}
|
||||
d = true;
|
||||
}
|
||||
Method method = c;
|
||||
if (method != null) {
|
||||
try {
|
||||
return ((Integer) method.invoke(drawable, new Object[0])).intValue();
|
||||
} catch (Exception e2) {
|
||||
Log.i("DrawableCompat", "Failed to invoke getLayoutDirection() via reflection", e2);
|
||||
c = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static boolean f(Drawable drawable) {
|
||||
if (Build.VERSION.SDK_INT >= 19) {
|
||||
return drawable.isAutoMirrored();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void g(Drawable drawable) {
|
||||
drawable.jumpToCurrentState();
|
||||
}
|
||||
|
||||
public static Drawable h(Drawable drawable) {
|
||||
int i = Build.VERSION.SDK_INT;
|
||||
return i >= 23 ? drawable : i >= 21 ? !(drawable instanceof TintAwareDrawable) ? new WrappedDrawableApi21(drawable) : drawable : !(drawable instanceof TintAwareDrawable) ? new WrappedDrawableApi14(drawable) : drawable;
|
||||
}
|
||||
|
||||
public static void a(Drawable drawable, float f, float f2) {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
drawable.setHotspot(f, f2);
|
||||
}
|
||||
}
|
||||
|
||||
public static void a(Drawable drawable, int i, int i2, int i3, int i4) {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
drawable.setHotspotBounds(i, i2, i3, i4);
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
public static void b(Drawable drawable) {
|
||||
DrawableContainer.DrawableContainerState drawableContainerState;
|
||||
int i = Build.VERSION.SDK_INT;
|
||||
if (i >= 23) {
|
||||
drawable.clearColorFilter();
|
||||
return;
|
||||
}
|
||||
if (i >= 21) {
|
||||
drawable.clearColorFilter();
|
||||
if (drawable instanceof InsetDrawable) {
|
||||
b(((InsetDrawable) drawable).getDrawable());
|
||||
return;
|
||||
}
|
||||
if (drawable instanceof WrappedDrawable) {
|
||||
b(((WrappedDrawable) drawable).a());
|
||||
return;
|
||||
}
|
||||
if (!(drawable instanceof DrawableContainer) || (drawableContainerState = (DrawableContainer.DrawableContainerState) ((DrawableContainer) drawable).getConstantState()) == null) {
|
||||
return;
|
||||
}
|
||||
int childCount = drawableContainerState.getChildCount();
|
||||
for (int i2 = 0; i2 < childCount; i2++) {
|
||||
Drawable child = drawableContainerState.getChild(i2);
|
||||
if (child != null) {
|
||||
b(child);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
drawable.clearColorFilter();
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
public static void a(Drawable drawable, ColorStateList colorStateList) {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
drawable.setTintList(colorStateList);
|
||||
} else if (drawable instanceof TintAwareDrawable) {
|
||||
((TintAwareDrawable) drawable).setTintList(colorStateList);
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
public static void a(Drawable drawable, PorterDuff.Mode mode) {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
drawable.setTintMode(mode);
|
||||
} else if (drawable instanceof TintAwareDrawable) {
|
||||
((TintAwareDrawable) drawable).setTintMode(mode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void a(Drawable drawable, Resources.Theme theme) {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
drawable.applyTheme(theme);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean a(Drawable drawable) {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
return drawable.canApplyTheme();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void a(Drawable drawable, Resources resources, XmlPullParser xmlPullParser, AttributeSet attributeSet, Resources.Theme theme) throws XmlPullParserException, IOException {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
drawable.inflate(resources, xmlPullParser, attributeSet, theme);
|
||||
} else {
|
||||
drawable.inflate(resources, xmlPullParser, attributeSet);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean a(Drawable drawable, int i) {
|
||||
int i2 = Build.VERSION.SDK_INT;
|
||||
if (i2 >= 23) {
|
||||
return drawable.setLayoutDirection(i);
|
||||
}
|
||||
if (i2 >= 17) {
|
||||
if (!b) {
|
||||
try {
|
||||
a = Drawable.class.getDeclaredMethod("setLayoutDirection", Integer.TYPE);
|
||||
a.setAccessible(true);
|
||||
} catch (NoSuchMethodException e) {
|
||||
Log.i("DrawableCompat", "Failed to retrieve setLayoutDirection(int) method", e);
|
||||
}
|
||||
b = true;
|
||||
}
|
||||
Method method = a;
|
||||
if (method != null) {
|
||||
try {
|
||||
method.invoke(drawable, Integer.valueOf(i));
|
||||
return true;
|
||||
} catch (Exception e2) {
|
||||
Log.i("DrawableCompat", "Failed to invoke setLayoutDirection(int) via reflection", e2);
|
||||
a = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
268
sources/androidx/core/graphics/drawable/IconCompat.java
Normal file
268
sources/androidx/core/graphics/drawable/IconCompat.java
Normal file
@@ -0,0 +1,268 @@
|
||||
package androidx.core.graphics.drawable;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.os.Build;
|
||||
import android.os.Parcelable;
|
||||
import android.util.Log;
|
||||
import androidx.versionedparcelable.CustomVersionedParcelable;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class IconCompat extends CustomVersionedParcelable {
|
||||
static final PorterDuff.Mode j = PorterDuff.Mode.SRC_IN;
|
||||
public int a;
|
||||
Object b;
|
||||
public byte[] c;
|
||||
public Parcelable d;
|
||||
public int e;
|
||||
public int f;
|
||||
public ColorStateList g = null;
|
||||
PorterDuff.Mode h = j;
|
||||
public String i;
|
||||
|
||||
private static String a(int i) {
|
||||
return i != 1 ? i != 2 ? i != 3 ? i != 4 ? i != 5 ? "UNKNOWN" : "BITMAP_MASKABLE" : "URI" : "DATA" : "RESOURCE" : "BITMAP";
|
||||
}
|
||||
|
||||
public int a() {
|
||||
if (this.a == -1 && Build.VERSION.SDK_INT >= 23) {
|
||||
return a((Icon) this.b);
|
||||
}
|
||||
if (this.a == 2) {
|
||||
return this.e;
|
||||
}
|
||||
throw new IllegalStateException("called getResId() on " + this);
|
||||
}
|
||||
|
||||
public String b() {
|
||||
if (this.a == -1 && Build.VERSION.SDK_INT >= 23) {
|
||||
return b((Icon) this.b);
|
||||
}
|
||||
if (this.a == 2) {
|
||||
return ((String) this.b).split(":", -1)[0];
|
||||
}
|
||||
throw new IllegalStateException("called getResPackage() on " + this);
|
||||
}
|
||||
|
||||
public void c() {
|
||||
this.h = PorterDuff.Mode.valueOf(this.i);
|
||||
int i = this.a;
|
||||
if (i == -1) {
|
||||
Parcelable parcelable = this.d;
|
||||
if (parcelable == null) {
|
||||
throw new IllegalArgumentException("Invalid icon");
|
||||
}
|
||||
this.b = parcelable;
|
||||
return;
|
||||
}
|
||||
if (i != 1) {
|
||||
if (i != 2) {
|
||||
if (i == 3) {
|
||||
this.b = this.c;
|
||||
return;
|
||||
} else if (i != 4) {
|
||||
if (i != 5) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.b = new String(this.c, Charset.forName("UTF-16"));
|
||||
return;
|
||||
}
|
||||
Parcelable parcelable2 = this.d;
|
||||
if (parcelable2 != null) {
|
||||
this.b = parcelable2;
|
||||
return;
|
||||
}
|
||||
byte[] bArr = this.c;
|
||||
this.b = bArr;
|
||||
this.a = 3;
|
||||
this.e = 0;
|
||||
this.f = bArr.length;
|
||||
}
|
||||
|
||||
/* JADX WARN: Code restructure failed: missing block: B:15:0x002b, code lost:
|
||||
|
||||
if (r1 != 5) goto L23;
|
||||
*/
|
||||
/* JADX WARN: Removed duplicated region for block: B:18:0x009e */
|
||||
/* JADX WARN: Removed duplicated region for block: B:21:0x00ae */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public java.lang.String toString() {
|
||||
/*
|
||||
r4 = this;
|
||||
int r0 = r4.a
|
||||
r1 = -1
|
||||
if (r0 != r1) goto Lc
|
||||
java.lang.Object r0 = r4.b
|
||||
java.lang.String r0 = java.lang.String.valueOf(r0)
|
||||
return r0
|
||||
Lc:
|
||||
java.lang.StringBuilder r0 = new java.lang.StringBuilder
|
||||
java.lang.String r1 = "Icon(typ="
|
||||
r0.<init>(r1)
|
||||
int r1 = r4.a
|
||||
java.lang.String r1 = a(r1)
|
||||
r0.append(r1)
|
||||
int r1 = r4.a
|
||||
r2 = 1
|
||||
if (r1 == r2) goto L7a
|
||||
r3 = 2
|
||||
if (r1 == r3) goto L52
|
||||
r2 = 3
|
||||
if (r1 == r2) goto L39
|
||||
r2 = 4
|
||||
if (r1 == r2) goto L2e
|
||||
r2 = 5
|
||||
if (r1 == r2) goto L7a
|
||||
goto L9a
|
||||
L2e:
|
||||
java.lang.String r1 = " uri="
|
||||
r0.append(r1)
|
||||
java.lang.Object r1 = r4.b
|
||||
r0.append(r1)
|
||||
goto L9a
|
||||
L39:
|
||||
java.lang.String r1 = " len="
|
||||
r0.append(r1)
|
||||
int r1 = r4.e
|
||||
r0.append(r1)
|
||||
int r1 = r4.f
|
||||
if (r1 == 0) goto L9a
|
||||
java.lang.String r1 = " off="
|
||||
r0.append(r1)
|
||||
int r1 = r4.f
|
||||
r0.append(r1)
|
||||
goto L9a
|
||||
L52:
|
||||
java.lang.String r1 = " pkg="
|
||||
r0.append(r1)
|
||||
java.lang.String r1 = r4.b()
|
||||
r0.append(r1)
|
||||
java.lang.String r1 = " id="
|
||||
r0.append(r1)
|
||||
java.lang.Object[] r1 = new java.lang.Object[r2]
|
||||
r2 = 0
|
||||
int r3 = r4.a()
|
||||
java.lang.Integer r3 = java.lang.Integer.valueOf(r3)
|
||||
r1[r2] = r3
|
||||
java.lang.String r2 = "0x%08x"
|
||||
java.lang.String r1 = java.lang.String.format(r2, r1)
|
||||
r0.append(r1)
|
||||
goto L9a
|
||||
L7a:
|
||||
java.lang.String r1 = " size="
|
||||
r0.append(r1)
|
||||
java.lang.Object r1 = r4.b
|
||||
android.graphics.Bitmap r1 = (android.graphics.Bitmap) r1
|
||||
int r1 = r1.getWidth()
|
||||
r0.append(r1)
|
||||
java.lang.String r1 = "x"
|
||||
r0.append(r1)
|
||||
java.lang.Object r1 = r4.b
|
||||
android.graphics.Bitmap r1 = (android.graphics.Bitmap) r1
|
||||
int r1 = r1.getHeight()
|
||||
r0.append(r1)
|
||||
L9a:
|
||||
android.content.res.ColorStateList r1 = r4.g
|
||||
if (r1 == 0) goto La8
|
||||
java.lang.String r1 = " tint="
|
||||
r0.append(r1)
|
||||
android.content.res.ColorStateList r1 = r4.g
|
||||
r0.append(r1)
|
||||
La8:
|
||||
android.graphics.PorterDuff$Mode r1 = r4.h
|
||||
android.graphics.PorterDuff$Mode r2 = androidx.core.graphics.drawable.IconCompat.j
|
||||
if (r1 == r2) goto Lb8
|
||||
java.lang.String r1 = " mode="
|
||||
r0.append(r1)
|
||||
android.graphics.PorterDuff$Mode r1 = r4.h
|
||||
r0.append(r1)
|
||||
Lb8:
|
||||
java.lang.String r1 = ")"
|
||||
r0.append(r1)
|
||||
java.lang.String r0 = r0.toString()
|
||||
return r0
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: androidx.core.graphics.drawable.IconCompat.toString():java.lang.String");
|
||||
}
|
||||
|
||||
private static String b(Icon icon) {
|
||||
if (Build.VERSION.SDK_INT >= 28) {
|
||||
return icon.getResPackage();
|
||||
}
|
||||
try {
|
||||
return (String) icon.getClass().getMethod("getResPackage", new Class[0]).invoke(icon, new Object[0]);
|
||||
} catch (IllegalAccessException e) {
|
||||
Log.e("IconCompat", "Unable to get icon package", e);
|
||||
return null;
|
||||
} catch (NoSuchMethodException e2) {
|
||||
Log.e("IconCompat", "Unable to get icon package", e2);
|
||||
return null;
|
||||
} catch (InvocationTargetException e3) {
|
||||
Log.e("IconCompat", "Unable to get icon package", e3);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void a(boolean z) {
|
||||
this.i = this.h.name();
|
||||
int i = this.a;
|
||||
if (i == -1) {
|
||||
if (!z) {
|
||||
this.d = (Parcelable) this.b;
|
||||
return;
|
||||
}
|
||||
throw new IllegalArgumentException("Can't serialize Icon created with IconCompat#createFromIcon");
|
||||
}
|
||||
if (i != 1) {
|
||||
if (i == 2) {
|
||||
this.c = ((String) this.b).getBytes(Charset.forName("UTF-16"));
|
||||
return;
|
||||
}
|
||||
if (i == 3) {
|
||||
this.c = (byte[]) this.b;
|
||||
return;
|
||||
} else if (i == 4) {
|
||||
this.c = this.b.toString().getBytes(Charset.forName("UTF-16"));
|
||||
return;
|
||||
} else if (i != 5) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (z) {
|
||||
Bitmap bitmap = (Bitmap) this.b;
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
bitmap.compress(Bitmap.CompressFormat.PNG, 90, byteArrayOutputStream);
|
||||
this.c = byteArrayOutputStream.toByteArray();
|
||||
return;
|
||||
}
|
||||
this.d = (Parcelable) this.b;
|
||||
}
|
||||
|
||||
private static int a(Icon icon) {
|
||||
if (Build.VERSION.SDK_INT >= 28) {
|
||||
return icon.getResId();
|
||||
}
|
||||
try {
|
||||
return ((Integer) icon.getClass().getMethod("getResId", new Class[0]).invoke(icon, new Object[0])).intValue();
|
||||
} catch (IllegalAccessException e) {
|
||||
Log.e("IconCompat", "Unable to get icon resource", e);
|
||||
return 0;
|
||||
} catch (NoSuchMethodException e2) {
|
||||
Log.e("IconCompat", "Unable to get icon resource", e2);
|
||||
return 0;
|
||||
} catch (InvocationTargetException e3) {
|
||||
Log.e("IconCompat", "Unable to get icon resource", e3);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
package androidx.core.graphics.drawable;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import androidx.versionedparcelable.VersionedParcel;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class IconCompatParcelizer {
|
||||
public static IconCompat read(VersionedParcel versionedParcel) {
|
||||
IconCompat iconCompat = new IconCompat();
|
||||
iconCompat.a = versionedParcel.a(iconCompat.a, 1);
|
||||
iconCompat.c = versionedParcel.a(iconCompat.c, 2);
|
||||
iconCompat.d = versionedParcel.a((VersionedParcel) iconCompat.d, 3);
|
||||
iconCompat.e = versionedParcel.a(iconCompat.e, 4);
|
||||
iconCompat.f = versionedParcel.a(iconCompat.f, 5);
|
||||
iconCompat.g = (ColorStateList) versionedParcel.a((VersionedParcel) iconCompat.g, 6);
|
||||
iconCompat.i = versionedParcel.a(iconCompat.i, 7);
|
||||
iconCompat.c();
|
||||
return iconCompat;
|
||||
}
|
||||
|
||||
public static void write(IconCompat iconCompat, VersionedParcel versionedParcel) {
|
||||
versionedParcel.a(true, true);
|
||||
iconCompat.a(versionedParcel.c());
|
||||
versionedParcel.b(iconCompat.a, 1);
|
||||
versionedParcel.b(iconCompat.c, 2);
|
||||
versionedParcel.b(iconCompat.d, 3);
|
||||
versionedParcel.b(iconCompat.e, 4);
|
||||
versionedParcel.b(iconCompat.f, 5);
|
||||
versionedParcel.b(iconCompat.g, 6);
|
||||
versionedParcel.b(iconCompat.i, 7);
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
package androidx.core.graphics.drawable;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.PorterDuff;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface TintAwareDrawable {
|
||||
void setTint(int i);
|
||||
|
||||
void setTintList(ColorStateList colorStateList);
|
||||
|
||||
void setTintMode(PorterDuff.Mode mode);
|
||||
}
|
10
sources/androidx/core/graphics/drawable/WrappedDrawable.java
Normal file
10
sources/androidx/core/graphics/drawable/WrappedDrawable.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package androidx.core.graphics.drawable;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface WrappedDrawable {
|
||||
Drawable a();
|
||||
|
||||
void a(Drawable drawable);
|
||||
}
|
@@ -0,0 +1,332 @@
|
||||
package androidx.core.graphics.drawable;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Region;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class WrappedDrawableApi14 extends Drawable implements Drawable.Callback, WrappedDrawable, TintAwareDrawable {
|
||||
static final PorterDuff.Mode g = PorterDuff.Mode.SRC_IN;
|
||||
private int a;
|
||||
private PorterDuff.Mode b;
|
||||
private boolean c;
|
||||
DrawableWrapperState d;
|
||||
private boolean e;
|
||||
Drawable f;
|
||||
|
||||
protected static abstract class DrawableWrapperState extends Drawable.ConstantState {
|
||||
int a;
|
||||
Drawable.ConstantState b;
|
||||
ColorStateList c;
|
||||
PorterDuff.Mode d;
|
||||
|
||||
DrawableWrapperState(DrawableWrapperState drawableWrapperState, Resources resources) {
|
||||
this.c = null;
|
||||
this.d = WrappedDrawableApi14.g;
|
||||
if (drawableWrapperState != null) {
|
||||
this.a = drawableWrapperState.a;
|
||||
this.b = drawableWrapperState.b;
|
||||
this.c = drawableWrapperState.c;
|
||||
this.d = drawableWrapperState.d;
|
||||
}
|
||||
}
|
||||
|
||||
boolean a() {
|
||||
return this.b != null;
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable.ConstantState
|
||||
public int getChangingConfigurations() {
|
||||
int i = this.a;
|
||||
Drawable.ConstantState constantState = this.b;
|
||||
return i | (constantState != null ? constantState.getChangingConfigurations() : 0);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable.ConstantState
|
||||
public Drawable newDrawable() {
|
||||
return newDrawable(null);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable.ConstantState
|
||||
public abstract Drawable newDrawable(Resources resources);
|
||||
}
|
||||
|
||||
private static class DrawableWrapperStateBase extends DrawableWrapperState {
|
||||
DrawableWrapperStateBase(DrawableWrapperState drawableWrapperState, Resources resources) {
|
||||
super(drawableWrapperState, resources);
|
||||
}
|
||||
|
||||
@Override // androidx.core.graphics.drawable.WrappedDrawableApi14.DrawableWrapperState, android.graphics.drawable.Drawable.ConstantState
|
||||
public Drawable newDrawable(Resources resources) {
|
||||
return new WrappedDrawableApi14(this, resources);
|
||||
}
|
||||
}
|
||||
|
||||
WrappedDrawableApi14(DrawableWrapperState drawableWrapperState, Resources resources) {
|
||||
this.d = drawableWrapperState;
|
||||
a(resources);
|
||||
}
|
||||
|
||||
private void a(Resources resources) {
|
||||
Drawable.ConstantState constantState;
|
||||
DrawableWrapperState drawableWrapperState = this.d;
|
||||
if (drawableWrapperState == null || (constantState = drawableWrapperState.b) == null) {
|
||||
return;
|
||||
}
|
||||
a(constantState.newDrawable(resources));
|
||||
}
|
||||
|
||||
protected boolean b() {
|
||||
return true;
|
||||
}
|
||||
|
||||
DrawableWrapperState c() {
|
||||
return new DrawableWrapperStateBase(this.d, null);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public void draw(Canvas canvas) {
|
||||
this.f.draw(canvas);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public int getChangingConfigurations() {
|
||||
int changingConfigurations = super.getChangingConfigurations();
|
||||
DrawableWrapperState drawableWrapperState = this.d;
|
||||
return changingConfigurations | (drawableWrapperState != null ? drawableWrapperState.getChangingConfigurations() : 0) | this.f.getChangingConfigurations();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public Drawable.ConstantState getConstantState() {
|
||||
DrawableWrapperState drawableWrapperState = this.d;
|
||||
if (drawableWrapperState == null || !drawableWrapperState.a()) {
|
||||
return null;
|
||||
}
|
||||
this.d.a = getChangingConfigurations();
|
||||
return this.d;
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public Drawable getCurrent() {
|
||||
return this.f.getCurrent();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public int getIntrinsicHeight() {
|
||||
return this.f.getIntrinsicHeight();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public int getIntrinsicWidth() {
|
||||
return this.f.getIntrinsicWidth();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public int getMinimumHeight() {
|
||||
return this.f.getMinimumHeight();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public int getMinimumWidth() {
|
||||
return this.f.getMinimumWidth();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public int getOpacity() {
|
||||
return this.f.getOpacity();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public boolean getPadding(Rect rect) {
|
||||
return this.f.getPadding(rect);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public int[] getState() {
|
||||
return this.f.getState();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public Region getTransparentRegion() {
|
||||
return this.f.getTransparentRegion();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable.Callback
|
||||
public void invalidateDrawable(Drawable drawable) {
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public boolean isAutoMirrored() {
|
||||
return this.f.isAutoMirrored();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public boolean isStateful() {
|
||||
DrawableWrapperState drawableWrapperState;
|
||||
ColorStateList colorStateList = (!b() || (drawableWrapperState = this.d) == null) ? null : drawableWrapperState.c;
|
||||
return (colorStateList != null && colorStateList.isStateful()) || this.f.isStateful();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public void jumpToCurrentState() {
|
||||
this.f.jumpToCurrentState();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public Drawable mutate() {
|
||||
if (!this.e && super.mutate() == this) {
|
||||
this.d = c();
|
||||
Drawable drawable = this.f;
|
||||
if (drawable != null) {
|
||||
drawable.mutate();
|
||||
}
|
||||
DrawableWrapperState drawableWrapperState = this.d;
|
||||
if (drawableWrapperState != null) {
|
||||
Drawable drawable2 = this.f;
|
||||
drawableWrapperState.b = drawable2 != null ? drawable2.getConstantState() : null;
|
||||
}
|
||||
this.e = true;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
protected void onBoundsChange(Rect rect) {
|
||||
Drawable drawable = this.f;
|
||||
if (drawable != null) {
|
||||
drawable.setBounds(rect);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
protected boolean onLevelChange(int i) {
|
||||
return this.f.setLevel(i);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable.Callback
|
||||
public void scheduleDrawable(Drawable drawable, Runnable runnable, long j) {
|
||||
scheduleSelf(runnable, j);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public void setAlpha(int i) {
|
||||
this.f.setAlpha(i);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public void setAutoMirrored(boolean z) {
|
||||
this.f.setAutoMirrored(z);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public void setChangingConfigurations(int i) {
|
||||
this.f.setChangingConfigurations(i);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public void setColorFilter(ColorFilter colorFilter) {
|
||||
this.f.setColorFilter(colorFilter);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public void setDither(boolean z) {
|
||||
this.f.setDither(z);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public void setFilterBitmap(boolean z) {
|
||||
this.f.setFilterBitmap(z);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public boolean setState(int[] iArr) {
|
||||
return a(iArr) || this.f.setState(iArr);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable, androidx.core.graphics.drawable.TintAwareDrawable
|
||||
public void setTint(int i) {
|
||||
setTintList(ColorStateList.valueOf(i));
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable, androidx.core.graphics.drawable.TintAwareDrawable
|
||||
public void setTintList(ColorStateList colorStateList) {
|
||||
this.d.c = colorStateList;
|
||||
a(getState());
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable, androidx.core.graphics.drawable.TintAwareDrawable
|
||||
public void setTintMode(PorterDuff.Mode mode) {
|
||||
this.d.d = mode;
|
||||
a(getState());
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public boolean setVisible(boolean z, boolean z2) {
|
||||
return super.setVisible(z, z2) || this.f.setVisible(z, z2);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable.Callback
|
||||
public void unscheduleDrawable(Drawable drawable, Runnable runnable) {
|
||||
unscheduleSelf(runnable);
|
||||
}
|
||||
|
||||
private boolean a(int[] iArr) {
|
||||
if (!b()) {
|
||||
return false;
|
||||
}
|
||||
DrawableWrapperState drawableWrapperState = this.d;
|
||||
ColorStateList colorStateList = drawableWrapperState.c;
|
||||
PorterDuff.Mode mode = drawableWrapperState.d;
|
||||
if (colorStateList != null && mode != null) {
|
||||
int colorForState = colorStateList.getColorForState(iArr, colorStateList.getDefaultColor());
|
||||
if (!this.c || colorForState != this.a || mode != this.b) {
|
||||
setColorFilter(colorForState, mode);
|
||||
this.a = colorForState;
|
||||
this.b = mode;
|
||||
this.c = true;
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
this.c = false;
|
||||
clearColorFilter();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
WrappedDrawableApi14(Drawable drawable) {
|
||||
this.d = c();
|
||||
a(drawable);
|
||||
}
|
||||
|
||||
@Override // androidx.core.graphics.drawable.WrappedDrawable
|
||||
public final Drawable a() {
|
||||
return this.f;
|
||||
}
|
||||
|
||||
@Override // androidx.core.graphics.drawable.WrappedDrawable
|
||||
public final void a(Drawable drawable) {
|
||||
Drawable drawable2 = this.f;
|
||||
if (drawable2 != null) {
|
||||
drawable2.setCallback(null);
|
||||
}
|
||||
this.f = drawable;
|
||||
if (drawable != null) {
|
||||
drawable.setCallback(this);
|
||||
setVisible(drawable.isVisible(), true);
|
||||
setState(drawable.getState());
|
||||
setLevel(drawable.getLevel());
|
||||
setBounds(drawable.getBounds());
|
||||
DrawableWrapperState drawableWrapperState = this.d;
|
||||
if (drawableWrapperState != null) {
|
||||
drawableWrapperState.b = drawable.getConstantState();
|
||||
}
|
||||
}
|
||||
invalidateSelf();
|
||||
}
|
||||
}
|
@@ -0,0 +1,136 @@
|
||||
package androidx.core.graphics.drawable;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Outline;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.DrawableContainer;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.graphics.drawable.InsetDrawable;
|
||||
import android.graphics.drawable.RippleDrawable;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import androidx.core.graphics.drawable.WrappedDrawableApi14;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class WrappedDrawableApi21 extends WrappedDrawableApi14 {
|
||||
private static Method h;
|
||||
|
||||
private static class DrawableWrapperStateLollipop extends WrappedDrawableApi14.DrawableWrapperState {
|
||||
DrawableWrapperStateLollipop(WrappedDrawableApi14.DrawableWrapperState drawableWrapperState, Resources resources) {
|
||||
super(drawableWrapperState, resources);
|
||||
}
|
||||
|
||||
@Override // androidx.core.graphics.drawable.WrappedDrawableApi14.DrawableWrapperState, android.graphics.drawable.Drawable.ConstantState
|
||||
public Drawable newDrawable(Resources resources) {
|
||||
return new WrappedDrawableApi21(this, resources);
|
||||
}
|
||||
}
|
||||
|
||||
WrappedDrawableApi21(Drawable drawable) {
|
||||
super(drawable);
|
||||
d();
|
||||
}
|
||||
|
||||
private void d() {
|
||||
if (h == null) {
|
||||
try {
|
||||
h = Drawable.class.getDeclaredMethod("isProjected", new Class[0]);
|
||||
} catch (Exception e) {
|
||||
Log.w("WrappedDrawableApi21", "Failed to retrieve Drawable#isProjected() method", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.core.graphics.drawable.WrappedDrawableApi14
|
||||
protected boolean b() {
|
||||
if (Build.VERSION.SDK_INT != 21) {
|
||||
return false;
|
||||
}
|
||||
Drawable drawable = this.f;
|
||||
return (drawable instanceof GradientDrawable) || (drawable instanceof DrawableContainer) || (drawable instanceof InsetDrawable) || (drawable instanceof RippleDrawable);
|
||||
}
|
||||
|
||||
@Override // androidx.core.graphics.drawable.WrappedDrawableApi14
|
||||
WrappedDrawableApi14.DrawableWrapperState c() {
|
||||
return new DrawableWrapperStateLollipop(this.d, null);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public Rect getDirtyBounds() {
|
||||
return this.f.getDirtyBounds();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public void getOutline(Outline outline) {
|
||||
this.f.getOutline(outline);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public boolean isProjected() {
|
||||
Method method;
|
||||
Drawable drawable = this.f;
|
||||
if (drawable != null && (method = h) != null) {
|
||||
try {
|
||||
return ((Boolean) method.invoke(drawable, new Object[0])).booleanValue();
|
||||
} catch (Exception e) {
|
||||
Log.w("WrappedDrawableApi21", "Error calling Drawable#isProjected() method", e);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public void setHotspot(float f, float f2) {
|
||||
this.f.setHotspot(f, f2);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public void setHotspotBounds(int i, int i2, int i3, int i4) {
|
||||
this.f.setHotspotBounds(i, i2, i3, i4);
|
||||
}
|
||||
|
||||
@Override // androidx.core.graphics.drawable.WrappedDrawableApi14, android.graphics.drawable.Drawable
|
||||
public boolean setState(int[] iArr) {
|
||||
if (!super.setState(iArr)) {
|
||||
return false;
|
||||
}
|
||||
invalidateSelf();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // androidx.core.graphics.drawable.WrappedDrawableApi14, android.graphics.drawable.Drawable, androidx.core.graphics.drawable.TintAwareDrawable
|
||||
public void setTint(int i) {
|
||||
if (b()) {
|
||||
super.setTint(i);
|
||||
} else {
|
||||
this.f.setTint(i);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.core.graphics.drawable.WrappedDrawableApi14, android.graphics.drawable.Drawable, androidx.core.graphics.drawable.TintAwareDrawable
|
||||
public void setTintList(ColorStateList colorStateList) {
|
||||
if (b()) {
|
||||
super.setTintList(colorStateList);
|
||||
} else {
|
||||
this.f.setTintList(colorStateList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.core.graphics.drawable.WrappedDrawableApi14, android.graphics.drawable.Drawable, androidx.core.graphics.drawable.TintAwareDrawable
|
||||
public void setTintMode(PorterDuff.Mode mode) {
|
||||
if (b()) {
|
||||
super.setTintMode(mode);
|
||||
} else {
|
||||
this.f.setTintMode(mode);
|
||||
}
|
||||
}
|
||||
|
||||
WrappedDrawableApi21(WrappedDrawableApi14.DrawableWrapperState drawableWrapperState, Resources resources) {
|
||||
super(drawableWrapperState, resources);
|
||||
d();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user