导航菜单

页面标题

页面副标题

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

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

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


package com.sweetedge.mantracounter.Authentication;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.util.Log;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import androidx.core.app.ActivityCompat;
import androidx.viewpager2.widget.ViewPager2;
import com.android.volley.AuthFailureError;
import com.android.volley.NetworkResponse;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import com.google.firebase.crashlytics.buildtools.reloc.org.apache.http.client.methods.HttpGet;
import com.sweetedge.mantracounter.Authentication.VolleyMultipartRequest;
import com.sweetedge.mantracounter.MainActivity;
import com.sweetedge.mantracounter.R;
import com.sweetedge.mantracounter.Splash;
import com.sweetedge.mantracounter.Suggest;
import com.sweetedge.mantracounter.cashfree.CircleIndicator;
import com.sweetedge.mantracounter.cashfree.OverlappingPageTransformer;
import com.sweetedge.mantracounter.cashfree.ViewPagerAdapter;
import com.sweetedge.mantracounter.group.GroupConst;
import com.sweetedge.mantracounter.list.MantraListDb;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import push_notif.TokenClass;
import save_data.Const;
import save_data.iUtils;
import sweetedge.extra.PLog;
import sweetedge.popup.PToast;
import sweetedge.preference.PSharedPreference;
import sweetedge.screen.PIntent;

public class UserWebService {
    public static String CITY = null;
    public static String DOB = null;
    public static String Grp = null;
    public static String ID = null;
    public static String IMG = null;
    public static String NAME = null;
    public static String NO_AD_ENABLE = "";
    public static String Prime = "";
    public static String TOKEN = null;
    public static String TOTAL = null;
    public static String WorldTOTAL = null;
    public static boolean isCreate = false;

    public static void UpdateID(final Context context, final String str, final String str2) {
        Volley.newRequestQueue(context).add(new StringRequest(1, Const.userweburl, new Response.Listener<String>() {
            public void onResponse(String str3) {
                if (str3.trim().length() > 2) {
                    PToast.showT(context, str3.trim());
                }
            }
        }, new Response.ErrorListener() {
            public void onErrorResponse(VolleyError volleyError) {
                PToast.showT(context, "The server is down, Please try after some time!");
                Log.e("Response Error", "" + volleyError);
            }
        }) {
            protected Map<String, String> getParams() {
                HashMap hashMap = new HashMap();
                hashMap.put("WHAT", "UPDATE_ID");
                hashMap.put("gmail", str);
                hashMap.put(MantraListDb.MILLI, str2);
                return hashMap;
            }
        });
    }

    public static void UploadImagetoServer(Context context, final Bitmap bitmap, String str, final String str2) {
        PLog.print("Uploading " + bitmap.getRowBytes());
        final String str3 = UserDataPref.get(context, Const.GMAIL);
        Volley.newRequestQueue(context).add(new VolleyMultipartRequest(1, str, new Response.Listener<NetworkResponse>() {
            public void onResponse(NetworkResponse networkResponse) {
                PLog.print("Result = ".concat(new String(networkResponse.data)));
                MainActivity.user_Img_Drawer.setImageBitmap(bitmap);
                User_Screen.UserImageS = str3;
                File file = new File(str2);
                if (iUtils.checkFile(str2)) {
                    file.delete();
                }
            }
        }, new Response.ErrorListener() {
            public void onErrorResponse(VolleyError volleyError) {
                PLog.print("GotError" + volleyError.getMessage());
            }
        }) {
            protected Map<String, String> getParams() throws AuthFailureError {
                HashMap hashMap = new HashMap();
                hashMap.put("WHAT", "UPLOAD");
                hashMap.put("IMAGENAME", str3);
                PLog.print("Image Name = " + str3);
                return hashMap;
            }

            @Override
            protected Map<String, VolleyMultipartRequest.DataPart> getByteData() {
                HashMap hashMap = new HashMap();
                hashMap.put("image", new VolleyMultipartRequest.DataPart(str3 + ".png", UserWebService.getFileDataFromDrawable(bitmap)));
                return hashMap;
            }
        });
    }

    public static byte[] getFileDataFromDrawable(Bitmap bitmap) {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        bitmap.compress(Bitmap.CompressFormat.PNG, 80, byteArrayOutputStream);
        return byteArrayOutputStream.toByteArray();
    }

