导航菜单

页面标题

页面副标题

Brevistay v5.8.2 - WebFragment.java 源代码

正在查看: Brevistay v5.8.2 应用的 WebFragment.java JAVA 源代码文件

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


package com.brevistay.app.view.main.fragments;

import android.app.Activity;
import android.app.DownloadManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.webkit.CookieManager;
import android.webkit.JavascriptInterface;
import android.webkit.URLUtil;
import android.webkit.WebResourceRequest;
import android.webkit.WebStorage;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.navigation.NavArgsLazy;
import com.airbnb.lottie.LottieAnimationView;
import com.brevistay.app.view.login.LoginActivity;
import com.brevistay.app.view.main.MainActivity;
import com.brevistay.app.view.main.fragments.WebFragment;
import com.facebook.appevents.internal.ViewHierarchyConstants;
import com.facebook.share.widget.ShareDialog;
import kotlin.Metadata;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Reflection;
import kotlin.text.StringsKt;

@Metadata(d1 = {"\u0000:\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\u0018\u00002\u00020\u0001:\u0002\u0017\u0018B\u0007¢\u0006\u0004\b\u0002\u0010\u0003J\u0012\u0010\u0012\u001a\u00020\u00132\b\u0010\u0014\u001a\u0004\u0018\u00010\u0015H\u0015J\b\u0010\u0016\u001a\u00020\u0013H\u0016R\u001b\u0010\u0004\u001a\u00020\u00058BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\b\u0010\t\u001a\u0004\b\u0006\u0010\u0007R\u000e\u0010\n\u001a\u00020\u000bX\u0082.¢\u0006\u0002\n\u0000R\u000e\u0010\f\u001a\u00020\rX\u0082.¢\u0006\u0002\n\u0000R\u000e\u0010\u000e\u001a\u00020\u000fX\u0082.¢\u0006\u0002\n\u0000R\u0010\u0010\u0010\u001a\u0004\u0018\u00010\u0011X\u0082\u000e¢\u0006\u0002\n\u0000¨\u0006\u0019"}, d2 = {"Lcom/brevistay/app/view/main/fragments/WebFragment;", "Landroidx/appcompat/app/AppCompatActivity;", "<init>", "()V", "args", "Lcom/brevistay/app/view/main/fragments/WebFragmentArgs;", "getArgs", "()Lcom/brevistay/app/view/main/fragments/WebFragmentArgs;", "args$delegate", "Landroidx/navigation/NavArgsLazy;", "webView", "Landroid/webkit/WebView;", "appbar", "Landroid/widget/RelativeLayout;", "loadingAnimationView", "Lcom/airbnb/lottie/LottieAnimationView;", "previousUrl", "", "onCreate", "", "savedInstanceState", "Landroid/os/Bundle;", "onBackPressed", "JavaScriptShareInterface", "MyWebViewClient", "app_release"}, k = 1, mv = {2, 1, 0}, xi = 48)
public final class WebFragment extends AppCompatActivity {
    private RelativeLayout appbar;

    private final NavArgsLazy args;
    private LottieAnimationView loadingAnimationView;
    private String previousUrl;
    private WebView webView;

    public WebFragment() {
        final Activity activity = (Activity) this;
        this.args = new NavArgsLazy(Reflection.getOrCreateKotlinClass(WebFragmentArgs.class), new Function0<Bundle>() {
            {
                super(0);
            }

            public final Bundle m282invoke() {
                Bundle bundle;
                Intent intent = activity.getIntent();
                if (intent != null) {
                    Activity activity2 = activity;
                    bundle = intent.getExtras();
                    if (bundle == null) {
                        throw new IllegalStateException("Activity " + activity2 + " has null extras in " + intent);
                    }
                } else {
                    bundle = null;
                }
                if (bundle != null) {
                    return bundle;
                }
                throw new IllegalStateException("Activity " + activity + " has a null Intent");
            }
        });
    }

