导航菜单

页面标题

页面副标题

Mitra Bukalapak v2.55.0 - InAppMessageHtmlBaseView.java 源代码

正在查看: Mitra Bukalapak v2.55.0 应用的 InAppMessageHtmlBaseView.java JAVA 源代码文件

本页面展示 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 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.inappmessage.views.InAppMessageHtmlBaseView;
import com.braze.ui.support.ViewUtils;
import defpackage.fja;
import kotlin.Metadata;

@Metadata(d1 = {"\u0000d\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\n\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\b&\u0018\u0000 32\u00020\u00012\u00020\u0002:\u00013B\u001b\u0012\b\u0010.\u001a\u0004\u0018\u00010-\u0012\b\u00100\u001a\u0004\u0018\u00010/¢\u0006\u0004\b1\u00102J\b\u0010\u0004\u001a\u00020\u0003H\u0016J\u001e\u0010\b\u001a\u00020\u00032\b\u0010\u0006\u001a\u0004\u0018\u00010\u00052\n\b\u0002\u0010\u0007\u001a\u0004\u0018\u00010\u0005H\u0017J\u0010\u0010\u000b\u001a\u00020\u00032\u0006\u0010\n\u001a\u00020\tH\u0016J\u0012\u0010\u000e\u001a\u00020\u00032\b\u0010\r\u001a\u0004\u0018\u00010\fH\u0016J\u0018\u0010\u0014\u001a\u00020\u00132\u0006\u0010\u0010\u001a\u00020\u000f2\u0006\u0010\u0012\u001a\u00020\u0011H\u0016J\b\u0010\u0015\u001a\u00020\u000fH&J\u0010\u0010\u0016\u001a\u00020\u00132\u0006\u0010\u0012\u001a\u00020\u0011H\u0016J\u0010\u0010\u0019\u001a\u00020\u00032\u0006\u0010\u0018\u001a\u00020\u0017H\u0016J\u0006\u0010\u001a\u001a\u00020\u0003R\u0018\u0010\u001c\u001a\u0004\u0018\u00010\u001b8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\u001c\u0010\u001dR\u0018\u0010\n\u001a\u0004\u0018\u00010\t8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\n\u0010\u001eR\u0016\u0010\u001f\u001a\u00020\u00138\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\u001f\u0010 R\"\u0010!\u001a\u00020\u00138\u0016@\u0016X\u0096\u000e¢\u0006\u0012\n\u0004\b!\u0010 \u001a\u0004\b\"\u0010#\"\u0004\b$\u0010%R\u0016\u0010)\u001a\u0004\u0018\u00010&8VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b'\u0010(R\u0016\u0010,\u001a\u0004\u0018\u00010\u001b8WX\u0096\u0004¢\u0006\u0006\u001a\u0004\b*\u0010+¨\u00064"}, d2 = {"Lcom/braze/ui/inappmessage/views/InAppMessageHtmlBaseView;", "Landroid/widget/RelativeLayout;", "Lcom/braze/ui/inappmessage/views/IInAppMessageView;", "Llm9;", "finishWebViewDisplay", "", "htmlBody", "assetDirectoryUrl", "setWebViewContent", "Lcom/braze/ui/inappmessage/utils/InAppMessageWebViewClient;", "inAppMessageWebViewClient", "setInAppMessageWebViewClient", "Lcom/braze/ui/inappmessage/listeners/IWebViewClientStateListener;", "listener", "setHtmlPageFinishedListener", "", "keyCode", "Landroid/view/KeyEvent;", "event", "", "onKeyDown", "getWebViewViewId", "dispatchKeyEvent", "Lpla;", "insets", "applyWindowInsets", "setupDirectionalNavigation", "Landroid/webkit/WebView;", "configuredMessageWebView", "Landroid/webkit/WebView;", "Lcom/braze/ui/inappmessage/utils/InAppMessageWebViewClient;", "isFinished", "Z", "hasAppliedWindowInsets", "getHasAppliedWindowInsets", "()Z", "setHasAppliedWindowInsets", "(Z)V", "Landroid/view/View;", "getMessageClickableView", "()Landroid/view/View;", "messageClickableView", "getMessageWebView", "()Landroid/webkit/WebView;", "messageWebView", "Landroid/content/Context;", "context", "Landroid/util/AttributeSet;", "attrs", "<init>", "(Landroid/content/Context;Landroid/util/AttributeSet;)V", "Companion", "android-sdk-ui_release"}, k = 1, mv = {1, 8, 0})
public abstract class InAppMessageHtmlBaseView extends RelativeLayout implements IInAppMessageView {
    private WebView configuredMessageWebView;
    private boolean hasAppliedWindowInsets;
    private InAppMessageWebViewClient inAppMessageWebViewClient;
    private boolean isFinished;

