导航菜单

页面标题

页面副标题

Bhakti v5.4.0 - YellowBotWebviewFragment.java 源代码

正在查看: Bhakti v5.4.0 应用的 YellowBotWebviewFragment.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.yellowmessenger.ymchat;

import T0.N0;
import Z5.g;
import android.content.ClipData;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.graphics.Insets;
import android.graphics.Rect;
import android.location.LocationManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.speech.SpeechRecognizer;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowInsets;
import android.webkit.GeolocationPermissions;
import android.webkit.ValueCallback;
import android.webkit.WebView;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.core.content.FileProvider;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.firebase.perf.network.FirebasePerfOkHttpClient;
import com.truecaller.android.sdk.legacy.TruecallerSdkScope;
import com.vlv.aravali.views.fragments.DialogInterfaceOnDismissListenerC1770a;
import g2.z0;
import in.juspay.hyper.constants.LogSubCategory;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import jb.f;
import kotlin.Metadata;
import kotlin.Pair;
import kotlin.collections.Q;
import kotlin.collections.y;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import okhttp3.FormBody;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;

@Metadata
public final class YellowBotWebviewFragment extends Fragment {
    public static final m Companion = new m();
    private ImageView closeButton;
    private FrameLayout errorOverlay;
    private GeolocationPermissions.Callback geoCallback;
    private String geoOrigin;
    private boolean hasAudioPermissionInManifest;
    private boolean isAgentConnected;
    private boolean isBotClosing;
    private boolean isMediaUploadOptionSelected;
    private boolean isMultiFileUpload;
    private String mCameraPhotoPath;
    private ValueCallback<Uri[]> mFilePathCallback;
    private YmMovableFloatingActionButton micButton;
    private WebView myWebView;
    private View parentLayout;
    private final j.c requestPermissionLauncher;
    private String requestedPermission;
    private SpeechRecognizer sr;
    private String uid;
    private boolean willStartMic;
    private String postUrl = "https://app.yellowmessenger.com/api/chat/upload?bot=";
    private boolean shouldKeepApplicationInBackground = true;
    private final String TAG = "YMChat";
    private final List<String> errorPathsToValidate = y.l(new String[]{"/widget/mobile.js", "/widget/v2/mobile.js", "/plugin/latest/dist/mobile.min.js", "/plugin/latest/dist/widget.min.js", "/plugin/widget-v2/latest/dist/mobile.min.js", "/plugin/widget-v2/latest/dist/widget.min.js"});
    private final int INPUT_FILE_REQUEST_CODE = 1;

    public YellowBotWebviewFragment() {
        j.c registerForActivityResult = registerForActivityResult(new L8.n(5), new j(this));
        Intrinsics.checkNotNullExpressionValue(registerForActivityResult, "registerForActivityResul…        }\n        }\n    }");
        this.requestPermissionLauncher = registerForActivityResult;
    }