    public static void updateDatatoServer(final Context context, final String str, final String str2, final String str3, final TextView textView, final String str4) {
        Volley.newRequestQueue(context).add(new StringRequest(1, Const.userweburl, new Response.Listener<String>() {
            public void onResponse(String str5) {
                textView.setText("3");
                UserWebService.SolveFetchedResponseintoData(str5, context, false, str4);
            }
        }, new Response.ErrorListener() {
            public void onErrorResponse(VolleyError volleyError) {
                PLog.print("Update data to server Response Error" + volleyError);
            }
        }) {
            protected Map<String, String> getParams() {
                HashMap hashMap = new HashMap();
                hashMap.put("WHAT", "UPDATE");
                hashMap.put("gmail", str4);
                hashMap.put(MantraListDb.NAME, str);
                hashMap.put("dob", str2);
                hashMap.put("lang", PSharedPreference.getString(context, "Language", "en"));
                hashMap.put("city", str3);
                return hashMap;
            }
        });
    }

    public static void fetchData(final Context context, final boolean z, final String str) {
        if (str.length() > 5) {
            Volley.newRequestQueue(context).add(new StringRequest(1, Const.userweburl, new Response.Listener<String>() {
                public void onResponse(String str2) {
                    PLog.print("Response Fetch Data = " + str2);
                    if (!str2.startsWith("No Record")) {
                        UserWebService.SolveFetchedResponseintoData(str2, context, z, str);
                    } else {
                        PSharedPreference.setString(context, Const.GMAIL, "null");
                        PIntent.goNewScreenwithFinishedThis(context, Splash.class);
                    }
                }
            }, new Response.ErrorListener() {
                public void onErrorResponse(VolleyError volleyError) {
                    MainActivity.PrimeChecked = false;
                    PToast.showT(context, "No Connection");
                    PIntent.goNewScreenwithFinishedThis(context, MainActivity.class);
                }
            }) {
                protected Map<String, String> getParams() {
                    HashMap hashMap = new HashMap();
                    hashMap.put("WHAT", HttpGet.METHOD_NAME);
                    String string = PSharedPreference.getString(context, "IMG_PHOTO", "Gallery");
                    if (string.contains("/")) {
                        string = string.substring(string.lastIndexOf("/") + 1);
                    }
                    String string2 = PSharedPreference.getString(context, "Mantra", "none");
                    if (string2 != null && string2.length() > 0 && string2.contains("/")) {
                        string2 = string2.substring(string2.lastIndexOf("/") + 1);
                    }
                    hashMap.put("GODMANTRA", string2);
                    hashMap.put("GODIMG", string);
                    hashMap.put("VERSION", Suggest.getAppVersion(context));
                    hashMap.put("gmail", str);
                    hashMap.put("LANGU", PSharedPreference.getString(context, "Language", "en").trim());
                    MantraListDb mantraListDb = new MantraListDb(context);
                    mantraListDb.open();
                    Cursor all = mantraListDb.getAll();
                    if (all != null && all.getCount() > 0) {
                        hashMap.put("mantra_list", all.getCount() + "");
                    }
                    mantraListDb.close();
                    PLog.print("Version = " + Suggest.getAppVersion(context) + "______________________________________________________");
                    StringBuilder sb = new StringBuilder("Puting = Img  = ");
                    sb.append(PSharedPreference.getString(context, "IMG_PHOTO", "Gallery"));
                    PLog.print(sb.toString());
                    PLog.print("Gmail = " + str);
                    PLog.print("LANG = " + PSharedPreference.getString(context, "Language", "en"));
                    return hashMap;
                }
            });
        } else {
            TokenClass.generateandstoreinserverandRedirect(context, "");
        }
    }

