导航菜单

页面标题

页面副标题

St.John's v1.0.9 - SplashActivity.java 源代码

正在查看: St.John's v1.0.9 应用的 SplashActivity.java JAVA 源代码文件

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


package com.mcb.stjohnsemschool.activity;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.Html;
import android.view.ContextThemeWrapper;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import com.an.biometric.BiometricManager$;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.mcb.stjohnsemschool.DB.MyClassBoardDB;
import com.mcb.stjohnsemschool.model.LoginModel;
import com.mcb.stjohnsemschool.model.LoginResponse;
import com.mcb.stjohnsemschool.model.SchoolUrlsModel;
import com.mcb.stjohnsemschool.model.SchoolUrlsResponseModel;
import com.mcb.stjohnsemschool.services.ApiClient;
import com.mcb.stjohnsemschool.services.ApiInterface;
import com.mcb.stjohnsemschool.utils.TransparentProgressDialog;
import com.mcb.stjohnsemschool.utils.Utility;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class SplashActivity extends AppCompatActivity implements View.OnClickListener {
    private Activity activity;
    private ConnectivityManager conMgr;
    private Context context;
    private boolean isNew;
    private Dialog mDialogAlert;
    private TextView mDialogeAlertYes;
    private SharedPreferences.Editor mEditor;
    private String mGuid;
    private TransparentProgressDialog mProgressbar;
    private SharedPreferences mSharedPref;
    private String regId;
    private final int REQUEST_CODE_ASK_MULTIPLE_PERMISSIONS = 124;
    private boolean mIsLoggedin = false;
    private MyClassBoardDB db = null;
    private String username = "";
    private String password = "";
    private String deviceName = "";
    private String deviceMan = "";
    private String mAboutdeviceTotal = "";
    private String deviceid = "";
    private String versionName = "";
    private String packageName = "";
    private String playstoreURL = "";
    private String imgPath = "";
    private String type = null;
    private String TAG = SplashActivity.class.getName();
    String orgId = "";

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_splash_screen);
        FirebaseAnalytics firebaseAnalytics = FirebaseAnalytics.getInstance(this);
        String str = null;
        firebaseAnalytics.setCurrentScreen(this, "Splash Screen", null);
        firebaseAnalytics.setAnalyticsCollectionEnabled(true);
        this.context = getApplicationContext();
        this.activity = this;
        String str2 = "";
        SharedPreferences sharedPreferences = getSharedPreferences("", 0);
        this.mSharedPref = sharedPreferences;
        this.mEditor = sharedPreferences.edit();
        this.orgId = this.mSharedPref.getString("OrganisationId", this.orgId);
        enableFirstTimeOptions();
        Bundle extras = getIntent().getExtras();
        if (extras != null) {
            this.type = extras.getString("type");
            String string = extras.getString("Link");
            getIntent().removeExtra("type");
            getIntent().replaceExtras(new Bundle());
            extras.clear();
            str2 = string;
        }
        if (getIntent().getFlags() == 269484032 || getIntent().getFlags() == 873496576) {
            this.type = null;
        } else {
            str = str2;
        }
        if (str != null && str.length() > 0 && !str.equalsIgnoreCase("null") && str.startsWith("http")) {
            Intent intent = new Intent(getApplicationContext(), (Class<?>) WebViewActivity.class);
            intent.putExtra("URL", str);
            intent.putExtra("Title", "MCB");
            startActivity(intent);
            finish();
            return;
        }
        if (Build.VERSION.SDK_INT < 23) {
            checkLogin();
        } else {
            getMultiplePermissions();
        }
        Dialog dialog = new Dialog(this, R.style.Theme_Dialog);
        this.mDialogAlert = dialog;
        WindowManager.LayoutParams attributes = dialog.getWindow().getAttributes();
        attributes.dimAmount = 5.0f;
        this.mDialogAlert.getWindow().setAttributes(attributes);
        this.mDialogAlert.getWindow().addFlags(2);
        this.mDialogAlert.setContentView(R.layout.dialog_alert);
        this.mDialogAlert.setCanceledOnTouchOutside(true);
        TextView textView = (TextView) this.mDialogAlert.findViewById(R.id.ok_alert_dialog);
        this.mDialogeAlertYes = textView;
        textView.setOnClickListener(this);
    }

    private void enableFirstTimeOptions() {
        boolean z = this.mSharedPref.getBoolean("is_new", false);
        this.isNew = z;
        if (z) {
            return;
        }
        this.mEditor.putBoolean("is_new", true);
        this.mEditor.putBoolean("notification", true);
        this.mEditor.putBoolean("notification_sound", true);
        this.mEditor.putInt("primary_color", getResources().getColor(R.color.ColorPrimary));
        this.mEditor.putInt("dark_color", getResources().getColor(R.color.ColorPrimaryDark));
        this.mEditor.commit();
    }

    private void checkLogin() {
        this.deviceid = Utility.getDeviceId(this);
        this.db = new MyClassBoardDB(this);
        this.regId = this.mSharedPref.getString("RegisterId", "");
        this.deviceName = Build.MODEL;
        this.deviceMan = Build.MANUFACTURER;
        this.mAboutdeviceTotal = "Android," + this.deviceMan + "," + this.deviceName;
        PrintStream printStream = System.out;
        StringBuilder sb = new StringBuilder("mAboutdeviceTotal  ");
        sb.append(this.mAboutdeviceTotal);
        printStream.println(sb.toString());
        this.mProgressbar = new TransparentProgressDialog(this, R.drawable.spinner_loading_imag);
        this.mIsLoggedin = this.mSharedPref.getBoolean("isloggedin", this.mIsLoggedin);
        this.username = this.mSharedPref.getString("usernamekey", this.username);
        this.password = this.mSharedPref.getString("passwordkey", this.password);
        this.mGuid = this.mSharedPref.getString("user_guid_key", "");
        try {
            this.packageName = getApplicationContext().getPackageName();
            this.versionName = getPackageManager().getPackageInfo(this.packageName, 0).versionName;
            this.playstoreURL = "https://play.google.com/store/apps/details?id=" + this.packageName;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        if (this.mIsLoggedin) {
            String str = this.mGuid;
            if (str != null && str.length() > 0) {
                loadLoginData(this.mGuid);
                return;
            } else {
                startActivity(new Intent((Context) this, (Class<?>) LoginActivity.class));
                finish();
                return;
            }
        }
        startActivity(new Intent((Context) this, (Class<?>) LoginActivity.class));
        finish();
    }

    public void getMultiplePermissions() {
        ArrayList arrayList = new ArrayList();
        ArrayList arrayList2 = new ArrayList();
        if (Build.VERSION.SDK_INT >= 33) {
            if (!addPermission(arrayList2, "android.permission.POST_NOTIFICATIONS")) {
                arrayList.add("android.permission.POST_NOTIFICATIONS");
            }
        } else if (!addPermission(arrayList2, "android.permission.READ_PHONE_STATE")) {
            arrayList.add("Read Phone State");
        }
        if (arrayList2.size() > 0) {
            BiometricManager$.ExternalSyntheticApiModelOutline0.m(this, (String[]) arrayList2.toArray(new String[arrayList2.size()]), 124);
        } else {
            checkLogin();
        }
    }

    private boolean addPermission(List<String> list, String str) {
        if (ActivityCompat.checkSelfPermission(this, str) == 0) {
            return true;
        }
        list.add(str);
        return BiometricManager$.ExternalSyntheticApiModelOutline0.m(this, str);
    }

    private void showDialogOK(String str, DialogInterface.OnClickListener onClickListener) {
        new AlertDialog.Builder(new ContextThemeWrapper((Context) this, R.style.MyDialogTheme)).setMessage(str).setPositiveButton("OK", onClickListener).create().show();
    }

    public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
        if (i == 124) {
            HashMap hashMap = new HashMap();
            if (Build.VERSION.SDK_INT >= 33) {
                hashMap.put("android.permission.POST_NOTIFICATIONS", 0);
                checkLogin();
            } else {
                hashMap.put("android.permission.READ_PHONE_STATE", 0);
                checkLogin();
            }
            if (iArr.length > 0) {
                for (int i2 = 0; i2 < strArr.length; i2++) {
                    hashMap.put(strArr[i2], Integer.valueOf(iArr[i2]));
                }
                if (Build.VERSION.SDK_INT >= 33) {
                    if (((Integer) hashMap.get("android.permission.POST_NOTIFICATIONS")).intValue() == 0) {
                        checkLogin();
                        return;
                    }
                    if (ActivityCompat.shouldShowRequestPermissionRationale(this, "android.permission.POST_NOTIFICATIONS")) {
                        showDialogOK("Notification permission is required,Please allow it.", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int i3) {
                                if (i3 != -1) {
                                    return;
                                }
                                SplashActivity.this.getMultiplePermissions();
                            }
                        });
                        return;
                    }
                    Toast.makeText((Context) this, (CharSequence) ("Go to settings-->Apps-->" + getResources().getString(2131886124) + " and enable permissions"), 1).show();
                    return;
                }
                return;
            }
            if (((Integer) hashMap.get("android.permission.READ_PHONE_STATE")).intValue() == 0) {
                checkLogin();
                return;
            }
            if (ActivityCompat.shouldShowRequestPermissionRationale(this, "android.permission.READ_PHONE_STATE")) {
                showDialogOK("Phone State Permission required for this app. Please grant permissions", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i3) {
                        if (i3 != -1) {
                            return;
                        }
                        SplashActivity.this.getMultiplePermissions();
                    }
                });
                return;
            }
            Toast.makeText((Context) this, (CharSequence) ("Go to settings-->Apps-->" + getResources().getString(2131886124) + " and enable permissions"), 1).show();
            return;
        }
        super.onRequestPermissionsResult(i, strArr, iArr);
    }

    @Override
    public void onClick(View view) {
        Dialog dialog;
        if (view == this.mDialogeAlertYes && (dialog = this.mDialogAlert) != null && dialog.isShowing()) {
            this.mDialogAlert.dismiss();
            Intent intent = new Intent((Context) this, (Class<?>) FeeActivity.class);
            intent.putExtra("IS_FEE_DUE", true);
            startActivity(intent);
            finish();
        }
    }

    private void getApiUrl() {
        ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService("connectivity");
        this.conMgr = connectivityManager;
        if (connectivityManager.getActiveNetworkInfo() != null && this.conMgr.getActiveNetworkInfo().isAvailable() && this.conMgr.getActiveNetworkInfo().isConnected()) {
            getSchoolApiUrl();
        } else {
            Toast.makeText(getApplicationContext(), "Check your Network Connection", 0).show();
        }
    }

    private void getSchoolApiUrl() {
        TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
        if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
            this.mProgressbar.show();
        }
        ((ApiInterface) ApiClient.getClient().create(ApiInterface.class)).getSchoolUrls().enqueue(new Callback<SchoolUrlsResponseModel>() {
            public void onResponse(Call<SchoolUrlsResponseModel> call, Response<SchoolUrlsResponseModel> response) {
                if (SplashActivity.this.mProgressbar != null && SplashActivity.this.mProgressbar.isShowing()) {
                    SplashActivity.this.mProgressbar.dismiss();
                }
                if (response == null || response.body() == null) {
                    Utility.showAlertDialog(SplashActivity.this.activity);
                    return;
                }
                SchoolUrlsResponseModel schoolUrlsResponseModel = (SchoolUrlsResponseModel) response.body();
                if (schoolUrlsResponseModel.getStatus() == 1) {
                    new ArrayList();
                    ArrayList data = schoolUrlsResponseModel.getData();
                    String string = SplashActivity.this.mSharedPref.getString("schoolNameURLkey", "");
                    if (data != null && data.size() > 0) {
                        Iterator it = data.iterator();
                        while (it.hasNext()) {
                            SchoolUrlsModel schoolUrlsModel = (SchoolUrlsModel) it.next();
                            if (string.equalsIgnoreCase(schoolUrlsModel.getWebUrl())) {
                                SplashActivity.this.mEditor.putString("schoolApiUrlKey", schoolUrlsModel.getApiUrl());
                                SplashActivity.this.mEditor.commit();
                                SplashActivity splashActivity = SplashActivity.this;
                                splashActivity.loadLoginData(splashActivity.mGuid);
                                return;
                            }
                        }
                    }
                    Intent intent = new Intent(SplashActivity.this.context, (Class<?>) LoginActivity.class);
                    intent.putExtra("From", "FromSplash");
                    SplashActivity.this.startActivity(intent);
                    SplashActivity.this.finish();
                }
            }

            public void onFailure(Call<SchoolUrlsResponseModel> call, Throwable th) {
                if (SplashActivity.this.mProgressbar != null && SplashActivity.this.mProgressbar.isShowing()) {
                    SplashActivity.this.mProgressbar.dismiss();
                }
                Utility.showAlertDialog(SplashActivity.this.activity);
            }
        });
    }

    public void loadLoginData(String str) {
        ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService("connectivity");
        if (connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isAvailable() && connectivityManager.getActiveNetworkInfo().isConnected()) {
            getLoginData(str);
        } else {
            Toast.makeText(getApplicationContext(), "Check your Network Connection", 0).show();
        }
    }

    private void getLoginData(final String str) {
        TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
        if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
            this.mProgressbar.show();
        }
        HashMap hashMap = new HashMap();
        hashMap.put("UserGUID", str);
        hashMap.put("OrganisationID", String.valueOf(25));
        hashMap.put("device_type", this.mAboutdeviceTotal);
        hashMap.put("device_id", this.deviceid);
        String str2 = this.regId;
        if (str2 != null) {
            hashMap.put("device_token", str2);
        } else {
            hashMap.put("device_token", "");
        }
        hashMap.put("usercurrentversion", this.versionName);
        hashMap.put("packagename", this.packageName);
        hashMap.put("apikey", "hjysgt87e-andparentid-84376-mcb-dt34986tj");
        ((ApiInterface) ApiClient.getClientWithStaticHeader(getApplicationContext()).create(ApiInterface.class)).GetParentLogin(hashMap).enqueue(new Callback<LoginResponse>() {
            public void onResponse(Call<LoginResponse> call, Response<LoginResponse> response) {
                if (SplashActivity.this.mProgressbar != null && SplashActivity.this.mProgressbar.isShowing()) {
                    SplashActivity.this.mProgressbar.dismiss();
                }
                if (response == null || response.body() == null) {
                    Utility.showAlertDialog(SplashActivity.this.activity);
                    return;
                }
                LoginResponse loginResponse = (LoginResponse) response.body();
                int status = loginResponse.getStatus();
                String message = loginResponse.getMessage();
                if (status == 0) {
                    Toast.makeText(SplashActivity.this.getApplicationContext(), message, 0).show();
                    return;
                }
                if (status == -1) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper((Context) SplashActivity.this, R.style.MyDialogTheme));
                    builder.setMessage("There is newer version of this application available, click OK to upgrade now?. If your play store not showing any update please clear cache of play store and check again.").setPositiveButton("OK", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            SplashActivity.this.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(SplashActivity.this.playstoreURL)));
                            SplashActivity.this.finish();
                        }
                    }).setCancelable(false);
                    builder.create().show();
                    return;
                }
                LoginModel data = loginResponse.getData();
                if (data != null) {
                    Bundle bundle = new Bundle();
                    bundle.putString("user_name", data.getUsername());
                    FirebaseAnalytics.getInstance(SplashActivity.this.getApplicationContext()).logEvent("EVENT_USER_LOGIN", bundle);
                    String ablyApiKey = data.getAblyApiKey();
                    if (ablyApiKey == null) {
                        ablyApiKey = "";
                    }
                    SplashActivity.this.mEditor.putString("AblyApiKey", ablyApiKey);
                    SplashActivity.this.mEditor.putString("user_guid_key", str);
                    SplashActivity.this.mEditor.putString("usernamekey", data.getUsername());
                    SplashActivity.this.mEditor.putString("UseridKey", String.valueOf(data.getUserId()));
                    SplashActivity.this.mEditor.putString("studentEnrollmentIdKey", String.valueOf(data.getStudentEnrollmentId()));
                    SplashActivity.this.mEditor.putString("main_user_id", String.valueOf(data.getUserId()));
                    SplashActivity.this.mEditor.putString("main_student_enrollment_id", String.valueOf(data.getStudentEnrollmentId()));
                    SplashActivity.this.mEditor.putString("OrganisationNameKey", data.getOrgName());
                    SplashActivity.this.mEditor.putString("BranchLogo", String.valueOf(data.getBranchLogoPath()));
                    SplashActivity.this.mEditor.putString("OAuthToken", data.getoAuthToken());
                    SplashActivity.this.mEditor.putString("SchoolApiKey", data.getSchoolApiKey());
                    int orgId = data.getOrgId();
                    int userTypeId = data.getUserTypeId();
                    data.isOTPSecurityEnabled();
                    boolean isMaskEmail = data.isMaskEmail();
                    boolean isMaskMobile = data.isMaskMobile();
                    SplashActivity.this.mEditor.putInt("MainOrganisationId", orgId);
                    SplashActivity.this.mEditor.putString("orgnizationIdKey", String.valueOf(orgId));
                    SplashActivity.this.mEditor.putInt("MainUserTypeId", userTypeId);
                    SplashActivity.this.mEditor.putBoolean("MaskEmail", isMaskEmail);
                    SplashActivity.this.mEditor.putBoolean("MaskMobile", isMaskMobile);
                    SplashActivity.this.mEditor.commit();
                    final int isChangePassword = data.getIsChangePassword();
                    data.getLastDate();
                    if (status != 2) {
                        SplashActivity.this.moveToNextPage(isChangePassword);
                    } else {
                        new AlertDialog.Builder(SplashActivity.this.activity).setMessage(Html.fromHtml(message)).setCancelable(false).setTitle("Alert").setIcon(android.R.drawable.ic_dialog_alert).setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int i) {
                                dialogInterface.cancel();
                                SplashActivity.this.moveToNextPage(isChangePassword);
                            }
                        }).show();
                    }
                }
            }

            public void onFailure(Call<LoginResponse> call, Throwable th) {
                if (SplashActivity.this.mProgressbar != null && SplashActivity.this.mProgressbar.isShowing()) {
                    SplashActivity.this.mProgressbar.dismiss();
                }
                Utility.showAlertDialog(SplashActivity.this.activity);
            }
        });
    }

    public void moveToNextPage(int i) {
        if (i == 1) {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setMessage("Your password has expired. Please set a new password.").setPositiveButton("OK", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i2) {
                    SplashActivity.this.startActivity(new Intent(SplashActivity.this.getApplicationContext(), (Class<?>) ChangePasswordActivity.class));
                    SplashActivity.this.finish();
                }
            }).setCancelable(false);
            builder.create().show();
        } else {
            Intent intent = new Intent((Context) this, (Class<?>) ProfileActivity.class);
            intent.putExtra("type", this.type);
            startActivity(intent);
            finish();
        }
    }

    protected void onResume() {
        super.onResume();
        String string = getSharedPreferences("", 0).getString("usernamekey", "");
        Bundle bundle = new Bundle();
        bundle.putString("user_name", string);
        FirebaseAnalytics.getInstance(this).logEvent("PAGE_SPLASH_SCREEN", bundle);
    }
}