导航菜单

页面标题

页面副标题

Clash Legends v0.0.1 - FirstActivity.java 源代码

正在查看: Clash Legends v0.0.1 应用的 FirstActivity.java JAVA 源代码文件

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


package com.clash.legends.ui.activities;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.android.volley.AuthFailureError;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
import com.clash.legends.models.CurrentUser;
import com.clash.legends.ui.activities.FirstActivity;
import com.clash.legends.utils.LoadingDialog;
import com.clash.legends.utils.LocaleHelper;
import com.clash.legends.utils.UserLocalStore;
import com.google.android.gms.auth.api.signin.GoogleSignIn;
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.messaging.FirebaseMessaging;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;

public class FirstActivity extends AppCompatActivity {
    Context context;
    RequestQueue dQueue;
    LoadingDialog loadingDialog;
    Resources resources;
    CurrentUser user;
    UserLocalStore userLocalStore;
    RequestQueue vQueue;
    String versionName = null;
    int versionCode = 0;
    String latestVersionName = null;
    int latestVersionCode = 0;
    String forceUpdate = "No";
    String downloadUrl = "";
    int waitTime = 0;
    String memberStatus = "";
    String forceLogout = "No";

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(2131558444);
        Context locale = LocaleHelper.setLocale(this);
        this.context = locale;
        this.resources = locale.getResources();
        LoadingDialog loadingDialog = new LoadingDialog(this);
        this.loadingDialog = loadingDialog;
        loadingDialog.show();
        UserLocalStore userLocalStore = new UserLocalStore(this);
        this.userLocalStore = userLocalStore;
        this.user = userLocalStore.getLoggedInUser();
        FirebaseMessaging.getInstance().setAutoInitEnabled(true);
        SharedPreferences spp = getApplicationContext().getSharedPreferences("tabitem", 0);
        SharedPreferences.Editor editor1111 = spp.edit();
        editor1111.putString("TAB", "0");
        editor1111.apply();
        if (!this.user.getMemberid().isEmpty()) {
            RequestQueue newRequestQueue = Volley.newRequestQueue(getApplicationContext());
            this.dQueue = newRequestQueue;
            newRequestQueue.getCache().clear();
            String durl = this.resources.getString(2131886167) + "dashboard/" + this.user.getMemberid();
            JsonObjectRequest drequest = new JsonObjectRequest(durl, null, new Response.Listener() {
                public final void onResponse(Object obj) {
                    FirstActivity.this.m31lambda$onCreate$0$comclashlegendsuiactivitiesFirstActivity((JSONObject) obj);
                }
            }, new Response.ErrorListener() {
                public final void onErrorResponse(VolleyError volleyError) {
                    Log.e("**VolleyErrorfirst", "error" + volleyError.getMessage());
                }
            }) {
                protected Map<String, String> getParams() throws AuthFailureError {
                    return super.getParams();
                }

                public Map<String, String> getHeaders() {
                    Map<String, String> headers = new HashMap<>();
                    CurrentUser user = FirstActivity.this.userLocalStore.getLoggedInUser();
                    String token = "Bearer " + user.getToken();
                    headers.put("Content-Type", "application/json");
                    headers.put("Authorization", token);
                    headers.put("x-localization", LocaleHelper.getPersist(FirstActivity.this.context));
                    return headers;
                }
            };
            drequest.setShouldCache(false);
            this.dQueue.add(drequest);
        }
        RequestQueue newRequestQueue2 = Volley.newRequestQueue(this);
        this.vQueue = newRequestQueue2;
        newRequestQueue2.getCache().clear();
        String vurl = this.resources.getString(2131886167) + "version/android";
        JsonObjectRequest request = new JsonObjectRequest(0, vurl, null, new AnonymousClass2(), new Response.ErrorListener() {
            public final void onErrorResponse(VolleyError volleyError) {
                Log.e("errorversion", volleyError.toString());
            }
        }) {
            protected Map<String, String> getParams() throws AuthFailureError {
                return super.getParams();
            }

            public Map<String, String> getHeaders() {
                Map<String, String> headers = new HashMap<>();
                headers.put("x-localization", "en");
                return headers;
            }
        };
        request.setShouldCache(false);
        this.vQueue.add(request);
    }

    void m31lambda$onCreate$0$comclashlegendsuiactivitiesFirstActivity(JSONObject response) {
        try {
            JSONObject memobj = new JSONObject(response.getString("member"));
            String string = memobj.getString("member_status");
            this.memberStatus = string;
            if (TextUtils.equals(string, "0") && !this.user.getUsername().equals("") && !this.user.getPassword().equals("")) {
                this.userLocalStore.clearUserData();
                Toast.makeText(getApplicationContext(), this.resources.getString(2131887105), 0).show();
                startActivity(new Intent(getApplicationContext(), (Class<?>) MainActivity.class));
                finishAffinity();
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    class AnonymousClass2 implements Response.Listener<JSONObject> {
        AnonymousClass2() {
        }

        public void onResponse(JSONObject response) {
            Log.d("version", response.toString());
            try {
                FirstActivity.this.latestVersionName = response.getString("version");
                FirstActivity.this.latestVersionCode = Integer.parseInt(response.getString("version"));
                FirstActivity.this.downloadUrl = response.getString("url");
                FirstActivity.this.forceUpdate = response.getString("force_update");
                FirstActivity.this.forceLogout = response.getString("force_logged_out");
                SharedPreferences sp = FirstActivity.this.getSharedPreferences("SMINFO", 0);
                SharedPreferences.Editor editor = sp.edit();
                editor.putString("fb", response.getString("fb_login"));
                editor.putString("google", response.getString("google_login"));
                editor.putString("otp", response.getString("firebase_otp"));
                editor.putString("baner", response.getString("banner_ads_show"));
                editor.putString("firebase_key", "");
                editor.apply();
                try {
                    FirstActivity firstActivity = FirstActivity.this;
                    firstActivity.versionName = firstActivity.getPackageManager().getPackageInfo(FirstActivity.this.getPackageName(), 0).versionName;
                    FirstActivity firstActivity2 = FirstActivity.this;
                    firstActivity2.versionCode = firstActivity2.getPackageManager().getPackageInfo(FirstActivity.this.getPackageName(), 0).versionCode;
                } catch (PackageManager.NameNotFoundException e) {
                }
                if (FirstActivity.this.versionCode < FirstActivity.this.latestVersionCode) {
                    if (TextUtils.equals(FirstActivity.this.forceUpdate, "Yes")) {
                        if (TextUtils.equals(FirstActivity.this.forceLogout, "Yes")) {
                            FirstActivity.this.logoutall();
                        }
                        FirstActivity.this.loadingDialog.dismiss();
                        FirstActivity.this.startActivity(new Intent(FirstActivity.this.getApplicationContext(), (Class<?>) AppUpdateActivity.class));
                        return;
                    }
                    FirstActivity.this.loadingDialog.dismiss();
                    AlertDialog.Builder builder = new AlertDialog.Builder(FirstActivity.this);
                    builder.setCancelable(false);
                    builder.setTitle(FirstActivity.this.resources.getString(2131886168));
                    builder.setMessage(FirstActivity.this.resources.getString(2131886622));
                    builder.setNegativeButton(FirstActivity.this.resources.getString(2131886507), new DialogInterface.OnClickListener() {
                        @Override
                        public final void onClick(DialogInterface dialogInterface, int i) {
                            FirstActivity.AnonymousClass2.this.m32x56df4a38(dialogInterface, i);
                        }
                    });
                    builder.setPositiveButton(FirstActivity.this.resources.getString(2131887052), new DialogInterface.OnClickListener() {
                        @Override
                        public final void onClick(DialogInterface dialogInterface, int i) {
                            FirstActivity.AnonymousClass2.this.m33x5668e439(dialogInterface, i);
                        }
                    });
                    builder.create();
                    builder.show();
                    return;
                }
                FirstActivity.this.loadingDialog.dismiss();
                final Handler tipsHanlder = new Handler();
                Runnable tipsRunnable = new Runnable() {
                    @Override
                    public void run() {
                        tipsHanlder.postDelayed(this, 1000L);
                        if (TextUtils.equals(String.valueOf(FirstActivity.this.waitTime), "1")) {
                            if (!FirstActivity.this.user.getUsername().equals("") && !FirstActivity.this.user.getMemberid().equals("")) {
                                if (TextUtils.equals(FirstActivity.this.memberStatus, "1")) {
                                    FirstActivity.this.startActivity(new Intent(FirstActivity.this.getApplicationContext(), (Class<?>) HomeActivity.class));
                                }
                            } else {
                                SharedPreferences prefs = FirstActivity.this.getSharedPreferences("first_time", 0);
                                boolean ft = prefs.getBoolean("f_t", true);
                                if (ft) {
                                    FirstActivity.this.startActivity(new Intent(FirstActivity.this.getApplicationContext(), (Class<?>) SelectedLanguageActivity.class));
                                } else {
                                    FirstActivity.this.startActivity(new Intent(FirstActivity.this.getApplicationContext(), (Class<?>) MainActivity.class));
                                }
                            }
                        }
                        FirstActivity.this.waitTime++;
                    }
                };
                tipsHanlder.post(tipsRunnable);
            } catch (JSONException e2) {
                e2.printStackTrace();
                try {
                    Log.d("um msg", response.getString("message"));
                    if (TextUtils.equals(response.getString("message"), "<h1>Under Maintenance</h1>")) {
                        AlertDialog.Builder builder2 = new AlertDialog.Builder(FirstActivity.this);
                        builder2.setCancelable(false);
                        builder2.setTitle(FirstActivity.this.resources.getString(2131886166));
                        builder2.setMessage(FirstActivity.this.resources.getString(2131886403));
                        builder2.setPositiveButton(FirstActivity.this.resources.getString(2131886445), new DialogInterface.OnClickListener() {
                            @Override
                            public final void onClick(DialogInterface dialogInterface, int i) {
                                FirstActivity.AnonymousClass2.this.m34x55f27e3a(dialogInterface, i);
                            }
                        });
                        builder2.create();
                        builder2.show();
                    }
                } catch (JSONException ex) {
                    ex.printStackTrace();
                }
                e2.printStackTrace();
            }
        }

        void m32x56df4a38(DialogInterface dialogInterface, int i) {
            if (!FirstActivity.this.user.getUsername().equals("") && !FirstActivity.this.user.getPassword().equals("")) {
                if (TextUtils.equals(FirstActivity.this.memberStatus, "1")) {
                    FirstActivity.this.startActivity(new Intent(FirstActivity.this.getApplicationContext(), (Class<?>) HomeActivity.class));
                }
            } else {
                SharedPreferences prefs = FirstActivity.this.getSharedPreferences("first_time", 0);
                boolean ft = prefs.getBoolean("f_t", true);
                if (ft) {
                    FirstActivity.this.startActivity(new Intent(FirstActivity.this.getApplicationContext(), (Class<?>) SelectedLanguageActivity.class));
                } else {
                    FirstActivity.this.startActivity(new Intent(FirstActivity.this.getApplicationContext(), (Class<?>) MainActivity.class));
                }
            }
        }

        void m33x5668e439(DialogInterface dialogInterface, int i) {
            if (TextUtils.equals(FirstActivity.this.forceLogout, "Yes")) {
                FirstActivity.this.logoutall();
            }
            FirstActivity.this.startActivity(new Intent(FirstActivity.this.getApplicationContext(), (Class<?>) AppUpdateActivity.class));
        }

        void m34x55f27e3a(DialogInterface dialogInterface, int i) {
            FirstActivity.this.finishAffinity();
        }
    }

    public void logoutall() {
        this.userLocalStore.clearUserData();
        FirebaseAuth.getInstance().signOut();
        GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestIdToken(getString(2131886411)).requestEmail().build();
        GoogleSignIn.getClient(getApplicationContext(), gso).signOut();
    }

    protected void onRestart() {
        super.onRestart();
        recreate();
    }

    protected void onDestroy() {
        super.onDestroy();
        try {
            this.loadingDialog.dismiss();
        } catch (Exception e) {
        }
    }
}