导航菜单

页面标题

页面副标题

Rilo v2.0.21 - ContractWebViewActivity.java 源代码

正在查看: Rilo v2.0.21 应用的 ContractWebViewActivity.java JAVA 源代码文件

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


package app.callpe.ui.misc;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.View;
import android.webkit.JavascriptInterface;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import androidx.activity.ComponentActivity;
import androidx.appcompat.app.AlertDialog;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LifecycleOwnerKt;
import androidx.lifecycle.ViewModelLazy;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelStore;
import androidx.lifecycle.viewmodel.CreationExtras;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import app.callpe.databinding.ActivityWebViewBinding;
import app.callpe.ui.home.AccountViewModel;
import app.callpe.ui.home.WithdrawActivity;
import app.callpe.ui.home.agent.fragments.EarningFragment;
import app.callpe.ui.home.vitok.fragments.StreamerStatsHomeFragment;
import app.callpe.ui.misc.ContractWebViewActivity;
import dagger.hilt.android.AndroidEntryPoint;
import kotlin.Lazy;
import kotlin.Metadata;
import kotlin.coroutines.CoroutineContext;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Reflection;
import kotlin.text.StringsKt;
import kotlinx.coroutines.BuildersKt;
import kotlinx.coroutines.CoroutineStart;
import kotlinx.coroutines.Job;
import timber.log.Timber;

