导航菜单

页面标题

页面副标题

泰剧兔 v1.5.7.0 - MeishuWebviewActivity.java 源代码

正在查看: 泰剧兔 v1.5.7.0 应用的 MeishuWebviewActivity.java JAVA 源代码文件

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


package com.meishu.sdk.activity;

import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.ZoomButtonsController;
import androidx.appcompat.app.AppCompatActivity;
import com.meishu.sdk.R;
import com.meishu.sdk.core.AdSdk;
import com.meishu.sdk.core.loader.ShareInfo;
import com.meishu.sdk.core.loader.ShareInteractionListener;
import com.meishu.sdk.core.utils.MsConstants;
import com.meishu.sdk.core.webview.DownloadListener;
import com.meishu.sdk.core.webview.WebViewClient;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

public class MeishuWebviewActivity extends AppCompatActivity {
    public static final String EXTRA_AD_AMID_KEY = "EXTRA_AD_AMID_KEY";
    public static final String EXTRA_AD_DURL_KEY = "EXTRA_AD_DURL_KEY";
    public static final String EXTRA_AD_UUID_KEY = "EXTRA_AD_UUID_KEY";
    private static ShareInteractionListener shareListener;
    Map<String, String> extraHeaders = new HashMap();
    private String shareInfo;
    private WebView webView;

    public static void setShareListener(ShareInteractionListener shareInteractionListener) {
        shareListener = shareInteractionListener;
    }

    public void onCreate(Bundle bundle) {
        super/*androidx.fragment.app.FragmentActivity*/.onCreate(bundle);
        setContentView(R.layout.ms_activity_meishu_webview);
        String[] stringArrayExtra = getIntent().getStringArrayExtra(EXTRA_AD_DURL_KEY);
        ImageView imageView = (ImageView) findViewById(R.id.ms_img_share);
        WebView webView = (WebView) findViewById(R.id.ms_webView);
        this.webView = webView;
        webView.setScrollBarStyle(0);
        this.extraHeaders.put("X-Requested-With", "");
        WebSettings settings = this.webView.getSettings();
        settings.setSavePassword(false);
        settings.setJavaScriptEnabled(true);
        settings.setDomStorageEnabled(true);
        settings.setAllowFileAccess(false);
        if (Build.VERSION.SDK_INT < 31) {
            settings.setAppCachePath(getCacheDir().getAbsolutePath());
            settings.setAppCacheEnabled(true);
        }
        this.webView.setWebChromeClient(new WebChromeClient());
        this.webView.setDownloadListener(DownloadListener.createInstance(this));
        this.webView.setWebViewClient(WebViewClient.createInstance(this));
        try {
            if (MsConstants.IS_FIRST_WEB) {
                MsConstants.IS_FIRST_WEB = false;
                String defaultUserAgent = WebSettings.getDefaultUserAgent(this);
                if (defaultUserAgent != null) {
                    AdSdk.getSharedPreferences().edit().putString("user_agent", defaultUserAgent).apply();
                }
            }
        } catch (Throwable unused) {
        }
        if (stringArrayExtra != null && stringArrayExtra.length > 0) {
            try {
                String queryParameter = Uri.parse(stringArrayExtra[0]).getQueryParameter("__ms_share_info");
                this.shareInfo = queryParameter;
                if (shareListener == null || TextUtils.isEmpty(queryParameter)) {
                    imageView.setVisibility(4);
                } else {
                    imageView.setVisibility(0);
                    imageView.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            if (MeishuWebviewActivity.shareListener != null) {
                                MeishuWebviewActivity.shareListener.onShareButtonClicked(new ShareInfo(MeishuWebviewActivity.this.shareInfo, MeishuWebviewActivity.this.webView.getUrl()));
                            }
                        }
                    });
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            this.webView.loadUrl(stringArrayExtra[0], this.extraHeaders);
        }
        findViewById(R.id.ms_img_close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                MeishuWebviewActivity.this.finish();
            }
        });
    }

    public void onDestroy() {
        try {
            super.onDestroy();
            shareListener = null;
            this.webView.destroy();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        if (i != 4 || !this.webView.canGoBack()) {
            return super.onKeyDown(i, keyEvent);
        }
        this.webView.goBack();
        return true;
    }

    public void onPause() {
        try {
            super/*androidx.fragment.app.FragmentActivity*/.onPause();
            this.webView.onPause();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void onResume() {
        try {
            super/*androidx.fragment.app.FragmentActivity*/.onResume();
            this.webView.onResume();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void setZoomControlGone(View view) {
        try {
            Field declaredField = WebView.class.getDeclaredField("mZoomButtonsController");
            declaredField.setAccessible(true);
            ZoomButtonsController zoomButtonsController = new ZoomButtonsController(view);
            zoomButtonsController.getZoomControls().setVisibility(8);
            try {
                declaredField.set(view, zoomButtonsController);
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (IllegalArgumentException e2) {
                e2.printStackTrace();
            }
        } catch (NoSuchFieldException e3) {
            e3.printStackTrace();
        } catch (SecurityException e4) {
            e4.printStackTrace();
        }
    }
}