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;

/* JADX INFO: compiled from: PrecomputedTextCompat.java */
/* JADX INFO: loaded from: classes.dex */
public class c implements Spannable {

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    private final Spannable f1809e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private final a f1810f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    private final PrecomputedText f1811g;

    public a a() {
        return this.f1810f;
    }

    public PrecomputedText b() {
        Spannable spannable = this.f1809e;
        if (spannable instanceof PrecomputedText) {
            return (PrecomputedText) spannable;
        }
        return null;
    }

    @Override // java.lang.CharSequence
    public char charAt(int i3) {
        return this.f1809e.charAt(i3);
    }

    @Override // android.text.Spanned
    public int getSpanEnd(Object obj) {
        return this.f1809e.getSpanEnd(obj);
    }

    @Override // android.text.Spanned
    public int getSpanFlags(Object obj) {
        return this.f1809e.getSpanFlags(obj);
    }

    @Override // android.text.Spanned
    public int getSpanStart(Object obj) {
        return this.f1809e.getSpanStart(obj);
    }

    @Override // android.text.Spanned
    public <T> T[] getSpans(int i3, int i4, Class<T> cls) {
        return Build.VERSION.SDK_INT >= 29 ? (T[]) this.f1811g.getSpans(i3, i4, cls) : (T[]) this.f1809e.getSpans(i3, i4, cls);
    }

    @Override // java.lang.CharSequence
    public int length() {
        return this.f1809e.length();
    }

    @Override // android.text.Spanned
    public int nextSpanTransition(int i3, int i4, Class cls) {
        return this.f1809e.nextSpanTransition(i3, i4, 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 >= 29) {
            this.f1811g.removeSpan(obj);
        } else {
            this.f1809e.removeSpan(obj);
        }
    }

    @Override // android.text.Spannable
    public void setSpan(Object obj, int i3, int i4, int i5) {
        if (obj instanceof MetricAffectingSpan) {
            throw new IllegalArgumentException("MetricAffectingSpan can not be set to PrecomputedText.");
        }
        if (Build.VERSION.SDK_INT >= 29) {
            this.f1811g.setSpan(obj, i3, i4, i5);
        } else {
            this.f1809e.setSpan(obj, i3, i4, i5);
        }
    }

    @Override // java.lang.CharSequence
    public CharSequence subSequence(int i3, int i4) {
        return this.f1809e.subSequence(i3, i4);
    }

    @Override // java.lang.CharSequence
    public String toString() {
        return this.f1809e.toString();
    }

    /* JADX INFO: compiled from: PrecomputedTextCompat.java */
    public static final class a {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        private final TextPaint f1812a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        private final TextDirectionHeuristic f1813b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        private final int f1814c;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        private final int f1815d;

        /* JADX INFO: renamed from: androidx.core.text.c$a$a, reason: collision with other inner class name */
        /* JADX INFO: compiled from: PrecomputedTextCompat.java */
        public static class C0018a {

            /* JADX INFO: renamed from: a, reason: collision with root package name */
            private final TextPaint f1816a;

            /* JADX INFO: renamed from: b, reason: collision with root package name */
            private TextDirectionHeuristic f1817b;

            /* JADX INFO: renamed from: c, reason: collision with root package name */
            private int f1818c;

            /* JADX INFO: renamed from: d, reason: collision with root package name */
            private int f1819d;

            public C0018a(TextPaint textPaint) {
                this.f1816a = textPaint;
                int i3 = Build.VERSION.SDK_INT;
                if (i3 >= 23) {
                    this.f1818c = 1;
                    this.f1819d = 1;
                } else {
                    this.f1819d = 0;
                    this.f1818c = 0;
                }
                if (i3 >= 18) {
                    this.f1817b = TextDirectionHeuristics.FIRSTSTRONG_LTR;
                } else {
                    this.f1817b = null;
                }
            }

            public a a() {
                return new a(this.f1816a, this.f1817b, this.f1818c, this.f1819d);
            }

            public C0018a b(int i3) {
                this.f1818c = i3;
                return this;
            }

            public C0018a c(int i3) {
                this.f1819d = i3;
                return this;
            }

            public C0018a d(TextDirectionHeuristic textDirectionHeuristic) {
                this.f1817b = textDirectionHeuristic;
                return this;
            }
        }

        a(TextPaint textPaint, TextDirectionHeuristic textDirectionHeuristic, int i3, int i4) {
            if (Build.VERSION.SDK_INT >= 29) {
                new PrecomputedText.Params.Builder(textPaint).setBreakStrategy(i3).setHyphenationFrequency(i4).setTextDirection(textDirectionHeuristic).build();
            }
            this.f1812a = textPaint;
            this.f1813b = textDirectionHeuristic;
            this.f1814c = i3;
            this.f1815d = i4;
        }

