iKredit v1.2.0.3版本的 MD5 值为:2c00c5c79eecbd6be4c3c546c28d778d

以下内容为反编译后的 CFWebView.java 源代码,内容仅作参考


package com.gocashfree.cashfreesdk.ui.web_checkout;

import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Xml;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.gocashfree.cashfreesdk.CFPaymentService;
import com.gocashfree.cashfreesdk.R;
import com.gocashfree.cashfreesdk.a.c.a.g;
import com.gocashfree.cashfreesdk.d.a;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;

public class CFWebView extends WebView {
    public static final String APP_VERSION = "appVersion";
    public static final String CF_PAYMENT_JS_INTERFACE = "PaymentJSInterface";
    public static final String FB = "_fb";
    public static final String HIDE_HEADER = "hideHeader";
    public static final String HIDE_HEADER_TRUE = "1";
    private String a;
    private boolean b;
    private com.gocashfree.cashfreesdk.a.b.c c;
    String d;

    class a extends WebViewClient {
        final com.gocashfree.cashfreesdk.b.a.b a;

        a(com.gocashfree.cashfreesdk.b.a.b bVar) {
            this.a = bVar;
        }

        private void a(String str) {
            if ((str.startsWith("https://www.cashfree.com/") && str.startsWith("https://payments.cashfree.com/")) || CFWebView.this.a.isEmpty()) {
                return;
            }
            com.gocashfree.cashfreesdk.d.c.a("CFWebView", "checkAction called on " + str);
            CFWebView.this.evaluateJavascript(CFWebView.this.a + " checkAction('" + str + "');", null);
        }

        @Override
        public void doUpdateVisitedHistory(WebView webView, String str, boolean z) {
            super.doUpdateVisitedHistory(webView, str, z);
            com.gocashfree.cashfreesdk.d.c.a("CFWebView", "doUpdateVisitedHistory : " + str);
            this.a.hideActionUI();
            if (Build.VERSION.SDK_INT >= 19) {
                a(str);
                if (str.startsWith("https://payments.cashfree.com/")) {
                    CFWebView.this.evaluateJavascript(" setAPPVersion('1.4.9.4');", null);
                }
            }
        }

        @Override
        public void onPageFinished(WebView webView, String str) {
            super.onPageFinished(webView, str);
            com.gocashfree.cashfreesdk.d.c.a("CFWebView", "Log: onPageFinished : " + str);
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView webView, String str) {
            HashMap hashMap = new HashMap();
            hashMap.put("Referer", CFWebView.this.d.isEmpty() ? "https://www.cashfree.com/" : CFWebView.this.d);
            CFWebView.this.loadUrl(str, hashMap);
            return false;
        }
    }

    class b implements com.gocashfree.cashfreesdk.a.c.a.b {
        final Bundle a;

        b(Bundle bundle) {
            this.a = bundle;
        }

        @Override
        public void a(String str) {
            CFWebView.this.a = str;
            if (CFWebView.this.a == null || CFWebView.this.a.isEmpty()) {
                CFWebView.this.c.a(a.EnumC0034a.ACTION_TEMP_DISABLED);
            } else {
                CFWebView.this.b = true;
                CFWebView.this.c.a(a.EnumC0034a.ACTION_TEMP_RECEIVED);
            }
            CFWebView.this.b(this.a);
        }
    }

    class c implements com.gocashfree.cashfreesdk.a.c.a.a {
        final Bundle a;

        c(Bundle bundle) {
            this.a = bundle;
        }

        @Override
        public void a(String str) {
            CFWebView.this.c.a(a.EnumC0034a.ACTION_TEMP_FETCH_ERROR);
            CFWebView.this.b(this.a);
            CFWebView.this.b = false;
        }
    }

    public CFWebView(Context context) {
        super(context);
        this.a = "";
        this.d = "";
    }

    public boolean isTemplateAvailable() {
        Log.d("CFWebView", "actionTemplateAvailable :" + this.b);
        return this.b;
    }

    public void loginTriggered(String str) {
        this.c.a(a.EnumC0034a.NB_LOGIN_TRIG);
        if (Build.VERSION.SDK_INT >= 19) {
            com.gocashfree.cashfreesdk.d.c.a("CFWebView", " loginTriggered('" + str + "');");
            evaluateJavascript(" loginTriggered('" + str + "');", null);
        }
    }

    public void setCustomerID(String str, String str2) {
        if (Build.VERSION.SDK_INT < 19 || str.isEmpty()) {
            return;
        }
        com.gocashfree.cashfreesdk.d.c.a("CFWebView", " handleCustId('" + str2 + "');");
        this.c.a(a.EnumC0034a.SET_SAVED_CUST_ID);
        evaluateJavascript(" handleCustId('" + str + "', '" + str2 + "');", null);
    }

    public void setPaymentEventLog(com.gocashfree.cashfreesdk.a.b.c cVar) {
        this.c = cVar;
    }

    public void b(Bundle bundle) {
        loadDataWithBaseURL("", a(bundle, a(bundle.getString("stage"))), "text/html", Xml.Encoding.UTF_8.name(), "");
    }

    private String a(String str) {
        if ("PROD".equals(str)) {
            return getContext().getText(R.string.endpoint_prod).toString();
        }
        return getContext().getText(R.string.endpoint_test).toString();
    }

    public void a(com.gocashfree.cashfreesdk.b.a.b bVar) {
        getSettings().setJavaScriptEnabled(true);
        getSettings().setDomStorageEnabled(true);
        setWebViewClient(new a(bVar));
    }

    public void a(Bundle bundle) {
        new g().a(getContext(), bundle.getString("stage"), bundle.getString(CFPaymentService.PARAM_APP_ID), new b(bundle), new c(bundle));
    }

    private String a(Bundle bundle, String str) {
        InputStream openRawResource = getResources().openRawResource(R.raw.cashfree_pay_form);
        StringBuilder sb = new StringBuilder();
        try {
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(openRawResource));
            while (true) {
                String readLine = bufferedReader.readLine();
                if (readLine == null) {
                    break;
                }
                sb.append(readLine);
            }
        } catch (IOException unused) {
        }
        StringBuilder sb2 = new StringBuilder();
        for (String str2 : bundle.keySet()) {
            if (!str2.startsWith(FB)) {
                sb2.append(String.format("<input type=\"hidden\" name=\"%s\" value=\"%s\"/>", str2, bundle.get(str2)));
            }
        }
        sb2.append(String.format("<input type=\"hidden\" name=\"%s\" value=\"%s\"/>", HIDE_HEADER, "1"));
        sb2.append(String.format("<input type=\"hidden\" name=\"%s\" value=\"%s\"/>", "appVersion", "1.4.9.4"));
        String format = String.format(sb.toString(), str, sb2.toString());
        Log.d("CFWebView", "Form " + format);
        return format;
    }

    public CFWebView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.a = "";
        this.d = "";
    }

    public CFWebView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.a = "";
        this.d = "";
    }

    public CFWebView(Context context, AttributeSet attributeSet, int i, int i2) {
        super(context, attributeSet, i, i2);
        this.a = "";
        this.d = "";
    }

    public CFWebView(Context context, AttributeSet attributeSet, int i, boolean z) {
        super(context, attributeSet, i, z);
        this.a = "";
        this.d = "";
    }
}