导航菜单

页面标题

页面副标题

Clash Legends v0.0.1 - BaseCheckoutActivity.java 源代码

正在查看: Clash Legends v0.0.1 应用的 BaseCheckoutActivity.java JAVA 源代码文件

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


package com.razorpay;

import android.R;
import android.app.Activity;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.RelativeLayout;
import android.widget.Toast;
import com.payu.custombrowser.util.b;
import com.razorpay.CheckoutPresenterImpl;
import java.util.ConcurrentModificationException;
import java.util.HashMap;
import java.util.Map;
import kotlinx.coroutines.internal.LockFreeTaskQueueCore;
import org.json.JSONException;
import org.json.JSONObject;

class BaseCheckoutActivity extends Activity implements SmsAgentInterface, CheckoutPresenterImpl.CheckoutView {
    private static int UPI_REQUEST_CODE = 99;
    protected Object checkoutBridgeObject;
    private RelativeLayout container;
    private ViewGroup parent;
    protected CheckoutPresenter presenter;
    private WebChromeClient primaryWebChromeClient;
    private WebView primaryWebView;
    private WebViewClient primaryWebViewClient;
    private RZPProgressBar rzpbar;
    private WebChromeClient secondaryWebChromeClient;
    private WebView secondaryWebView;
    private WebViewClient secondaryWebViewClient;
    private SmsAgent smsAgent;

    BaseCheckoutActivity() {
    }

    private void setWebViewClient(int webViewType, WebViewClient webViewClient) {
        switch (webViewType) {
            case 1:
                this.primaryWebViewClient = webViewClient;
                break;
            case 2:
                this.secondaryWebViewClient = webViewClient;
                break;
        }
    }

    private void setWebChromeClient(int webViewType, WebChromeClient webChromeClient) {
        switch (webViewType) {
            case 1:
                this.primaryWebChromeClient = webChromeClient;
                break;
            case 2:
                this.secondaryWebChromeClient = webChromeClient;
                break;
        }
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        SharedPreferenceUtil.handleSdkUpdate(this, Config.SDK_VERSION);
        Config.getInstance().init(this);
        BaseUtils.checkForLatestVersion(this, Config.SDK_VERSION_CODE);
        this.presenter.setCheckoutLoadStartAt();
        setWebViewClient(1, new PrimaryWebViewClient(this.presenter));
        setWebViewClient(2, new SecondaryWebViewClient(this.presenter));
        setWebChromeClient(1, new PrimaryWebChromeClient(this.presenter));
        setWebChromeClient(2, new SecondaryWebChromeClient(this.presenter));
        checkSmsPermission();
        BaseUtils.setup();
        AnalyticsUtil.trackEvent(AnalyticsEvent.CHECKOUT_INIT);
        requestWindowFeature(1);
        super.onCreate(savedInstanceState);
        Logger.d("CheckoutActivity onCreate called");
        Bundle extras = savedInstanceState;
        boolean acitvityRestored = true;
        if (savedInstanceState == null) {
            extras = getIntent().getExtras();
            acitvityRestored = false;
        }
        if (!this.presenter.setOptions(extras, acitvityRestored)) {
            return;
        }
        this.parent = (ViewGroup) findViewById(R.id.content);
        createPrimaryWebView(this.checkoutBridgeObject);
        createSecondaryWebView();
        createContainer();
        this.presenter.loadForm("");
        this.presenter.passPrefillToSegment();
        boolean fullScreen = (getWindow().getAttributes().flags & LockFreeTaskQueueCore.MIN_ADD_SPIN_CAPACITY) != 0;
        if (fullScreen) {
            AndroidBug5497Workaround.assistActivity(this);
            Logger.d("FULLSCREEN");
        } else {
            Logger.d("NOT FULLSCREEN");
        }
        if (ResourceUtils.isTablet(this)) {
            Logger.d("is tablet");
            setFinishOnTouchOutside(false);
            WindowManager.LayoutParams params = getWindow().getAttributes();
            int width = ResourceUtils.dpToPx(this, 375);
            int height = ResourceUtils.getViewHeight(this);
            if (height > 600) {
                height = ResourceUtils.dpToPx(this, 600);
            }
            params.height = height;
            params.width = width;
            getWindow().setAttributes(params);
        } else {
            setRequestedOrientation(1);
        }
        this.presenter.fetchCondfig();
        this.presenter.handleCardSaving();
        if (!BaseUtils.isDeviceHaveCorrectTlsVersion()) {
            AnalyticsUtil.trackEvent(AnalyticsEvent.CHECKOUT_TLS_ERROR);
            destroy(6, "TLSv1  is not supported for security reasons");
        }
    }

