MD5 校验值:8df004f6dd2453bdf1d8ecd51cca1137
InAppMessageHtmlBaseView.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。
package com.braze.ui.inappmessage.views; import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.net.Uri; import android.os.Build; import android.os.Message; import android.util.AttributeSet; import android.view.KeyEvent; import android.view.View; import android.view.ViewGroup; import android.webkit.ConsoleMessage; import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; import android.widget.RelativeLayout; import androidx.core.view.b1; import com.braze.configuration.BrazeConfigurationProvider; import com.braze.support.BrazeLogger; import com.braze.ui.inappmessage.BrazeInAppMessageManager; import com.braze.ui.inappmessage.listeners.IWebViewClientStateListener; import com.braze.ui.inappmessage.utils.InAppMessageViewUtils; import com.braze.ui.inappmessage.utils.InAppMessageWebViewClient; import com.braze.ui.support.ViewUtils; import kotlin.jvm.internal.h; import kotlin.jvm.internal.p; public abstract class InAppMessageHtmlBaseView extends RelativeLayout implements IInAppMessageView { public static final Companion Companion = new Companion(null); private WebView configuredMessageWebView; private boolean hasAppliedWindowInsets; private InAppMessageWebViewClient inAppMessageWebViewClient; private boolean isFinished; public static final class Companion { public Companion(h hVar) { this(); } private Companion() { } } public InAppMessageHtmlBaseView(Context context, AttributeSet attributeSet) { super(context, attributeSet); } public static void setWebViewContent$default(InAppMessageHtmlBaseView inAppMessageHtmlBaseView, String str, String str2, int i10, Object obj) { if (obj == null) { if ((i10 & 2) != 0) { str2 = null; } inAppMessageHtmlBaseView.setWebViewContent(str, str2); return; } throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: setWebViewContent"); } public static final void setupDirectionalNavigation$lambda$1(WebView webView) { p.g(webView, "$webView"); webView.requestFocus(); } @Override public void applyWindowInsets(b1 insets) { p.g(insets, "insets"); setHasAppliedWindowInsets(true); Context context = getContext(); p.f(context, "this.context"); if (new BrazeConfigurationProvider(context).isHtmlInAppMessageApplyWindowInsetsEnabled() && getLayoutParams() != null && (getLayoutParams() instanceof ViewGroup.MarginLayoutParams)) { ViewGroup.LayoutParams layoutParams = getLayoutParams(); p.e(layoutParams, "null cannot be cast to non-null type android.view.ViewGroup.MarginLayoutParams"); ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) layoutParams; marginLayoutParams.setMargins(ViewUtils.getMaxSafeLeftInset(insets) + marginLayoutParams.leftMargin, ViewUtils.getMaxSafeTopInset(insets) + marginLayoutParams.topMargin, ViewUtils.getMaxSafeRightInset(insets) + marginLayoutParams.rightMargin, ViewUtils.getMaxSafeBottomInset(insets) + marginLayoutParams.bottomMargin); } } @Override public boolean dispatchKeyEvent(KeyEvent event) { p.g(event, "event"); if (!isInTouchMode() && event.getKeyCode() == 4 && BrazeInAppMessageManager.Companion.getInstance().getDoesBackButtonDismissInAppMessageView()) { InAppMessageViewUtils.closeInAppMessageOnKeycodeBack(); return true; } return super.dispatchKeyEvent(event); } public void finishWebViewDisplay() { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, (BrazeLogger.Priority) null, (Throwable) null, InAppMessageHtmlBaseView$finishWebViewDisplay$1.INSTANCE, 3, (Object) null); this.isFinished = true; WebView webView = this.configuredMessageWebView; if (webView != null) { webView.loadUrl("about:blank"); webView.onPause(); webView.removeAllViews(); this.configuredMessageWebView = null; } } @Override public boolean getHasAppliedWindowInsets() { return this.hasAppliedWindowInsets; } @SuppressLint({"SetJavaScriptEnabled"}) public WebView getMessageWebView() { if (this.isFinished) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, BrazeLogger.Priority.W, (Throwable) null, InAppMessageHtmlBaseView$messageWebView$1.INSTANCE, 2, (Object) null); return null; } int webViewViewId = getWebViewViewId(); if (webViewViewId == 0) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, (BrazeLogger.Priority) null, (Throwable) null, InAppMessageHtmlBaseView$messageWebView$2.INSTANCE, 3, (Object) null); return null; } WebView webView = this.configuredMessageWebView; if (webView != null) { return webView; } WebView webView2 = (WebView) findViewById(webViewViewId); if (webView2 == null) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, (BrazeLogger.Priority) null, (Throwable) null, new InAppMessageHtmlBaseView$messageWebView$3(webViewViewId), 3, (Object) null); return null; } WebSettings settings = webView2.getSettings(); p.f(settings, "webView.settings"); settings.setJavaScriptEnabled(true); settings.setUseWideViewPort(true); settings.setLoadWithOverviewMode(true); settings.setDisplayZoomControls(false); settings.setDomStorageEnabled(true); settings.setAllowFileAccess(true); webView2.setLayerType(2, null); webView2.setBackgroundColor(0); try { if (k5.b.a("FORCE_DARK")) { Context context = getContext(); p.f(context, "context"); if (ViewUtils.isDeviceInNightMode(context)) { k5.a.b(settings, 2); } } if (k5.b.a("FORCE_DARK_STRATEGY")) { k5.a.c(settings, 1); } } catch (Throwable th) { BrazeLogger.INSTANCE.brazelog(this, BrazeLogger.Priority.E, th, InAppMessageHtmlBaseView$messageWebView$4.INSTANCE); } Context context2 = getContext(); p.f(context2, "this.context"); final boolean isHtmlInAppMessageHtmlLinkTargetEnabled = new BrazeConfigurationProvider(context2).isHtmlInAppMessageHtmlLinkTargetEnabled(); if (isHtmlInAppMessageHtmlLinkTargetEnabled) { webView2.getSettings().setSupportMultipleWindows(true); BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, BrazeLogger.Priority.V, (Throwable) null, InAppMessageHtmlBaseView$messageWebView$5.INSTANCE, 2, (Object) null); } else { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, BrazeLogger.Priority.V, (Throwable) null, InAppMessageHtmlBaseView$messageWebView$6.INSTANCE, 2, (Object) null); } webView2.setWebChromeClient(new WebChromeClient() { @Override public Bitmap getDefaultVideoPoster() { Bitmap createBitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); p.f(createBitmap, "createBitmap(1, 1, Bitmap.Config.ARGB_8888)"); return createBitmap; } @Override public boolean onConsoleMessage(ConsoleMessage cm) { p.g(cm, "cm"); BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, InAppMessageHtmlBaseView.this, (BrazeLogger.Priority) null, (Throwable) null, new InAppMessageHtmlBaseView$messageWebView$7$onConsoleMessage$1(cm), 3, (Object) null); return true; } @Override public boolean onCreateWindow(WebView webView3, boolean z10, boolean z11, Message message) { if (!isHtmlInAppMessageHtmlLinkTargetEnabled) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, BrazeLogger.Priority.V, (Throwable) null, InAppMessageHtmlBaseView$messageWebView$7$onCreateWindow$1.INSTANCE, 2, (Object) null); return super.onCreateWindow(webView3, z10, z11, message); } if (webView3 == null) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, BrazeLogger.Priority.V, (Throwable) null, InAppMessageHtmlBaseView$messageWebView$7$onCreateWindow$2.INSTANCE, 2, (Object) null); } else { WebView.HitTestResult hitTestResult = webView3.getHitTestResult(); p.f(hitTestResult, "view.hitTestResult"); BrazeLogger brazeLogger = BrazeLogger.INSTANCE; BrazeLogger.Priority priority = BrazeLogger.Priority.V; BrazeLogger.brazelog$default(brazeLogger, this, priority, (Throwable) null, new InAppMessageHtmlBaseView$messageWebView$7$onCreateWindow$3(hitTestResult), 2, (Object) null); int type = hitTestResult.getType(); if (type != 2) { if (type != 4) { if (type != 7) { BrazeLogger.brazelog$default(brazeLogger, this, priority, (Throwable) null, new InAppMessageHtmlBaseView$messageWebView$7$onCreateWindow$4(hitTestResult), 2, (Object) null); } else { InAppMessageHtmlBaseView.this.getContext().startActivity(new Intent("android.intent.action.VIEW", Uri.parse(hitTestResult.getExtra()))); } } else { InAppMessageHtmlBaseView.this.getContext().startActivity(new Intent("android.intent.action.VIEW", Uri.parse("mailto:" + hitTestResult.getExtra()))); } } else { InAppMessageHtmlBaseView.this.getContext().startActivity(new Intent("android.intent.action.VIEW", Uri.parse("tel:" + hitTestResult.getExtra()))); } } return false; } }); this.configuredMessageWebView = webView2; return webView2; } public abstract int getWebViewViewId(); @Override public boolean onKeyDown(int i10, KeyEvent event) { p.g(event, "event"); if (i10 == 4 && BrazeInAppMessageManager.Companion.getInstance().getDoesBackButtonDismissInAppMessageView()) { InAppMessageViewUtils.closeInAppMessageOnKeycodeBack(); return true; } WebView webView = this.configuredMessageWebView; if (webView != null) { ViewUtils.setFocusableInTouchModeAndRequestFocus(webView); } return super.onKeyDown(i10, event); } public void setHasAppliedWindowInsets(boolean z10) { this.hasAppliedWindowInsets = z10; } public void setHtmlPageFinishedListener(IWebViewClientStateListener iWebViewClientStateListener) { InAppMessageWebViewClient inAppMessageWebViewClient = this.inAppMessageWebViewClient; if (inAppMessageWebViewClient != null) { inAppMessageWebViewClient.setWebViewClientStateListener(iWebViewClientStateListener); } } public void setInAppMessageWebViewClient(InAppMessageWebViewClient inAppMessageWebViewClient) { p.g(inAppMessageWebViewClient, "inAppMessageWebViewClient"); WebView messageWebView = getMessageWebView(); if (messageWebView != null) { messageWebView.setWebViewClient(inAppMessageWebViewClient); } this.inAppMessageWebViewClient = inAppMessageWebViewClient; } public final void setWebViewContent(String str) { setWebViewContent$default(this, str, null, 2, null); } public final void setupDirectionalNavigation() { final WebView messageWebView = getMessageWebView(); if (messageWebView == null) { return; } messageWebView.setNextFocusDownId(messageWebView.getId()); messageWebView.setNextFocusLeftId(messageWebView.getId()); messageWebView.setNextFocusRightId(messageWebView.getId()); messageWebView.setNextFocusUpId(messageWebView.getId()); messageWebView.requestFocus(); if (Build.VERSION.SDK_INT >= 26) { messageWebView.setFocusedByDefault(true); } messageWebView.post(new Runnable() { @Override public final void run() { InAppMessageHtmlBaseView.setupDirectionalNavigation$lambda$1(messageWebView); } }); } public void setWebViewContent(String str, String str2) { if (str != null) { WebView messageWebView = getMessageWebView(); if (messageWebView != null) { messageWebView.loadDataWithBaseURL("file://" + str2 + '/', str, "text/html", "utf-8", null); return; } return; } BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, (BrazeLogger.Priority) null, (Throwable) null, InAppMessageHtmlBaseView$setWebViewContent$1.INSTANCE, 3, (Object) null); } @Override public View getMessageClickableView() { return this; } }