七色猫视频 v9.9.9版本的 MD5 值为:6e3740f68cd7a75ec951b5f356e1fd2c

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


package com.rdweb.websdk;

import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import androidx.activity.OnBackPressedCallback;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import org.json.JSONException;
import org.json.JSONObject;
public class JSWebviewFragment extends JSHtml5Fragment {
    private static String TAG = "com.rdweb.websdk.JSWebviewFragment";
    final int REQUEST_CODE_FILE_CAPTURE;
    final int REQUEST_CODE_FILE_SAVE;
    private Bitmap bitmap;
    private String downUrl;
    private ConstraintLayout layout;
    private String title;

    public JSWebviewFragment() {
        this.REQUEST_CODE_FILE_SAVE = 1;
        this.REQUEST_CODE_FILE_CAPTURE = 2;
        this.downUrl = null;
        this.title = "";
    }

    public JSWebviewFragment(String str, String str2) {
        this.REQUEST_CODE_FILE_SAVE = 1;
        this.REQUEST_CODE_FILE_CAPTURE = 2;
        this.downUrl = null;
        this.title = "";
        this.webUrl = str;
        this.title = str2;
    }

    @Override
    public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        View inflate = layoutInflater.inflate(R.layout.activity_webview, viewGroup, false);
        this.layout = (ConstraintLayout) inflate.findViewById(R.id.bg_content);
        getActivity().getOnBackPressedDispatcher().addCallback(new OnBackPressedCallback(true) {
            @Override
            public void handleOnBackPressed() {
                JSWebviewFragment.this.webView.goBack();
            }
        });
        loadWebView();
        getActivity().setRequestedOrientation(1);
        return inflate;
    }

    @Override
    public void onPause() {
        super.onPause();
        getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (JSWebviewFragment.this.webView != null) {
                    JSWebviewFragment.this.webView.evaluateJavascript("javascript:applicationDidEnterBackground()", null);
                }
            }
        });
    }

    @Override
    public void onResume() {
        super.onResume();
        getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (JSWebviewFragment.this.webView != null) {
                    JSWebviewFragment.this.webView.evaluateJavascript("javascript:applicationWillEnterForeground()", null);
                }
            }
        });
    }

    @Override
    public void onDestroy() {
        if (this.webView != null) {
            this.layout.removeAllViews();
            this.webView.removeAllViews();
            this.webView.destroy();
            this.webView = null;
        }
        Log.d(TAG, "销毁了");
        super.onDestroy();
    }

    private void loadWebView() {
        if (!TextUtils.isEmpty(this.title)) {
            getActivity().setTitle(this.title);
        }
        if (this.webView != null) {
            this.webView.removeAllViews();
            this.webView.destroy();
            this.webView = null;
        }
        this.webView = new JSWebView(getActivity(), this);
        this.webView.addJavascriptInterface(new JSCallAndroidForFragment(this), "android");
        this.webView.setLayoutParams(new CoordinatorLayout.LayoutParams(0, 0));
        this.layout.addView(this.webView);
        this.webView.setOnHtml5WebViewListener(this);
        this.webView.getSettings().getUserAgentString();
        Utils.getUniqueID(getActivity());
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("apiurl", this.webUrl);
            jSONObject.put("origindomain", "");
            jSONObject.put("deviceid", Utils.getUniqueID(getActivity()));
            jSONObject.put("PUBLIC_KEY", "");
            jSONObject.put("version", "App(" + Utils.getVersionCode(getActivity()) + ")Res()");
        } catch (JSONException unused) {
        }
        jSONObject.toString();
        this.webView.loadUrl(this.webUrl);
    }

    private void downImage(final String str) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                JSWebviewFragment jSWebviewFragment = JSWebviewFragment.this;
                jSWebviewFragment.bitmap = jSWebviewFragment.GetImageInputStream(str);
                JSWebviewFragment.this.getActivity().runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        if (JSWebviewFragment.this.bitmap != null) {
                            JSWebviewFragment jSWebviewFragment2 = JSWebviewFragment.this;
                            Bitmap bitmap = JSWebviewFragment.this.bitmap;
                            jSWebviewFragment2.saveImage(bitmap, System.currentTimeMillis() + "");
                        }
                    }
                });
            }
        }).start();
    }

    @Override
    public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
        String str;
        super.onRequestPermissionsResult(i, strArr, iArr);
        if (iArr.length != 0 && iArr[0] == 0) {
            if (i == 2) {
                Bitmap captureWebView = Utils.captureWebView(this.webView);
                saveImage(captureWebView, System.currentTimeMillis() + "");
            } else if (i == 1 && (str = this.downUrl) != null) {
                downImage(str);
                this.downUrl = null;
            }
            Toast.makeText(getActivity(), "权限开启成功", 1).show();
            return;
        }
        Toast.makeText(getActivity(), "权限开启失败", 1).show();
    }

    public void openNativeWeb(final String str) {
        getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                Intent intent = new Intent(JSWebviewFragment.this.getActivity(), JSGameWebviewActivity.class);
                intent.putExtra("NativeWebBean", str);
                JSWebviewFragment.this.getActivity().startActivity(intent);
            }
        });
    }

    public void openThirdWeb(final String str) {
        getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                try {
                    String str2 = str;
                    JSWebviewFragment.this.startActivity(new Intent("android.intent.action.VIEW", Uri.parse("")));
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    public void saveImageUrl(String str) {
        if (ContextCompat.checkSelfPermission(getActivity(), "android.permission.WRITE_EXTERNAL_STORAGE") != 0 || ContextCompat.checkSelfPermission(getActivity(), "android.permission.READ_EXTERNAL_STORAGE") != 0) {
            this.downUrl = str;
            ActivityCompat.requestPermissions(getActivity(), new String[]{"android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_EXTERNAL_STORAGE"}, 1);
            return;
        }
        downImage(str);
        this.downUrl = str;
    }

    public void captureScreen() {
        getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (ContextCompat.checkSelfPermission(JSWebviewFragment.this.getActivity(), "android.permission.WRITE_EXTERNAL_STORAGE") != 0 || ContextCompat.checkSelfPermission(JSWebviewFragment.this.getActivity(), "android.permission.READ_EXTERNAL_STORAGE") != 0) {
                    ActivityCompat.requestPermissions(JSWebviewFragment.this.getActivity(), new String[]{"android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_EXTERNAL_STORAGE"}, 2);
                    return;
                }
                Bitmap captureWebView = Utils.captureWebView(JSWebviewFragment.this.webView);
                JSWebviewFragment jSWebviewFragment = JSWebviewFragment.this;
                jSWebviewFragment.saveImage(captureWebView, System.currentTimeMillis() + "");
            }
        });
    }
}