    @Override
    public void onSaveInstanceState(Bundle savedInstanceState) {
        super.onSaveInstanceState(savedInstanceState);
        this.presenter.saveInstanceState(savedInstanceState);
    }

    @Override
    public void onBackPressed() {
        Map<String, Object> props = new HashMap<>();
        this.presenter.backPressed(props);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        AnalyticsUtil.trackEvent(AnalyticsEvent.ACTIVITY_ONDESTROY_CALLED);
        Logger.d("CheckoutActivity onDestroy called");
        try {
            this.presenter.cleanUpOnDestroy();
        } catch (ConcurrentModificationException e) {
            AnalyticsUtil.reportError(e, "critical", e.getLocalizedMessage());
            e.printStackTrace();
        }
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
    }

    private void createPrimaryWebView(Object jsBridge) {
        WebView webView = new WebView(this);
        this.primaryWebView = webView;
        BaseUtils.setWebViewSettings(this, webView, false);
        this.primaryWebView.clearFormData();
        this.primaryWebView.addJavascriptInterface(jsBridge, "CheckoutBridge");
        this.primaryWebView.setWebChromeClient(this.primaryWebChromeClient);
        this.primaryWebView.setWebViewClient(this.primaryWebViewClient);
    }

    private void createSecondaryWebView() {
        WebView webView = new WebView(this);
        this.secondaryWebView = webView;
        BaseUtils.setWebViewSettings(this, webView, false);
        this.secondaryWebView.clearFormData();
        this.secondaryWebView.addJavascriptInterface(new MagicBridge((CheckoutInteractor) this.presenter), "MagicBridge");
        this.secondaryWebView.addJavascriptInterface(new CheckoutBridge((CheckoutInteractor) this.presenter, 2), "CheckoutBridge");
        this.secondaryWebView.setVisibility(8);
        this.secondaryWebView.setWebChromeClient(this.secondaryWebChromeClient);
        this.secondaryWebView.setWebViewClient(this.secondaryWebViewClient);
    }