    public InAppMessageHtmlBaseView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
    }

    public static void setWebViewContent$default(InAppMessageHtmlBaseView inAppMessageHtmlBaseView, String str, String str2, int i, Object obj) {
        if (obj != null) {
            throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: setWebViewContent");
        }
        if ((i & 2) != 0) {
            str2 = null;
        }
        inAppMessageHtmlBaseView.setWebViewContent(str, str2);
    }

    public static final void setupDirectionalNavigation$lambda$1(WebView webView) {
        p64.h(webView, "$webView");
        webView.requestFocus();
    }

    @Override
    public void applyWindowInsets(pla plaVar) {
        p64.h(plaVar, "insets");
        setHasAppliedWindowInsets(true);
        Context context = getContext();
        p64.g(context, "this.context");
        if (new BrazeConfigurationProvider(context).isHtmlInAppMessageApplyWindowInsetsEnabled() && getLayoutParams() != null && (getLayoutParams() instanceof ViewGroup.MarginLayoutParams)) {
            ViewGroup.LayoutParams layoutParams = getLayoutParams();
            p64.f(layoutParams, "null cannot be cast to non-null type android.view.ViewGroup.MarginLayoutParams");
            ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) layoutParams;
            marginLayoutParams.setMargins(ViewUtils.getMaxSafeLeftInset(plaVar) + marginLayoutParams.leftMargin, ViewUtils.getMaxSafeTopInset(plaVar) + marginLayoutParams.topMargin, ViewUtils.getMaxSafeRightInset(plaVar) + marginLayoutParams.rightMargin, ViewUtils.getMaxSafeBottomInset(plaVar) + marginLayoutParams.bottomMargin);
        }
    }

    @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        p64.h(event, "event");
        if (isInTouchMode() || event.getKeyCode() != 4 || !BrazeInAppMessageManager.Companion.getInstance().getDoesBackButtonDismissInAppMessageView()) {
            return super.dispatchKeyEvent(event);
        }
        InAppMessageViewUtils.closeInAppMessageOnKeycodeBack();
        return true;
    }

    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;
    }

    @Override
    public View getMessageClickableView() {
        return this;
    }

    @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();
        p64.g(settings, "webView.settings");
        settings.setJavaScriptEnabled(true);
        settings.setUseWideViewPort(true);
        settings.setLoadWithOverviewMode(true);
        settings.setDisplayZoomControls(false);
        settings.setDomStorageEnabled(true);
        settings.setAllowFileAccess(false);
        webView2.setLayerType(2, null);
        webView2.setBackgroundColor(0);
        try {
            if (fja.a("FORCE_DARK")) {
                Context context = getContext();
                p64.g(context, "context");
                if (ViewUtils.isDeviceInNightMode(context)) {
                    wia.b(settings, 2);
                }
            }
            if (fja.a("FORCE_DARK_STRATEGY")) {
                wia.c(settings, 1);
            }
        } catch (Throwable th) {
            BrazeLogger.INSTANCE.brazelog(this, BrazeLogger.Priority.E, th, InAppMessageHtmlBaseView$messageWebView$4.INSTANCE);
        }
        Context context2 = getContext();
        p64.g(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);
                p64.g(createBitmap, "createBitmap(1, 1, Bitmap.Config.ARGB_8888)");
                return createBitmap;
            }

            @Override
            public boolean onConsoleMessage(ConsoleMessage cm) {
                p64.h(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 view, boolean isDialog, boolean isUserGesture, Message resultMsg) {
                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(view, isDialog, isUserGesture, resultMsg);
                }
                if (view == 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 = view.getHitTestResult();
                    p64.g(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);
                    try {
                        int type = hitTestResult.getType();
                        if (type == 2) {
                            InAppMessageHtmlBaseView.this.getContext().startActivity(new Intent("android.intent.action.VIEW", Uri.parse("tel:" + hitTestResult.getExtra())));
                        } else if (type == 4) {
                            InAppMessageHtmlBaseView.this.getContext().startActivity(new Intent("android.intent.action.VIEW", Uri.parse("mailto:" + hitTestResult.getExtra())));
                        } else 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())));
                        }
                    } catch (Exception e) {
                        BrazeLogger.INSTANCE.brazelog(this, BrazeLogger.Priority.E, e, new InAppMessageHtmlBaseView$messageWebView$7$onCreateWindow$5(hitTestResult));
                    }
                }
                return false;
            }
        });
        this.configuredMessageWebView = webView2;
        return webView2;
    }

    public abstract int getWebViewViewId();

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        p64.h(event, "event");
        if (keyCode == 4 && BrazeInAppMessageManager.Companion.getInstance().getDoesBackButtonDismissInAppMessageView()) {
            InAppMessageViewUtils.closeInAppMessageOnKeycodeBack();
            return true;
        }
        WebView webView = this.configuredMessageWebView;
        if (webView != null) {
            ViewUtils.setFocusableInTouchModeAndRequestFocus(webView);
        }
        return super.onKeyDown(keyCode, event);
    }

    public void setHasAppliedWindowInsets(boolean z) {
        this.hasAppliedWindowInsets = z;
    }

    public void setHtmlPageFinishedListener(IWebViewClientStateListener iWebViewClientStateListener) {
        InAppMessageWebViewClient inAppMessageWebViewClient = this.inAppMessageWebViewClient;
        if (inAppMessageWebViewClient != null) {
            inAppMessageWebViewClient.setWebViewClientStateListener(iWebViewClientStateListener);
        }
    }

    public void setInAppMessageWebViewClient(InAppMessageWebViewClient inAppMessageWebViewClient) {
        p64.h(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) {
            BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, (BrazeLogger.Priority) null, (Throwable) null, InAppMessageHtmlBaseView$setWebViewContent$1.INSTANCE, 3, (Object) null);
            return;
        }
        WebView messageWebView = getMessageWebView();
        if (messageWebView != null) {
            messageWebView.loadDataWithBaseURL("https://iamcache.braze/", str, "text/html", "utf-8", null);
        }
    }
}