    public static void SolveFetchedResponseintoData(String str, Context context, boolean z, String str2) {
        PLog.print("SolveFetchResponseintoDataResponse = " + str);
        if (str.startsWith("<!DOCTYPE") || !isValidJson(str)) {
            return;
        }
        try {
            if (!str.equals("No Record")) {
                MainActivity.PrimeChecked = true;
                JSONObject jSONObject = new JSONObject(str);
                if (jSONObject.has("MantraCounter")) {
                    if (jSONObject.get("MantraCounter").toString().equals("null")) {
                        PLog.print("No Record");
                        return;
                    }
                    JSONArray jSONArray = jSONObject.getJSONArray("MantraCounter");
                    WorldTOTAL = str.substring(str.lastIndexOf("}") + 1);
                    PLog.print("Whole Total :" + str.substring(str.lastIndexOf("}") + 1));
                    PLog.print("Length= " + jSONArray.length());
                    if (jSONArray.length() > 0) {
                        for (int i = 0; i < jSONArray.length(); i++) {
                            try {
                                NAME = jSONArray.getJSONObject(i).getString("Name").trim();
                                TOTAL = jSONArray.getJSONObject(i).getString("Total").trim();
                                DOB = jSONArray.getJSONObject(i).getString("Dob").trim();
                                Prime = jSONArray.getJSONObject(i).getString("Prime").trim();
                                IMG = jSONArray.getJSONObject(i).getString("Img").trim();
                                CITY = jSONArray.getJSONObject(i).getString("City").trim();
                                Grp = jSONArray.getJSONObject(i).getString("Grp").trim();
                                NO_AD_ENABLE = jSONArray.getJSONObject(i).getString("NOAD_Enable").trim();
                                TOKEN = jSONArray.getJSONObject(i).getString("Token");
                                ID = jSONArray.getJSONObject(i).getString("ID");
                                TokenClass.generateandstoreinserverandRedirect(context, TOKEN);
                                PLog.print("Name = " + NAME);
                                PLog.print("Total = " + TOTAL);
                                PLog.print("DOB = " + DOB);
                                PLog.print("PRIME = " + Prime);
                                PLog.print("Image = " + IMG);
                                PLog.print("City = " + CITY);
                                PLog.print("Group = " + Grp);
                                UserDataPref.setData(context, NAME, TOTAL, DOB, Prime, IMG, CITY, Grp);
                                StorePercentage(context, NAME, DOB, IMG, CITY);
                                if (z) {
                                    PIntent.goNewScreenwithFinishedThis(context, MainActivity.class);
                                }
                                PLog.print("ID = " + ID + " = " + Authentication.getDeviceID(context));
                                if (ID.length() > 2) {
                                    if (!ID.equals(Authentication.getDeviceID(context))) {
                                        MainActivity.ISidMatch = false;
                                    } else {
                                        PLog.print("Same ID is There");
                                        MainActivity.ISidMatch = true;
                                    }
                                } else {
                                    try {
                                        UpdateID(context, str2, Authentication.getDeviceID(context));
                                    } catch (Exception unused) {
                                        PToast.showT(context, "Failed to connect Server");
                                    }
                                }
                            } catch (Exception unused2) {
                            }
                        }
                        return;
                    }
                    PIntent.goNewScreen(context, Authentication.class);
                    return;
                }
                if (jSONObject.has("")) {
                    return;
                }
                PLog.print("Response =" + str);
                PToast.showT(context, "Error getting Data");
                return;
            }
            PToast.showT(context, "No Record Found !");
        } catch (JSONException e) {
            MainActivity.PrimeChecked = false;
            throw new RuntimeException(e);
        }
    }

    private static boolean isValidJson(String str) {
        try {
            new JSONObject(str);
            return true;
        } catch (JSONException unused) {
            return false;
        }
    }

    private static void StorePercentage(Context context, String str, String str2, String str3, String str4) {
        int i = str.length() != 0 ? 1 : 0;
        if (str2.length() != 0) {
            i++;
        }
        if (str3.length() != 0) {
            i++;
        }
        if (str4.length() != 0) {
            i++;
        }
        PSharedPreference.setInteger(context, "PERC", (i * 100) / 4);
    }

    public static void createAcc(final Context context, final String str, final String str2) {
        if (isCreate) {
            isCreate = false;
            Volley.newRequestQueue(context).add(new StringRequest(1, Const.userweburl, new Response.Listener<String>() {
                public void onResponse(String str3) {
                    PLog.print("Response = " + str3);
                    PSharedPreference.setString(context, "U_phone", "null");
                    PSharedPreference.setString(context, Const.GMAIL, str);
                    PLog.print("Writing Gmail = " + str);
                    PToast.showT(context, context.getResources().getString(R.string.loginsuccess) + str);
                    context.startActivity(new Intent(context, (Class<?>) Splash.class));
                    ActivityCompat.finishAffinity((Activity) context);
                }
            }, new Response.ErrorListener() {
                public void onErrorResponse(VolleyError volleyError) {
                    PLog.print("Create Acc Error" + volleyError + " = " + volleyError.getMessage());
                }
            }) {
                protected Map<String, String> getParams() {
                    HashMap hashMap = new HashMap();
                    if (UserDataPref.get(context, "U_phone").length() > 5) {
                        hashMap.put("mob", UserDataPref.get(context, "U_phone"));
                    }
                    hashMap.put("gmail", str);
                    hashMap.put(MantraListDb.NAME, str2);
                    hashMap.put("ID", Authentication.getDeviceID(context));
                    Context context2 = context;
                    PSharedPreference.setString(context2, "U_total", MainActivity.getTotalMantra(context2));
                    hashMap.put("total", MainActivity.getTotalMantra(context));
                    hashMap.put("lang", PSharedPreference.getString(context, "Language", "en"));
                    return hashMap;
                }
            });
        }
    }

