package com.vungle.ads.internal.ui.view; import android.annotation.SuppressLint; import android.content.Context; import android.content.ContextWrapper; import android.os.Build; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.RelativeLayout; import androidx.annotation.VisibleForTesting; import com.vungle.ads.internal.util.HandlerScheduler; import com.vungle.ads.internal.util.Logger; import com.vungle.ads.internal.util.ViewUtility; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import kotlin.jvm.internal.DefaultConstructorMarker; import kotlin.jvm.internal.Intrinsics; /* loaded from: classes4.dex */ public final class MRAIDAdWidget extends RelativeLayout { public static final Companion Companion = new Companion(null); private static final String TAG = "MRAIDAdWidget"; private CloseDelegate closeDelegate; private OnViewTouchListener onViewTouchListener; private OrientationDelegate orientationDelegate; private final WebView webView; public interface CloseDelegate { void close(); } public interface OnViewTouchListener { boolean onTouch(MotionEvent motionEvent); } public interface OrientationDelegate { void setOrientation(int i); } @VisibleForTesting public static /* synthetic */ void getCloseDelegate$vungle_ads_release$annotations() { } @VisibleForTesting public static /* synthetic */ void getOnViewTouchListener$vungle_ads_release$annotations() { } @VisibleForTesting public static /* synthetic */ void getOrientationDelegate$vungle_ads_release$annotations() { } public final CloseDelegate getCloseDelegate$vungle_ads_release() { return this.closeDelegate; } public final OnViewTouchListener getOnViewTouchListener$vungle_ads_release() { return this.onViewTouchListener; } public final OrientationDelegate getOrientationDelegate$vungle_ads_release() { return this.orientationDelegate; } public final void setCloseDelegate(CloseDelegate closeDelegate) { Intrinsics.checkNotNullParameter(closeDelegate, "closeDelegate"); this.closeDelegate = closeDelegate; } public final void setCloseDelegate$vungle_ads_release(CloseDelegate closeDelegate) { this.closeDelegate = closeDelegate; } public final void setOnViewTouchListener(OnViewTouchListener onViewTouchListener) { this.onViewTouchListener = onViewTouchListener; } public final void setOnViewTouchListener$vungle_ads_release(OnViewTouchListener onViewTouchListener) { this.onViewTouchListener = onViewTouchListener; } public final void setOrientationDelegate(OrientationDelegate orientationDelegate) { this.orientationDelegate = orientationDelegate; } public final void setOrientationDelegate$vungle_ads_release(OrientationDelegate orientationDelegate) { this.orientationDelegate = orientationDelegate; } /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ public MRAIDAdWidget(Context context) throws InstantiationException { super(context); Intrinsics.checkNotNullParameter(context, "context"); ViewGroup.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-1, -1); setLayoutParams(layoutParams); WebView webView = ViewUtility.INSTANCE.getWebView(context); this.webView = webView; webView.setLayoutParams(layoutParams); webView.setTag("VungleWebView"); addView(webView, layoutParams); bindListeners(); prepare(); } @SuppressLint({"ClickableViewAccessibility"}) private final void bindListeners() { this.webView.setOnTouchListener(new View.OnTouchListener() { // from class: com.vungle.ads.internal.ui.view.MRAIDAdWidget$$ExternalSyntheticLambda0 @Override // android.view.View.OnTouchListener public final boolean onTouch(View view, MotionEvent motionEvent) { boolean m3985bindListeners$lambda0; m3985bindListeners$lambda0 = MRAIDAdWidget.m3985bindListeners$lambda0(MRAIDAdWidget.this, view, motionEvent); return m3985bindListeners$lambda0; } }); } /* JADX INFO: Access modifiers changed from: private */ /* renamed from: bindListeners$lambda-0, reason: not valid java name */ public static final boolean m3985bindListeners$lambda0(MRAIDAdWidget this$0, View view, MotionEvent motionEvent) { Intrinsics.checkNotNullParameter(this$0, "this$0"); OnViewTouchListener onViewTouchListener = this$0.onViewTouchListener; if (onViewTouchListener != null) { return onViewTouchListener.onTouch(motionEvent); } return false; } private final void prepare() { WebView webView = this.webView; webView.setLayerType(2, null); webView.setBackgroundColor(0); webView.getSettings().setMediaPlaybackRequiresUserGesture(false); webView.setVisibility(8); } public final void close() { CloseDelegate closeDelegate = this.closeDelegate; if (closeDelegate != null) { closeDelegate.close(); } } public final void setOrientation(int i) { OrientationDelegate orientationDelegate = this.orientationDelegate; if (orientationDelegate != null) { orientationDelegate.setOrientation(i); } } public final void linkWebView(WebViewClient vngWebViewClient) { Intrinsics.checkNotNullParameter(vngWebViewClient, "vngWebViewClient"); WebView webView = this.webView; applyDefault(webView); webView.setWebViewClient(vngWebViewClient); } public final void showWebsite(String url) { Intrinsics.checkNotNullParameter(url, "url"); Logger.Companion.d(TAG, "loadUrl: " + url); WebView webView = this.webView; webView.setVisibility(0); webView.loadUrl(url); } private final void applyDefault(WebView webView) { WebSettings settings = webView.getSettings(); Intrinsics.checkNotNullExpressionValue(settings, "webView.settings"); settings.setBuiltInZoomControls(false); settings.setJavaScriptEnabled(true); settings.setLoadWithOverviewMode(true); settings.setSaveFormData(true); settings.setUseWideViewPort(false); settings.setAllowFileAccess(true); settings.setAllowFileAccessFromFileURLs(true); settings.setAllowUniversalAccessFromFileURLs(true); webView.setVisibility(4); settings.setMediaPlaybackRequiresUserGesture(false); } public final void pauseWeb() { this.webView.onPause(); } public final void resumeWeb() { this.webView.onResume(); } public final String getUrl() { return this.webView.getUrl(); } public final void destroyWebView(long j) { WebView webView = this.webView; webView.setWebChromeClient(null); removeAllViews(); if (j <= 0) { new DestroyRunnable(webView).run(); } else { new HandlerScheduler().schedule(new DestroyRunnable(webView), j); } } public static final class DestroyRunnable implements Runnable { private final WebView webView; public DestroyRunnable(WebView webView) { Intrinsics.checkNotNullParameter(webView, "webView"); this.webView = webView; } @Override // java.lang.Runnable public void run() { try { this.webView.stopLoading(); if (Build.VERSION.SDK_INT >= 29) { this.webView.setWebViewRenderProcessClient(null); } this.webView.loadData("", null, null); this.webView.destroy(); } catch (Throwable unused) { } } } @Override // android.view.ViewGroup, android.view.View public void onAttachedToWindow() { super.onAttachedToWindow(); ViewGroup.LayoutParams layoutParams = getLayoutParams(); if (layoutParams != null) { layoutParams.height = -1; layoutParams.width = -1; } ViewGroup.LayoutParams layoutParams2 = this.webView.getLayoutParams(); if (layoutParams2 != null) { layoutParams2.height = -1; layoutParams2.width = -1; } } public static final class AudioContextWrapper extends ContextWrapper { public AudioContextWrapper(Context context) { super(context); } @Override // android.content.ContextWrapper, android.content.Context public Object getSystemService(String name) { Object systemService; Intrinsics.checkNotNullParameter(name, "name"); if (Intrinsics.areEqual("audio", name)) { systemService = getApplicationContext().getSystemService(name); } else { systemService = super.getSystemService(name); } Intrinsics.checkNotNullExpressionValue(systemService, "if (AUDIO_SERVICE == nam…rvice(name)\n }"); return systemService; } } public static final class Companion { public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } private Companion() { } } @Retention(RetentionPolicy.RUNTIME) public @interface AdStopReason { public static final Companion Companion = Companion.$$INSTANCE; public static final int IS_AD_FINISHED_BY_API = 4; public static final int IS_AD_FINISHING = 2; public static final int IS_CHANGING_CONFIGURATION = 1; public static final class Companion { static final /* synthetic */ Companion $$INSTANCE = new Companion(); public static final int IS_AD_FINISHED_BY_API = 4; public static final int IS_AD_FINISHING = 2; public static final int IS_CHANGING_CONFIGURATION = 1; private Companion() { } } } }