导航菜单

页面标题

页面副标题

Mantra Counter v25.01 - PAds.java 源代码

正在查看: Mantra Counter v25.01 应用的 PAds.java JAVA 源代码文件

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


package com.sweetedge.mantracounter;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition;
import com.google.firebase.crashlytics.buildtools.reloc.org.apache.http.HttpHost;
import com.makeramen.roundedimageview.RoundedDrawable;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONObject;
import sweetedge.extra.PLog;
import sweetedge.popup.PDialog;

public class PAds {
    public static String CURRENTVERSION = null;
    public static String DESC = null;
    public static String HELP_URL = "none";
    public static String IMAGE = null;
    public static String ISSHOW = null;
    public static String LASTVERSION = null;
    public static String NAME = null;
    public static String OTUPDATELINK = null;
    public static String PACKAGE = null;
    public static String TARGET_PACKAGE = null;
    public static String UPDATE_DESC = null;
    public static String VERSION = null;
    static String adFetchUrl = "https://davdapranav.com/webservice_files/appview_for_ads.php";
    static AlertDialog.Builder cb = null;
    static AlertDialog cd = null;
    static String clickUrl = "https://davdapranav.com/webservice_files/appview_clicks.php";
    public static boolean isDialogReady = false;
    static String isPOPUP = "0";
    static boolean isShowWhenReady = true;
    static boolean isValidJSON = false;

    public static void loadAds(final Activity activity, final Context context, boolean z) {
        isDialogReady = false;
        isShowWhenReady = z;
        Volley.newRequestQueue(context).add(new StringRequest(1, adFetchUrl, new Response.Listener<String>() {
            public void onResponse(String str) {
                Log.e("Response", str);
                PAds.showJson(str, context, activity);
            }
        }, new Response.ErrorListener() {
            public void onErrorResponse(VolleyError volleyError) {
                Log.e("Response Error", "" + volleyError);
            }
        }) {
            protected Map<String, String> getParams() {
                HashMap hashMap = new HashMap();
                hashMap.put("P", context.getPackageName());
                return hashMap;
            }
        });
    }

