package c.f.j;

import android.annotation.SuppressLint;
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 c.f.k.b;

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

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

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

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

    public C0030a a() {
        return this.f1436f;
    }

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

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

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

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

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

    @Override // android.text.Spanned
    @SuppressLint({"NewApi"})
    public <T> T[] getSpans(int i2, int i3, Class<T> cls) {
        return Build.VERSION.SDK_INT >= 29 ? (T[]) this.f1437g.getSpans(i2, i3, cls) : (T[]) this.f1435b.getSpans(i2, i3, cls);
    }

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

    @Override // android.text.Spanned
    public int nextSpanTransition(int i2, int i3, Class cls) {
        return this.f1435b.nextSpanTransition(i2, i3, cls);
    }

    @Override // android.text.Spannable
    @SuppressLint({"NewApi"})
    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.f1437g.removeSpan(obj);
        } else {
            this.f1435b.removeSpan(obj);
        }
    }

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

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

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

    /* JADX INFO: renamed from: c.f.j.a$a, reason: collision with other inner class name */
    /* JADX INFO: compiled from: PrecomputedTextCompat.java */
    public static final class C0030a {
        private final TextPaint a;

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

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

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

        /* JADX INFO: renamed from: c.f.j.a$a$a, reason: collision with other inner class name */
        /* JADX INFO: compiled from: PrecomputedTextCompat.java */
        public static class C0031a {
            private final TextPaint a;

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

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

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

            public C0031a(TextPaint textPaint) {
                this.a = textPaint;
                if (Build.VERSION.SDK_INT >= 23) {
                    this.f1442c = 1;
                    this.f1443d = 1;
                } else {
                    this.f1443d = 0;
                    this.f1442c = 0;
                }
                if (Build.VERSION.SDK_INT >= 18) {
                    this.f1441b = TextDirectionHeuristics.FIRSTSTRONG_LTR;
                } else {
                    this.f1441b = null;
                }
            }

            public C0030a a() {
                return new C0030a(this.a, this.f1441b, this.f1442c, this.f1443d);
            }

            public C0031a b(int i2) {
                this.f1442c = i2;
                return this;
            }

            public C0031a c(int i2) {
                this.f1443d = i2;
                return this;
            }

            public C0031a d(TextDirectionHeuristic textDirectionHeuristic) {
                this.f1441b = textDirectionHeuristic;
                return this;
            }
        }

        @SuppressLint({"NewApi"})
        C0030a(TextPaint textPaint, TextDirectionHeuristic textDirectionHeuristic, int i2, int i3) {
            if (Build.VERSION.SDK_INT >= 29) {
                new PrecomputedText.Params.Builder(textPaint).setBreakStrategy(i2).setHyphenationFrequency(i3).setTextDirection(textDirectionHeuristic).build();
            }
            this.a = textPaint;
            this.f1438b = textDirectionHeuristic;
            this.f1439c = i2;
            this.f1440d = i3;
        }

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

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

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

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

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

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

        public int hashCode() {
            int i2 = Build.VERSION.SDK_INT;
            return i2 >= 24 ? b.b(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.f1438b, Integer.valueOf(this.f1439c), Integer.valueOf(this.f1440d)) : i2 >= 21 ? b.b(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.f1438b, Integer.valueOf(this.f1439c), Integer.valueOf(this.f1440d)) : i2 >= 18 ? b.b(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.f1438b, Integer.valueOf(this.f1439c), Integer.valueOf(this.f1440d)) : i2 >= 17 ? b.b(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.f1438b, Integer.valueOf(this.f1439c), Integer.valueOf(this.f1440d)) : b.b(Float.valueOf(this.a.getTextSize()), Float.valueOf(this.a.getTextScaleX()), Float.valueOf(this.a.getTextSkewX()), Integer.valueOf(this.a.getFlags()), this.a.getTypeface(), this.f1438b, Integer.valueOf(this.f1439c), Integer.valueOf(this.f1440d));
        }

        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 i2 = Build.VERSION.SDK_INT;
            if (i2 >= 24) {
                sb.append(", textLocale=" + this.a.getTextLocales());
            } else if (i2 >= 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.f1438b);
            sb.append(", breakStrategy=" + this.f1439c);
            sb.append(", hyphenationFrequency=" + this.f1440d);
            sb.append("}");
            return sb.toString();
        }

        public C0030a(PrecomputedText.Params params) {
            this.a = params.getTextPaint();
            this.f1438b = params.getTextDirection();
            this.f1439c = params.getBreakStrategy();
            this.f1440d = params.getHyphenationFrequency();
            int i2 = Build.VERSION.SDK_INT;
        }
    }
}
