PSP Dragon Emulator v1.0版本的 MD5 值为:c6379fb6b63c27b6a7d2f2f6f6f51637

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


package com.airpush.injector.internal.ads.adchoice;

import android.content.Context;
import android.graphics.Color;
import android.os.Build;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.airpush.injector.internal.common.utils.ViewUtils;
import java.util.concurrent.atomic.AtomicBoolean;
public class AdChoiceDialogView extends RelativeLayout {
    public static final String ADCHOICE_DEFALT_URL = "http://cdnap.airpush.com/ap/index.html";
    private AdChoiceDialodEventsListener listener;
    private WebView webView;

    public interface AdChoiceDialodEventsListener {
        void onClose();

        void onOpenBrowser(String str);
    }

    public AdChoiceDialogView(Context context, AdChoiceDialodEventsListener adChoiceDialodEventsListener) {
        super(context);
        this.listener = adChoiceDialodEventsListener;
        setLayoutParams(new FrameLayout.LayoutParams(-1, -1));
        setBackgroundColor(-1);
        LinearLayout genHeader = genHeader(context);
        LinearLayout genButtonFrame = genButtonFrame(context);
        ProgressBar progressBar = new ProgressBar(context);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewUtils.dpToPxRounded(context, 40), ViewUtils.dpToPxRounded(context, 40));
        layoutParams.addRule(13, -1);
        progressBar.setLayoutParams(layoutParams);
        addView(progressBar);
        addView(genHeader);
        addView(genButtonFrame);
        this.webView = genWebView(context, genButtonFrame.getId(), genHeader.getId(), new Runnable() {
            @Override
            public void run() {
                AdChoiceDialogView.this.addView(AdChoiceDialogView.this.webView);
            }
        });
    }

    private LinearLayout genHeader(Context context) {
        LinearLayout linearLayout = new LinearLayout(context);
        linearLayout.setId(ViewUtils.generateViewId());
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-1, ViewUtils.dpToPxRounded(context, 50));
        layoutParams.addRule(10, -1);
        linearLayout.setLayoutParams(layoutParams);
        linearLayout.setBackgroundColor(-12303292);
        TextView textView = new TextView(context);
        LinearLayout.LayoutParams layoutParams2 = new LinearLayout.LayoutParams(-1, -2);
        layoutParams2.gravity = 17;
        textView.setLayoutParams(layoutParams2);
        textView.setText("Interest-Based Advertising by Airpush");
        if (Build.VERSION.SDK_INT >= 23) {
            textView.setTextAppearance(16973889);
        } else {
            textView.setTextAppearance(context, 16973889);
        }
        textView.setTextColor(Color.parseColor("#FFFFFF"));
        textView.setGravity(17);
        linearLayout.addView(textView);
        return linearLayout;
    }

    private LinearLayout genButtonFrame(Context context) {
        LinearLayout linearLayout = new LinearLayout(context);
        linearLayout.setId(ViewUtils.generateViewId());
        linearLayout.setBackgroundColor(-12303292);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-1, -2);
        layoutParams.addRule(12, -1);
        linearLayout.setLayoutParams(layoutParams);
        linearLayout.addView(genCloseButton(context));
        return linearLayout;
    }

    private WebView genWebView(Context context, int i, int i2, final Runnable runnable) {
        final AtomicBoolean atomicBoolean = new AtomicBoolean(false);
        WebView webView = new WebView(context);
        if (Build.VERSION.SDK_INT == 19) {
            webView.setLayerType(1, null);
        }
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-1, -1);
        layoutParams.addRule(2, i);
        layoutParams.addRule(3, i2);
        webView.setLayoutParams(layoutParams);
        webView.getSettings().setDefaultTextEncodingName("UTF-8");
        webView.getSettings().setAllowFileAccess(false);
        webView.getSettings().setAllowContentAccess(false);
        if (Build.VERSION.SDK_INT >= 16) {
            webView.getSettings().setAllowFileAccessFromFileURLs(false);
            webView.getSettings().setAllowUniversalAccessFromFileURLs(false);
        }
        webView.setWebChromeClient(new WebChromeClient());
        webView.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView webView2, String str) {
                if (str == null || str.isEmpty()) {
                    return true;
                }
                AdChoiceDialogView.this.listener.onOpenBrowser(str);
                return true;
            }

            @Override
            public void onPageFinished(WebView webView2, String str) {
                if (atomicBoolean.compareAndSet(false, true)) {
                    runnable.run();
                }
                super.onPageFinished(webView2, str);
            }
        });
        webView.setScrollBarStyle(33554432);
        webView.loadUrl(ADCHOICE_DEFALT_URL);
        return webView;
    }

    private Button genCloseButton(Context context) {
        Button button = new Button(context);
        button.setAllCaps(false);
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -1);
        int dpToPxRounded = ViewUtils.dpToPxRounded(context, 30);
        int dpToPxRounded2 = ViewUtils.dpToPxRounded(context, 10);
        layoutParams.setMargins(dpToPxRounded, dpToPxRounded2, dpToPxRounded, dpToPxRounded2);
        button.setLayoutParams(layoutParams);
        button.setText("Close");
        button.setTextColor(-1);
        button.setBackgroundColor(Color.parseColor("#00A2DB"));
        button.setTextColor(-1);
        if (Build.VERSION.SDK_INT >= 23) {
            button.setTextAppearance(16973892);
        } else {
            button.setTextAppearance(context, 16973892);
        }
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                AdChoiceDialogView.this.listener.onClose();
                if (AdChoiceDialogView.this.webView != null) {
                    AdChoiceDialogView.this.webView.stopLoading();
                    AdChoiceDialogView.this.webView.destroy();
                }
            }
        });
        return button;
    }
}