From Russia v1.0版本的 MD5 值为:52aeb8738ddf971390ea1486e59c6ccd

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


package com.brorders.launcher.activity;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.StatFs;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatButton;
import com.brorders.game.R;
import com.brorders.game.core.GTASA;
import com.brorders.launcher.other.Utils;
import com.brorders.weikton.reg.Preferences;
import java.io.File;
import java.io.IOException;
import java.util.Timer;
import java.util.TimerTask;
import org.ini4j.Wini;

public class MainActivity extends AppCompatActivity {
    private static final int PERMISSION_STORAGE = 101;
    ImageButton ib_info;
    EditText nickname;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragment_main);
        IsMemoryEnough(GetAvialableMemory());
        final Animation animation = AnimationUtils.loadAnimation(this, R.anim.button_click);
        if (checkSelfPermission("android.permission.RECORD_AUDIO") == -1) {
            requestPermissions(new String[]{"android.permission.RECORD_AUDIO"}, 1000);
        }
        if (!GetStoragePermission.ISPermission(this)) {
            GetStoragePermission.requestPermission(this, 101);
        }
        InitLogic();
        LoadNick();
        this.nickname = (EditText) findViewById(R.id.edit_text_name);
        this.ib_info = (ImageButton) findViewById(R.id.ib_info);
        ((AppCompatButton) findViewById(R.id.button_play)).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                v.startAnimation(animation);
                Timer t = new Timer();
                t.schedule(new TimerTask() {
                    @Override
                    public void run() {
                        MainActivity.this.onClickPlay();
                    }
                }, 200L);
            }
        });
        this.ib_info.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                v.startAnimation(animation);
                TextView info_nick = (TextView) MainActivity.this.findViewById(R.id.text_view_info_about_nickname);
                if (info_nick.getVisibility() == 4) {
                    info_nick.setVisibility(0);
                } else {
                    info_nick.setVisibility(4);
                }
            }
        });
        ((ImageButton) findViewById(R.id.button_vk)).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                v.startAnimation(animation);
                Timer t = new Timer();
                t.schedule(new TimerTask() {
                    @Override
                    public void run() {
                        MainActivity.this.startActivity(new Intent("android.intent.action.VIEW", Uri.parse("https://vk.me/")));
                    }
                }, 200L);
            }
        });
        ((ImageButton) findViewById(R.id.button_discord)).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                v.startAnimation(animation);
                Timer t = new Timer();
                t.schedule(new TimerTask() {
                    @Override
                    public void run() {
                        MainActivity.this.startActivity(new Intent("android.intent.action.VIEW", Uri.parse("https://discord.com/")));
                    }
                }, 200L);
            }
        });
        ((ImageButton) findViewById(R.id.button_telegram)).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                v.startAnimation(animation);
                Timer t = new Timer();
                t.schedule(new TimerTask() {
                    @Override
                    public void run() {
                        MainActivity.this.startActivity(new Intent("android.intent.action.VIEW", Uri.parse("https://t.me/FromRussiaCRMP")));
                    }
                }, 200L);
            }
        });
        ((AppCompatButton) findViewById(R.id.button_clean_game)).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                v.startAnimation(animation);
                Timer t = new Timer();
                t.schedule(new TimerTask() {
                    @Override
                    public void run() {
                        MainActivity.this.ToLoad();
                    }
                }, 200L);
            }
        });
        this.nickname.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == 3 || actionId == 6 || (event.getAction() == 0 && event.getKeyCode() == 66)) {
                    try {
                        File f = new File(Environment.getExternalStorageDirectory() + "/BrDataCache/SAMP/settings.ini");
                        if (!f.exists()) {
                            f.createNewFile();
                            f.mkdirs();
                        }
                        Wini w = new Wini(new File(Environment.getExternalStorageDirectory() + "/BrDataCache/SAMP/settings.ini"));
                        if (MainActivity.this.checkValidNick()) {
                            w.put("client", "name", MainActivity.this.nickname.getText().toString());
                            MainActivity.this.tost("Ваш новый никнейм успешно сохранен!");
                            Preferences.setNick(String.valueOf(MainActivity.this.nickname.getText()));
                        } else {
                            MainActivity.this.checkValidNick();
                        }
                        w.store();
                        return false;
                    } catch (IOException e) {
                        e.printStackTrace();
                        MainActivity.this.tost("Установите игру!");
                        return false;
                    }
                }
                return false;
            }
        });
        this.nickname.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
                try {
                    File f = new File(Environment.getExternalStorageDirectory() + "/BrDataCache/SAMP/settings.ini");
                    if (!f.exists()) {
                        f.createNewFile();
                        f.mkdirs();
                    }
                    Wini w = new Wini(new File(Environment.getExternalStorageDirectory() + "/BrDataCache/SAMP/settings.ini"));
                    if (MainActivity.this.checkValidNick()) {
                        w.put("client", "name", MainActivity.this.nickname.getText().toString());
                    } else {
                        MainActivity.this.checkValidNick();
                    }
                    w.store();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void afterTextChanged(Editable editable) {
            }
        });
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        if (requestCode != 1000) {
            if (checkSelfPermission("android.permission.RECORD_AUDIO") == -1) {
                requestPermissions(new String[]{"android.permission.RECORD_AUDIO"}, 1000);
            }
            if (!GetStoragePermission.ISPermission(this)) {
                GetStoragePermission.requestPermission(this, 101);
            }
        }
    }

    public void onClickPlay() {
        if (checkSelfPermission("android.permission.RECORD_AUDIO") == -1) {
            requestPermissions(new String[]{"android.permission.RECORD_AUDIO"}, 1000);
        }
        if (!GetStoragePermission.ISPermission(this)) {
            GetStoragePermission.requestPermission(this, 101);
        }
        if (IsGameInstalled()) {
            startActivity(new Intent(this, (Class<?>) GTASA.class));
        } else {
            ToLoad();
        }
    }

    private boolean IsGameInstalled() {
        String path = Environment.getExternalStorageDirectory() + "/BrDataCache/";
        if (!new File(path + "texdb/gta3.img").exists()) {
            return false;
        }
        if (!new File(path + "anim/anim.img").exists()) {
            return false;
        }
        if (!new File(path + "loader/reytiz.sys").exists()) {
            return false;
        }
        if (!new File(path + "SAMP/reytiz.dat").exists()) {
            return false;
        }
        if (!new File(path + "data/reytiz.dat").exists()) {
            return false;
        }
        if (!new File(path + "audio/SFX/FEET.osw").exists()) {
            return false;
        }
        if (!new File(path + "data/plants.dat").exists()) {
            return false;
        }
        if (!new File(path + "data/gta.dat").exists()) {
            return false;
        }
        if (!new File(path + "data/fonts.dat").exists()) {
            return false;
        }
        if (!new File(path + "data/water.dat").exists()) {
            return false;
        }
        if (!new File(path + "data/paths/carrec.img").exists()) {
            return false;
        }
        if (!new File(path + "models/effects.fxp").exists()) {
            return false;
        }
        if (!new File(path + "SAMP/vehicles.ide").exists()) {
            return false;
        }
        if (!new File(path + "SAMP/gta.dat").exists()) {
            return false;
        }
        if (!new File(path + "texdb/samp.img").exists()) {
            return false;
        }
        if (!new File(path + "texdb/samp/samp.txt").exists()) {
            return false;
        }
        if (!new File(path + "texdb/gta3/gta3.txt").exists()) {
            return false;
        }
        if (!new File(path + "texdb/player/player.txt").exists()) {
            return false;
        }
        StringBuilder sb = new StringBuilder();
        sb.append(path);
        sb.append("texdb/gta_int/gta_int.txt");
        return new File(sb.toString()).exists();
    }

    private void InitLogic() {
        try {
            Wini w = new Wini(new File(Environment.getExternalStorageDirectory() + "/BrDataCache/SAMP/settings.ini"));
            EditText editText = (EditText) findViewById(R.id.edit_text_name);
            this.nickname = editText;
            editText.setText(w.get("client", "name"));
            w.store();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public boolean checkValidNick() {
        EditText nick = (EditText) findViewById(R.id.edit_text_name);
        if (nick.getText().toString().isEmpty()) {
            tost("Введите ник");
            return false;
        }
        if (!nick.getText().toString().contains("_")) {
            return false;
        }
        if (nick.getText().toString().length() < 4) {
            tost("Длина ника должна быть не менее 4 символов");
            return false;
        }
        return true;
    }

    public long GetAvialableMemory() {
        StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
        long bytesAvailable = stat.getBlockSizeLong() * stat.getAvailableBlocksLong();
        return (bytesAvailable / Utils.MB) / Utils.KB;
    }

    public void IsMemoryEnough(long memory) {
        if (IsGameInstalled()) {
            if (memory < 2) {
                tost("У вас осталось мало свободной памяти!");
            }
        } else if (memory < 4) {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle("Недстаточно памяти");
            builder.setMessage("У вас недостаточно памяти для установки игры. Необходимо как минимум 3,5ГБ! Освободите память и вернитесь в приложение");
            builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                }
            });
            AlertDialog dialog = builder.create();
            dialog.show();
        }
    }

    private void LoadNick() {
        try {
            Wini w = new Wini(new File(Environment.getExternalStorageDirectory() + "/BrDataCache/SAMP/settings.ini"));
            Preferences.setNick(w.get("client", "name"));
            w.store();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void tost(String pon) {
        Toast.makeText(this, pon, 1).show();
    }

    public void ToLoad() {
        startActivity(new Intent(this, (Class<?>) NewLoaderActivity.class));
    }
}