@Metadata(d1 = {"\u0000J\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0010\u000e\n\u0002\b\u0003\b\u0007\u0018\u00002\u00020\u0001:\u0001!B\u0005¢\u0006\u0002\u0010\u0002J\u0006\u0010\u0011\u001a\u00020\u0012J\b\u0010\u0013\u001a\u00020\u0014H\u0002J\b\u0010\u0015\u001a\u00020\u0012H\u0016J\u0012\u0010\u0016\u001a\u00020\u00122\b\u0010\u0017\u001a\u0004\u0018\u00010\u0018H\u0014J\b\u0010\u0019\u001a\u00020\u0012H\u0014J\b\u0010\u001a\u001a\u00020\u0012H\u0014J\b\u0010\u001b\u001a\u00020\u0012H\u0002J\b\u0010\u001c\u001a\u00020\u0012H\u0003J\u0010\u0010\u001d\u001a\u00020\u00122\u0006\u0010\u001e\u001a\u00020\u001fH\u0002J\b\u0010 \u001a\u00020\u0012H\u0002R\u000e\u0010\u0003\u001a\u00020\u0004X\u0082.¢\u0006\u0002\n\u0000R\u000e\u0010\u0005\u001a\u00020\u0006X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0007\u001a\u00020\bX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\t\u001a\u00020\nX\u0082\u000e¢\u0006\u0002\n\u0000R\u001b\u0010\u000b\u001a\u00020\f8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\u000f\u0010\u0010\u001a\u0004\b\r\u0010\u000e¨\u0006\""}, d2 = {"Lapp/callpe/ui/misc/ContractWebViewActivity;", "Landroidx/appcompat/app/AppCompatActivity;", "()V", "binding", "Lapp/callpe/databinding/ActivityWebViewBinding;", "broadcastReceiver", "Landroid/content/BroadcastReceiver;", "dialogAlreadyShowing", "", "retryCount", "", "viewModel", "Lapp/callpe/ui/home/AccountViewModel;", "getViewModel", "()Lapp/callpe/ui/home/AccountViewModel;", "viewModel$delegate", "Lkotlin/Lazy;", "handleWebViewError", "", "observeEvent", "Lkotlinx/coroutines/Job;", "onBackPressed", "onCreate", "savedInstanceState", "Landroid/os/Bundle;", "onDestroy", "onStart", "registerReceiver", "setUpWebView", "showExitDialog", "kycContractStatus", "", "unRegisterReceiver", "WebAppInterface", "app_riloRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
@AndroidEntryPoint
public final class ContractWebViewActivity extends Hilt_ContractWebViewActivity {
    private ActivityWebViewBinding binding;
    private final BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            Intrinsics.checkNotNullParameter(context, "context");
            Intrinsics.checkNotNullParameter(intent, "intent");
            Timber.e("Action %s", new Object[]{intent.getAction()});
            String action = intent.getAction();
            if (action != null && action.hashCode() == 956262121 && action.equals(StreamerStatsHomeFragment.CONTRACT_SIGNED)) {
                StreamerStatsHomeFragment.INSTANCE.setResume(true);
                WithdrawActivity.INSTANCE.setResume(true);
                EarningFragment.INSTANCE.setResume(true);
                ContractWebViewActivity.this.finish();
            }
        }
    };
    private boolean dialogAlreadyShowing;
    private int retryCount;

    private final Lazy viewModel;

    public ContractWebViewActivity() {
        final ComponentActivity componentActivity = (ComponentActivity) this;
        final Function0 function0 = null;
        this.viewModel = new ViewModelLazy(Reflection.getOrCreateKotlinClass(AccountViewModel.class), new Function0<ViewModelStore>() {
            {
                super(0);
            }

            public final ViewModelStore m1922invoke() {
                return componentActivity.getViewModelStore();
            }
        }, new Function0<ViewModelProvider.Factory>() {
            {
                super(0);
            }

            public final ViewModelProvider.Factory m1921invoke() {
                return componentActivity.getDefaultViewModelProviderFactory();
            }
        }, new Function0<CreationExtras>() {
            {
                super(0);
            }

            public final CreationExtras m1923invoke() {
                CreationExtras creationExtras;
                Function0 function02 = function0;
                return (function02 == null || (creationExtras = (CreationExtras) function02.invoke()) == null) ? componentActivity.getDefaultViewModelCreationExtras() : creationExtras;
            }
        });
    }

    public final AccountViewModel getViewModel() {
        return (AccountViewModel) this.viewModel.getValue();
    }

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityWebViewBinding inflate = ActivityWebViewBinding.inflate(getLayoutInflater());
        Intrinsics.checkNotNullExpressionValue(inflate, "inflate(layoutInflater)");
        this.binding = inflate;
        if (inflate == null) {
            Intrinsics.throwUninitializedPropertyAccessException("binding");
            inflate = null;
        }
        setContentView((View) inflate.getRoot());
        setUpWebView();
        observeEvent();
    }

    private final Job observeEvent() {
        return BuildersKt.launch$default(LifecycleOwnerKt.getLifecycleScope((LifecycleOwner) this), (CoroutineContext) null, (CoroutineStart) null, new ContractWebViewActivity$observeEvent$1(this, null), 3, (Object) null);
    }

    public final void showExitDialog(String kycContractStatus) {
        if (Intrinsics.areEqual(kycContractStatus, "COMPLETED")) {
            finish();
            return;
        }
        if (!Intrinsics.areEqual(kycContractStatus, "INITIATED") || this.dialogAlreadyShowing) {
            return;
        }
        AlertDialog create = new AlertDialog.Builder((Context) this).setTitle("Action Required").setMessage("Please sign to use the app.").setPositiveButton("OK", new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                ContractWebViewActivity.showExitDialog$lambda$0(ContractWebViewActivity.this, dialogInterface, i);
            }
        }).setCancelable(false).create();
        Intrinsics.checkNotNullExpressionValue(create, "Builder(this).setTitle(\"…ancelable(false).create()");
        create.show();
        this.dialogAlreadyShowing = true;
    }

    public static final void showExitDialog$lambda$0(ContractWebViewActivity contractWebViewActivity, DialogInterface dialogInterface, int i) {
        Intrinsics.checkNotNullParameter(contractWebViewActivity, "this$0");
        dialogInterface.dismiss();
        contractWebViewActivity.dialogAlreadyShowing = false;
    }

    private final void setUpWebView() {
        String valueOf = String.valueOf(getIntent().getStringExtra("url"));
        ActivityWebViewBinding activityWebViewBinding = this.binding;
        ActivityWebViewBinding activityWebViewBinding2 = null;
        if (activityWebViewBinding == null) {
            Intrinsics.throwUninitializedPropertyAccessException("binding");
            activityWebViewBinding = null;
        }
        activityWebViewBinding.webView.getSettings().setJavaScriptEnabled(true);
        ActivityWebViewBinding activityWebViewBinding3 = this.binding;
        if (activityWebViewBinding3 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("binding");
            activityWebViewBinding3 = null;
        }
        activityWebViewBinding3.webView.addJavascriptInterface(new WebAppInterface(), "Android");
        String str = valueOf;
        if (StringsKt.contains$default(str, "docs.google.com", false, 2, (Object) null)) {
            ActivityWebViewBinding activityWebViewBinding4 = this.binding;
            if (activityWebViewBinding4 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("binding");
                activityWebViewBinding4 = null;
            }
            activityWebViewBinding4.webView.getSettings().setLoadWithOverviewMode(true);
            ActivityWebViewBinding activityWebViewBinding5 = this.binding;
            if (activityWebViewBinding5 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("binding");
                activityWebViewBinding5 = null;
            }
            activityWebViewBinding5.webView.getSettings().setUseWideViewPort(true);
            ActivityWebViewBinding activityWebViewBinding6 = this.binding;
            if (activityWebViewBinding6 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("binding");
                activityWebViewBinding6 = null;
            }
            activityWebViewBinding6.webView.getSettings().setSupportZoom(true);
            ActivityWebViewBinding activityWebViewBinding7 = this.binding;
            if (activityWebViewBinding7 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("binding");
                activityWebViewBinding7 = null;
            }
            activityWebViewBinding7.webView.getSettings().setBuiltInZoomControls(true);
            ActivityWebViewBinding activityWebViewBinding8 = this.binding;
            if (activityWebViewBinding8 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("binding");
                activityWebViewBinding8 = null;
            }
            activityWebViewBinding8.webView.getSettings().setDisplayZoomControls(false);
            ActivityWebViewBinding activityWebViewBinding9 = this.binding;
            if (activityWebViewBinding9 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("binding");
                activityWebViewBinding9 = null;
            }
            activityWebViewBinding9.webView.setScrollBarStyle(33554432);
            ActivityWebViewBinding activityWebViewBinding10 = this.binding;
            if (activityWebViewBinding10 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("binding");
                activityWebViewBinding10 = null;
            }
            activityWebViewBinding10.webView.setScrollbarFadingEnabled(false);
        }
        ActivityWebViewBinding activityWebViewBinding11 = this.binding;
        if (activityWebViewBinding11 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("binding");
            activityWebViewBinding11 = null;
        }
        final String str2 = "window.addEventListener('error', function(event) {\n    Android.onError();\n    return true;\n});\n\nwindow.addEventListener('unhandledrejection', function(event) {\n    Android.onError();\n    return true;\n});";
        activityWebViewBinding11.webView.setWebViewClient(new WebViewClient() {
            @Override
            public void onPageFinished(WebView view, String url) {
                ActivityWebViewBinding activityWebViewBinding12;
                ActivityWebViewBinding activityWebViewBinding13;
                super.onPageFinished(view, url);
                activityWebViewBinding12 = ContractWebViewActivity.this.binding;
                if (activityWebViewBinding12 == null) {
                    Intrinsics.throwUninitializedPropertyAccessException("binding");
                    activityWebViewBinding12 = null;
                }
                ProgressBar progressBar = activityWebViewBinding12.progress;
                Intrinsics.checkNotNullExpressionValue(progressBar, "binding.progress");
                progressBar.setVisibility(8);
                activityWebViewBinding13 = ContractWebViewActivity.this.binding;
                if (activityWebViewBinding13 == null) {
                    Intrinsics.throwUninitializedPropertyAccessException("binding");
                    activityWebViewBinding13 = null;
                }
                activityWebViewBinding13.webView.evaluateJavascript(str2, null);
                Timber.d("Current url " + url, new Object[0]);
                if (view != null) {
                    view.scrollTo(0, view.getContentHeight());
                }
            }

            @Override
            public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
                super.onReceivedError(view, request, error);
                ContractWebViewActivity.this.handleWebViewError();
            }

            @Override
            public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
                super.onReceivedHttpError(view, request, errorResponse);
                ContractWebViewActivity.this.handleWebViewError();
            }
        });
        ActivityWebViewBinding activityWebViewBinding12 = this.binding;
        if (activityWebViewBinding12 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("binding");
            activityWebViewBinding12 = null;
        }
        activityWebViewBinding12.webView.loadUrl(valueOf);
        ActivityWebViewBinding activityWebViewBinding13 = this.binding;
        if (activityWebViewBinding13 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("binding");
        } else {
            activityWebViewBinding2 = activityWebViewBinding13;
        }
        LinearLayout linearLayout = activityWebViewBinding2.pageNotFound;
        Intrinsics.checkNotNullExpressionValue(linearLayout, "binding.pageNotFound");
        linearLayout.setVisibility(str.length() == 0 ? 0 : 8);
    }

    public final void handleWebViewError() {
        ActivityWebViewBinding activityWebViewBinding = this.binding;
        if (activityWebViewBinding == null) {
            Intrinsics.throwUninitializedPropertyAccessException("binding");
            activityWebViewBinding = null;
        }
        ProgressBar progressBar = activityWebViewBinding.progress;
        Intrinsics.checkNotNullExpressionValue(progressBar, "binding.progress");
        progressBar.setVisibility(8);
        if (this.dialogAlreadyShowing) {
            return;
        }
        AlertDialog create = new AlertDialog.Builder((Context) this).setTitle("Error").setMessage("There was an issue loading the page. Please try again later.").setPositiveButton("Retry", new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                ContractWebViewActivity.handleWebViewError$lambda$1(ContractWebViewActivity.this, dialogInterface, i);
            }
        }).setNegativeButton("Close", new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                ContractWebViewActivity.handleWebViewError$lambda$2(ContractWebViewActivity.this, dialogInterface, i);
            }
        }).setCancelable(false).create();
        Intrinsics.checkNotNullExpressionValue(create, "Builder(this).setTitle(\"…ancelable(false).create()");
        create.show();
        this.dialogAlreadyShowing = true;
    }

    public static final void handleWebViewError$lambda$1(ContractWebViewActivity contractWebViewActivity, DialogInterface dialogInterface, int i) {
        Intrinsics.checkNotNullParameter(contractWebViewActivity, "this$0");
        ActivityWebViewBinding activityWebViewBinding = contractWebViewActivity.binding;
        if (activityWebViewBinding == null) {
            Intrinsics.throwUninitializedPropertyAccessException("binding");
            activityWebViewBinding = null;
        }
        activityWebViewBinding.webView.reload();
        dialogInterface.dismiss();
        contractWebViewActivity.dialogAlreadyShowing = false;
    }

    public static final void handleWebViewError$lambda$2(ContractWebViewActivity contractWebViewActivity, DialogInterface dialogInterface, int i) {
        Intrinsics.checkNotNullParameter(contractWebViewActivity, "this$0");
        dialogInterface.dismiss();
        contractWebViewActivity.dialogAlreadyShowing = false;
        contractWebViewActivity.finish();
    }

    @Metadata(d1 = {"\u0000\u0012\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\b\u0086\u0004\u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002J\b\u0010\u0003\u001a\u00020\u0004H\u0007¨\u0006\u0005"}, d2 = {"Lapp/callpe/ui/misc/ContractWebViewActivity$WebAppInterface;", "", "(Lapp/callpe/ui/misc/ContractWebViewActivity;)V", "onError", "", "app_riloRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
    public final class WebAppInterface {
        public WebAppInterface() {
        }

        @JavascriptInterface
        public final void onError() {
            final ContractWebViewActivity contractWebViewActivity = ContractWebViewActivity.this;
            contractWebViewActivity.runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    ContractWebViewActivity.WebAppInterface.onError$lambda$0(ContractWebViewActivity.this);
                }
            });
        }

        public static final void onError$lambda$0(ContractWebViewActivity contractWebViewActivity) {
            Intrinsics.checkNotNullParameter(contractWebViewActivity, "this$0");
            contractWebViewActivity.handleWebViewError();
        }
    }

    protected void onStart() {
        super.onStart();
        registerReceiver();
    }

    protected void onDestroy() {
        super.onDestroy();
        unRegisterReceiver();
        StreamerStatsHomeFragment.INSTANCE.setResume(true);
        WithdrawActivity.INSTANCE.setResume(true);
        EarningFragment.INSTANCE.setResume(true);
    }

    private final void registerReceiver() {
        LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance((Context) this);
        Intrinsics.checkNotNullExpressionValue(localBroadcastManager, "getInstance(this)");
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(StreamerStatsHomeFragment.CONTRACT_SIGNED);
        localBroadcastManager.registerReceiver(this.broadcastReceiver, intentFilter);
    }

    private final void unRegisterReceiver() {
        LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance((Context) this);
        Intrinsics.checkNotNullExpressionValue(localBroadcastManager, "getInstance(this)");
        localBroadcastManager.unregisterReceiver(this.broadcastReceiver);
    }

    public void onBackPressed() {
        AccountViewModel.getUserDetails$default(getViewModel(), false, false, 3, null);
    }
}