package r3;

import android.app.Activity;
import android.content.res.Resources;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
import android.window.SplashScreenView;
import com.google.android.gms.common.api.Api;
import kotlin.jvm.internal.k;
import kotlin.jvm.internal.t;

/* loaded from: classes.dex */
public final class c {

    /* renamed from: b, reason: collision with root package name */
    public static final a f34437b = new a(null);

    /* renamed from: a, reason: collision with root package name */
    private final C0805c f34438a;

    /* loaded from: classes.dex */
    public static final class a {
        private a() {
        }

        public /* synthetic */ a(k kVar) {
            this();
        }

        public final c a(Activity activity) {
            t.g(activity, "<this>");
            c cVar = new c(activity, null);
            cVar.b();
            return cVar;
        }
    }

    /* loaded from: classes.dex */
    private static final class b extends C0805c {

        /* renamed from: h, reason: collision with root package name */
        private boolean f34439h;

        /* renamed from: i, reason: collision with root package name */
        private final ViewGroup.OnHierarchyChangeListener f34440i;

        /* loaded from: classes.dex */
        public static final class a implements ViewGroup.OnHierarchyChangeListener {

            /* renamed from: b, reason: collision with root package name */
            final /* synthetic */ Activity f34442b;

            a(Activity activity) {
                this.f34442b = activity;
            }

            @Override // android.view.ViewGroup.OnHierarchyChangeListener
            public void onChildViewAdded(View view, View view2) {
                if (f.a(view2)) {
                    b bVar = b.this;
                    bVar.e(bVar.d(g.a(view2)));
                    ((ViewGroup) this.f34442b.getWindow().getDecorView()).setOnHierarchyChangeListener(null);
                }
            }

            @Override // android.view.ViewGroup.OnHierarchyChangeListener
            public void onChildViewRemoved(View view, View view2) {
            }
        }

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public b(Activity activity) {
            super(activity);
            t.g(activity, "activity");
            this.f34439h = true;
            this.f34440i = new a(activity);
        }

        @Override // r3.c.C0805c
        public void b() {
            Resources.Theme theme = a().getTheme();
            t.f(theme, "activity.theme");
            c(theme, new TypedValue());
            ((ViewGroup) a().getWindow().getDecorView()).setOnHierarchyChangeListener(this.f34440i);
        }

        public final boolean d(SplashScreenView child) {
            View rootView;
            t.g(child, "child");
            WindowInsets build = new WindowInsets.Builder().build();
            t.f(build, "Builder().build()");
            Rect rect = new Rect(Integer.MIN_VALUE, Integer.MIN_VALUE, Api.BaseClientBuilder.API_PRIORITY_OTHER, Api.BaseClientBuilder.API_PRIORITY_OTHER);
            rootView = child.getRootView();
            return (build == rootView.computeSystemWindowInsets(build, rect) && rect.isEmpty()) ? false : true;
        }

        public final void e(boolean z10) {
            this.f34439h = z10;
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* renamed from: r3.c$c, reason: collision with other inner class name */
    /* loaded from: classes.dex */
    public static class C0805c {

        /* renamed from: a, reason: collision with root package name */
        private final Activity f34443a;

        /* renamed from: b, reason: collision with root package name */
        private int f34444b;

        /* renamed from: c, reason: collision with root package name */
        private Integer f34445c;

        /* renamed from: d, reason: collision with root package name */
        private Integer f34446d;

        /* renamed from: e, reason: collision with root package name */
        private Drawable f34447e;

        /* renamed from: f, reason: collision with root package name */
        private boolean f34448f;

        /* renamed from: g, reason: collision with root package name */
        private d f34449g;

        public C0805c(Activity activity) {
            t.g(activity, "activity");
            this.f34443a = activity;
            this.f34449g = new d() { // from class: r3.d
            };
        }

        public final Activity a() {
            return this.f34443a;
        }

        public void b() {
            TypedValue typedValue = new TypedValue();
            Resources.Theme currentTheme = this.f34443a.getTheme();
            if (currentTheme.resolveAttribute(r3.a.f34435d, typedValue, true)) {
                this.f34445c = Integer.valueOf(typedValue.resourceId);
                this.f34446d = Integer.valueOf(typedValue.data);
            }
            if (currentTheme.resolveAttribute(r3.a.f34434c, typedValue, true)) {
                this.f34447e = currentTheme.getDrawable(typedValue.resourceId);
            }
            if (currentTheme.resolveAttribute(r3.a.f34433b, typedValue, true)) {
                this.f34448f = typedValue.resourceId == r3.b.f34436a;
            }
            t.f(currentTheme, "currentTheme");
            c(currentTheme, typedValue);
        }

        protected final void c(Resources.Theme currentTheme, TypedValue typedValue) {
            t.g(currentTheme, "currentTheme");
            t.g(typedValue, "typedValue");
            if (currentTheme.resolveAttribute(r3.a.f34432a, typedValue, true)) {
                int i10 = typedValue.resourceId;
                this.f34444b = i10;
                if (i10 != 0) {
                    this.f34443a.setTheme(i10);
                }
            }
        }
    }

    /* loaded from: classes.dex */
    public interface d {
    }

    public /* synthetic */ c(Activity activity, k kVar) {
        this(activity);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void b() {
        this.f34438a.b();
    }

    private c(Activity activity) {
        this.f34438a = Build.VERSION.SDK_INT >= 31 ? new b(activity) : new C0805c(activity);
    }
}
