package a.c.g;

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 a implements Spannable {

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private static final Object f243c = new Object();

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

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

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

    public C0010a a() {
        return this.f245e;
    }

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

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

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

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

    @Override // android.text.Spanned
    public int getSpanStart(Object obj) {
        return this.f244d.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.f246f.getSpans(i, i2, cls) : (T[]) this.f244d.getSpans(i, i2, cls);
    }

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

    @Override // android.text.Spanned
    public int nextSpanTransition(int i, int i2, Class cls) {
        return this.f244d.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.f246f.removeSpan(obj);
        } else {
            this.f244d.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.f246f.setSpan(obj, i, i2, i3);
        } else {
            this.f244d.setSpan(obj, i, i2, i3);
        }
    }

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

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

    /* JADX INFO: renamed from: a.c.g.a$a, reason: collision with other inner class name */
    /* JADX INFO: compiled from: PrecomputedTextCompat.java */
    public static final class C0010a {

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

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

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

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

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        final PrecomputedText.Params f251e;

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

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

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

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

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

            public C0011a(TextPaint textPaint) {
                this.f252a = textPaint;
                int i = Build.VERSION.SDK_INT;
                if (i >= 23) {
                    this.f254c = 1;
                    this.f255d = 1;
                } else {
                    this.f255d = 0;
                    this.f254c = 0;
                }
                if (i >= 18) {
                    this.f253b = TextDirectionHeuristics.FIRSTSTRONG_LTR;
                } else {
                    this.f253b = null;
                }
            }

            public C0010a a() {
                return new C0010a(this.f252a, this.f253b, this.f254c, this.f255d);
            }

            public C0011a b(int i) {
                this.f254c = i;
                return this;
            }

            public C0011a c(int i) {
                this.f255d = i;
                return this;
            }

            public C0011a d(TextDirectionHeuristic textDirectionHeuristic) {
                this.f253b = textDirectionHeuristic;
                return this;
            }
        }

        C0010a(TextPaint textPaint, TextDirectionHeuristic textDirectionHeuristic, int i, int i2) {
            if (Build.VERSION.SDK_INT >= 28) {
                this.f251e = new PrecomputedText.Params.Builder(textPaint).setBreakStrategy(i).setHyphenationFrequency(i2).setTextDirection(textDirectionHeuristic).build();
            } else {
                this.f251e = null;
            }
            this.f247a = textPaint;
            this.f248b = textDirectionHeuristic;
            this.f249c = i;
            this.f250d = i2;
        }

        public int a() {
            return this.f249c;
        }

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

        public TextDirectionHeuristic c() {
            return this.f248b;
        }

        public TextPaint d() {
            return this.f247a;
        }

        public boolean equals(Object obj) {
            if (obj == this) {
                return true;
            }
            if (obj == null || !(obj instanceof C0010a)) {
                return false;
            }
            C0010a c0010a = (C0010a) obj;
            PrecomputedText.Params params = this.f251e;
            if (params != null) {
                return params.equals(c0010a.f251e);
            }
            int i = Build.VERSION.SDK_INT;
            if (i >= 23 && (this.f249c != c0010a.a() || this.f250d != c0010a.b())) {
                return false;
            }
            if ((i >= 18 && this.f248b != c0010a.c()) || this.f247a.getTextSize() != c0010a.d().getTextSize() || this.f247a.getTextScaleX() != c0010a.d().getTextScaleX() || this.f247a.getTextSkewX() != c0010a.d().getTextSkewX()) {
                return false;
            }
            if ((i >= 21 && (this.f247a.getLetterSpacing() != c0010a.d().getLetterSpacing() || !TextUtils.equals(this.f247a.getFontFeatureSettings(), c0010a.d().getFontFeatureSettings()))) || this.f247a.getFlags() != c0010a.d().getFlags()) {
                return false;
            }
            if (i >= 24) {
                if (!this.f247a.getTextLocales().equals(c0010a.d().getTextLocales())) {
                    return false;
                }
            } else if (i >= 17 && !this.f247a.getTextLocale().equals(c0010a.d().getTextLocale())) {
                return false;
            }
            if (this.f247a.getTypeface() == null) {
                if (c0010a.d().getTypeface() != null) {
                    return false;
                }
            } else if (!this.f247a.getTypeface().equals(c0010a.d().getTypeface())) {
                return false;
            }
            return true;
        }

        public int hashCode() {
            int i = Build.VERSION.SDK_INT;
            return i >= 24 ? a.c.h.a.a(Float.valueOf(this.f247a.getTextSize()), Float.valueOf(this.f247a.getTextScaleX()), Float.valueOf(this.f247a.getTextSkewX()), Float.valueOf(this.f247a.getLetterSpacing()), Integer.valueOf(this.f247a.getFlags()), this.f247a.getTextLocales(), this.f247a.getTypeface(), Boolean.valueOf(this.f247a.isElegantTextHeight()), this.f248b, Integer.valueOf(this.f249c), Integer.valueOf(this.f250d)) : i >= 21 ? a.c.h.a.a(Float.valueOf(this.f247a.getTextSize()), Float.valueOf(this.f247a.getTextScaleX()), Float.valueOf(this.f247a.getTextSkewX()), Float.valueOf(this.f247a.getLetterSpacing()), Integer.valueOf(this.f247a.getFlags()), this.f247a.getTextLocale(), this.f247a.getTypeface(), Boolean.valueOf(this.f247a.isElegantTextHeight()), this.f248b, Integer.valueOf(this.f249c), Integer.valueOf(this.f250d)) : i >= 18 ? a.c.h.a.a(Float.valueOf(this.f247a.getTextSize()), Float.valueOf(this.f247a.getTextScaleX()), Float.valueOf(this.f247a.getTextSkewX()), Integer.valueOf(this.f247a.getFlags()), this.f247a.getTextLocale(), this.f247a.getTypeface(), this.f248b, Integer.valueOf(this.f249c), Integer.valueOf(this.f250d)) : i >= 17 ? a.c.h.a.a(Float.valueOf(this.f247a.getTextSize()), Float.valueOf(this.f247a.getTextScaleX()), Float.valueOf(this.f247a.getTextSkewX()), Integer.valueOf(this.f247a.getFlags()), this.f247a.getTextLocale(), this.f247a.getTypeface(), this.f248b, Integer.valueOf(this.f249c), Integer.valueOf(this.f250d)) : a.c.h.a.a(Float.valueOf(this.f247a.getTextSize()), Float.valueOf(this.f247a.getTextScaleX()), Float.valueOf(this.f247a.getTextSkewX()), Integer.valueOf(this.f247a.getFlags()), this.f247a.getTypeface(), this.f248b, Integer.valueOf(this.f249c), Integer.valueOf(this.f250d));
        }

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

        public C0010a(PrecomputedText.Params params) {
            this.f247a = params.getTextPaint();
            this.f248b = params.getTextDirection();
            this.f249c = params.getBreakStrategy();
            this.f250d = params.getHyphenationFrequency();
            this.f251e = params;
        }
    }
}
