256 lines
9.8 KiB
Java
256 lines
9.8 KiB
Java
package androidx.core.text;
|
|
|
|
import android.os.Build;
|
|
import android.text.PrecomputedText;
|
|
import android.text.Spannable;
|
|
import android.text.TextDirectionHeuristic;
|
|
import android.text.TextDirectionHeuristics;
|
|
import android.text.TextPaint;
|
|
import android.text.TextUtils;
|
|
import android.text.style.MetricAffectingSpan;
|
|
import androidx.core.util.ObjectsCompat;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class PrecomputedTextCompat implements Spannable {
|
|
private final Spannable a;
|
|
private final Params b;
|
|
private final PrecomputedText c;
|
|
|
|
public Params a() {
|
|
return this.b;
|
|
}
|
|
|
|
public PrecomputedText b() {
|
|
Spannable spannable = this.a;
|
|
if (spannable instanceof PrecomputedText) {
|
|
return (PrecomputedText) spannable;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override // java.lang.CharSequence
|
|
public char charAt(int i) {
|
|
return this.a.charAt(i);
|
|
}
|
|
|
|
@Override // android.text.Spanned
|
|
public int getSpanEnd(Object obj) {
|
|
return this.a.getSpanEnd(obj);
|
|
}
|
|
|
|
@Override // android.text.Spanned
|
|
public int getSpanFlags(Object obj) {
|
|
return this.a.getSpanFlags(obj);
|
|
}
|
|
|
|
@Override // android.text.Spanned
|
|
public int getSpanStart(Object obj) {
|
|
return this.a.getSpanStart(obj);
|
|
}
|
|
|
|
@Override // android.text.Spanned
|
|
public <T> T[] getSpans(int i, int i2, Class<T> cls) {
|
|
return Build.VERSION.SDK_INT >= 28 ? (T[]) this.c.getSpans(i, i2, cls) : (T[]) this.a.getSpans(i, i2, cls);
|
|
}
|
|
|
|
@Override // java.lang.CharSequence
|
|
public int length() {
|
|
return this.a.length();
|
|
}
|
|
|
|
@Override // android.text.Spanned
|
|
public int nextSpanTransition(int i, int i2, Class cls) {
|
|
return this.a.nextSpanTransition(i, i2, cls);
|
|
}
|
|
|
|
@Override // android.text.Spannable
|
|
public void removeSpan(Object obj) {
|
|
if (obj instanceof MetricAffectingSpan) {
|
|
throw new IllegalArgumentException("MetricAffectingSpan can not be removed from PrecomputedText.");
|
|
}
|
|
if (Build.VERSION.SDK_INT >= 28) {
|
|
this.c.removeSpan(obj);
|
|
} else {
|
|
this.a.removeSpan(obj);
|
|
}
|
|
}
|
|
|
|
@Override // android.text.Spannable
|
|
public void setSpan(Object obj, int i, int i2, int i3) {
|
|
if (obj instanceof MetricAffectingSpan) {
|
|
throw new IllegalArgumentException("MetricAffectingSpan can not be set to PrecomputedText.");
|
|
}
|
|
if (Build.VERSION.SDK_INT >= 28) {
|
|
this.c.setSpan(obj, i, i2, i3);
|
|
} else {
|
|
this.a.setSpan(obj, i, i2, i3);
|
|
}
|
|
}
|
|
|
|
@Override // java.lang.CharSequence
|
|
public CharSequence subSequence(int i, int i2) {
|
|
return this.a.subSequence(i, i2);
|
|
}
|
|
|
|
@Override // java.lang.CharSequence
|
|
public String toString() {
|
|
return this.a.toString();
|
|
}
|
|
|
|
public static final class Params {
|
|
private final TextPaint a;
|
|
private final TextDirectionHeuristic b;
|
|
private final int c;
|
|
private final int d;
|
|
final PrecomputedText.Params e;
|
|
|
|
public static class Builder {
|
|
private final TextPaint a;
|
|
private TextDirectionHeuristic b;
|
|
private int c;
|
|
private int d;
|
|
|
|
public Builder(TextPaint textPaint) {
|
|
this.a = textPaint;
|
|
if (Build.VERSION.SDK_INT >= 23) {
|
|
this.c = 1;
|
|
this.d = 1;
|
|
} else {
|
|
this.d = 0;
|
|
this.c = 0;
|
|
}
|
|
if (Build.VERSION.SDK_INT >= 18) {
|
|
this.b = TextDirectionHeuristics.FIRSTSTRONG_LTR;
|
|
} else {
|
|
this.b = null;
|
|
}
|
|
}
|
|
|
|
public Builder a(int i) {
|
|
this.c = i;
|
|
return this;
|
|
}
|
|
|
|
public Builder b(int i) {
|
|
this.d = i;
|
|
return this;
|
|
}
|
|
|
|
public Builder a(TextDirectionHeuristic textDirectionHeuristic) {
|
|
this.b = textDirectionHeuristic;
|
|
return this;
|
|
}
|
|
|
|
public Params a() {
|
|
return new Params(this.a, this.b, this.c, this.d);
|
|
}
|
|
}
|
|
|
|
Params(TextPaint textPaint, TextDirectionHeuristic textDirectionHeuristic, int i, int i2) {
|
|
if (Build.VERSION.SDK_INT >= 28) {
|
|
this.e = new PrecomputedText.Params.Builder(textPaint).setBreakStrategy(i).setHyphenationFrequency(i2).setTextDirection(textDirectionHeuristic).build();
|
|
} else {
|
|
this.e = null;
|
|
}
|
|
this.a = textPaint;
|
|
this.b = textDirectionHeuristic;
|
|
this.c = i;
|
|
this.d = i2;
|
|
}
|
|
|
|
public int a() {
|
|
return this.c;
|
|
}
|
|
|
|
public int b() {
|
|
return this.d;
|
|
}
|
|
|
|
public TextDirectionHeuristic c() {
|
|
return this.b;
|
|
}
|
|
|
|
public TextPaint d() {
|
|
return this.a;
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (obj == this) {
|
|
return true;
|
|
}
|
|
if (obj == null || !(obj instanceof Params)) {
|
|
return false;
|
|
}
|
|
Params params = (Params) obj;
|
|
PrecomputedText.Params params2 = this.e;
|
|
if (params2 != null) {
|
|
return params2.equals(params.e);
|
|
}
|
|
if (Build.VERSION.SDK_INT >= 23 && (this.c != params.a() || this.d != params.b())) {
|
|
return false;
|
|
}
|
|
if ((Build.VERSION.SDK_INT >= 18 && this.b != params.c()) || this.a.getTextSize() != params.d().getTextSize() || this.a.getTextScaleX() != params.d().getTextScaleX() || this.a.getTextSkewX() != params.d().getTextSkewX()) {
|
|
return false;
|
|
}
|
|
if ((Build.VERSION.SDK_INT >= 21 && (this.a.getLetterSpacing() != params.d().getLetterSpacing() || !TextUtils.equals(this.a.getFontFeatureSettings(), params.d().getFontFeatureSettings()))) || this.a.getFlags() != params.d().getFlags()) {
|
|
return false;
|
|
}
|
|
int i = Build.VERSION.SDK_INT;
|
|
if (i >= 24) {
|
|
if (!this.a.getTextLocales().equals(params.d().getTextLocales())) {
|
|
return false;
|
|
}
|
|
} else if (i >= 17 && !this.a.getTextLocale().equals(params.d().getTextLocale())) {
|
|
return false;
|
|
}
|
|
if (this.a.getTypeface() == null) {
|
|
if (params.d().getTypeface() != null) {
|
|
return false;
|
|
}
|
|
} else if (!this.a.getTypeface().equals(params.d().getTypeface())) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public int hashCode() {
|
|
int i = Build.VERSION.SDK_INT;
|
|
return i >= 24 ? ObjectsCompat.a(Float.valueOf(this.a.getTextSize()), Float.valueOf(this.a.getTextScaleX()), Float.valueOf(this.a.getTextSkewX()), Float.valueOf(this.a.getLetterSpacing()), Integer.valueOf(this.a.getFlags()), this.a.getTextLocales(), this.a.getTypeface(), Boolean.valueOf(this.a.isElegantTextHeight()), this.b, Integer.valueOf(this.c), Integer.valueOf(this.d)) : i >= 21 ? ObjectsCompat.a(Float.valueOf(this.a.getTextSize()), Float.valueOf(this.a.getTextScaleX()), Float.valueOf(this.a.getTextSkewX()), Float.valueOf(this.a.getLetterSpacing()), Integer.valueOf(this.a.getFlags()), this.a.getTextLocale(), this.a.getTypeface(), Boolean.valueOf(this.a.isElegantTextHeight()), this.b, Integer.valueOf(this.c), Integer.valueOf(this.d)) : i >= 18 ? ObjectsCompat.a(Float.valueOf(this.a.getTextSize()), Float.valueOf(this.a.getTextScaleX()), Float.valueOf(this.a.getTextSkewX()), Integer.valueOf(this.a.getFlags()), this.a.getTextLocale(), this.a.getTypeface(), this.b, Integer.valueOf(this.c), Integer.valueOf(this.d)) : i >= 17 ? ObjectsCompat.a(Float.valueOf(this.a.getTextSize()), Float.valueOf(this.a.getTextScaleX()), Float.valueOf(this.a.getTextSkewX()), Integer.valueOf(this.a.getFlags()), this.a.getTextLocale(), this.a.getTypeface(), this.b, Integer.valueOf(this.c), Integer.valueOf(this.d)) : ObjectsCompat.a(Float.valueOf(this.a.getTextSize()), Float.valueOf(this.a.getTextScaleX()), Float.valueOf(this.a.getTextSkewX()), Integer.valueOf(this.a.getFlags()), this.a.getTypeface(), this.b, Integer.valueOf(this.c), Integer.valueOf(this.d));
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder sb = new StringBuilder("{");
|
|
sb.append("textSize=" + this.a.getTextSize());
|
|
sb.append(", textScaleX=" + this.a.getTextScaleX());
|
|
sb.append(", textSkewX=" + this.a.getTextSkewX());
|
|
if (Build.VERSION.SDK_INT >= 21) {
|
|
sb.append(", letterSpacing=" + this.a.getLetterSpacing());
|
|
sb.append(", elegantTextHeight=" + this.a.isElegantTextHeight());
|
|
}
|
|
int i = Build.VERSION.SDK_INT;
|
|
if (i >= 24) {
|
|
sb.append(", textLocale=" + this.a.getTextLocales());
|
|
} else if (i >= 17) {
|
|
sb.append(", textLocale=" + this.a.getTextLocale());
|
|
}
|
|
sb.append(", typeface=" + this.a.getTypeface());
|
|
if (Build.VERSION.SDK_INT >= 26) {
|
|
sb.append(", variationSettings=" + this.a.getFontVariationSettings());
|
|
}
|
|
sb.append(", textDir=" + this.b);
|
|
sb.append(", breakStrategy=" + this.c);
|
|
sb.append(", hyphenationFrequency=" + this.d);
|
|
sb.append("}");
|
|
return sb.toString();
|
|
}
|
|
|
|
public Params(PrecomputedText.Params params) {
|
|
this.a = params.getTextPaint();
|
|
this.b = params.getTextDirection();
|
|
this.c = params.getBreakStrategy();
|
|
this.d = params.getHyphenationFrequency();
|
|
this.e = params;
|
|
}
|
|
}
|
|
}
|