You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
556 lines
20 KiB
556 lines
20 KiB
package p028j;
|
|
|
|
import android.content.Context;
|
|
import android.content.res.Resources;
|
|
import android.content.res.TypedArray;
|
|
import android.graphics.RectF;
|
|
import android.os.Build;
|
|
import android.text.Layout;
|
|
import android.text.StaticLayout;
|
|
import android.text.TextDirectionHeuristic;
|
|
import android.text.TextDirectionHeuristics;
|
|
import android.text.TextPaint;
|
|
import android.text.method.TransformationMethod;
|
|
import android.util.AttributeSet;
|
|
import android.util.DisplayMetrics;
|
|
import android.util.Log;
|
|
import android.util.TypedValue;
|
|
import android.view.View;
|
|
import android.widget.TextView;
|
|
import java.lang.reflect.Field;
|
|
import java.lang.reflect.Method;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Collections;
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
import p007c.C0494j;
|
|
import p023h0.C0829h1;
|
|
|
|
/* renamed from: j.p1 */
|
|
/* loaded from: classes.dex */
|
|
public class C1174p1 {
|
|
|
|
/* renamed from: l */
|
|
public static final RectF f2859l = new RectF();
|
|
|
|
/* renamed from: m */
|
|
public static ConcurrentHashMap<String, Method> f2860m = new ConcurrentHashMap<>();
|
|
|
|
/* renamed from: n */
|
|
public static ConcurrentHashMap<String, Field> f2861n = new ConcurrentHashMap<>();
|
|
|
|
/* renamed from: a */
|
|
public int f2862a = 0;
|
|
|
|
/* renamed from: b */
|
|
public boolean f2863b = false;
|
|
|
|
/* renamed from: c */
|
|
public float f2864c = -1.0f;
|
|
|
|
/* renamed from: d */
|
|
public float f2865d = -1.0f;
|
|
|
|
/* renamed from: e */
|
|
public float f2866e = -1.0f;
|
|
|
|
/* renamed from: f */
|
|
public int[] f2867f = new int[0];
|
|
|
|
/* renamed from: g */
|
|
public boolean f2868g = false;
|
|
|
|
/* renamed from: h */
|
|
public TextPaint f2869h;
|
|
|
|
/* renamed from: i */
|
|
public final TextView f2870i;
|
|
|
|
/* renamed from: j */
|
|
public final Context f2871j;
|
|
|
|
/* renamed from: k */
|
|
public final C1180f f2872k;
|
|
|
|
/* renamed from: j.p1$a */
|
|
/* loaded from: classes.dex */
|
|
public static final class C1175a {
|
|
/* renamed from: a */
|
|
public static StaticLayout m1916a(CharSequence charSequence, Layout.Alignment alignment, int i, TextView textView, TextPaint textPaint) {
|
|
return new StaticLayout(charSequence, textPaint, i, alignment, textView.getLineSpacingMultiplier(), textView.getLineSpacingExtra(), textView.getIncludeFontPadding());
|
|
}
|
|
|
|
/* renamed from: b */
|
|
public static int m1915b(TextView textView) {
|
|
return textView.getMaxLines();
|
|
}
|
|
}
|
|
|
|
/* renamed from: j.p1$b */
|
|
/* loaded from: classes.dex */
|
|
public static final class C1176b {
|
|
/* renamed from: a */
|
|
public static boolean m1914a(View view) {
|
|
boolean isInLayout;
|
|
isInLayout = view.isInLayout();
|
|
return isInLayout;
|
|
}
|
|
}
|
|
|
|
/* renamed from: j.p1$c */
|
|
/* loaded from: classes.dex */
|
|
public static final class C1177c {
|
|
/* renamed from: a */
|
|
public static StaticLayout m1913a(CharSequence charSequence, Layout.Alignment alignment, int i, int i2, TextView textView, TextPaint textPaint, C1180f c1180f) {
|
|
StaticLayout.Builder obtain;
|
|
StaticLayout.Builder alignment2;
|
|
StaticLayout.Builder lineSpacing;
|
|
StaticLayout.Builder includePad;
|
|
int breakStrategy;
|
|
StaticLayout.Builder breakStrategy2;
|
|
int hyphenationFrequency;
|
|
StaticLayout.Builder hyphenationFrequency2;
|
|
StaticLayout build;
|
|
obtain = StaticLayout.Builder.obtain(charSequence, 0, charSequence.length(), textPaint, i);
|
|
alignment2 = obtain.setAlignment(alignment);
|
|
lineSpacing = alignment2.setLineSpacing(textView.getLineSpacingExtra(), textView.getLineSpacingMultiplier());
|
|
includePad = lineSpacing.setIncludePad(textView.getIncludeFontPadding());
|
|
breakStrategy = textView.getBreakStrategy();
|
|
breakStrategy2 = includePad.setBreakStrategy(breakStrategy);
|
|
hyphenationFrequency = textView.getHyphenationFrequency();
|
|
hyphenationFrequency2 = breakStrategy2.setHyphenationFrequency(hyphenationFrequency);
|
|
if (i2 == -1) {
|
|
i2 = Integer.MAX_VALUE;
|
|
}
|
|
hyphenationFrequency2.setMaxLines(i2);
|
|
try {
|
|
c1180f.mo1912a(obtain, textView);
|
|
} catch (ClassCastException unused) {
|
|
Log.w("ACTVAutoSizeHelper", "Failed to obtain TextDirectionHeuristic, auto size may be incorrect");
|
|
}
|
|
build = obtain.build();
|
|
return build;
|
|
}
|
|
}
|
|
|
|
/* renamed from: j.p1$d */
|
|
/* loaded from: classes.dex */
|
|
public static class C1178d extends C1180f {
|
|
@Override // p028j.C1174p1.C1180f
|
|
/* renamed from: a */
|
|
public void mo1912a(StaticLayout.Builder builder, TextView textView) {
|
|
TextDirectionHeuristic textDirectionHeuristic;
|
|
textDirectionHeuristic = TextDirectionHeuristics.FIRSTSTRONG_LTR;
|
|
builder.setTextDirection((TextDirectionHeuristic) C1174p1.m1930m(textView, "getTextDirectionHeuristic", textDirectionHeuristic));
|
|
}
|
|
}
|
|
|
|
/* renamed from: j.p1$e */
|
|
/* loaded from: classes.dex */
|
|
public static class C1179e extends C1178d {
|
|
@Override // p028j.C1174p1.C1178d, p028j.C1174p1.C1180f
|
|
/* renamed from: a */
|
|
public void mo1912a(StaticLayout.Builder builder, TextView textView) {
|
|
TextDirectionHeuristic textDirectionHeuristic;
|
|
textDirectionHeuristic = textView.getTextDirectionHeuristic();
|
|
builder.setTextDirection(textDirectionHeuristic);
|
|
}
|
|
|
|
@Override // p028j.C1174p1.C1180f
|
|
/* renamed from: b */
|
|
public boolean mo1911b(TextView textView) {
|
|
boolean isHorizontallyScrollable;
|
|
isHorizontallyScrollable = textView.isHorizontallyScrollable();
|
|
return isHorizontallyScrollable;
|
|
}
|
|
}
|
|
|
|
/* renamed from: j.p1$f */
|
|
/* loaded from: classes.dex */
|
|
public static class C1180f {
|
|
/* renamed from: a */
|
|
public void mo1912a(StaticLayout.Builder builder, TextView textView) {
|
|
}
|
|
|
|
/* renamed from: b */
|
|
public boolean mo1911b(TextView textView) {
|
|
return ((Boolean) C1174p1.m1930m(textView, "getHorizontallyScrolling", Boolean.FALSE)).booleanValue();
|
|
}
|
|
}
|
|
|
|
public C1174p1(TextView textView) {
|
|
this.f2870i = textView;
|
|
this.f2871j = textView.getContext();
|
|
int i = Build.VERSION.SDK_INT;
|
|
this.f2872k = i >= 29 ? new C1179e() : i >= 23 ? new C1178d() : new C1180f();
|
|
}
|
|
|
|
/* renamed from: k */
|
|
public static Method m1932k(String str) {
|
|
try {
|
|
Method method = f2860m.get(str);
|
|
if (method == null && (method = TextView.class.getDeclaredMethod(str, new Class[0])) != null) {
|
|
method.setAccessible(true);
|
|
f2860m.put(str, method);
|
|
}
|
|
return method;
|
|
} catch (Exception e) {
|
|
Log.w("ACTVAutoSizeHelper", "Failed to retrieve TextView#" + str + "() method", e);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/* renamed from: m */
|
|
public static <T> T m1930m(Object obj, String str, T t) {
|
|
try {
|
|
return (T) m1932k(str).invoke(obj, new Object[0]);
|
|
} catch (Exception e) {
|
|
Log.w("ACTVAutoSizeHelper", "Failed to invoke TextView#" + str + "() method", e);
|
|
return t;
|
|
}
|
|
}
|
|
|
|
/* renamed from: a */
|
|
public void m1942a() {
|
|
if (m1929n()) {
|
|
if (this.f2863b) {
|
|
if (this.f2870i.getMeasuredHeight() <= 0 || this.f2870i.getMeasuredWidth() <= 0) {
|
|
return;
|
|
}
|
|
int measuredWidth = this.f2872k.mo1911b(this.f2870i) ? 1048576 : (this.f2870i.getMeasuredWidth() - this.f2870i.getTotalPaddingLeft()) - this.f2870i.getTotalPaddingRight();
|
|
int height = (this.f2870i.getHeight() - this.f2870i.getCompoundPaddingBottom()) - this.f2870i.getCompoundPaddingTop();
|
|
if (measuredWidth <= 0 || height <= 0) {
|
|
return;
|
|
}
|
|
RectF rectF = f2859l;
|
|
synchronized (rectF) {
|
|
rectF.setEmpty();
|
|
rectF.right = measuredWidth;
|
|
rectF.bottom = height;
|
|
float m1938e = m1938e(rectF);
|
|
if (m1938e != this.f2870i.getTextSize()) {
|
|
m1923t(0, m1938e);
|
|
}
|
|
}
|
|
}
|
|
this.f2863b = true;
|
|
}
|
|
}
|
|
|
|
/* renamed from: b */
|
|
public final int[] m1941b(int[] iArr) {
|
|
int length = iArr.length;
|
|
if (length == 0) {
|
|
return iArr;
|
|
}
|
|
Arrays.sort(iArr);
|
|
ArrayList arrayList = new ArrayList();
|
|
for (int i : iArr) {
|
|
if (i > 0 && Collections.binarySearch(arrayList, Integer.valueOf(i)) < 0) {
|
|
arrayList.add(Integer.valueOf(i));
|
|
}
|
|
}
|
|
if (length == arrayList.size()) {
|
|
return iArr;
|
|
}
|
|
int size = arrayList.size();
|
|
int[] iArr2 = new int[size];
|
|
for (int i2 = 0; i2 < size; i2++) {
|
|
iArr2[i2] = ((Integer) arrayList.get(i2)).intValue();
|
|
}
|
|
return iArr2;
|
|
}
|
|
|
|
/* renamed from: c */
|
|
public final void m1940c() {
|
|
this.f2862a = 0;
|
|
this.f2865d = -1.0f;
|
|
this.f2866e = -1.0f;
|
|
this.f2864c = -1.0f;
|
|
this.f2867f = new int[0];
|
|
this.f2863b = false;
|
|
}
|
|
|
|
/* renamed from: d */
|
|
public StaticLayout m1939d(CharSequence charSequence, Layout.Alignment alignment, int i, int i2) {
|
|
return Build.VERSION.SDK_INT >= 23 ? C1177c.m1913a(charSequence, alignment, i, i2, this.f2870i, this.f2869h, this.f2872k) : C1175a.m1916a(charSequence, alignment, i, this.f2870i, this.f2869h);
|
|
}
|
|
|
|
/* renamed from: e */
|
|
public final int m1938e(RectF rectF) {
|
|
int length = this.f2867f.length;
|
|
if (length != 0) {
|
|
int i = 1;
|
|
int i2 = length - 1;
|
|
int i3 = 0;
|
|
while (i <= i2) {
|
|
int i4 = (i + i2) / 2;
|
|
if (m1919x(this.f2867f[i4], rectF)) {
|
|
int i5 = i4 + 1;
|
|
i3 = i;
|
|
i = i5;
|
|
} else {
|
|
i3 = i4 - 1;
|
|
i2 = i3;
|
|
}
|
|
}
|
|
return this.f2867f[i3];
|
|
}
|
|
throw new IllegalStateException("No available text sizes to choose from.");
|
|
}
|
|
|
|
/* renamed from: f */
|
|
public int m1937f() {
|
|
return Math.round(this.f2866e);
|
|
}
|
|
|
|
/* renamed from: g */
|
|
public int m1936g() {
|
|
return Math.round(this.f2865d);
|
|
}
|
|
|
|
/* renamed from: h */
|
|
public int m1935h() {
|
|
return Math.round(this.f2864c);
|
|
}
|
|
|
|
/* renamed from: i */
|
|
public int[] m1934i() {
|
|
return this.f2867f;
|
|
}
|
|
|
|
/* renamed from: j */
|
|
public int m1933j() {
|
|
return this.f2862a;
|
|
}
|
|
|
|
/* renamed from: l */
|
|
public void m1931l(int i) {
|
|
TextPaint textPaint = this.f2869h;
|
|
if (textPaint == null) {
|
|
this.f2869h = new TextPaint();
|
|
} else {
|
|
textPaint.reset();
|
|
}
|
|
this.f2869h.set(this.f2870i.getPaint());
|
|
this.f2869h.setTextSize(i);
|
|
}
|
|
|
|
/* renamed from: n */
|
|
public boolean m1929n() {
|
|
return m1918y() && this.f2862a != 0;
|
|
}
|
|
|
|
/* renamed from: o */
|
|
public void m1928o(AttributeSet attributeSet, int i) {
|
|
int resourceId;
|
|
Context context = this.f2871j;
|
|
int[] iArr = C0494j.f1832g0;
|
|
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, iArr, i, 0);
|
|
TextView textView = this.f2870i;
|
|
C0829h1.m2850M(textView, textView.getContext(), iArr, attributeSet, obtainStyledAttributes, i, 0);
|
|
int i2 = C0494j.f1857l0;
|
|
if (obtainStyledAttributes.hasValue(i2)) {
|
|
this.f2862a = obtainStyledAttributes.getInt(i2, 0);
|
|
}
|
|
int i3 = C0494j.f1852k0;
|
|
float dimension = obtainStyledAttributes.hasValue(i3) ? obtainStyledAttributes.getDimension(i3, -1.0f) : -1.0f;
|
|
int i4 = C0494j.f1842i0;
|
|
float dimension2 = obtainStyledAttributes.hasValue(i4) ? obtainStyledAttributes.getDimension(i4, -1.0f) : -1.0f;
|
|
int i5 = C0494j.f1837h0;
|
|
float dimension3 = obtainStyledAttributes.hasValue(i5) ? obtainStyledAttributes.getDimension(i5, -1.0f) : -1.0f;
|
|
int i6 = C0494j.f1847j0;
|
|
if (obtainStyledAttributes.hasValue(i6) && (resourceId = obtainStyledAttributes.getResourceId(i6, 0)) > 0) {
|
|
TypedArray obtainTypedArray = obtainStyledAttributes.getResources().obtainTypedArray(resourceId);
|
|
m1921v(obtainTypedArray);
|
|
obtainTypedArray.recycle();
|
|
}
|
|
obtainStyledAttributes.recycle();
|
|
if (!m1918y()) {
|
|
this.f2862a = 0;
|
|
} else if (this.f2862a == 1) {
|
|
if (!this.f2868g) {
|
|
DisplayMetrics displayMetrics = this.f2871j.getResources().getDisplayMetrics();
|
|
if (dimension2 == -1.0f) {
|
|
dimension2 = TypedValue.applyDimension(2, 12.0f, displayMetrics);
|
|
}
|
|
if (dimension3 == -1.0f) {
|
|
dimension3 = TypedValue.applyDimension(2, 112.0f, displayMetrics);
|
|
}
|
|
if (dimension == -1.0f) {
|
|
dimension = 1.0f;
|
|
}
|
|
m1917z(dimension2, dimension3, dimension);
|
|
}
|
|
m1922u();
|
|
}
|
|
}
|
|
|
|
/* renamed from: p */
|
|
public void m1927p(int i, int i2, int i3, int i4) {
|
|
if (m1918y()) {
|
|
DisplayMetrics displayMetrics = this.f2871j.getResources().getDisplayMetrics();
|
|
m1917z(TypedValue.applyDimension(i4, i, displayMetrics), TypedValue.applyDimension(i4, i2, displayMetrics), TypedValue.applyDimension(i4, i3, displayMetrics));
|
|
if (m1922u()) {
|
|
m1942a();
|
|
}
|
|
}
|
|
}
|
|
|
|
/* renamed from: q */
|
|
public void m1926q(int[] iArr, int i) {
|
|
if (m1918y()) {
|
|
int length = iArr.length;
|
|
if (length > 0) {
|
|
int[] iArr2 = new int[length];
|
|
if (i == 0) {
|
|
iArr2 = Arrays.copyOf(iArr, length);
|
|
} else {
|
|
DisplayMetrics displayMetrics = this.f2871j.getResources().getDisplayMetrics();
|
|
for (int i2 = 0; i2 < length; i2++) {
|
|
iArr2[i2] = Math.round(TypedValue.applyDimension(i, iArr[i2], displayMetrics));
|
|
}
|
|
}
|
|
this.f2867f = m1941b(iArr2);
|
|
if (!m1920w()) {
|
|
throw new IllegalArgumentException("None of the preset sizes is valid: " + Arrays.toString(iArr));
|
|
}
|
|
} else {
|
|
this.f2868g = false;
|
|
}
|
|
if (m1922u()) {
|
|
m1942a();
|
|
}
|
|
}
|
|
}
|
|
|
|
/* renamed from: r */
|
|
public void m1925r(int i) {
|
|
if (m1918y()) {
|
|
if (i == 0) {
|
|
m1940c();
|
|
} else if (i != 1) {
|
|
throw new IllegalArgumentException("Unknown auto-size text type: " + i);
|
|
} else {
|
|
DisplayMetrics displayMetrics = this.f2871j.getResources().getDisplayMetrics();
|
|
m1917z(TypedValue.applyDimension(2, 12.0f, displayMetrics), TypedValue.applyDimension(2, 112.0f, displayMetrics), 1.0f);
|
|
if (m1922u()) {
|
|
m1942a();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/* renamed from: s */
|
|
public final void m1924s(float f) {
|
|
if (f != this.f2870i.getPaint().getTextSize()) {
|
|
this.f2870i.getPaint().setTextSize(f);
|
|
boolean m1914a = Build.VERSION.SDK_INT >= 18 ? C1176b.m1914a(this.f2870i) : false;
|
|
if (this.f2870i.getLayout() != null) {
|
|
this.f2863b = false;
|
|
try {
|
|
Method m1932k = m1932k("nullLayouts");
|
|
if (m1932k != null) {
|
|
m1932k.invoke(this.f2870i, new Object[0]);
|
|
}
|
|
} catch (Exception e) {
|
|
Log.w("ACTVAutoSizeHelper", "Failed to invoke TextView#nullLayouts() method", e);
|
|
}
|
|
if (m1914a) {
|
|
this.f2870i.forceLayout();
|
|
} else {
|
|
this.f2870i.requestLayout();
|
|
}
|
|
this.f2870i.invalidate();
|
|
}
|
|
}
|
|
}
|
|
|
|
/* renamed from: t */
|
|
public void m1923t(int i, float f) {
|
|
Context context = this.f2871j;
|
|
m1924s(TypedValue.applyDimension(i, f, (context == null ? Resources.getSystem() : context.getResources()).getDisplayMetrics()));
|
|
}
|
|
|
|
/* renamed from: u */
|
|
public final boolean m1922u() {
|
|
if (m1918y() && this.f2862a == 1) {
|
|
if (!this.f2868g || this.f2867f.length == 0) {
|
|
int floor = ((int) Math.floor((this.f2866e - this.f2865d) / this.f2864c)) + 1;
|
|
int[] iArr = new int[floor];
|
|
for (int i = 0; i < floor; i++) {
|
|
iArr[i] = Math.round(this.f2865d + (i * this.f2864c));
|
|
}
|
|
this.f2867f = m1941b(iArr);
|
|
}
|
|
this.f2863b = true;
|
|
} else {
|
|
this.f2863b = false;
|
|
}
|
|
return this.f2863b;
|
|
}
|
|
|
|
/* renamed from: v */
|
|
public final void m1921v(TypedArray typedArray) {
|
|
int length = typedArray.length();
|
|
int[] iArr = new int[length];
|
|
if (length > 0) {
|
|
for (int i = 0; i < length; i++) {
|
|
iArr[i] = typedArray.getDimensionPixelSize(i, -1);
|
|
}
|
|
this.f2867f = m1941b(iArr);
|
|
m1920w();
|
|
}
|
|
}
|
|
|
|
/* renamed from: w */
|
|
public final boolean m1920w() {
|
|
int[] iArr = this.f2867f;
|
|
int length = iArr.length;
|
|
boolean z = length > 0;
|
|
this.f2868g = z;
|
|
if (z) {
|
|
this.f2862a = 1;
|
|
this.f2865d = iArr[0];
|
|
this.f2866e = iArr[length - 1];
|
|
this.f2864c = -1.0f;
|
|
}
|
|
return z;
|
|
}
|
|
|
|
/* renamed from: x */
|
|
public final boolean m1919x(int i, RectF rectF) {
|
|
CharSequence transformation;
|
|
CharSequence text = this.f2870i.getText();
|
|
TransformationMethod transformationMethod = this.f2870i.getTransformationMethod();
|
|
if (transformationMethod != null && (transformation = transformationMethod.getTransformation(text, this.f2870i)) != null) {
|
|
text = transformation;
|
|
}
|
|
int m1915b = C1175a.m1915b(this.f2870i);
|
|
m1931l(i);
|
|
StaticLayout m1939d = m1939d(text, (Layout.Alignment) m1930m(this.f2870i, "getLayoutAlignment", Layout.Alignment.ALIGN_NORMAL), Math.round(rectF.right), m1915b);
|
|
return (m1915b == -1 || (m1939d.getLineCount() <= m1915b && m1939d.getLineEnd(m1939d.getLineCount() - 1) == text.length())) && ((float) m1939d.getHeight()) <= rectF.bottom;
|
|
}
|
|
|
|
/* renamed from: y */
|
|
public final boolean m1918y() {
|
|
return !(this.f2870i instanceof C1123k);
|
|
}
|
|
|
|
/* renamed from: z */
|
|
public final void m1917z(float f, float f2, float f3) {
|
|
if (f <= 0.0f) {
|
|
throw new IllegalArgumentException("Minimum auto-size text size (" + f + "px) is less or equal to (0px)");
|
|
} else if (f2 <= f) {
|
|
throw new IllegalArgumentException("Maximum auto-size text size (" + f2 + "px) is less or equal to minimum auto-size text size (" + f + "px)");
|
|
} else if (f3 <= 0.0f) {
|
|
throw new IllegalArgumentException("The auto-size step granularity (" + f3 + "px) is less or equal to (0px)");
|
|
} else {
|
|
this.f2862a = 1;
|
|
this.f2865d = f;
|
|
this.f2866e = f2;
|
|
this.f2864c = f3;
|
|
this.f2868g = false;
|
|
}
|
|
}
|
|
} |