    private final void alignMicButton() {
        Window window;
        View decorView;
        final int i = ((g) uo.a.H().b).d;
        FloatingActionButton floatingActionButton = this.micButton;
        if (floatingActionButton == null) {
            Intrinsics.m("micButton");
            throw null;
        }
        ViewGroup.LayoutParams layoutParams = floatingActionButton.getLayoutParams();
        if (layoutParams == null) {
            throw new NullPointerException("null cannot be cast to non-null type android.widget.RelativeLayout.LayoutParams");
        }
        final RelativeLayout.LayoutParams layoutParams2 = (RelativeLayout.LayoutParams) layoutParams;
        if (Build.VERSION.SDK_INT > 34) {
            FragmentActivity activity = getActivity();
            if (activity != null && (window = activity.getWindow()) != null && (decorView = window.getDecorView()) != null) {
                decorView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
                    @Override
                    public final WindowInsets onApplyWindowInsets(View view, WindowInsets windowInsets) {
                        WindowInsets m13alignMicButton$lambda21;
                        m13alignMicButton$lambda21 = YellowBotWebviewFragment.m13alignMicButton$lambda21(i, layoutParams2, this, view, windowInsets);
                        return m13alignMicButton$lambda21;
                    }
                });
            }
        } else if (i == 1) {
            layoutParams2.setMargins(0, 0, 4, 200);
        } else {
            layoutParams2.setMargins(0, 0, 0, 186);
        }
        FloatingActionButton floatingActionButton2 = this.micButton;
        if (floatingActionButton2 != null) {
            floatingActionButton2.setLayoutParams(layoutParams2);
        } else {
            Intrinsics.m("micButton");
            throw null;
        }
    }

    public static final WindowInsets m13alignMicButton$lambda21(int i, RelativeLayout.LayoutParams layoutParams, YellowBotWebviewFragment yellowBotWebviewFragment, View view, WindowInsets windowInsets) {
        int systemBars;
        Intrinsics.checkNotNullParameter(layoutParams, "$params");
        Intrinsics.checkNotNullParameter(yellowBotWebviewFragment, "this$0");
        Intrinsics.checkNotNullParameter(view, "<anonymous parameter 0>");
        Intrinsics.checkNotNullParameter(windowInsets, "insets");
        systemBars = WindowInsets.Type.systemBars();
        Insets x = e1.d.x(windowInsets, systemBars);
        Intrinsics.checkNotNullExpressionValue(x, "insets.getInsets(WindowInsets.Type.systemBars())");
        Insets x2 = e1.d.x(windowInsets, z0.s());
        Intrinsics.checkNotNullExpressionValue(x2, "insets.getInsets(WindowI…ets.Type.displayCutout())");
        int A = N0.A(x);
        int D = N0.D(x);
        int a = N0.a(x2);
        int C = N0.C(x2);
        if (i == 1) {
            layoutParams.setMargins(a, A, C + 4, D + 200);
        } else {
            layoutParams.setMargins(a, A, C, D + 186);
        }
        FloatingActionButton floatingActionButton = yellowBotWebviewFragment.micButton;
        if (floatingActionButton != null) {
            floatingActionButton.setTranslationY(floatingActionButton.getTranslationY() + (D / 2));
            return windowInsets;
        }
        Intrinsics.m("micButton");
        throw null;
    }

    private final void checkAndLaunchCamera() {
        if (getContext() != null) {
            Context requireContext = requireContext();
            Intrinsics.checkNotNullExpressionValue(requireContext, "requireContext()");
            if (!hasCameraPermissionInManifest(requireContext)) {
                launchCameraIntent();
                return;
            }
            Context requireContext2 = requireContext();
            Intrinsics.checkNotNullExpressionValue(requireContext2, "requireContext()");
            if (checkForCameraPermission(requireContext2)) {
                launchCameraIntent();
            }
        }
    }

    private final boolean checkForCameraPermission(Context context) {
        if (U1.b.a(context, "android.permission.CAMERA") == 0) {
            return true;
        }
        this.requestedPermission = "android.permission.CAMERA";
        this.requestPermissionLauncher.a("android.permission.CAMERA");
        return false;
    }

    public final boolean checkForLocationPermission(Context context) {
        if (U1.b.a(context, "android.permission.ACCESS_FINE_LOCATION") == 0) {
            return true;
        }
        this.requestedPermission = "android.permission.ACCESS_FINE_LOCATION";
        this.requestPermissionLauncher.a("android.permission.ACCESS_FINE_LOCATION");
        return false;
    }

    private final void closeBot() {
        try {
            requireActivity().runOnUiThread(new com.vlv.aravali.settings.ui.e(this, 6));
        } catch (Exception unused) {
        }
    }

    public static final void m14closeBot$lambda18(YellowBotWebviewFragment yellowBotWebviewFragment) {
        Intrinsics.checkNotNullParameter(yellowBotWebviewFragment, "this$0");
        WebView webView = yellowBotWebviewFragment.myWebView;
        if (webView != null) {
            webView.loadUrl("");
        } else {
            Intrinsics.m("myWebView");
            throw null;
        }
    }

    private final File createImageFile() throws IOException {
        return File.createTempFile(Ai.o.a('_', "JPEG_", new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(new Date())), ".jpg", requireContext().getExternalCacheDir());
    }

    private final void disableShouldKeepApplicationInBackground() {
        this.shouldKeepApplicationInBackground = false;
    }

    public final void emitUrlClickEvent(String str) {
        new com.google.gson.d().h(Q.c(new Pair("url", str)));
        Object obj = f.i().a;
    }

    private final void enableShouldKeepApplicationInBackground() {
        this.shouldKeepApplicationInBackground = true;
    }

    private final boolean getSpeechEnabled() {
        ((g) uo.a.H().b).getClass();
        if (((g) uo.a.H().b).j != null) {
            return Intrinsics.c((Object) null, Boolean.TRUE);
        }
        return false;
    }

    private final boolean hasAudioPermissionInManifest(Context context) {
        try {
            String[] strArr = context.getPackageManager().getPackageInfo(context.getPackageName(), TruecallerSdkScope.FOOTER_TYPE_LATER).requestedPermissions;
            if (strArr != null && strArr.length != 0) {
                for (String str : strArr) {
                    if (Intrinsics.c(str, "android.permission.RECORD_AUDIO")) {
                        return true;
                    }
                }
            }
        } catch (PackageManager.NameNotFoundException unused) {
        }
        return false;
    }

    private final boolean hasCameraPermissionInManifest(Context context) {
        try {
            String[] strArr = context.getPackageManager().getPackageInfo(context.getPackageName(), TruecallerSdkScope.FOOTER_TYPE_LATER).requestedPermissions;
            if (strArr != null && strArr.length != 0) {
                for (String str : strArr) {
                    if (Intrinsics.c(str, "android.permission.CAMERA")) {
                        return true;
                    }
                }
            }
        } catch (PackageManager.NameNotFoundException unused) {
        }
        return false;
    }

    public final boolean hasLocationPermissionInManifest(Context context) {
        try {
            String[] strArr = context.getPackageManager().getPackageInfo(context.getPackageName(), TruecallerSdkScope.FOOTER_TYPE_LATER).requestedPermissions;
            if (strArr != null && strArr.length != 0) {
                for (String str : strArr) {
                    if (Intrinsics.c(str, "android.permission.ACCESS_FINE_LOCATION")) {
                        return true;
                    }
                }
            }
        } catch (PackageManager.NameNotFoundException unused) {
        }
        return false;
    }

    private final void hideCloseButton() {
        ImageView imageView = this.closeButton;
        if (imageView != null) {
            imageView.setVisibility(8);
        } else {
            Intrinsics.m("closeButton");
            throw null;
        }
    }

    private final void hideMic() {
        YmMovableFloatingActionButton ymMovableFloatingActionButton = this.micButton;
        if (ymMovableFloatingActionButton != null) {
            ymMovableFloatingActionButton.g();
        } else {
            Intrinsics.m("micButton");
            throw null;
        }
    }

    public final boolean isDeviceLocationEnabled(Context context) {
        Object systemService = context.getSystemService("location");
        if (systemService == null) {
            throw new NullPointerException("null cannot be cast to non-null type android.location.LocationManager");
        }
        LocationManager locationManager = (LocationManager) systemService;
        return locationManager.isProviderEnabled("gps") || locationManager.isProviderEnabled(LogSubCategory.ApiCall.NETWORK);
    }

    private final boolean isMultiFileUpload() {
        return this.isMultiFileUpload;
    }

    private final void launchCameraIntent() {
        File file;
        try {
            Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
            if (getActivity() == null || intent.resolveActivity(requireActivity().getPackageManager()) == null) {
                return;
            }
            try {
                file = createImageFile();
                try {
                    intent.putExtra("PhotoPath", this.mCameraPhotoPath);
                } catch (IOException unused) {
                }
            } catch (IOException unused2) {
                file = null;
            }
            if (file == null) {
                View view = this.parentLayout;
                if (view != null) {
                    g.z0(view, requireContext().getString(e.ym_message_camera_error));
                    return;
                } else {
                    Intrinsics.m("parentLayout");
                    throw null;
                }
            }
            this.mCameraPhotoPath = "file:" + file.getAbsolutePath();
            if (getContext() == null) {
                return;
            }
            Uri uriForFile = FileProvider.getUriForFile(requireContext(), requireContext().getPackageName() + ".yellow.chatbot.provider", file);
            Intrinsics.checkNotNullExpressionValue(uriForFile, "getUriForFile(\n         …ile\n                    )");
            intent.putExtra("output", uriForFile);
            intent.addFlags(1);
            disableShouldKeepApplicationInBackground();
            startActivityForResult(intent, this.INPUT_FILE_REQUEST_CODE);
        } catch (Exception unused3) {
            View view2 = this.parentLayout;
            if (view2 != null) {
                g.z0(view2, requireContext().getString(e.ym_message_camera_error));
            } else {
                Intrinsics.m("parentLayout");
                throw null;
            }
        }
    }

    private final void launchFileIntent() {
        Intent intent = new Intent("android.intent.action.GET_CONTENT");
        intent.addCategory("android.intent.category.OPENABLE");
        intent.setType("*/*");
        if (isMultiFileUpload()) {
            intent.putExtra("android.intent.extra.ALLOW_MULTIPLE", true);
        }
        if (getActivity() != null) {
            disableShouldKeepApplicationInBackground();
            startActivityForResult(intent, this.INPUT_FILE_REQUEST_CODE);
        }
    }

    public static final void m15onCreate$lambda12(YellowBotWebviewFragment yellowBotWebviewFragment, uo.c cVar) {
        Intrinsics.checkNotNullParameter(yellowBotWebviewFragment, "this$0");
        Intrinsics.checkNotNullParameter(cVar, "botEvent");
        cVar.getClass();
    }

    private static final void m16onCreate$lambda12$lambda1(YellowBotWebviewFragment yellowBotWebviewFragment) {
        Intrinsics.checkNotNullParameter(yellowBotWebviewFragment, "this$0");
        Object obj = f.i().a;
        if (yellowBotWebviewFragment.getActivity() instanceof YellowBotWebViewActivity) {
            yellowBotWebviewFragment.closeBot();
            FragmentActivity activity = yellowBotWebviewFragment.getActivity();
            if (activity != null) {
                activity.onBackPressed();
            }
            yellowBotWebviewFragment.isBotClosing = true;
        }
    }

    private static final void m17onCreate$lambda12$lambda10(YellowBotWebviewFragment yellowBotWebviewFragment, uo.c cVar) {
        Intrinsics.checkNotNullParameter(yellowBotWebviewFragment, "this$0");
        Intrinsics.checkNotNullParameter(cVar, "$botEvent");
        cVar.getClass();
        Intrinsics.checkNotNullExpressionValue((Object) null, "botEvent.data");
        yellowBotWebviewFragment.sendEvent("revalidate-token", null);
    }

    private static final void m18onCreate$lambda12$lambda11(YellowBotWebviewFragment yellowBotWebviewFragment, uo.c cVar) {
        Intrinsics.checkNotNullParameter(yellowBotWebviewFragment, "this$0");
        Intrinsics.checkNotNullParameter(cVar, "$botEvent");
        cVar.getClass();
        Intrinsics.checkNotNullExpressionValue((Object) null, "botEvent.data");
        yellowBotWebviewFragment.sendEvent("event-from-client", null);
    }

    private static final void m19onCreate$lambda12$lambda2(YellowBotWebviewFragment yellowBotWebviewFragment) {
        Intrinsics.checkNotNullParameter(yellowBotWebviewFragment, "this$0");
        yellowBotWebviewFragment.hideMic();
        yellowBotWebviewFragment.hideCloseButton();
    }

    private static final void m20onCreate$lambda12$lambda3(YellowBotWebviewFragment yellowBotWebviewFragment) {
        Intrinsics.checkNotNullParameter(yellowBotWebviewFragment, "this$0");
        yellowBotWebviewFragment.showCloseButton();
        yellowBotWebviewFragment.showMic();
    }

    private static final void m21onCreate$lambda12$lambda4(YellowBotWebviewFragment yellowBotWebviewFragment, uo.c cVar) {
        Intrinsics.checkNotNullParameter(yellowBotWebviewFragment, "this$0");
        Intrinsics.checkNotNullParameter(cVar, "$botEvent");
        cVar.getClass();
        yellowBotWebviewFragment.uid = null;
    }

    private static final void m22onCreate$lambda12$lambda5(YellowBotWebviewFragment yellowBotWebviewFragment) {
        Intrinsics.checkNotNullParameter(yellowBotWebviewFragment, "this$0");
        yellowBotWebviewFragment.isAgentConnected = true;
    }

    private static final void m23onCreate$lambda12$lambda6(YellowBotWebviewFragment yellowBotWebviewFragment) {
        Intrinsics.checkNotNullParameter(yellowBotWebviewFragment, "this$0");
        yellowBotWebviewFragment.isAgentConnected = false;
    }

    private static final void m24onCreate$lambda12$lambda7(YellowBotWebviewFragment yellowBotWebviewFragment) {
        Intrinsics.checkNotNullParameter(yellowBotWebviewFragment, "this$0");
        yellowBotWebviewFragment.setMultiFileUpload(true);
    }

    private static final void m25onCreate$lambda12$lambda8(YellowBotWebviewFragment yellowBotWebviewFragment) {
        Intrinsics.checkNotNullParameter(yellowBotWebviewFragment, "this$0");
        yellowBotWebviewFragment.setMultiFileUpload(false);
    }

    private static final void m26onCreate$lambda12$lambda9(YellowBotWebviewFragment yellowBotWebviewFragment) {
        Intrinsics.checkNotNullParameter(yellowBotWebviewFragment, "this$0");
        yellowBotWebviewFragment.reload();
    }

    public static final void m27onViewCreated$lambda13(YellowBotWebviewFragment yellowBotWebviewFragment, View view) {
        Intrinsics.checkNotNullParameter(yellowBotWebviewFragment, "this$0");
        yellowBotWebviewFragment.showVoiceOption();
    }

    public static final void m28onViewCreated$lambda14(YellowBotWebviewFragment yellowBotWebviewFragment, View view) {
        Intrinsics.checkNotNullParameter(yellowBotWebviewFragment, "this$0");
        Object obj = f.i().a;
        if (yellowBotWebviewFragment.getActivity() instanceof YellowBotWebViewActivity) {
            yellowBotWebviewFragment.closeBot();
            FragmentActivity activity = yellowBotWebviewFragment.getActivity();
            if (activity != null) {
                activity.onBackPressed();
            }
            yellowBotWebviewFragment.isBotClosing = true;
        }
    }

    private final View preLoadWebView() {
        File filesDir;
        FragmentActivity activity = getActivity();
        WebView webView = this.myWebView;
        if (webView == null) {
            Intrinsics.m("myWebView");
            throw null;
        }
        webView.getSettings().setJavaScriptEnabled(true);
        WebView webView2 = this.myWebView;
        if (webView2 == null) {
            Intrinsics.m("myWebView");
            throw null;
        }
        webView2.getSettings().setDomStorageEnabled(true);
        WebView webView3 = this.myWebView;
        if (webView3 == null) {
            Intrinsics.m("myWebView");
            throw null;
        }
        webView3.getSettings().setSupportMultipleWindows(true);
        WebView webView4 = this.myWebView;
        if (webView4 == null) {
            Intrinsics.m("myWebView");
            throw null;
        }
        webView4.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
        WebView webView5 = this.myWebView;
        if (webView5 == null) {
            Intrinsics.m("myWebView");
            throw null;
        }
        webView5.getSettings().setAllowFileAccess(true);
        WebView webView6 = this.myWebView;
        if (webView6 == null) {
            Intrinsics.m("myWebView");
            throw null;
        }
        webView6.getSettings().setGeolocationDatabasePath((activity == null || (filesDir = activity.getFilesDir()) == null) ? null : filesDir.getPath());
        WebView webView7 = this.myWebView;
        if (webView7 == null) {
            Intrinsics.m("myWebView");
            throw null;
        }
        webView7.getSettings().setMediaPlaybackRequiresUserGesture(false);
        WebView webView8 = this.myWebView;
        if (webView8 == null) {
            Intrinsics.m("myWebView");
            throw null;
        }
        FragmentActivity requireActivity = requireActivity();
        WebView webView9 = this.myWebView;
        if (webView9 == null) {
            Intrinsics.m("myWebView");
            throw null;
        }
        uo.b bVar = new uo.b();
        bVar.a = requireActivity;
        bVar.b = webView9;
        webView8.addJavascriptInterface(bVar, "YMHandler");
        WebView webView10 = this.myWebView;
        if (webView10 == null) {
            Intrinsics.m("myWebView");
            throw null;
        }
        webView10.setWebViewClient(new o(this));
        WebView webView11 = this.myWebView;
        if (webView11 == null) {
            Intrinsics.m("myWebView");
            throw null;
        }
        webView11.setWebChromeClient(new p(this, activity));
        ((g) uo.a.H().b).getClass();
        String string = getString(e.ym_chatbot_base_url);
        Intrinsics.checkNotNullExpressionValue(string, "if (ConfigService.getIns…atbot_base_url)\n        }");
        String packageName = requireContext().getPackageName();
        uo.a H = uo.a.H();
        H.getClass();
        Uri.Builder appendQueryParameter = Uri.parse(string).buildUpon().appendQueryParameter("botId", ((g) H.b).a);
        HashMap hashMap = ((g) H.b).e;
        if (hashMap == null) {
            hashMap = new HashMap();
        }
        H.c = hashMap;
        hashMap.put("Platform", "Android-App");
        Uri.Builder appendQueryParameter2 = appendQueryParameter.appendQueryParameter("ym.payload", new com.google.gson.d().h((HashMap) H.c));
        String str = ((g) H.b).b;
        if (str == null) {
            str = "";
        }
        Uri.Builder appendQueryParameter3 = appendQueryParameter2.appendQueryParameter("ymAuthenticationToken", str);
        ((g) H.b).getClass();
        Uri.Builder appendQueryParameter4 = appendQueryParameter3.appendQueryParameter("useSecureYmAuth", String.valueOf(false));
        ((g) H.b).getClass();
        ((g) H.b).getClass();
        Uri.Builder appendQueryParameter5 = appendQueryParameter4.appendQueryParameter("deviceToken", "");
        ((g) H.b).getClass();
        Uri.Builder appendQueryParameter6 = appendQueryParameter5.appendQueryParameter("customBaseUrl", "https://app.yellowmessenger.com").appendQueryParameter("version", Integer.toString(((g) H.b).d));
        ((g) H.b).getClass();
        String uri = appendQueryParameter6.appendQueryParameter("customLoaderUrl", "file:///android_asset/yellowLoader.gif").appendQueryParameter("appId", packageName).appendQueryParameter("disableActionsOnLoad", String.valueOf(((g) H.b).g)).appendQueryParameter("ym.theme", ((g) H.b).k != null ? new com.google.gson.d().h(((g) H.b).k) : "").build().toString();
        WebView webView12 = this.myWebView;
        if (webView12 == null) {
            Intrinsics.m("myWebView");
            throw null;
        }
        webView12.loadUrl(uri);
        WebView webView13 = this.myWebView;
        if (webView13 != null) {
            return webView13;
        }
        Intrinsics.m("myWebView");
        throw null;
    }

    public static final void m29requestPermissionLauncher$lambda0(YellowBotWebviewFragment yellowBotWebviewFragment, boolean z) {
        Intrinsics.checkNotNullParameter(yellowBotWebviewFragment, "this$0");
        if (TextUtils.isEmpty(yellowBotWebviewFragment.requestedPermission)) {
            return;
        }
        if (Intrinsics.c(yellowBotWebviewFragment.requestedPermission, "android.permission.CAMERA")) {
            if (z) {
                yellowBotWebviewFragment.launchCameraIntent();
                return;
            }
            yellowBotWebviewFragment.resetFilePathCallback();
            if (yellowBotWebviewFragment.getContext() != null) {
                Context requireContext = yellowBotWebviewFragment.requireContext();
                View view = yellowBotWebviewFragment.parentLayout;
                if (view != null) {
                    g.A0(requireContext, yellowBotWebviewFragment.getString(e.ym_message_camera_permission), view);
                    return;
                } else {
                    Intrinsics.m("parentLayout");
                    throw null;
                }
            }
            return;
        }
        if (!Intrinsics.c(yellowBotWebviewFragment.requestedPermission, "android.permission.ACCESS_FINE_LOCATION")) {
            if (!Intrinsics.c(yellowBotWebviewFragment.requestedPermission, "android.permission.RECORD_AUDIO")) {
                yellowBotWebviewFragment.resetFilePathCallback();
                return;
            }
            if (z) {
                yellowBotWebviewFragment.toggleBottomSheet();
                return;
            }
            Context requireContext2 = yellowBotWebviewFragment.requireContext();
            View view2 = yellowBotWebviewFragment.parentLayout;
            if (view2 != null) {
                g.A0(requireContext2, yellowBotWebviewFragment.getString(e.ym_message_mic_permission), view2);
                return;
            } else {
                Intrinsics.m("parentLayout");
                throw null;
            }
        }
        if (!z || yellowBotWebviewFragment.geoCallback == null || yellowBotWebviewFragment.geoOrigin == null) {
            GeolocationPermissions.Callback callback = yellowBotWebviewFragment.geoCallback;
            if (callback != null && yellowBotWebviewFragment.geoOrigin != null) {
                Intrinsics.e(callback);
                callback.invoke(yellowBotWebviewFragment.geoOrigin, false, false);
            }
            yellowBotWebviewFragment.geoCallback = null;
            yellowBotWebviewFragment.geoOrigin = null;
            if (yellowBotWebviewFragment.getContext() != null) {
                Context requireContext3 = yellowBotWebviewFragment.requireContext();
                View view3 = yellowBotWebviewFragment.parentLayout;
                if (view3 != null) {
                    g.A0(requireContext3, yellowBotWebviewFragment.getString(e.ym_message_location_permission), view3);
                    return;
                } else {
                    Intrinsics.m("parentLayout");
                    throw null;
                }
            }
            return;
        }
        Context requireContext4 = yellowBotWebviewFragment.requireContext();
        Intrinsics.checkNotNullExpressionValue(requireContext4, "requireContext()");
        if (yellowBotWebviewFragment.isDeviceLocationEnabled(requireContext4)) {
            GeolocationPermissions.Callback callback2 = yellowBotWebviewFragment.geoCallback;
            Intrinsics.e(callback2);
            callback2.invoke(yellowBotWebviewFragment.geoOrigin, true, false);
        } else {
            View view4 = yellowBotWebviewFragment.parentLayout;
            if (view4 == null) {
                Intrinsics.m("parentLayout");
                throw null;
            }
            g.z0(view4, yellowBotWebviewFragment.getString(e.ym_device_location_not_enabled));
            GeolocationPermissions.Callback callback3 = yellowBotWebviewFragment.geoCallback;
            Intrinsics.e(callback3);
            callback3.invoke(yellowBotWebviewFragment.geoOrigin, false, false);
        }
        yellowBotWebviewFragment.geoCallback = null;
        yellowBotWebviewFragment.geoOrigin = null;
    }

    private final void resetFilePathCallback() {
        ValueCallback<Uri[]> valueCallback = this.mFilePathCallback;
        if (valueCallback != null) {
            Intrinsics.e(valueCallback);
            valueCallback.onReceiveValue(null);
            this.mFilePathCallback = null;
        }
    }

    private final void runUpload(String str) {
        if (str == null) {
            return;
        }
        try {
            this.postUrl += ((g) uo.a.H().b).a + "&uid=" + str + "&secure=false";
            run();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public final void setCloseButtonColor() {
        try {
            int i = ((g) uo.a.H().b).c;
            if (i == -1 || getContext() == null) {
                return;
            }
            ImageView imageView = this.closeButton;
            if (imageView != null) {
                imageView.getDrawable().setTint(q8.j.p(requireContext(), i));
            } else {
                Intrinsics.m("closeButton");
                throw null;
            }
        } catch (Exception unused) {
        }
    }

    private final void setCloseButtonColorFromHex() {
        try {
            ((g) uo.a.H().b).getClass();
            if ("".length() > 0) {
                ImageView imageView = this.closeButton;
                if (imageView != null) {
                    imageView.getDrawable().setTint(Color.parseColor(""));
                } else {
                    Intrinsics.m("closeButton");
                    throw null;
                }
            }
        } catch (Exception unused) {
        }
    }

    private final void setKeyboardListener() {
        View view = this.parentLayout;
        if (view != null) {
            view.getViewTreeObserver().addOnGlobalLayoutListener(new Cj.a(this, 14));
        } else {
            Intrinsics.m("parentLayout");
            throw null;
        }
    }

    public static final void m30setKeyboardListener$lambda20(YellowBotWebviewFragment yellowBotWebviewFragment) {
        Intrinsics.checkNotNullParameter(yellowBotWebviewFragment, "this$0");
        Rect rect = new Rect();
        View view = yellowBotWebviewFragment.parentLayout;
        if (view == null) {
            Intrinsics.m("parentLayout");
            throw null;
        }
        view.getWindowVisibleDisplayFrame(rect);
        View view2 = yellowBotWebviewFragment.parentLayout;
        if (view2 == null) {
            Intrinsics.m("parentLayout");
            throw null;
        }
        if (r1 - rect.bottom > view2.getRootView().getHeight() * 0.15d) {
            yellowBotWebviewFragment.hideMic();
        } else {
            yellowBotWebviewFragment.showMic();
        }
    }

    private final void setMultiFileUpload(boolean z) {
        this.isMultiFileUpload = z;
    }

    private final void setStatusBarColor() {
        try {
            ((g) uo.a.H().b).getClass();
        } catch (Exception unused) {
        }
    }

    private final void setStatusBarColorFromHex() {
        try {
            ((g) uo.a.H().b).getClass();
            if ("".length() <= 0 || getActivity() == null) {
                return;
            }
            Window window = requireActivity().getWindow();
            Intrinsics.checkNotNullExpressionValue(window, "requireActivity().window");
            window.clearFlags(67108864);
            window.addFlags(Integer.MIN_VALUE);
            window.setStatusBarColor(Color.parseColor(""));
        } catch (Exception unused) {
        }
    }

    private final void showBottomSheet() {
        if (getContext() != null) {
            final f fVar = new f(requireContext());
            fVar.setContentView(d.bottom_sheet_dialog_attachment);
            LinearLayout linearLayout = (LinearLayout) fVar.findViewById(c.camera_layout);
            LinearLayout linearLayout2 = (LinearLayout) fVar.findViewById(c.file_layout);
            if (linearLayout != null) {
                final int i = 0;
                linearLayout.setOnClickListener(new View.OnClickListener(this) {
                    public final YellowBotWebviewFragment b;

                    {
                        this.b = this;
                    }

                    @Override
                    public final void onClick(View view) {
                        switch (i) {
                            case 0:
                                YellowBotWebviewFragment.m31showBottomSheet$lambda15(this.b, fVar, view);
                                break;
                            default:
                                YellowBotWebviewFragment.m32showBottomSheet$lambda16(this.b, fVar, view);
                                break;
                        }
                    }
                });
            }
            if (linearLayout2 != null) {
                final int i2 = 1;
                linearLayout2.setOnClickListener(new View.OnClickListener(this) {
                    public final YellowBotWebviewFragment b;

                    {
                        this.b = this;
                    }

                    @Override
                    public final void onClick(View view) {
                        switch (i2) {
                            case 0:
                                YellowBotWebviewFragment.m31showBottomSheet$lambda15(this.b, fVar, view);
                                break;
                            default:
                                YellowBotWebviewFragment.m32showBottomSheet$lambda16(this.b, fVar, view);
                                break;
                        }
                    }
                });
            }
            fVar.setOnDismissListener(new DialogInterfaceOnDismissListenerC1770a(this, 4));
            fVar.show();
        }
    }

    public static final void m31showBottomSheet$lambda15(YellowBotWebviewFragment yellowBotWebviewFragment, f fVar, View view) {
        Intrinsics.checkNotNullParameter(yellowBotWebviewFragment, "this$0");
        Intrinsics.checkNotNullParameter(fVar, "$bottomSheetDialog");
        yellowBotWebviewFragment.isMediaUploadOptionSelected = true;
        yellowBotWebviewFragment.checkAndLaunchCamera();
        fVar.dismiss();
    }

    public static final void m32showBottomSheet$lambda16(YellowBotWebviewFragment yellowBotWebviewFragment, f fVar, View view) {
        Intrinsics.checkNotNullParameter(yellowBotWebviewFragment, "this$0");
        Intrinsics.checkNotNullParameter(fVar, "$bottomSheetDialog");
        yellowBotWebviewFragment.isMediaUploadOptionSelected = true;
        if (yellowBotWebviewFragment.getContext() != null) {
            yellowBotWebviewFragment.launchFileIntent();
        }
        fVar.dismiss();
    }

    public static final void m33showBottomSheet$lambda17(YellowBotWebviewFragment yellowBotWebviewFragment, DialogInterface dialogInterface) {
        Intrinsics.checkNotNullParameter(yellowBotWebviewFragment, "this$0");
        if (yellowBotWebviewFragment.isMediaUploadOptionSelected) {
            return;
        }
        yellowBotWebviewFragment.resetFilePathCallback();
    }

    private final void showCloseButton() {
        ((g) uo.a.H().b).getClass();
        ImageView imageView = this.closeButton;
        if (imageView == null) {
            Intrinsics.m("closeButton");
            throw null;
        }
        imageView.setVisibility(0);
        setCloseButtonColor();
    }

    public final void showFileChooser() {
        ((g) uo.a.H().b).getClass();
        if (!isMultiFileUpload()) {
            showBottomSheet();
        } else if (getContext() != null) {
            launchFileIntent();
        }
    }

    private final void showMic() {
        if (getSpeechEnabled() && this.hasAudioPermissionInManifest) {
            YmMovableFloatingActionButton ymMovableFloatingActionButton = this.micButton;
            if (ymMovableFloatingActionButton != null) {
                ymMovableFloatingActionButton.m((hb.b) null, true);
                return;
            } else {
                Intrinsics.m("micButton");
                throw null;
            }
        }
        YmMovableFloatingActionButton ymMovableFloatingActionButton2 = this.micButton;
        if (ymMovableFloatingActionButton2 != null) {
            ymMovableFloatingActionButton2.g();
        } else {
            Intrinsics.m("micButton");
            throw null;
        }
    }

    private final void showVoiceOption() {
        if (this.hasAudioPermissionInManifest) {
            if (U1.b.a(requireContext(), "android.permission.RECORD_AUDIO") == 0) {
                toggleBottomSheet();
                return;
            } else {
                this.requestedPermission = "android.permission.RECORD_AUDIO";
                this.requestPermissionLauncher.a("android.permission.RECORD_AUDIO");
                return;
            }
        }
        View view = this.parentLayout;
        if (view != null) {
            g.z0(view, getString(e.ym_declare_audio_permission));
        } else {
            Intrinsics.m("parentLayout");
            throw null;
        }
    }

    private final void startListeningWithoutDialog() {
        if (getContext() != null) {
            Context requireContext = requireContext();
            Intrinsics.checkNotNullExpressionValue(requireContext, "requireContext()");
            Intent intent = new Intent("android.speech.action.RECOGNIZE_SPEECH");
            HashMap hashMap = ((g) uo.a.H().b).e;
            String str = hashMap != null ? (String) hashMap.get("defaultLanguage") : null;
            if (str == null) {
                str = Locale.getDefault().toString();
            }
            intent.putExtra("android.speech.extra.LANGUAGE", str);
            intent.putExtra("android.speech.extra.LANGUAGE_PREFERENCE", str);
            intent.putExtra("android.speech.extra.ONLY_RETURN_LANGUAGE_PREFERENCE", str);
            intent.putExtra("android.speech.extra.LANGUAGE_MODEL", "free_form");
            intent.putExtra("android.speech.extra.PARTIAL_RESULTS", true);
            intent.putExtra("android.speech.extra.MAX_RESULTS", 5);
            intent.putExtra("calling_package", requireContext.getPackageName());
            SpeechRecognizer createSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(requireContext);
            this.sr = createSpeechRecognizer;
            n nVar = new n(this);
            Intrinsics.e(createSpeechRecognizer);
            createSpeechRecognizer.setRecognitionListener(nVar);
            SpeechRecognizer speechRecognizer = this.sr;
            Intrinsics.e(speechRecognizer);
            speechRecognizer.startListening(intent);
        }
    }

    private final void toggleBottomSheet() {
        if (getContext() == null) {
            return;
        }
        View view = this.parentLayout;
        if (view == null) {
            Intrinsics.m("parentLayout");
            throw null;
        }
        View findViewById = view.findViewById(c.voiceArea);
        Intrinsics.checkNotNullExpressionValue(findViewById, "parentLayout.findViewByI…veLayout>(R.id.voiceArea)");
        RelativeLayout relativeLayout = (RelativeLayout) findViewById;
        View view2 = this.parentLayout;
        if (view2 == null) {
            Intrinsics.m("parentLayout");
            throw null;
        }
        Object findViewById2 = view2.findViewById(c.floatingActionButton);
        Intrinsics.checkNotNullExpressionValue(findViewById2, "parentLayout.findViewByI….id.floatingActionButton)");
        YmMovableFloatingActionButton ymMovableFloatingActionButton = (YmMovableFloatingActionButton) findViewById2;
        View view3 = this.parentLayout;
        if (view3 == null) {
            Intrinsics.m("parentLayout");
            throw null;
        }
        View findViewById3 = view3.findViewById(c.speechTranscription);
        Intrinsics.checkNotNullExpressionValue(findViewById3, "parentLayout.findViewByI…R.id.speechTranscription)");
        TextView textView = (TextView) findViewById3;
        if (relativeLayout.getVisibility() == 4) {
            textView.setText(e.ym_msg_listening);
            this.willStartMic = false;
            relativeLayout.setVisibility(0);
            startListeningWithoutDialog();
            ymMovableFloatingActionButton.setImageDrawable(D8.i.j0(requireContext(), b.ic_back_button_ym));
            return;
        }
        relativeLayout.setVisibility(4);
        ymMovableFloatingActionButton.setImageDrawable(D8.i.j0(requireContext(), b.ic_mic_ym_small));
        SpeechRecognizer speechRecognizer = this.sr;
        if (speechRecognizer != null) {
            Intrinsics.e(speechRecognizer);
            speechRecognizer.stopListening();
        }
    }

    private final void updateAgentStatus(String str) {
        OkHttpClient okHttpClient = new OkHttpClient();
        ((g) uo.a.H().b).getClass();
        if (this.uid != null) {
            FormBody.Builder builder = new FormBody.Builder((Charset) null, 1, (DefaultConstructorMarker) null);
            String str2 = this.uid;
            Intrinsics.e(str2);
            FirebasePerfOkHttpClient.enqueue(okHttpClient.newCall(new Request.Builder().url("https://app.yellowmessenger.com/api/presence/usersPresence/log_user_profile").post(builder.add(LogSubCategory.Action.USER, str2).add("resource", "bot_" + ((g) uo.a.H().b).a).add("status", str).build()).build()), new io.sentry.hints.i(22));
        }
    }

    public final void closeVoiceArea() {
        if (getContext() == null) {
            return;
        }
        View view = this.parentLayout;
        if (view == null) {
            Intrinsics.m("parentLayout");
            throw null;
        }
        View findViewById = view.findViewById(c.voiceArea);
        Intrinsics.checkNotNullExpressionValue(findViewById, "parentLayout.findViewByI…veLayout>(R.id.voiceArea)");
        RelativeLayout relativeLayout = (RelativeLayout) findViewById;
        View view2 = this.parentLayout;
        if (view2 == null) {
            Intrinsics.m("parentLayout");
            throw null;
        }
        Object findViewById2 = view2.findViewById(c.floatingActionButton);
        Intrinsics.checkNotNullExpressionValue(findViewById2, "parentLayout.findViewByI….id.floatingActionButton)");
        YmMovableFloatingActionButton ymMovableFloatingActionButton = (YmMovableFloatingActionButton) findViewById2;
        View view3 = this.parentLayout;
        if (view3 == null) {
            Intrinsics.m("parentLayout");
            throw null;
        }
        View findViewById3 = view3.findViewById(c.speechTranscription);
        Intrinsics.checkNotNullExpressionValue(findViewById3, "parentLayout.findViewByI…R.id.speechTranscription)");
        relativeLayout.setVisibility(4);
        ymMovableFloatingActionButton.setImageDrawable(D8.i.j0(requireContext(), b.ic_mic_ym_small));
        SpeechRecognizer speechRecognizer = this.sr;
        if (speechRecognizer != null) {
            Intrinsics.e(speechRecognizer);
            speechRecognizer.stopListening();
            SpeechRecognizer speechRecognizer2 = this.sr;
            Intrinsics.e(speechRecognizer2);
            speechRecognizer2.destroy();
        }
    }

    public final String getPostUrl() {
        return this.postUrl;
    }

    public final SpeechRecognizer getSr() {
        return this.sr;
    }

    public void onActivityResult(int i, int i2, Intent intent) {
        Uri[] uriArr;
        if (i != this.INPUT_FILE_REQUEST_CODE || this.mFilePathCallback == null) {
            super.onActivityResult(i, i2, intent);
            return;
        }
        if (i2 == -1) {
            if (intent != null && intent.getDataString() != null) {
                uriArr = new Uri[]{Uri.parse(intent.getDataString())};
            } else if (intent == null || intent.getClipData() == null) {
                String str = this.mCameraPhotoPath;
                if (str != null) {
                    uriArr = new Uri[]{Uri.parse(str)};
                }
            } else {
                ClipData clipData = intent.getClipData();
                Intrinsics.e(clipData);
                int itemCount = clipData.getItemCount();
                if (itemCount > 0) {
                    Uri[] uriArr2 = new Uri[itemCount];
                    for (int i3 = 0; i3 < itemCount; i3++) {
                        ClipData clipData2 = intent.getClipData();
                        Intrinsics.e(clipData2);
                        uriArr2[i3] = clipData2.getItemAt(i3).getUri();
                    }
                    uriArr = uriArr2;
                }
            }
            ValueCallback<Uri[]> valueCallback = this.mFilePathCallback;
            Intrinsics.e(valueCallback);
            valueCallback.onReceiveValue(uriArr);
            this.mFilePathCallback = null;
        }
        uriArr = null;
        ValueCallback<Uri[]> valueCallback2 = this.mFilePathCallback;
        Intrinsics.e(valueCallback2);
        valueCallback2.onReceiveValue(uriArr);
        this.mFilePathCallback = null;
    }

    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        if (Build.VERSION.SDK_INT <= 34) {
            setStatusBarColor();
        }
        Context requireContext = requireContext();
        Intrinsics.checkNotNullExpressionValue(requireContext, "requireContext()");
        this.hasAudioPermissionInManifest = hasAudioPermissionInManifest(requireContext);
        f.i().b = new j(this);
    }

    public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        Intrinsics.checkNotNullParameter(layoutInflater, "inflater");
        View inflate = layoutInflater.inflate(d.fragment_yellow_bot_webview, viewGroup, false);
        View findViewById = inflate.findViewById(c.yellowWebView);
        Intrinsics.checkNotNullExpressionValue(findViewById, "v.findViewById(R.id.yellowWebView)");
        this.myWebView = (WebView) findViewById;
        View findViewById2 = inflate.findViewById(c.errorView);
        Intrinsics.checkNotNullExpressionValue(findViewById2, "v.findViewById(R.id.errorView)");
        this.errorOverlay = (FrameLayout) findViewById2;
        preLoadWebView();
        return inflate;
    }

    public void onDestroy() {
        f.i().b = null;
        super.onDestroy();
    }

    public void onStart() {
        throw new UnsupportedOperationException("Method not decompiled: com.yellowmessenger.ymchat.YellowBotWebviewFragment.onStart():void");
    }

    public void onStop() {
        if (this.shouldKeepApplicationInBackground) {
            if (this.isAgentConnected) {
                updateAgentStatus("offline");
            } else {
                ((g) uo.a.H().b).getClass();
            }
        }
        if (!this.isBotClosing) {
            f i = f.i();
            getString(e.ym_chat_bot_background_event);
            Object obj = i.a;
        }
        super.onStop();
    }

    public void onViewCreated(View view, Bundle bundle) {
        Intrinsics.checkNotNullParameter(view, "view");
        super.onViewCreated(view, bundle);
        this.parentLayout = view;
        boolean speechEnabled = getSpeechEnabled();
        Object findViewById = view.findViewById(c.floatingActionButton);
        Intrinsics.checkNotNullExpressionValue(findViewById, "view.findViewById(R.id.floatingActionButton)");
        YmMovableFloatingActionButton ymMovableFloatingActionButton = (YmMovableFloatingActionButton) findViewById;
        this.micButton = ymMovableFloatingActionButton;
        if (speechEnabled) {
            if (!this.hasAudioPermissionInManifest) {
                View view2 = this.parentLayout;
                if (view2 == null) {
                    Intrinsics.m("parentLayout");
                    throw null;
                }
                g.z0(view2, getString(e.ym_declare_audio_permission));
            } else {
                if (ymMovableFloatingActionButton == null) {
                    Intrinsics.m("micButton");
                    throw null;
                }
                boolean z = false;
                ymMovableFloatingActionButton.setVisibility(0);
                FloatingActionButton floatingActionButton = this.micButton;
                if (floatingActionButton == null) {
                    Intrinsics.m("micButton");
                    throw null;
                }
                final int i = 0;
                floatingActionButton.setOnClickListener(new View.OnClickListener(this) {
                    public final YellowBotWebviewFragment b;

                    {
                        this.b = this;
                    }

                    @Override
                    public final void onClick(View view3) {
                        switch (i) {
                            case 0:
                                YellowBotWebviewFragment.m27onViewCreated$lambda13(this.b, view3);
                                break;
                            default:
                                YellowBotWebviewFragment.m28onViewCreated$lambda14(this.b, view3);
                                break;
                        }
                    }
                });
                alignMicButton();
                Yf.a aVar = ((g) uo.a.H().b).i;
                if (((g) uo.a.H().b).j != null) {
                    try {
                        z = Intrinsics.c((Object) null, Boolean.FALSE);
                    } catch (Exception unused) {
                    }
                }
                if (z) {
                    YmMovableFloatingActionButton ymMovableFloatingActionButton2 = this.micButton;
                    if (ymMovableFloatingActionButton2 == null) {
                        Intrinsics.m("micButton");
                        throw null;
                    }
                    ymMovableFloatingActionButton2.setButtonToStatic();
                }
            }
        }
        View findViewById2 = view.findViewById(c.backButton);
        Intrinsics.checkNotNullExpressionValue(findViewById2, "view.findViewById(R.id.backButton)");
        ImageView imageView = (ImageView) findViewById2;
        this.closeButton = imageView;
        if (imageView == null) {
            Intrinsics.m("closeButton");
            throw null;
        }
        final int i2 = 1;
        imageView.setOnClickListener(new View.OnClickListener(this) {
            public final YellowBotWebviewFragment b;

            {
                this.b = this;
            }

            @Override
            public final void onClick(View view3) {
                switch (i2) {
                    case 0:
                        YellowBotWebviewFragment.m27onViewCreated$lambda13(this.b, view3);
                        break;
                    default:
                        YellowBotWebviewFragment.m28onViewCreated$lambda14(this.b, view3);
                        break;
                }
            }
        });
        showCloseButton();
        if (Build.VERSION.SDK_INT <= 34) {
            setStatusBarColorFromHex();
        }
        setCloseButtonColorFromHex();
        setKeyboardListener();
    }

    public final void reload() {
        WebView webView = this.myWebView;
        if (webView != null) {
            webView.reload();
        } else {
            Intrinsics.m("myWebView");
            throw null;
        }
    }

    public final void run() throws IOException {
        OkHttpClient okHttpClient = new OkHttpClient();
        String str = (String) ((HashMap) uo.a.H().d).get("imagePath");
        if (str == null || str.length() == 0) {
            return;
        }
        File file = new File(str);
        FirebasePerfOkHttpClient.enqueue(okHttpClient.newCall(new Request.Builder().url(this.postUrl).post(new MultipartBody.Builder((String) null, 1, (DefaultConstructorMarker) null).setType(MultipartBody.FORM).addFormDataPart("images", file.getName(), RequestBody.Companion.create(kotlin.text.y.g(str, "png", false) ? MediaType.Companion.parse("image/png") : MediaType.Companion.parse("image/jpeg"), file)).build()).build()), new hg.g(22));
    }

    public final void sendEvent(String str, String str2) {
        Intrinsics.checkNotNullParameter(str, "eventCode");
        Intrinsics.checkNotNullParameter(str2, "eventData");
        WebView webView = this.myWebView;
        if (webView != null) {
            webView.loadUrl(Ai.o.k("javascript:sendEvent('", str, "','", str2, "');"));
        } else {
            Intrinsics.m("myWebView");
            throw null;
        }
    }

    public final void setPostUrl(String str) {
        Intrinsics.checkNotNullParameter(str, "<set-?>");
        this.postUrl = str;
    }

    public final void setSr(SpeechRecognizer speechRecognizer) {
        this.sr = speechRecognizer;
    }
}