新增:设置-切换专用客户端版本
新增:长按插件可卸载插件
This commit is contained in:
parent
0bc3283def
commit
d20e3b04ae
@ -28,6 +28,13 @@ public class BaseViewHolder<T> extends RecyclerView.ViewHolder{
|
||||
onItemViewClick(mData);
|
||||
}
|
||||
});
|
||||
itemView.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
onItemViewLongClick(mData);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onInitializeView() {
|
||||
@ -55,5 +62,8 @@ public class BaseViewHolder<T> extends RecyclerView.ViewHolder{
|
||||
|
||||
public void onItemViewClick(T data) {
|
||||
|
||||
}
|
||||
public void onItemViewLongClick(T data){
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import android.widget.TextView;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.kaopiz.kprogresshud.KProgressHUD;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.yutou.jianr_mg.Data.AppData;
|
||||
import com.yutou.jianr_mg.Interfaces.ModInterface;
|
||||
import com.yutou.jianr_mg.R;
|
||||
import com.yutou.jianr_mg.Tools.ModUtils;
|
||||
@ -104,7 +105,7 @@ public class WarAdapter extends RecyclerAdapter<List<Map<String, JSONObject>>> {
|
||||
@Override
|
||||
public void onItemViewClick(List<Map<String, JSONObject>> data) {
|
||||
super.onItemViewClick(data);
|
||||
Utils.toast(getContext(),"详细内容正在咕,敬请期待");
|
||||
Utils.toast(getContext(),"详细内容正在咕,敬请期待:"+ AppData.magicPackageName);
|
||||
/* JSONArray array=new JSONArray();
|
||||
for (Map<String, JSONObject> datum : data) {
|
||||
try {
|
||||
|
@ -11,11 +11,13 @@ import com.yutou.jianr_mg.Application;
|
||||
import com.yutou.jianr_mg.Data.AppData;
|
||||
import com.yutou.jianr_mg.Data.MAppTools;
|
||||
import com.yutou.jianr_mg.R;
|
||||
import com.yutou.jianr_mg.Tools.JianRUtils;
|
||||
import com.yutou.jianr_mg.Tools.Utils;
|
||||
import com.yutou.jianr_mg.views.BaseActivity;
|
||||
|
||||
import cn.lemon.view.adapter.BaseViewHolder;
|
||||
import cn.lemon.view.adapter.RecyclerAdapter;
|
||||
import me.drakeet.materialdialog.MaterialDialog;
|
||||
|
||||
public class MainUtilsAdapter extends RecyclerAdapter<MAppTools> {
|
||||
private ImageLoader imageLoader;
|
||||
@ -94,5 +96,31 @@ public class MainUtilsAdapter extends RecyclerAdapter<MAppTools> {
|
||||
Utils.toast(getContext(), "启动失败,请升级至最新版本或联系管理员");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemViewLongClick(MAppTools data) {
|
||||
super.onItemViewLongClick(data);
|
||||
String type = data.getMainFunction().split("#")[1];
|
||||
if(AppData.plugsin.containsKey(data.getPluginName()+".jar")) {
|
||||
if (type.equals("localActivity")) {
|
||||
MaterialDialog dialog = new MaterialDialog(getContext());
|
||||
dialog.setTitle("卸载插件");
|
||||
dialog.setMessage("确定删除" + data.getName() + "插件?");
|
||||
dialog.setNegativeButton("取消", v -> dialog.dismiss());
|
||||
dialog.setPositiveButton("确定", v -> {
|
||||
try {
|
||||
AppData.plugsin.remove(data.getPluginName() + ".jar");
|
||||
Utils.removePlugins(data.getPluginName());
|
||||
Utils.toast(getContext(), "卸载成功,重启生效");
|
||||
dialog.dismiss();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
dialog.show();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
ActivitysManager.finishActivity(LoadingActivity.class);
|
||||
initViews();
|
||||
JianRUtils.downlaodInit(true);
|
||||
JianRUtils.readClientVersionIsbigzhao(this);
|
||||
new Thread(()->{
|
||||
JianRUtils.reloadJianNiang();
|
||||
JianRUtils.reloadEquipmnts();
|
||||
|
@ -5,10 +5,11 @@ package com.yutou.jianr_mg.Network;
|
||||
*/
|
||||
|
||||
public class HttpApi {
|
||||
public static final String HOME="http://jianr.jianrmod.cn/";
|
||||
// public static final String HOME = "http://192.168.31.240:8088/"; //zzz_gz wifi
|
||||
// public static final String HOME="http://jianr.jianrmod.cn/";
|
||||
//public static final String HOME = "http://192.168.31.240:8088/"; //zzz_gz wifi
|
||||
// public static final String HOME = "http://192.168.43.68:8088/"; //zzz_gz wifi
|
||||
//public static final String HOME = "http://192.168.137.1:8088/"; //笔记本本身WIFI
|
||||
// public static final String HOME = "http://192.168.1.84:8088/"; //公司
|
||||
public static final String HOME = "http://192.168.1.84:8088/"; //公司
|
||||
public static final String HOME_URL=HOME+"android/"; //服务器
|
||||
|
||||
public static final String MOD_ALL = "mod/all.do";
|
||||
|
@ -1,5 +1,8 @@
|
||||
package com.yutou.jianr_mg.Tools;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.yutou.jianr_mg.Application;
|
||||
import com.yutou.jianr_mg.Data.AppData;
|
||||
@ -177,36 +180,39 @@ public class JianRUtils {
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
private static List<JianNiang> jianNiangs;
|
||||
private static List<ShipEquipmnt> equipmnts;
|
||||
|
||||
public static void reloadJianNiang() {
|
||||
try {
|
||||
if(jianNiangs==null){
|
||||
jianNiangs=new ArrayList<>();
|
||||
JSONArray array=new JSONArray(Utils.readFile(Utils.getAppPath() + "/jdata/shipCardWu.json"));
|
||||
if (jianNiangs == null) {
|
||||
jianNiangs = new ArrayList<>();
|
||||
JSONArray array = new JSONArray(Utils.readFile(Utils.getAppPath() + "/jdata/shipCardWu.json"));
|
||||
for (int i = 0; i < array.length(); i++) {
|
||||
JSONObject json=array.getJSONObject(i);
|
||||
JianNiang jianNiang= JSON.parseObject(json.toString(),JianNiang.class);
|
||||
JSONObject json = array.getJSONObject(i);
|
||||
JianNiang jianNiang = JSON.parseObject(json.toString(), JianNiang.class);
|
||||
jianNiangs.add(jianNiang);
|
||||
}
|
||||
System.out.println("缓存舰娘数:"+jianNiangs.size());
|
||||
System.out.println("缓存舰娘数:" + jianNiangs.size());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
getInit();
|
||||
}
|
||||
}
|
||||
|
||||
public static List<ShipEquipmnt> reloadEquipmnts() {
|
||||
try {
|
||||
if(equipmnts==null){
|
||||
equipmnts=new ArrayList<>();
|
||||
JSONArray array=new JSONArray(Utils.readFile(Utils.getAppPath() + "/jdata/shipEquipmnt.json"));
|
||||
if (equipmnts == null) {
|
||||
equipmnts = new ArrayList<>();
|
||||
JSONArray array = new JSONArray(Utils.readFile(Utils.getAppPath() + "/jdata/shipEquipmnt.json"));
|
||||
for (int i = 0; i < array.length(); i++) {
|
||||
JSONObject json=array.getJSONObject(i);
|
||||
ShipEquipmnt jianNiang= JSON.parseObject(json.toString(),ShipEquipmnt.class);
|
||||
JSONObject json = array.getJSONObject(i);
|
||||
ShipEquipmnt jianNiang = JSON.parseObject(json.toString(), ShipEquipmnt.class);
|
||||
equipmnts.add(jianNiang);
|
||||
}
|
||||
System.out.println("缓存装备数:"+equipmnts.size());
|
||||
System.out.println("缓存装备数:" + equipmnts.size());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -214,22 +220,24 @@ public class JianRUtils {
|
||||
}
|
||||
return equipmnts;
|
||||
}
|
||||
public static ShipEquipmnt getEquipmnt(int cid,int type){
|
||||
try{
|
||||
List<ShipEquipmnt>equipmnts=reloadEquipmnts();
|
||||
|
||||
public static ShipEquipmnt getEquipmnt(int cid, int type) {
|
||||
try {
|
||||
List<ShipEquipmnt> equipmnts = reloadEquipmnts();
|
||||
for (ShipEquipmnt equipmnt : equipmnts) {
|
||||
if(equipmnt.getCid()==cid){
|
||||
if (equipmnt.getCid() == cid) {
|
||||
return equipmnt;
|
||||
}
|
||||
if(equipmnt.getType()==type){
|
||||
if (equipmnt.getType() == type) {
|
||||
return equipmnt;
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void getInit() {
|
||||
File file = new File(Utils.getAppPath() + "/getInitConfigs");
|
||||
try {
|
||||
@ -265,11 +273,32 @@ public class JianRUtils {
|
||||
|
||||
@Override
|
||||
public void over(boolean isOver) {
|
||||
new Thread(()->{
|
||||
new Thread(() -> {
|
||||
JianRUtils.reloadJianNiang();
|
||||
JianRUtils.reloadEquipmnts();
|
||||
}).start();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void readClientVersionIsbigzhao(Context context) {
|
||||
SharedPreferences sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
|
||||
AppData.magicPackageName = sp.getString("magicVersion", "com.bigzhao.jianrmagicbox");
|
||||
}
|
||||
|
||||
public static boolean readClientVersion(Context context) {
|
||||
SharedPreferences sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
|
||||
return sp.getString("magicVersion", "com.bigzhao.jianrmagicbox").equals("com.bigzhao.jianrmagicbox");
|
||||
}
|
||||
public static void changeClientVersion(boolean b,Context context) {
|
||||
SharedPreferences sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
|
||||
if(b){
|
||||
sp.edit().putString("magicVersion","com.huanmeng.zhanjian2").apply();
|
||||
AppData.magicPackageName="com.huanmeng.zhanjian2";
|
||||
}else{
|
||||
sp.edit().putString("magicVersion","com.bigzhao.jianrmagicbox").apply();
|
||||
AppData.magicPackageName="com.bigzhao.jianrmagicbox";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -218,9 +218,9 @@ public class Utils {
|
||||
|
||||
public static boolean writerFile(String srcFile, String data) {
|
||||
File file = new File(srcFile);
|
||||
File path=new File(file.getAbsolutePath().split(file.getName())[0]);
|
||||
File path = new File(file.getAbsolutePath().split(file.getName())[0]);
|
||||
if (!path.exists()) {
|
||||
path.mkdirs();
|
||||
path.mkdirs();
|
||||
}
|
||||
try {
|
||||
PrintWriter writer = new PrintWriter(file);
|
||||
@ -265,8 +265,10 @@ public class Utils {
|
||||
}
|
||||
|
||||
public static boolean getApplicationPackName(Context context, String packName) {
|
||||
|
||||
List<PackageInfo> packages = context.getPackageManager().getInstalledPackages(0);
|
||||
for (PackageInfo info : packages) {
|
||||
System.out.println("被检测的包名:" + packName + " 当前包名:" + info.packageName);
|
||||
if (info.packageName.equals(packName)) {
|
||||
return true;
|
||||
}
|
||||
@ -415,22 +417,22 @@ public class Utils {
|
||||
}
|
||||
|
||||
static void Base64Decode(String base64, File file) {
|
||||
try{
|
||||
byte[] b=Base64.decode(base64,Base64.DEFAULT);
|
||||
if(!file.exists()){
|
||||
try {
|
||||
byte[] b = Base64.decode(base64, Base64.DEFAULT);
|
||||
if (!file.exists()) {
|
||||
file.createNewFile();
|
||||
}
|
||||
FileOutputStream outputStream=new FileOutputStream(file);
|
||||
FileOutputStream outputStream = new FileOutputStream(file);
|
||||
outputStream.write(b);
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getVersion() {
|
||||
String versionName=null;
|
||||
String versionName = null;
|
||||
try {
|
||||
PackageManager pm = Application.application.getPackageManager();
|
||||
PackageInfo pi = pm.getPackageInfo(Application.application.getPackageName(), 0);
|
||||
@ -440,4 +442,27 @@ public class Utils {
|
||||
}
|
||||
return versionName;
|
||||
}
|
||||
|
||||
public static void removePlugins(String s) {
|
||||
File file = new File(Application.application.getFilesDir() + "/plugin/" + s + ".jar");
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
File dex = new File(Application.application.getFilesDir() + "/plugin/oat/");
|
||||
if (dex.exists()) {
|
||||
for (File listFile : dex.listFiles()) {
|
||||
if (listFile.getName().contains(s)) {
|
||||
listFile.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
File arm = new File(Application.application.getFilesDir() + "/plugin/oat/arm/");
|
||||
if (arm.exists()) {
|
||||
for (File listFile : arm.listFiles()) {
|
||||
if (listFile.getName().contains(s)) {
|
||||
listFile.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import com.bigzhao.jianrmagicbox.aidl.IMagicBoxBinder;
|
||||
import com.yutou.jianr_mg.Application;
|
||||
import com.yutou.jianr_mg.Data.AppData;
|
||||
import com.yutou.jianr_mg.Databases.JianRDataDataBase;
|
||||
import com.yutou.jianr_mg.Tools.JianRUtils;
|
||||
import com.yutou.jianr_mg.Tools.Utils;
|
||||
import com.yutou.jianr_mg.views.WarView;
|
||||
|
||||
@ -46,6 +47,7 @@ public class MagicBoxService {
|
||||
}
|
||||
|
||||
public static MagicBoxService init() {
|
||||
JianRUtils.readClientVersionIsbigzhao(Application.application);
|
||||
if (!Utils.getApplicationPackName(Application.application, AppData.magicPackageName)) {
|
||||
System.out.println("没有安装客户端");
|
||||
return null;
|
||||
|
@ -9,8 +9,11 @@ import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.yutou.jianr_mg.Application;
|
||||
import com.yutou.jianr_mg.Data.AppData;
|
||||
import com.yutou.jianr_mg.Network.HttpApi;
|
||||
import com.yutou.jianr_mg.R;
|
||||
import com.yutou.jianr_mg.Tools.JianRUtils;
|
||||
import com.yutou.jianr_mg.Tools.RootUtils;
|
||||
import com.yutou.jianr_mg.Tools.Utils;
|
||||
|
||||
@ -30,41 +33,52 @@ public class ConfigActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
listView = findViewById(R.id.listView);
|
||||
listView = findViewById(R.id.listView);
|
||||
listView.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, config));
|
||||
listView.setOnItemClickListener((parent, view, position, id) -> {
|
||||
Intent intent=null;
|
||||
switch (position){
|
||||
Intent intent = null;
|
||||
switch (position) {
|
||||
case 0:
|
||||
RootUtils.setRootInstallModel(ConfigActivity.this);
|
||||
break;
|
||||
case 1:
|
||||
Utils.initImageLoader(ConfigActivity.this).clearDiskCache();
|
||||
Toast.makeText(ConfigActivity.this,"咕",Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(ConfigActivity.this, "咕", Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
case 2:
|
||||
intent=new Intent(this,WebActivity.class);
|
||||
intent.putExtra("url", HttpApi.HOME_URL+"../html/join.jsp");
|
||||
intent = new Intent(this, WebActivity.class);
|
||||
intent.putExtra("url", HttpApi.HOME_URL + "../html/join.jsp");
|
||||
break;
|
||||
case 3:
|
||||
intent=new Intent(this,WebActivity.class);
|
||||
intent.putExtra("url", HttpApi.HOME_URL+"../html/about.jsp");
|
||||
intent = new Intent(this, WebActivity.class);
|
||||
intent.putExtra("url", HttpApi.HOME_URL + "../html/about.jsp");
|
||||
break;
|
||||
case 4:
|
||||
intent=new Intent(this,LicenseActivity.class);
|
||||
intent = new Intent(this, LicenseActivity.class);
|
||||
break;
|
||||
case 5:
|
||||
if (JianRUtils.readClientVersion(Application.application)) {
|
||||
JianRUtils.changeClientVersion(true,Application.application);
|
||||
Utils.toast(Application.application,"已切换至覆盖版兼容模式");
|
||||
}else {
|
||||
JianRUtils.changeClientVersion(false,Application.application);
|
||||
Utils.toast(Application.application,"已切换至共存版兼容模式");
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(intent!=null){
|
||||
if (intent != null) {
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
private void initCofig(){
|
||||
config=new ArrayList<>();
|
||||
|
||||
private void initCofig() {
|
||||
config = new ArrayList<>();
|
||||
config.add("设置ROOT安装模式");
|
||||
config.add("清空图片缓存");
|
||||
config.add("加群");
|
||||
config.add("关于我们");
|
||||
config.add("开源项目协议");
|
||||
config.add("切换专用客户端版本");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user