    private final WebFragmentArgs getArgs() {
        return (WebFragmentArgs) this.args.getValue();
    }

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(2131558562);
        View findViewById = findViewById(2131363570);
        Intrinsics.checkNotNullExpressionValue(findViewById, "findViewById(...)");
        RelativeLayout relativeLayout = (RelativeLayout) findViewById;
        WebView webView = (WebView) findViewById(2131364195);
        this.webView = webView;
        LottieAnimationView lottieAnimationView = null;
        if (webView == null) {
            Intrinsics.throwUninitializedPropertyAccessException("webView");
            webView = null;
        }
        webView.setWebViewClient(new MyWebViewClient(this, relativeLayout));
        WebView webView2 = this.webView;
        if (webView2 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("webView");
            webView2 = null;
        }
        webView2.getSettings().setJavaScriptEnabled(true);
        WebView webView3 = this.webView;
        if (webView3 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("webView");
            webView3 = null;
        }
        webView3.getSettings().setDomStorageEnabled(true);
        WebView webView4 = this.webView;
        if (webView4 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("webView");
            webView4 = null;
        }
        webView4.getSettings().setCacheMode(2);
        WebView webView5 = this.webView;
        if (webView5 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("webView");
            webView5 = null;
        }
        webView5.getSettings().setAllowFileAccess(true);
        WebView webView6 = this.webView;
        if (webView6 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("webView");
            webView6 = null;
        }
        webView6.getSettings().setAllowContentAccess(true);
        WebView webView7 = this.webView;
        if (webView7 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("webView");
            webView7 = null;
        }
        webView7.getSettings().setMediaPlaybackRequiresUserGesture(false);
        WebView webView8 = this.webView;
        if (webView8 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("webView");
            webView8 = null;
        }
        webView8.getSettings().setLoadWithOverviewMode(true);
        WebView webView9 = this.webView;
        if (webView9 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("webView");
            webView9 = null;
        }
        webView9.getSettings().setUseWideViewPort(true);
        WebView webView10 = this.webView;
        if (webView10 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("webView");
            webView10 = null;
        }
        webView10.getSettings().setUserAgentString("Mozilla/5.0 (Linux; Android 10; Mobile) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Mobile Safari/537.36");
        JavaScriptShareInterface javaScriptShareInterface = new JavaScriptShareInterface((Context) this);
        WebView webView11 = this.webView;
        if (webView11 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("webView");
            webView11 = null;
        }
        webView11.addJavascriptInterface(javaScriptShareInterface, "AndroidShareHandler");
        if (getIntent().getData() != null) {
            Log.d("holida_login", "intent.data " + getIntent().getData());
            Log.d("intentdata", String.valueOf(getIntent().getData()));
            this.webView = (WebView) findViewById(2131364195);
            ((WebView) findViewById(2131364195)).loadUrl(String.valueOf(getIntent().getData()));
            WebView webView12 = this.webView;
            if (webView12 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("webView");
                webView12 = null;
            }
            webView12.getSettings().setTextZoom(100);
        } else if (getArgs().getUrl() != null || Intrinsics.areEqual(getArgs().getUrl(), "")) {
            this.webView = (WebView) findViewById(2131364195);
            ((WebView) findViewById(2131364195)).loadUrl(getArgs().getUrl());
            Log.d("intentdata", "args.url = " + getArgs().getUrl());
            WebView webView13 = this.webView;
            if (webView13 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("webView");
                webView13 = null;
            }
            webView13.getSettings().setTextZoom(100);
            try {
                if (Intrinsics.areEqual(getArgs().getShowAppbar(), "false")) {
                    relativeLayout.setVisibility(8);
                }
            } catch (Exception unused) {
            }
        }
        if (StringsKt.contains$default(String.valueOf(getIntent().getData()), "P2W", false, 2, (Object) null)) {
            relativeLayout.setVisibility(8);
        }
        WebView webView14 = this.webView;
        if (webView14 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("webView");
            webView14 = null;
        }
        webView14.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public final boolean onTouch(View view, MotionEvent motionEvent) {
                boolean onCreate$lambda$0;
                onCreate$lambda$0 = WebFragment.onCreate$lambda$0(view, motionEvent);
                return onCreate$lambda$0;
            }
        });
        LottieAnimationView lottieAnimationView2 = (LottieAnimationView) findViewById(2131363700);
        this.loadingAnimationView = lottieAnimationView2;
        if (lottieAnimationView2 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("loadingAnimationView");
        } else {
            lottieAnimationView = lottieAnimationView2;
        }
        lottieAnimationView.loop(true);
        ((ImageView) findViewById(2131362228)).setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                super/*androidx.appcompat.app.AppCompatActivity*/.onBackPressed();
            }
        });
    }

    public static final boolean onCreate$lambda$0(View view, MotionEvent motionEvent) {
        return motionEvent.getPointerCount() > 1;
    }

    @Metadata(d1 = {"\u0000 \n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0000\u0018\u00002\u00020\u0001B\u000f\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0004\b\u0004\u0010\u0005J\u000e\u0010\u0007\u001a\u00020\b2\u0006\u0010\u0002\u001a\u00020\u0003J\u0012\u0010\t\u001a\u00020\b2\b\u0010\n\u001a\u0004\u0018\u00010\u000bH\u0007R\u0010\u0010\u0006\u001a\u0004\u0018\u00010\u0003X\u0082\u000e¢\u0006\u0002\n\u0000¨\u0006\f"}, d2 = {"Lcom/brevistay/app/view/main/fragments/WebFragment$JavaScriptShareInterface;", "", "applicationContext", "Landroid/content/Context;", "<init>", "(Landroid/content/Context;)V", "mContext", "JavaScriptShareInterface", "", ShareDialog.WEB_SHARE_DIALOG, "url", "", "app_release"}, k = 1, mv = {2, 1, 0}, xi = 48)
    public static final class JavaScriptShareInterface {
        private Context mContext;

        public JavaScriptShareInterface(Context context) {
            Intrinsics.checkNotNullParameter(context, "applicationContext");
            this.mContext = context;
        }

        public final void JavaScriptShareInterface(Context applicationContext) {
            Intrinsics.checkNotNullParameter(applicationContext, "applicationContext");
            this.mContext = applicationContext;
        }

        @JavascriptInterface
        public final void share(String url) {
            Intent intent = new Intent("android.intent.action.SEND");
            intent.setType("text/plain");
            intent.putExtra("android.intent.extra.TEXT", url);
            Context context = this.mContext;
            if (context != null) {
                context.startActivity(Intent.createChooser(intent, "Share via"));
            }
        }
    }

    public void onBackPressed() {
        WebView webView = this.webView;
        WebView webView2 = null;
        if (webView == null) {
            Intrinsics.throwUninitializedPropertyAccessException("webView");
            webView = null;
        }
        if (Intrinsics.areEqual(webView.getUrl(), "https://mobileapp.holida.com/")) {
            WebView webView3 = this.webView;
            if (webView3 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("webView");
                webView3 = null;
            }
            Log.d("webFragment-onBackPressed", webView3.getUrl() + " ");
            WebView webView4 = this.webView;
            if (webView4 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("webView");
            } else {
                webView2 = webView4;
            }
            webView2.clearHistory();
            super.onBackPressed();
            return;
        }
        WebView webView5 = this.webView;
        if (webView5 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("webView");
            webView5 = null;
        }
        if (webView5.isFocused()) {
            WebView webView6 = this.webView;
            if (webView6 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("webView");
                webView6 = null;
            }
            if (webView6.canGoBack()) {
                WebView webView7 = this.webView;
                if (webView7 == null) {
                    Intrinsics.throwUninitializedPropertyAccessException("webView");
                } else {
                    webView2 = webView7;
                }
                webView2.goBack();
                return;
            }
        }
        if (isTaskRoot()) {
            startActivity(new Intent((Context) this, (Class<?>) MainActivity.class));
            finish();
        } else {
            super.onBackPressed();
        }
    }

    @Metadata(d1 = {"\u0000:\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\b\u0086\u0004\u0018\u00002\u00020\u0001B\u0011\b\u0000\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0004\b\u0004\u0010\u0005J\u001c\u0010\u0006\u001a\u00020\u00072\b\u0010\b\u001a\u0004\u0018\u00010\t2\b\u0010\n\u001a\u0004\u0018\u00010\u000bH\u0016J\u0012\u0010\f\u001a\u0004\u0018\u00010\r2\u0006\u0010\u000e\u001a\u00020\rH\u0002J&\u0010\u000f\u001a\u00020\u00102\b\u0010\b\u001a\u0004\u0018\u00010\t2\b\u0010\u000e\u001a\u0004\u0018\u00010\r2\b\u0010\u0011\u001a\u0004\u0018\u00010\u0012H\u0016J\u001c\u0010\u0013\u001a\u00020\u00102\b\u0010\b\u001a\u0004\u0018\u00010\t2\b\u0010\u000e\u001a\u0004\u0018\u00010\rH\u0016J\b\u0010\u0014\u001a\u00020\u0010H\u0002R\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\u0015"}, d2 = {"Lcom/brevistay/app/view/main/fragments/WebFragment$MyWebViewClient;", "Landroid/webkit/WebViewClient;", "relativeLayout", "Landroid/widget/RelativeLayout;", "<init>", "(Lcom/brevistay/app/view/main/fragments/WebFragment;Landroid/widget/RelativeLayout;)V", "shouldOverrideUrlLoading", "", ViewHierarchyConstants.VIEW_KEY, "Landroid/webkit/WebView;", "request", "Landroid/webkit/WebResourceRequest;", "getFileNameFromUrl", "", "url", "onPageStarted", "", "favicon", "Landroid/graphics/Bitmap;", "onPageFinished", "clearWebViewData", "app_release"}, k = 1, mv = {2, 1, 0}, xi = 48)
    public final class MyWebViewClient extends WebViewClient {
        private final RelativeLayout relativeLayout;
        final WebFragment this$0;

        public MyWebViewClient(WebFragment webFragment, RelativeLayout relativeLayout) {
            Intrinsics.checkNotNullParameter(relativeLayout, "relativeLayout");
            this.this$0 = webFragment;
            this.relativeLayout = relativeLayout;
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
            Context context;
            Log.d("webFragment-urlLoading", (request != null ? request.getUrl() : null) + " ");
            String valueOf = String.valueOf(request != null ? request.getUrl() : null);
            String str = valueOf;
            if (StringsKt.contains$default(str, "docs", false, 2, (Object) null) || StringsKt.contains$default(str, ".pdf", false, 2, (Object) null) || StringsKt.endsWith$default(valueOf, ".apk", false, 2, (Object) null)) {
                Object systemService = (view == null || (context = view.getContext()) == null) ? null : context.getSystemService("download");
                Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.app.DownloadManager");
                DownloadManager.Request request2 = new DownloadManager.Request(Uri.parse(valueOf));
                request2.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, getFileNameFromUrl(valueOf));
                request2.setNotificationVisibility(1);
                ((DownloadManager) systemService).enqueue(request2);
                Toast.makeText(view != null ? view.getContext() : null, "Download Started!", 0).show();
                return true;
            }
            if (!StringsKt.startsWith$default(valueOf, "http://", false, 2, (Object) null) && !StringsKt.startsWith$default(valueOf, "https://", false, 2, (Object) null)) {
                Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(valueOf));
                Intrinsics.checkNotNull(view);
                view.getContext().startActivity(intent);
            } else if (view != null) {
                view.loadUrl(valueOf);
            }
            return true;
        }

        private final String getFileNameFromUrl(String url) {
            String guessFileName = URLUtil.guessFileName(url, null, null);
            return guessFileName == null ? "download.unknown" : guessFileName;
        }

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            super.onPageStarted(view, url, favicon);
            WebView webView = this.this$0.webView;
            LottieAnimationView lottieAnimationView = null;
            if (webView == null) {
                Intrinsics.throwUninitializedPropertyAccessException("webView");
                webView = null;
            }
            Log.d("webFragment-onPAgeStarted", url + ", " + webView.getUrl() + " ");
            if (url != null) {
                String str = url;
                if (StringsKt.contains(str, "holida", true) || StringsKt.contains(str, "juspay", true) || StringsKt.contains(str, "shaadi", true)) {
                    this.relativeLayout.setVisibility(8);
                }
                if (Intrinsics.areEqual(url, "https://staging.d279ann6lgepc8.amplifyapp.com/")) {
                    Log.d("webFragment-onPAge1", url + " ");
                    WebView webView2 = this.this$0.webView;
                    if (webView2 == null) {
                        Intrinsics.throwUninitializedPropertyAccessException("webView");
                        webView2 = null;
                    }
                    webView2.clearHistory();
                }
            }
            LottieAnimationView lottieAnimationView2 = this.this$0.loadingAnimationView;
            if (lottieAnimationView2 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("loadingAnimationView");
                lottieAnimationView2 = null;
            }
            lottieAnimationView2.setVisibility(0);
            LottieAnimationView lottieAnimationView3 = this.this$0.loadingAnimationView;
            if (lottieAnimationView3 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("loadingAnimationView");
            } else {
                lottieAnimationView = lottieAnimationView3;
            }
            lottieAnimationView.playAnimation();
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            String substringAfter$default;
            super.onPageFinished(view, url);
            LottieAnimationView lottieAnimationView = this.this$0.loadingAnimationView;
            if (lottieAnimationView == null) {
                Intrinsics.throwUninitializedPropertyAccessException("loadingAnimationView");
                lottieAnimationView = null;
            }
            lottieAnimationView.setVisibility(8);
            LottieAnimationView lottieAnimationView2 = this.this$0.loadingAnimationView;
            if (lottieAnimationView2 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("loadingAnimationView");
                lottieAnimationView2 = null;
            }
            lottieAnimationView2.cancelAnimation();
            Log.d("webFragment-onPAgeFinished", url + " ");
            if (url != null) {
                String str = url;
                if (StringsKt.contains(str, "#login", true)) {
                    Log.d("webFragment112", String.valueOf(url));
                    final WebFragment webFragment = this.this$0;
                    webFragment.runOnUiThread(new Runnable() {
                        @Override
                        public final void run() {
                            WebFragment.MyWebViewClient.onPageFinished$lambda$0(WebFragment.this);
                        }
                    });
                    if (StringsKt.contains$default(str, "payment", false, 2, (Object) null)) {
                        substringAfter$default = StringsKt.replace$default(url, "#login", "", false, 4, (Object) null);
                    } else {
                        substringAfter$default = StringsKt.substringAfter$default(url, "url=", (String) null, 2, (Object) null);
                    }
                    Log.d("webFragment-host", substringAfter$default + " ");
                    Intent intent = new Intent((Context) this.this$0, (Class<?>) LoginActivity.class);
                    intent.putExtra("channel", "webView");
                    intent.putExtra("urlWeb", substringAfter$default);
                    Log.d("holida_login", "channel = webView urlWeb = " + substringAfter$default + " ");
                    this.this$0.startActivity(intent);
                }
            }
        }

        public static final void onPageFinished$lambda$0(WebFragment webFragment) {
            Toast.makeText((Context) webFragment, "You Need To Login First", 0).show();
        }

        private final void clearWebViewData() {
            WebStorage.getInstance().deleteAllData();
            WebView webView = null;
            CookieManager.getInstance().removeAllCookies(null);
            CookieManager.getInstance().flush();
            WebView webView2 = this.this$0.webView;
            if (webView2 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("webView");
                webView2 = null;
            }
            webView2.clearCache(true);
            WebView webView3 = this.this$0.webView;
            if (webView3 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("webView");
                webView3 = null;
            }
            webView3.clearHistory();
            WebView webView4 = this.this$0.webView;
            if (webView4 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("webView");
                webView4 = null;
            }
            webView4.clearFormData();
            WebView webView5 = this.this$0.webView;
            if (webView5 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("webView");
            } else {
                webView = webView5;
            }
            webView.getSettings().setCacheMode(2);
        }
    }
}