        public boolean a(a aVar) {
            int i3 = Build.VERSION.SDK_INT;
            if ((i3 >= 23 && (this.f1814c != aVar.b() || this.f1815d != aVar.c())) || this.f1812a.getTextSize() != aVar.e().getTextSize() || this.f1812a.getTextScaleX() != aVar.e().getTextScaleX() || this.f1812a.getTextSkewX() != aVar.e().getTextSkewX()) {
                return false;
            }
            if ((i3 >= 21 && (this.f1812a.getLetterSpacing() != aVar.e().getLetterSpacing() || !TextUtils.equals(this.f1812a.getFontFeatureSettings(), aVar.e().getFontFeatureSettings()))) || this.f1812a.getFlags() != aVar.e().getFlags()) {
                return false;
            }
            if (i3 >= 24) {
                if (!this.f1812a.getTextLocales().equals(aVar.e().getTextLocales())) {
                    return false;
                }
            } else if (i3 >= 17 && !this.f1812a.getTextLocale().equals(aVar.e().getTextLocale())) {
                return false;
            }
            return this.f1812a.getTypeface() == null ? aVar.e().getTypeface() == null : this.f1812a.getTypeface().equals(aVar.e().getTypeface());
        }

        public int b() {
            return this.f1814c;
        }

        public int c() {
            return this.f1815d;
        }

        public TextDirectionHeuristic d() {
            return this.f1813b;
        }

        public TextPaint e() {
            return this.f1812a;
        }

        public boolean equals(Object obj) {
            if (obj == this) {
                return true;
            }
            if (!(obj instanceof a)) {
                return false;
            }
            a aVar = (a) obj;
            if (a(aVar)) {
                return Build.VERSION.SDK_INT < 18 || this.f1813b == aVar.d();
            }
            return false;
        }

        public int hashCode() {
            int i3 = Build.VERSION.SDK_INT;
            return i3 >= 24 ? androidx.core.util.c.b(Float.valueOf(this.f1812a.getTextSize()), Float.valueOf(this.f1812a.getTextScaleX()), Float.valueOf(this.f1812a.getTextSkewX()), Float.valueOf(this.f1812a.getLetterSpacing()), Integer.valueOf(this.f1812a.getFlags()), this.f1812a.getTextLocales(), this.f1812a.getTypeface(), Boolean.valueOf(this.f1812a.isElegantTextHeight()), this.f1813b, Integer.valueOf(this.f1814c), Integer.valueOf(this.f1815d)) : i3 >= 21 ? androidx.core.util.c.b(Float.valueOf(this.f1812a.getTextSize()), Float.valueOf(this.f1812a.getTextScaleX()), Float.valueOf(this.f1812a.getTextSkewX()), Float.valueOf(this.f1812a.getLetterSpacing()), Integer.valueOf(this.f1812a.getFlags()), this.f1812a.getTextLocale(), this.f1812a.getTypeface(), Boolean.valueOf(this.f1812a.isElegantTextHeight()), this.f1813b, Integer.valueOf(this.f1814c), Integer.valueOf(this.f1815d)) : i3 >= 18 ? androidx.core.util.c.b(Float.valueOf(this.f1812a.getTextSize()), Float.valueOf(this.f1812a.getTextScaleX()), Float.valueOf(this.f1812a.getTextSkewX()), Integer.valueOf(this.f1812a.getFlags()), this.f1812a.getTextLocale(), this.f1812a.getTypeface(), this.f1813b, Integer.valueOf(this.f1814c), Integer.valueOf(this.f1815d)) : i3 >= 17 ? androidx.core.util.c.b(Float.valueOf(this.f1812a.getTextSize()), Float.valueOf(this.f1812a.getTextScaleX()), Float.valueOf(this.f1812a.getTextSkewX()), Integer.valueOf(this.f1812a.getFlags()), this.f1812a.getTextLocale(), this.f1812a.getTypeface(), this.f1813b, Integer.valueOf(this.f1814c), Integer.valueOf(this.f1815d)) : androidx.core.util.c.b(Float.valueOf(this.f1812a.getTextSize()), Float.valueOf(this.f1812a.getTextScaleX()), Float.valueOf(this.f1812a.getTextSkewX()), Integer.valueOf(this.f1812a.getFlags()), this.f1812a.getTypeface(), this.f1813b, Integer.valueOf(this.f1814c), Integer.valueOf(this.f1815d));
        }

        public String toString() {
            StringBuilder sb = new StringBuilder("{");
            sb.append("textSize=" + this.f1812a.getTextSize());
            sb.append(", textScaleX=" + this.f1812a.getTextScaleX());
            sb.append(", textSkewX=" + this.f1812a.getTextSkewX());
            int i3 = Build.VERSION.SDK_INT;
            if (i3 >= 21) {
                sb.append(", letterSpacing=" + this.f1812a.getLetterSpacing());
                sb.append(", elegantTextHeight=" + this.f1812a.isElegantTextHeight());
            }
            if (i3 >= 24) {
                sb.append(", textLocale=" + this.f1812a.getTextLocales());
            } else if (i3 >= 17) {
                sb.append(", textLocale=" + this.f1812a.getTextLocale());
            }
            sb.append(", typeface=" + this.f1812a.getTypeface());
            if (i3 >= 26) {
                sb.append(", variationSettings=" + this.f1812a.getFontVariationSettings());
            }
            sb.append(", textDir=" + this.f1813b);
            sb.append(", breakStrategy=" + this.f1814c);
            sb.append(", hyphenationFrequency=" + this.f1815d);
            sb.append("}");
            return sb.toString();
        }

        public a(PrecomputedText.Params params) {
            this.f1812a = params.getTextPaint();
            this.f1813b = params.getTextDirection();
            this.f1814c = params.getBreakStrategy();
            this.f1815d = params.getHyphenationFrequency();
        }
    }
}
