导航菜单

页面标题

页面副标题

Rilo v2.0.21 - PaymentAuthWebViewActivity.java 源代码

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

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


package com.stripe.android.view;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import androidx.activity.ComponentActivity;
import androidx.activity.OnBackPressedCallback;
import androidx.activity.OnBackPressedDispatcher;
import androidx.activity.OnBackPressedDispatcherKt;
import androidx.appcompat.app.AppCompatActivity;
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 com.stripe.android.R;
import com.stripe.android.auth.PaymentBrowserAuthContract;
import com.stripe.android.core.Logger;
import com.stripe.android.core.exception.StripeException;
import com.stripe.android.databinding.StripePaymentAuthWebViewActivityBinding;
import com.stripe.android.payments.PaymentFlowResult;
import com.stripe.android.stripe3ds2.utils.CustomizeUtils;
import com.stripe.android.view.PaymentAuthWebViewActivityViewModel;
import kotlin.Lazy;
import kotlin.LazyKt;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.coroutines.CoroutineContext;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
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.flow.MutableStateFlow;
import kotlinx.coroutines.flow.StateFlowKt;

@Metadata(d1 = {"\u0000b\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0003\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\b\u0007\u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002J\b\u0010\u0018\u001a\u00020\u0019H\u0002J\u0010\u0010\u001a\u001a\u00020\u001b2\u0006\u0010\u001c\u001a\u00020\u001dH\u0002J\b\u0010\u001e\u001a\u00020\u0019H\u0002J\u0017\u0010\u001f\u001a\u00020\u00192\b\u0010 \u001a\u0004\u0018\u00010!H\u0001¢\u0006\u0002\b\"J\u0012\u0010#\u001a\u00020\u00192\b\u0010$\u001a\u0004\u0018\u00010%H\u0014J\u0010\u0010&\u001a\u00020'2\u0006\u0010(\u001a\u00020)H\u0016J\b\u0010*\u001a\u00020\u0019H\u0014J\u0010\u0010+\u001a\u00020'2\u0006\u0010,\u001a\u00020-H\u0016R\u001d\u0010\u0003\u001a\u0004\u0018\u00010\u00048BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\u0007\u0010\b\u001a\u0004\b\u0005\u0010\u0006R\u001b\u0010\t\u001a\u00020\n8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\r\u0010\b\u001a\u0004\b\u000b\u0010\fR\u001b\u0010\u000e\u001a\u00020\u000f8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\u0012\u0010\b\u001a\u0004\b\u0010\u0010\u0011R\u001b\u0010\u0013\u001a\u00020\u00148BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\u0017\u0010\b\u001a\u0004\b\u0015\u0010\u0016¨\u0006."}, d2 = {"Lcom/stripe/android/view/PaymentAuthWebViewActivity;", "Landroidx/appcompat/app/AppCompatActivity;", "()V", "_args", "Lcom/stripe/android/auth/PaymentBrowserAuthContract$Args;", "get_args", "()Lcom/stripe/android/auth/PaymentBrowserAuthContract$Args;", "_args$delegate", "Lkotlin/Lazy;", "logger", "Lcom/stripe/android/core/Logger;", "getLogger", "()Lcom/stripe/android/core/Logger;", "logger$delegate", "viewBinding", "Lcom/stripe/android/databinding/StripePaymentAuthWebViewActivityBinding;", "getViewBinding", "()Lcom/stripe/android/databinding/StripePaymentAuthWebViewActivityBinding;", "viewBinding$delegate", "viewModel", "Lcom/stripe/android/view/PaymentAuthWebViewActivityViewModel;", "getViewModel", "()Lcom/stripe/android/view/PaymentAuthWebViewActivityViewModel;", "viewModel$delegate", "cancelIntentSource", "", "createResultIntent", "Landroid/content/Intent;", "paymentFlowResult", "Lcom/stripe/android/payments/PaymentFlowResult$Unvalidated;", "customizeToolbar", "onAuthComplete", "error", "", "onAuthComplete$payments_core_release", "onCreate", "savedInstanceState", "Landroid/os/Bundle;", "onCreateOptionsMenu", "", "menu", "Landroid/view/Menu;", "onDestroy", "onOptionsItemSelected", "item", "Landroid/view/MenuItem;", "payments-core_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
public final class PaymentAuthWebViewActivity extends AppCompatActivity {
    public static final int $stable = 8;

    private final Lazy viewModel;

    private final Lazy viewBinding = LazyKt.lazy(new Function0<StripePaymentAuthWebViewActivityBinding>() {
        {
            super(0);
        }

        public final StripePaymentAuthWebViewActivityBinding m995invoke() {
            StripePaymentAuthWebViewActivityBinding inflate = StripePaymentAuthWebViewActivityBinding.inflate(PaymentAuthWebViewActivity.this.getLayoutInflater());
            Intrinsics.checkNotNullExpressionValue(inflate, "inflate(layoutInflater)");
            return inflate;
        }
    });

    private final Lazy _args = LazyKt.lazy(new Function0<PaymentBrowserAuthContract.Args>() {
        {
            super(0);
        }

        public final PaymentBrowserAuthContract.Args m992invoke() {
            PaymentBrowserAuthContract.Companion companion = PaymentBrowserAuthContract.Companion;
            Intent intent = PaymentAuthWebViewActivity.this.getIntent();
            Intrinsics.checkNotNullExpressionValue(intent, "intent");
            return companion.parseArgs$payments_core_release(intent);
        }
    });

    private final Lazy logger = LazyKt.lazy(new Function0<Logger>() {
        {
            super(0);
        }

        public final Logger m993invoke() {
            PaymentBrowserAuthContract.Args args;
            Logger.Companion companion = Logger.Companion;
            args = PaymentAuthWebViewActivity.this.get_args();
            return companion.getInstance(args != null && args.getEnableLogging());
        }
    });

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

            public final ViewModelStore m990invoke() {
                ViewModelStore viewModelStore = componentActivity.getViewModelStore();
                Intrinsics.checkNotNullExpressionValue(viewModelStore, "viewModelStore");
                return viewModelStore;
            }
        }, new Function0<ViewModelProvider.Factory>() {
            {
                super(0);
            }

            public final ViewModelProvider.Factory m996invoke() {
                Logger logger;
                PaymentBrowserAuthContract.Args args;
                Application application = PaymentAuthWebViewActivity.this.getApplication();
                Intrinsics.checkNotNullExpressionValue(application, "application");
                logger = PaymentAuthWebViewActivity.this.getLogger();
                args = PaymentAuthWebViewActivity.this.get_args();
                if (args != null) {
                    return new PaymentAuthWebViewActivityViewModel.Factory(application, logger, args);
                }
                throw new IllegalArgumentException("Required value was null.".toString());
            }
        }, new Function0<CreationExtras>() {
            {
                super(0);
            }

            public final CreationExtras m991invoke() {
                CreationExtras creationExtras;
                Function0 function02 = function0;
                if (function02 != null && (creationExtras = (CreationExtras) function02.invoke()) != null) {
                    return creationExtras;
                }
                CreationExtras defaultViewModelCreationExtras = componentActivity.getDefaultViewModelCreationExtras();
                Intrinsics.checkNotNullExpressionValue(defaultViewModelCreationExtras, "this.defaultViewModelCreationExtras");
                return defaultViewModelCreationExtras;
            }
        });
    }

    public final StripePaymentAuthWebViewActivityBinding getViewBinding() {
        return (StripePaymentAuthWebViewActivityBinding) this.viewBinding.getValue();
    }

    public final PaymentBrowserAuthContract.Args get_args() {
        return (PaymentBrowserAuthContract.Args) this._args.getValue();
    }

    public final Logger getLogger() {
        return (Logger) this.logger.getValue();
    }

    private final PaymentAuthWebViewActivityViewModel getViewModel() {
        return (PaymentAuthWebViewActivityViewModel) this.viewModel.getValue();
    }

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        PaymentBrowserAuthContract.Args args = get_args();
        if (args == null) {
            setResult(0);
            finish();
            return;
        }
        getLogger().debug("PaymentAuthWebViewActivity#onCreate()");
        setContentView(getViewBinding().getRoot());
        setSupportActionBar(getViewBinding().toolbar);
        customizeToolbar();
        OnBackPressedDispatcher onBackPressedDispatcher = getOnBackPressedDispatcher();
        Intrinsics.checkNotNullExpressionValue(onBackPressedDispatcher, "onBackPressedDispatcher");
        OnBackPressedDispatcherKt.addCallback$default(onBackPressedDispatcher, (LifecycleOwner) null, false, new Function1<OnBackPressedCallback, Unit>() {
            {
                super(1);
            }

            public Object invoke(Object obj) {
                invoke((OnBackPressedCallback) obj);
                return Unit.INSTANCE;
            }

            public final void invoke(OnBackPressedCallback onBackPressedCallback) {
                StripePaymentAuthWebViewActivityBinding viewBinding;
                StripePaymentAuthWebViewActivityBinding viewBinding2;
                Intrinsics.checkNotNullParameter(onBackPressedCallback, "$this$addCallback");
                viewBinding = PaymentAuthWebViewActivity.this.getViewBinding();
                if (viewBinding.webView.canGoBack()) {
                    viewBinding2 = PaymentAuthWebViewActivity.this.getViewBinding();
                    viewBinding2.webView.goBack();
                } else {
                    PaymentAuthWebViewActivity.this.cancelIntentSource();
                }
            }
        }, 3, (Object) null);
        String clientSecret = args.getClientSecret();
        setResult(-1, createResultIntent(getViewModel().getPaymentResult$payments_core_release()));
        if (StringsKt.isBlank(clientSecret)) {
            getLogger().debug("PaymentAuthWebViewActivity#onCreate() - clientSecret is blank");
            finish();
            return;
        }
        getLogger().debug("PaymentAuthWebViewActivity#onCreate() - PaymentAuthWebView init and loadUrl");
        MutableStateFlow MutableStateFlow = StateFlowKt.MutableStateFlow(false);
        BuildersKt.launch$default(LifecycleOwnerKt.getLifecycleScope((LifecycleOwner) this), (CoroutineContext) null, (CoroutineStart) null, new PaymentAuthWebViewActivity$onCreate$2(MutableStateFlow, this, null), 3, (Object) null);
        final PaymentAuthWebViewClient paymentAuthWebViewClient = new PaymentAuthWebViewClient(getLogger(), MutableStateFlow, clientSecret, args.getReturnUrl(), new PaymentAuthWebViewActivity$onCreate$webViewClient$1(this), new PaymentAuthWebViewActivity$onCreate$webViewClient$2(this));
        getViewBinding().webView.setOnLoadBlank$payments_core_release(new Function0<Unit>() {
            {
                super(0);
            }

            public Object invoke() {
                m994invoke();
                return Unit.INSTANCE;
            }

            public final void m994invoke() {
                PaymentAuthWebViewClient.this.setHasLoadedBlank$payments_core_release(true);
            }
        });
        getViewBinding().webView.setWebViewClient(paymentAuthWebViewClient);
        getViewBinding().webView.setWebChromeClient(new PaymentAuthWebChromeClient((Activity) this, getLogger()));
        getViewModel().logStart();
        getViewBinding().webView.loadUrl(args.getUrl(), getViewModel().getExtraHeaders());
    }

    public final void onAuthComplete$payments_core_release(Throwable error) {
        if (error != null) {
            getViewModel().logError();
            setResult(-1, createResultIntent(PaymentFlowResult.Unvalidated.copy$default(getViewModel().getPaymentResult$payments_core_release(), null, 2, StripeException.Companion.create(error), true, null, null, null, 113, null)));
        } else {
            getViewModel().logComplete();
        }
        finish();
    }

    protected void onDestroy() {
        getViewBinding().webViewContainer.removeAllViews();
        getViewBinding().webView.destroy();
        super.onDestroy();
    }

    public boolean onCreateOptionsMenu(Menu menu) {
        Intrinsics.checkNotNullParameter(menu, "menu");
        getLogger().debug("PaymentAuthWebViewActivity#onCreateOptionsMenu()");
        getMenuInflater().inflate(R.menu.stripe_payment_auth_web_view_menu, menu);
        String buttonText = getViewModel().getButtonText();
        if (buttonText != null) {
            getLogger().debug("PaymentAuthWebViewActivity#customizeToolbar() - updating close button text");
            menu.findItem(R.id.action_close).setTitle(buttonText);
        }
        return super.onCreateOptionsMenu(menu);
    }

    public boolean onOptionsItemSelected(MenuItem item) {
        Intrinsics.checkNotNullParameter(item, "item");
        getLogger().debug("PaymentAuthWebViewActivity#onOptionsItemSelected()");
        if (item.getItemId() == R.id.action_close) {
            cancelIntentSource();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    public final void cancelIntentSource() {
        setResult(-1, getViewModel().getCancellationResult$payments_core_release());
        finish();
    }

    private final void customizeToolbar() {
        getLogger().debug("PaymentAuthWebViewActivity#customizeToolbar()");
        PaymentAuthWebViewActivityViewModel.ToolbarTitleData toolbarTitle = getViewModel().getToolbarTitle();
        if (toolbarTitle != null) {
            getLogger().debug("PaymentAuthWebViewActivity#customizeToolbar() - updating toolbar title");
            getViewBinding().toolbar.setTitle(CustomizeUtils.INSTANCE.buildStyledText((Context) this, toolbarTitle.getText$payments_core_release(), toolbarTitle.getToolbarCustomization$payments_core_release()));
        }
        String toolbarBackgroundColor = getViewModel().getToolbarBackgroundColor();
        if (toolbarBackgroundColor != null) {
            getLogger().debug("PaymentAuthWebViewActivity#customizeToolbar() - updating toolbar background color");
            int parseColor = Color.parseColor(toolbarBackgroundColor);
            getViewBinding().toolbar.setBackgroundColor(parseColor);
            CustomizeUtils.INSTANCE.setStatusBarColor(this, parseColor);
        }
    }

    private final Intent createResultIntent(PaymentFlowResult.Unvalidated paymentFlowResult) {
        Intent putExtras = new Intent().putExtras(paymentFlowResult.toBundle());
        Intrinsics.checkNotNullExpressionValue(putExtras, "Intent().putExtras(paymentFlowResult.toBundle())");
        return putExtras;
    }
}