    public static void showJson(String str, final Context context, Activity activity) {
        try {
            JSONArray jSONArray = new JSONObject(str).getJSONArray("json");
            for (int i = 0; i < jSONArray.length(); i++) {
                try {
                    TARGET_PACKAGE = jSONArray.getJSONObject(i).getString("TARGET_PACKAGE");
                    NAME = jSONArray.getJSONObject(i).getString("NAME");
                    DESC = jSONArray.getJSONObject(i).getString("DES");
                    PACKAGE = jSONArray.getJSONObject(i).getString("PACKAGE");
                    IMAGE = jSONArray.getJSONObject(i).getString("IMAGE");
                    ISSHOW = jSONArray.getJSONObject(i).getString("ISSHOW");
                    VERSION = jSONArray.getJSONObject(i).getString("VERSION");
                    LASTVERSION = jSONArray.getJSONObject(i).getString("LAST_VERSION");
                    OTUPDATELINK = jSONArray.getJSONObject(i).getString("OTUPDATE");
                    isPOPUP = jSONArray.getJSONObject(i).getString("POPUP");
                    HELP_URL = jSONArray.getJSONObject(i).getString("HELP_URL");
                    UPDATE_DESC = jSONArray.getJSONObject(i).getString("UPDATE_DESC");
                    IMAGE = IMAGE.replace("\"", "");
                    isValidJSON = true;
                } catch (Exception unused) {
                }
                if (TARGET_PACKAGE.equals(context.getPackageName())) {
                    PLog.print("This Package is Ok");
                    PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
                    CURRENTVERSION = packageInfo.versionName;
                    Double valueOf = Double.valueOf(0.0d);
                    Double valueOf2 = Double.valueOf(0.0d);
                    Double valueOf3 = Double.valueOf(Double.parseDouble(packageInfo.versionName));
                    if (LASTVERSION.length() != 0) {
                        valueOf = Double.valueOf(Double.parseDouble(LASTVERSION));
                    }
                    if (VERSION.length() != 0) {
                        valueOf2 = Double.valueOf(Double.parseDouble(VERSION));
                    }
                    PLog.print("Helad");
                    String str2 = "♦" + UPDATE_DESC;
                    UPDATE_DESC = str2;
                    if (str2.contains(",")) {
                        UPDATE_DESC = UPDATE_DESC.replace(",", ".\n♦");
                    }
                    if (valueOf3.doubleValue() < valueOf.doubleValue()) {
                        PLog.print("Helad");
                        final Intent intent = new Intent("android.intent.action.VIEW", jSONArray.getJSONObject(i).getString("ONLYFB").equals("1") ? Uri.parse(OTUPDATELINK) : Uri.parse("market://details?id=" + context.getPackageName()));
                        showSimplest(context, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int i2) {
                                context.startActivity(intent);
                            }
                        }, "Update is Recommendent", "You are using older version,\nPlease update to latest version " + UPDATE_DESC, "Update", "");
                        Notifier.createNotificationSimple(context, intent, R.mipmap.ic_launcher, false, "My_Channel", context.getResources().getString(R.string.app_name), "Update to Version " + VERSION, 0, true);
                        return;
                    }
                    if (valueOf3.doubleValue() < valueOf2.doubleValue()) {
                        PLog.print("Heladsdg");
                        final Intent intent2 = new Intent("android.intent.action.VIEW", jSONArray.getJSONObject(i).getString("ONLYFB").equals("1") ? Uri.parse(OTUPDATELINK) : Uri.parse("market://details?id=" + context.getPackageName()));
                        if (ISSHOW.equals("1") && TARGET_PACKAGE.equals(context.getPackageName())) {
                            PLog.print("Enabled");
                            showDialog(context, NAME, DESC, PACKAGE, IMAGE);
                        }
                        PDialog.showSimple(context, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int i2) {
                                if (i2 == -1) {
                                    context.startActivity(intent2);
                                }
                            }
                        }, "New Version Available", "Update " + context.getResources().getString(R.string.app_name) + " is recommends,\nUpdate now to get latest features " + UPDATE_DESC, "Update", "No, Thanks");
                        Notifier.createNotificationSimple(context, intent2, R.mipmap.ic_launcher, false, "My_Channel", context.getResources().getString(R.string.app_name), "Update to Version " + VERSION, 0, true);
                        return;
                    }
                    PLog.print("Helad");
                    if (ISSHOW.equals("1") && TARGET_PACKAGE.equals(context.getPackageName())) {
                        PLog.print("Enabled");
                        showDialog(context, NAME, DESC, PACKAGE, IMAGE);
                        return;
                    }
                    return;
                }
            }
        } catch (Exception unused2) {
            isValidJSON = false;
        }
    }

    private static void showSimplest(Context context, DialogInterface.OnClickListener onClickListener, String str, String str2, String str3, String str4) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setTitle(str);
        builder.setMessage(str2);
        builder.setNeutralButton(str3, onClickListener);
        final AlertDialog create = builder.create();
        create.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialogInterface) {
                create.show();
            }
        });
        create.show();
    }

    public static void showDialog(final Context context, String str, String str2, final String str3, final String str4) {
        PLog.print("here");
        Typeface createFromAsset = Typeface.createFromAsset(context.getAssets(), "sweetedge_lib.otf");
        TextView textView = new TextView(context);
        textView.setText(str);
        textView.setLayoutParams(new ViewGroup.LayoutParams(-1, -2));
        textView.setGravity(17);
        textView.setPadding(0, 0, 0, 10);
        textView.setTextSize(25.0f);
        textView.setTextColor(Color.parseColor("#222222"));
        TextView textView2 = new TextView(context);
        textView2.setText(str2);
        textView2.setLayoutParams(new ViewGroup.LayoutParams(-1, -2));
        textView2.setGravity(17);
        textView2.setPadding(12, 10, 10, 12);
        textView2.setTextSize(18.0f);
        textView2.setTextColor(Color.parseColor("#333333"));
        TextView textView3 = new TextView(context);
        ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(-1, -2);
        textView3.setGravity(5);
        textView3.setPadding(5, 5, 5, 10);
        textView3.setText("*");
        textView3.setTextColor(RoundedDrawable.DEFAULT_BORDER_COLOR);
        textView3.setTypeface(createFromAsset, 1);
        textView3.setTextSize(22.0f);
        textView3.setLayoutParams(layoutParams);
        textView3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                PAds.cd.dismiss();
            }
        });
        final ImageView imageView = new ImageView(context);
        imageView.setLayoutParams(new ViewGroup.LayoutParams(-1, -2));
        TextView textView4 = new TextView(context);
        textView4.setBackgroundColor(-7829368);
        textView4.setLayoutParams(new ViewGroup.LayoutParams(-1, -2));
        textView4.setGravity(17);
        textView4.setPadding(20, 16, 16, 20);
        textView4.setTextSize(22.0f);
        textView4.setTextColor(-1);
        textView4.setText("2 View");
        textView4.setTypeface(createFromAsset);
        ScrollView scrollView = new ScrollView(context);
        LinearLayout linearLayout = new LinearLayout(context);
        linearLayout.setLayoutParams(new LinearLayout.LayoutParams(-1, -1));
        linearLayout.setBackgroundColor(-1);
        linearLayout.setOrientation(1);
        linearLayout.setPadding(15, 15, 15, 15);
        textView4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (str3.contains(HttpHost.DEFAULT_SCHEME_NAME)) {
                    context.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str3)));
                } else {
                    try {
                        context.startActivity(new Intent("android.intent.action.VIEW", Uri.parse("market://details?id=" + str3)));
                    } catch (ActivityNotFoundException unused) {
                        context.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(PAds.PACKAGE)));
                    }
                }
                PAds.callclick(context);
                PAds.cd.dismiss();
            }
        });
        linearLayout.addView(textView3, 0);
        linearLayout.addView(textView, 1);
        linearLayout.addView(imageView, 2);
        linearLayout.addView(textView2, 3);
        linearLayout.addView(textView4, 4);
        scrollView.setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
        scrollView.addView(linearLayout);
        AlertDialog.Builder builder = new AlertDialog.Builder(context, 4);
        cb = builder;
        builder.setCancelable(false);
        cb.setView(scrollView);
        cd = cb.create();
        PLog.print("here");
        Glide.with(context).load(str4).diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true).into(new CustomTarget<Drawable>() {
            public void onLoadCleared(Drawable drawable) {
            }

            public void onResourceReady(Object obj, Transition transition) {
                onResourceReady((Drawable) obj, (Transition<? super Drawable>) transition);
            }

            public void onResourceReady(Drawable drawable, Transition<? super Drawable> transition) {
                if (drawable == null) {
                    PLog.print("Null");
                    PAds.isDialogReady = false;
                    PLog.print("Failed with " + str4);
                    return;
                }
                imageView.setImageDrawable(drawable);
                if (PAds.isPOPUP.equals("1")) {
                    PAds.cd.show();
                    return;
                }
                PLog.print("Success");
                try {
                    if (PAds.isShowWhenReady) {
                        PAds.cd.show();
                    }
                    PAds.isDialogReady = true;
                } catch (Exception unused) {
                    PLog.print("Failed with ");
                }
            }
        });
    }

    public static void callclick(final Context context) {
        Volley.newRequestQueue(context).add(new StringRequest(1, clickUrl, new Response.Listener<String>() {
            public void onResponse(String str) {
            }
        }, new Response.ErrorListener() {
            public void onErrorResponse(VolleyError volleyError) {
                Toast.makeText(context, volleyError.getMessage(), 1).show();
            }
        }) {
            protected Map<String, String> getParams() {
                HashMap hashMap = new HashMap();
                hashMap.put("P", context.getPackageName());
                return hashMap;
            }
        });
    }

    public static boolean showAppDialog() {
        if (!isDialogReady || isShowWhenReady) {
            return false;
        }
        AlertDialog create = cb.create();
        cd = create;
        try {
            create.show();
        } catch (Exception unused) {
        }
        isDialogReady = false;
        return true;
    }

    public static void helpClick(Context context) throws PackageManager.NameNotFoundException {
        if (HELP_URL.length() > 5) {
            PLog.print(HELP_URL + " v " + CURRENTVERSION);
            context.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(HELP_URL + "&version=" + CURRENTVERSION)));
            return;
        }
        context.startActivity(new Intent("android.intent.action.VIEW", Uri.parse("https://davdapranav.com/AllApps/index.php?packagename=" + context.getPackageName() + "&version=" + context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName)));
    }
}