    public static void ErrorReport(final Context context, final String str) {
        Volley.newRequestQueue(context).add(new StringRequest(1, Const.errorReport, new Response.Listener<String>() {
            public void onResponse(String str2) {
                PLog.print("Response = " + str2);
            }
        }, new Response.ErrorListener() {
            public void onErrorResponse(VolleyError volleyError) {
                PLog.print("Create Acc Error" + volleyError + " = " + volleyError.getMessage());
            }
        }) {
            protected Map<String, String> getParams() {
                HashMap hashMap = new HashMap();
                hashMap.put("gmail", PSharedPreference.getString(context, Const.GMAIL, "None"));
                hashMap.put("errorlog", str);
                return hashMap;
            }
        });
    }

    public static void sendOTP(final Context context, final String str, final Button button, final EditText editText, final Button button2, final EditText editText2, final String str2) {
        Volley.newRequestQueue(context).add(new StringRequest(1, Const.customMailLogin, new Response.Listener<String>() {
            public void onResponse(String str3) {
                if (str3.trim().length() > 0) {
                    PToast.showT(context, str3.trim());
                    if (str3.contains("successfully") || str3.contains("OTP already sent recently")) {
                        button.setVisibility(8);
                        editText.setVisibility(0);
                        button2.setVisibility(0);
                        editText2.setEnabled(false);
                    }
                }
            }
        }, new Response.ErrorListener() {
            public void onErrorResponse(VolleyError volleyError) {
                PLog.print("Create Acc Error" + volleyError + " = " + volleyError.getMessage());
            }
        }) {
            protected Map<String, String> getParams() {
                HashMap hashMap = new HashMap();
                hashMap.put("what", "Send");
                hashMap.put("mail", str);
                hashMap.put(MantraListDb.MILLI, str2);
                return hashMap;
            }
        });
    }

    public static void verifyOTP(final Context context, final EditText editText, final EditText editText2) {
        Volley.newRequestQueue(context).add(new StringRequest(1, Const.customMailLogin, new Response.Listener<String>() {
            public void onResponse(String str) {
                if (str.trim().length() > 0) {
                    PToast.showT(context, str.trim());
                    if (str.toLowerCase().contains("verified")) {
                        UserWebService.isCreate = true;
                        UserWebService.createAcc(context, editText.getText().toString().trim(), "Unknown");
                    }
                }
            }
        }, new Response.ErrorListener() {
            public void onErrorResponse(VolleyError volleyError) {
                PLog.print("Create Acc Error" + volleyError + " = " + volleyError.getMessage());
            }
        }) {
            protected Map<String, String> getParams() {
                HashMap hashMap = new HashMap();
                hashMap.put("what", "Verify");
                hashMap.put("mail", editText.getText().toString().trim());
                hashMap.put("otp", editText2.getText().toString().trim());
                return hashMap;
            }
        });
    }

    public static boolean isNetworkAvailable(Context context) {
        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
        NetworkInfo activeNetworkInfo = connectivityManager != null ? connectivityManager.getActiveNetworkInfo() : null;
        return activeNetworkInfo != null && activeNetworkInfo.isConnected();
    }

    public static void updateTotalMala(final Context context, final String str, final String str2, final String str3) {
        PLog.print("Total Mala from DB = " + str);
        Volley.newRequestQueue(context).add(new StringRequest(1, Const.userweburl, new Response.Listener<String>() {
            public void onResponse(String str4) {
                String trim = str4.trim();
                PLog.print("ResponseUpdate = " + trim);
                if (trim.contains("ok")) {
                    PLog.print("Ok Response = " + str);
                    PSharedPreference.setString(context, "U_total", str);
                } else if (trim.contains("Total")) {
                    PSharedPreference.setString(context, "U_total", trim.substring(trim.indexOf(":") + 1));
                }
                if (trim.contains("WORLD")) {
                    String substring = trim.substring(trim.indexOf("WORLD"));
                    UserWebService.WorldTOTAL = substring.substring(substring.indexOf(":") + 1);
                    PLog.print("Set World from update total : " + UserWebService.WorldTOTAL);
                }
            }
        }, new Response.ErrorListener() {
            public void onErrorResponse(VolleyError volleyError) {
                PLog.print("Response Error" + volleyError + " = " + volleyError.getMessage());
            }
        }) {
            protected Map<String, String> getParams() {
                HashMap hashMap = new HashMap();
                hashMap.put("WHAT", "UPDATEMALA");
                hashMap.put("gmail", str3);
                hashMap.put("appversion", str2);
                hashMap.put("total", str);
                return hashMap;
            }
        });
    }