    private void createContainer() {
        RelativeLayout relativeLayout = new RelativeLayout(this);
        this.container = relativeLayout;
        relativeLayout.setLayoutParams(new RelativeLayout.LayoutParams(-1, -1));
        this.container.setBackgroundColor(-1);
        this.parent.addView(this.container);
        this.primaryWebView.setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
        this.secondaryWebView.setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
        this.container.addView(this.primaryWebView);
        this.container.addView(this.secondaryWebView);
        String color = this.presenter.getProgressBarColor();
        if (color != null) {
            this.rzpbar = new RZPProgressBar(this, this.container, color);
        } else {
            this.rzpbar = new RZPProgressBar(this, this.container);
        }
        this.presenter.setUpAddOn();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 1001) {
            this.presenter.sendOtpPermissionCallback(true);
        }
        this.presenter.onActivityResultReceived(requestCode, resultCode, data);
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        this.presenter.onRequestPermissionsResult(requestCode, permissions, grantResults);
    }

    @Override
    public void postSms(String sender, String message) {
        try {
            JSONObject sms = new JSONObject();
            sms.put(b.SENDER, sender);
            sms.put("message", message);
            String lastSms = sms.toString();
            String otpMessage = String.format("javascript: OTPElf.elfBridge.setSms(%s)", lastSms);
            loadUrl(1, otpMessage);
        } catch (JSONException e) {
            AnalyticsUtil.reportError(e, "error", e.getMessage());
            e.printStackTrace();
        }
    }

    @Override
    public void setSmsPermission(boolean hasSmsPermission) {
        this.presenter.sendOtpPermissionCallback(hasSmsPermission);
        SmsAgent smsAgent = this.smsAgent;
        if (smsAgent != null) {
            smsAgent.deregisterForCallbacks(this);
        }
    }

    @Override
    public void loadUrl(int webViewType, String url) {
        switch (webViewType) {
            case 1:
                this.primaryWebView.loadUrl(url);
                break;
            case 2:
                this.secondaryWebView.loadUrl(url);
                break;
        }
    }

    @Override
    public void checkSmsPermission() {
        SmsAgent smsAgentInstance = SmsAgent.getSmsAgentInstance();
        this.smsAgent = smsAgentInstance;
        smsAgentInstance.registerForCallbacks(this);
        this.smsAgent.takeActionsIfPermissionsAreGranted(this);
    }

    @Override
    public void addJavascriptInterfaceToPrimaryWebview(Object jsBridge, String bridgeName) {
        this.primaryWebView.addJavascriptInterface(jsBridge, bridgeName);
    }

    @Override
    public void loadData(int webViewType, String data, String mimeType, String encoding) {
        switch (webViewType) {
            case 1:
                this.primaryWebView.loadData(data, mimeType, encoding);
                break;
            case 2:
                this.secondaryWebView.loadData(data, mimeType, encoding);
                break;
        }
    }

    @Override
    public void loadDataWithBaseURL(int webViewType, String baseUrl, String data, String mimeType, String encoding, String historyUrl) {
        switch (webViewType) {
            case 1:
                this.primaryWebView.loadDataWithBaseURL(baseUrl, data, mimeType, encoding, historyUrl);
                break;
            case 2:
                this.secondaryWebView.loadDataWithBaseURL(baseUrl, data, mimeType, encoding, historyUrl);
                break;
        }
    }

    @Override
    public void makeWebViewVisible(int webViewType) {
        switch (webViewType) {
            case 1:
                if (this.primaryWebView.getVisibility() == 8) {
                    this.primaryWebView.setVisibility(0);
                    this.secondaryWebView.setVisibility(8);
                    CheckoutUtils.dismissLoader();
                    AnalyticsUtil.trackEvent(AnalyticsEvent.WEB_VIEW_SECONDARY_TO_PRIMARY_SWITCH);
                    break;
                }
                break;
            case 2:
                if (this.secondaryWebView.getVisibility() == 8) {
                    this.primaryWebView.setVisibility(8);
                    this.secondaryWebView.setVisibility(0);
                    CheckoutUtils.dismissLoader();
                    AnalyticsUtil.trackEvent(AnalyticsEvent.WEB_VIEW_PRIMARY_TO_SECONDARY_SWITCH);
                    break;
                }
                break;
        }
    }

    @Override
    public boolean isWebViewVisible(int webViewType) {
        switch (webViewType) {
            case 1:
                WebView webView = this.primaryWebView;
                if (webView == null || webView.getVisibility() != 0) {
                }
                break;
            case 2:
                WebView webView2 = this.secondaryWebView;
                if (webView2 == null || webView2.getVisibility() != 0) {
                }
                break;
        }
        return false;
    }

    @Override
    public void showToast(String message, int duration) {
        Toast.makeText(this, message, duration).show();
    }

    @Override
    public void destroy(int resultCode, String result) {
        Intent returnIntent = new Intent();
        returnIntent.putExtra("RESULT", result);
        if (result == null) {
            resultCode = 5;
        }
        setResult(resultCode, returnIntent);
        finish();
    }

    @Override
    public void showProgressBar(int progress) {
        RZPProgressBar rZPProgressBar = this.rzpbar;
        if (rZPProgressBar != null) {
            rZPProgressBar.show(progress);
        }
    }

    @Override
    public void hideProgressBar() {
        RZPProgressBar rZPProgressBar = this.rzpbar;
        if (rZPProgressBar != null) {
            rZPProgressBar.hide();
        }
    }

    @Override
    public void clearWebViewHistory(int webViewType) {
        switch (webViewType) {
            case 1:
                this.primaryWebView.clearHistory();
                break;
            case 2:
                this.secondaryWebView.clearHistory();
                break;
        }
    }

    @Override
    public WebView getWebView(int webViewType) {
        switch (webViewType) {
            case 1:
                WebView webView = this.primaryWebView;
                return webView;
            case 2:
                WebView webView2 = this.secondaryWebView;
                return webView2;
            default:
                return null;
        }
    }
}