导航菜单

页面标题

页面副标题

Rilo v2.0.21 - WebViewActivity.java 源代码

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

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


package app.callpe.ui.misc;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.print.PrintAttributes;
import android.print.PrintDocumentAdapter;
import android.print.PrintJob;
import android.print.PrintManager;
import android.view.View;
import android.webkit.ValueCallback;
import android.webkit.WebView;
import androidx.activity.result.ActivityResult;
import androidx.activity.result.ActivityResultCallback;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContract;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.appcompat.app.AppCompatActivity;
import app.callpe.common.utils.extensions.ActivityExtKt;
import app.callpe.databinding.ActivityWebViewBinding;
import kotlin.Metadata;
import kotlin.jvm.internal.Intrinsics;
import timber.log.Timber;

@Metadata(d1 = {"\u0000Z\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0011\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0003\u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002J\b\u0010\u0015\u001a\u00020\u0016H\u0002J\b\u0010\u0017\u001a\u00020\u0016H\u0003J\b\u0010\u0018\u001a\u00020\u0016H\u0002J\u0012\u0010\u0019\u001a\u00020\u00162\b\u0010\u001a\u001a\u0004\u0018\u00010\u001bH\u0014J\b\u0010\u001c\u001a\u00020\u0016H\u0014J\b\u0010\u001d\u001a\u00020\u0016H\u0002J\u0010\u0010\u001e\u001a\u00020\u00162\u0006\u0010\u001f\u001a\u00020 H\u0002J\b\u0010!\u001a\u00020\u0016H\u0002J\b\u0010\"\u001a\u00020\u0016H\u0002R\u000e\u0010\u0003\u001a\u00020\u0004X\u0082.¢\u0006\u0002\n\u0000R\u001c\u0010\u0005\u001a\u0010\u0012\f\u0012\n \b*\u0004\u0018\u00010\u00070\u00070\u0006X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\t\u001a\u00020\nX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u000b\u001a\u00020\nX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\f\u001a\u00020\rX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u000e\u001a\u00020\u000fX\u0082.¢\u0006\u0002\n\u0000R\u0016\u0010\u0010\u001a\n\u0012\u0004\u0012\u00020\u0012\u0018\u00010\u0011X\u0082\u000e¢\u0006\u0002\n\u0000R\u001c\u0010\u0013\u001a\u0010\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u00120\u0014\u0018\u00010\u0011X\u0082\u000e¢\u0006\u0002\n\u0000¨\u0006#"}, d2 = {"Lapp/callpe/ui/misc/WebViewActivity;", "Landroidx/appcompat/app/AppCompatActivity;", "()V", "binding", "Lapp/callpe/databinding/ActivityWebViewBinding;", "fileChooserLauncher", "Landroidx/activity/result/ActivityResultLauncher;", "Landroid/content/Intent;", "kotlin.jvm.PlatformType", "invoiceId", "", "myUrl", "printBtnPressed", "", "printJob", "Landroid/print/PrintJob;", "uploadMessage", "Landroid/webkit/ValueCallback;", "Landroid/net/Uri;", "uploadMessageAboveL", "", "handleIntents", "", "initViews", "onClicks", "onCreate", "savedInstanceState", "Landroid/os/Bundle;", "onResume", "openFileChooser", "printWebPage", "webView", "Landroid/webkit/WebView;", "setupDefaultSettings", "setupGoogleDocsSettings", "app_riloRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
public final class WebViewActivity extends AppCompatActivity {
    private ActivityWebViewBinding binding;
    private final ActivityResultLauncher<Intent> fileChooserLauncher;
    private boolean printBtnPressed;
    private PrintJob printJob;
    private ValueCallback<Uri> uploadMessage;
    private ValueCallback<Uri[]> uploadMessageAboveL;
    private String myUrl = "";
    private String invoiceId = "111";

    public WebViewActivity() {
        ActivityResultLauncher<Intent> registerForActivityResult = registerForActivityResult((ActivityResultContract) new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback() {
            public final void onActivityResult(Object obj) {
                WebViewActivity.fileChooserLauncher$lambda$1(WebViewActivity.this, (ActivityResult) obj);
            }
        });
        Intrinsics.checkNotNullExpressionValue(registerForActivityResult, "registerForActivityResul…l\n            }\n        }");
        this.fileChooserLauncher = registerForActivityResult;
    }

    public static final void fileChooserLauncher$lambda$1(WebViewActivity webViewActivity, ActivityResult activityResult) {
        Intrinsics.checkNotNullParameter(webViewActivity, "this$0");
        if (activityResult.getResultCode() == -1) {
            Intent data = activityResult.getData();
            Uri data2 = data != null ? data.getData() : null;
            ValueCallback<Uri> valueCallback = webViewActivity.uploadMessage;
            if (valueCallback != null) {
                valueCallback.onReceiveValue(data2);
            }
            ValueCallback<Uri[]> valueCallback2 = webViewActivity.uploadMessageAboveL;
            if (valueCallback2 != null) {
                valueCallback2.onReceiveValue(data2 != null ? new Uri[]{data2} : null);
            }
            webViewActivity.uploadMessage = null;
            webViewActivity.uploadMessageAboveL = null;
            return;
        }
        ValueCallback<Uri> valueCallback3 = webViewActivity.uploadMessage;
        if (valueCallback3 != null) {
            valueCallback3.onReceiveValue(null);
        }
        ValueCallback<Uri[]> valueCallback4 = webViewActivity.uploadMessageAboveL;
        if (valueCallback4 != null) {
            valueCallback4.onReceiveValue(null);
        }
        webViewActivity.uploadMessage = null;
        webViewActivity.uploadMessageAboveL = null;
    }

    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());
        handleIntents();
        initViews();
        onClicks();
    }

    private final void handleIntents() {
        Intent intent = getIntent();
        this.myUrl = String.valueOf(intent != null ? intent.getStringExtra("url") : null);
        Intent intent2 = getIntent();
        this.invoiceId = String.valueOf(intent2 != null ? intent2.getStringExtra("invoiceId") : null);
    }

    private final void initViews() {
        throw new UnsupportedOperationException("Method not decompiled: app.callpe.ui.misc.WebViewActivity.initViews():void");
    }

    public final void openFileChooser() {
        Intent intent = new Intent("android.intent.action.GET_CONTENT");
        intent.setType("*/*");
        intent.addCategory("android.intent.category.OPENABLE");
        this.fileChooserLauncher.launch(Intent.createChooser(intent, "Select a file"));
    }

    private final void setupGoogleDocsSettings() {
        ActivityWebViewBinding activityWebViewBinding = this.binding;
        if (activityWebViewBinding == null) {
            Intrinsics.throwUninitializedPropertyAccessException("binding");
            activityWebViewBinding = null;
        }
        WebView webView = activityWebViewBinding.webView;
        webView.getSettings().setLoadWithOverviewMode(true);
        webView.getSettings().setUseWideViewPort(true);
        webView.getSettings().setSupportZoom(true);
        webView.getSettings().setBuiltInZoomControls(true);
        webView.getSettings().setDisplayZoomControls(false);
        webView.setScrollBarStyle(33554432);
        webView.setScrollbarFadingEnabled(false);
    }

    private final void setupDefaultSettings() {
        ActivityWebViewBinding activityWebViewBinding = this.binding;
        if (activityWebViewBinding == null) {
            Intrinsics.throwUninitializedPropertyAccessException("binding");
            activityWebViewBinding = null;
        }
        WebView webView = activityWebViewBinding.webView;
        webView.getSettings().setLoadWithOverviewMode(true);
        webView.getSettings().setUseWideViewPort(true);
        webView.getSettings().setSupportZoom(true);
        webView.getSettings().setBuiltInZoomControls(true);
        webView.getSettings().setDisplayZoomControls(false);
        webView.getSettings().setDomStorageEnabled(true);
        webView.getSettings().setAllowFileAccess(true);
    }

    private final void onClicks() {
        ActivityWebViewBinding activityWebViewBinding = this.binding;
        if (activityWebViewBinding == null) {
            Intrinsics.throwUninitializedPropertyAccessException("binding");
            activityWebViewBinding = null;
        }
        activityWebViewBinding.saveAsPdfBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                WebViewActivity.onClicks$lambda$6(WebViewActivity.this, view);
            }
        });
    }

    public static final void onClicks$lambda$6(WebViewActivity webViewActivity, View view) {
        Intrinsics.checkNotNullParameter(webViewActivity, "this$0");
        ActivityWebViewBinding activityWebViewBinding = webViewActivity.binding;
        if (activityWebViewBinding == null) {
            Intrinsics.throwUninitializedPropertyAccessException("binding");
            activityWebViewBinding = null;
        }
        WebView webView = activityWebViewBinding.webView;
        Intrinsics.checkNotNullExpressionValue(webView, "binding.webView");
        webViewActivity.printWebPage(webView);
    }

    private final void printWebPage(WebView webView) {
        this.printBtnPressed = true;
        Object systemService = getSystemService("print");
        Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.print.PrintManager");
        String str = "Invoice_" + this.invoiceId;
        PrintDocumentAdapter createPrintDocumentAdapter = webView.createPrintDocumentAdapter(str);
        Intrinsics.checkNotNullExpressionValue(createPrintDocumentAdapter, "webView.createPrintDocumentAdapter(jobName)");
        PrintJob print = ((PrintManager) systemService).print(str, createPrintDocumentAdapter, new PrintAttributes.Builder().build());
        Intrinsics.checkNotNullExpressionValue(print, "printManager.print(jobNa…ibutes.Builder().build())");
        this.printJob = print;
    }

    protected void onResume() {
        super.onResume();
        if (this.printBtnPressed) {
            PrintJob printJob = this.printJob;
            PrintJob printJob2 = null;
            if (printJob == null) {
                Intrinsics.throwUninitializedPropertyAccessException("printJob");
                printJob = null;
            }
            if (printJob.isCompleted()) {
                Timber.d("Invoice: Pdf saved.", new Object[0]);
                ActivityExtKt.toast((Activity) this, "Invoice saved as pdf");
            } else {
                PrintJob printJob3 = this.printJob;
                if (printJob3 == null) {
                    Intrinsics.throwUninitializedPropertyAccessException("printJob");
                    printJob3 = null;
                }
                if (printJob3.isStarted()) {
                    Timber.d("Invoice: Pdf download started...", new Object[0]);
                } else {
                    PrintJob printJob4 = this.printJob;
                    if (printJob4 == null) {
                        Intrinsics.throwUninitializedPropertyAccessException("printJob");
                        printJob4 = null;
                    }
                    if (printJob4.isBlocked()) {
                        Timber.d("Invoice: Pdf download blocked.", new Object[0]);
                    } else {
                        PrintJob printJob5 = this.printJob;
                        if (printJob5 == null) {
                            Intrinsics.throwUninitializedPropertyAccessException("printJob");
                            printJob5 = null;
                        }
                        if (printJob5.isCancelled()) {
                            Timber.d("Invoice: Pdf download cancelled.", new Object[0]);
                        } else {
                            PrintJob printJob6 = this.printJob;
                            if (printJob6 == null) {
                                Intrinsics.throwUninitializedPropertyAccessException("printJob");
                                printJob6 = null;
                            }
                            if (printJob6.isFailed()) {
                                Timber.d("Invoice: Pdf download failed.", new Object[0]);
                                ActivityExtKt.toast((Activity) this, "Failed to download invoice");
                            } else {
                                PrintJob printJob7 = this.printJob;
                                if (printJob7 == null) {
                                    Intrinsics.throwUninitializedPropertyAccessException("printJob");
                                } else {
                                    printJob2 = printJob7;
                                }
                                if (printJob2.isQueued()) {
                                    Timber.d("Invoice: Pdf download job is queued...", new Object[0]);
                                }
                            }
                        }
                    }
                }
            }
            this.printBtnPressed = false;
        }
    }
}