    public static void logOutSetLastUseOff(final Context context, final String str) {
        PLog.print("Logging Out " + str);
        Volley.newRequestQueue(context).add(new StringRequest(1, Const.LOGOUT_URL, new Response.Listener<String>() {
            public void onResponse(String str2) {
                String trim = str2.trim();
                PLog.print("Reponse Logout = " + trim);
                if (trim.contains("Logout")) {
                    PSharedPreference.setString(context, Const.GMAIL, "null");
                    PIntent.goNewScreenwithFinishedThis(context, Splash.class);
                    PSharedPreference.setBoolean(context, "GMAILlogin", true);
                    PSharedPreference.setBoolean(context, GroupConst.isGroup, false);
                    PSharedPreference.setString(context, GroupConst.Grpid, "null");
                    PToast.showT(context, "Logout Successful !");
                }
            }
        }, new Response.ErrorListener() {
            public void onErrorResponse(VolleyError volleyError) {
                PLog.print("Response Error" + volleyError + " = " + volleyError.getMessage());
            }
        }) {
            protected Map<String, String> getParams() {
                HashMap hashMap = new HashMap();
                hashMap.put("gmail", str);
                hashMap.put("p", context.getPackageName());
                return hashMap;
            }
        });
    }

    public static void getPaymentData(final Context context, final ViewPager2 viewPager2, final CircleIndicator circleIndicator) {
        Volley.newRequestQueue(context).add(new StringRequest(1, Const.PaymentPlan, new Response.Listener<String>() {
            public void onResponse(String str) {
                PLog.print("Response Get Payment Data = " + str);
                if (str.contains("%")) {
                    ViewPagerAdapter.tips.clear();
                    ViewPagerAdapter.image.clear();
                    ViewPagerAdapter.amt.clear();
                    ViewPagerAdapter.time.clear();
                    String[] split = str.split("%");
                    for (int i = 0; i < split.length; i++) {
                        if (split[i].contains("*") && split[i].contains("#")) {
                            String str2 = split[i];
                            String substring = str2.substring(0, str2.indexOf("*"));
                            String str3 = split[i];
                            String substring2 = str3.substring(str3.indexOf("*") + 1, split[i].indexOf("^"));
                            String str4 = split[i];
                            String substring3 = str4.substring(str4.indexOf("^") + 1, split[i].indexOf("#"));
                            String str5 = split[i];
                            String substring4 = str5.substring(str5.indexOf("#") + 1);
                            ViewPagerAdapter.tips.add(substring3.trim());
                            ViewPagerAdapter.image.add(substring4.trim());
                            ViewPagerAdapter.amt.add(substring);
                            ViewPagerAdapter.time.add(substring2);
                        }
                    }
                    viewPager2.setAdapter(new ViewPagerAdapter(context));
                    viewPager2.setPageTransformer(new OverlappingPageTransformer());
                    circleIndicator.setPageCount(ViewPagerAdapter.image.size());
                    viewPager2.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
                        public void onPageSelected(int i2) {
                            super.onPageSelected(i2);
                            circleIndicator.setCurrentPage(i2);
                        }
                    });
                    return;
                }
                if (!str.contains("%") && str.contains("*") && str.contains("#")) {
                    str.substring(0, str.indexOf("*"));
                    str.substring(str.indexOf("*") + 1, str.indexOf("#"));
                    str.substring(str.indexOf("#") + 1);
                    PLog.print(str);
                }
            }
        }, new Response.ErrorListener() {
            public void onErrorResponse(VolleyError volleyError) {
                PLog.print("Response Error" + volleyError + " = " + volleyError.getMessage());
            }
        }) {
            protected Map<String, String> getParams() {
                HashMap hashMap = new HashMap();
                hashMap.put("INFO", "INFO");
                return hashMap;
            }
        });
    }
}