升级修复客户端插件,可支持覆盖版

This commit is contained in:
Yutousama 2019-06-13 09:27:31 +08:00
parent f1bfc4e071
commit 0bc3283def
3 changed files with 37 additions and 2 deletions

View File

@ -101,18 +101,34 @@ public class MainActivity implements BaseActivityInterface {
Button button3=new Button(context);
final Switch siwtch = new Switch(context);
siwtch.setText("共存版");
text1.setText("请将proj.manifest、Cocos2dxPrefsFile.xml和压缩包放到jianRMG/harmony/文件夹中");
text1.setText("更新说明:" +
"\n1、已支持覆盖版" +
"\n2、已安装压缩包时下次点击不再解压(如需覆盖解压请删除后缀.unzip)" +
"\n使用说明请将proj.manifest、Cocos2dxPrefsFile.xml和压缩包放到jianRMG/harmony/文件夹中" +
"\n注意切换客户端版本会影响悬浮窗监听的客户端版本" +
"\n注意2切换客户端版本如果提示“XXXX处理失败请重启盒子再尝试");
button.setText("创建harmony文件夹");
button2.setText("开始");
button3.setText("不会用?点这里");
if(Utils.readClientVersionIsbigzhao(context)){
siwtch.setChecked(false);
siwtch.setText("共存版");
}else{
siwtch.setChecked(true);
siwtch.setText("覆盖版");
}
siwtch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked){
siwtch.setText("覆盖版");
Utils.changeClientVersion(true,context);
Utils.toast(context,"已将盒子切换成覆盖版支持");
}else{
siwtch.setText("共存版");
Utils.changeClientVersion(false,context);
Utils.toast(context,"已将盒子切换成共存版支持");
}
}
});
@ -159,7 +175,7 @@ public class MainActivity implements BaseActivityInterface {
if (flag) {
for (File listFile : file.listFiles()) {
System.out.println("处理文件:" + listFile.getAbsolutePath());
if (listFile.getName().contains(".zip")) {
if (listFile.getName().endsWith(".zip")) {
File path;
if (siwtch.isChecked()) {
path = new File(Utils.getSDCardPath() + "/Android/data/com.huanmeng.zhanjian2/files/res_default/10/");

View File

@ -2,6 +2,7 @@ package com.jianrmod.plugins.harmony.Tools;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.os.Environment;
import android.os.Handler;
@ -313,4 +314,21 @@ public class Utils {
e.printStackTrace();
}
}
public static boolean readClientVersionIsbigzhao(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) {
try {
if(b){
context.getClassLoader().loadClass("com.yutou.jianr_mg.Data.AppData").getField("magicPackageName").set(null,"com.huanmeng.zhanjian2");
}else{
context.getClassLoader().loadClass("com.yutou.jianr_mg.Data.AppData").getField("magicPackageName").set(null,"ccom.bigzhao.jianrmagicbox");
}
}catch (Exception e){
e.printStackTrace();
}
}
}

View File

@ -56,6 +56,7 @@ public class ZipUtils {
} catch (Exception e) {
e.printStackTrace();
}
zipFile.renameTo(new File(zipFile.getAbsolutePath().replace(zipFile.getName(),"")+"/"+zipFile.getName()+".unzip"));
Utils.handler.post(new Runnable() {
@Override
public void run() {