上线专用客户端修复工具

This commit is contained in:
Yutousama 2019-06-10 17:41:37 +08:00
parent 825b3d820f
commit d18de231d0

View File

@ -10,6 +10,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.Switch;
import android.widget.TextView;
@ -30,6 +31,7 @@ public class MainActivity implements BaseActivityInterface {
private Context context;
private KProgressHUD hud;
public MainActivity() {
}
@ -37,14 +39,13 @@ public class MainActivity implements BaseActivityInterface {
@Override
public void onCreate(Bundle savedInstanceState, LinearLayout layout, final Context context, Intent intent) {
layout.setOrientation(LinearLayout.VERTICAL);
this.context=context;
Utils.handler=new Handler(Looper.getMainLooper());
hud=Utils.showLoading(context,null,"解压中...");
this.context = context;
Utils.handler = new Handler(Looper.getMainLooper());
hud = Utils.showLoading(context, null, "解压中...");
layout.addView(getView());
}
@Override
public void onRestart() {
@ -90,19 +91,29 @@ public class MainActivity implements BaseActivityInterface {
return null;
}
private ViewGroup getView(){
LinearLayout linearLayout=new LinearLayout(context);
private ViewGroup getView() {
LinearLayout linearLayout = new LinearLayout(context);
linearLayout.setOrientation(LinearLayout.VERTICAL);
TextView text1=new TextView(context);
Button button=new Button(context);
Button button2=new Button(context);
final Switch siwtch=new Switch(context);
siwtch.setTextOn("覆盖版");
siwtch.setTextOff("共存版");
text1.setText("请将proj.manifest、Cocos2dxPrefsFile.xml和压缩包放到jianRMG/harmony/文件夹中\n压缩包请重命名为data.zip");
TextView text1 = new TextView(context);
Button button = new Button(context);
Button button2 = new Button(context);
final Switch siwtch = new Switch(context);
siwtch.setText("共存版");
text1.setText("请将proj.manifest、Cocos2dxPrefsFile.xml和压缩包放到jianRMG/harmony/文件夹中");
button.setText("创建harmony文件夹");
button2.setText("开始");
siwtch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked){
siwtch.setText("覆盖版");
}else{
siwtch.setText("共存版");
}
}
});
linearLayout.addView(text1);
linearLayout.addView(button);
linearLayout.addView(button2);
@ -111,10 +122,10 @@ public class MainActivity implements BaseActivityInterface {
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
File file=new File(Utils.getAppPath()+"/harmony/");
if(file.exists()){
Utils.toast(context,"文件夹已存在");
}else {
File file = new File(Utils.getAppPath() + "/harmony/");
if (file.exists()) {
Utils.toast(context, "文件夹已存在");
} else {
file.mkdirs();
}
}
@ -123,46 +134,35 @@ public class MainActivity implements BaseActivityInterface {
@Override
public void onClick(View v) {
hud.show();
new Thread(new Runnable() {
@Override
public void run() {
File file=new File(Utils.getAppPath()+"/harmony/");
if(file.listFiles().length==0){
Utils.toast(context,"文件夹内为空请放入harmony文件夹中");
final File file = new File(Utils.getAppPath() + "/harmony/");
if (file.listFiles().length == 0) {
Utils.toast(context, "文件夹内为空请放入harmony文件夹中");
return;
}
File xml = new File(file.getAbsolutePath() + "/Cocos2dxPrefsFile.xml");
System.out.println(xml.getAbsoluteFile());
if (xml.exists()) {
ClientUttls.install(context, xml, "../shared_prefs/", new ModInterface() {
@Override
public void onAction(boolean flag, int type) {
System.out.println("处理xml" + flag);
if (flag) {
for (File listFile : file.listFiles()) {
System.out.println("处理文件:"+listFile.getAbsolutePath());
switch (listFile.getName()){
case "proj.manifest":
ClientUttls.install(context, listFile, "/files/", new ModInterface() {
@Override
public void onAction(boolean flag, int type) {
System.out.println("操作manifest文件"+flag);
}
});
break;
case "Cocos2dxPrefsFile.xml":
ClientUttls.install(context, listFile, "../shared_prefs/", new ModInterface() {
@Override
public void onAction(boolean flag, int type) {
System.out.println("处理xml"+flag);
}
});
break;
case "data.zip":
System.out.println("处理文件:" + listFile.getAbsolutePath());
if (listFile.getName().contains(".zip")) {
File path;
if(siwtch.isChecked()){
path=new File(Utils.getSDCardPath()+"/Android/data/com.huanmeng.zhanjian2/files/res_default/10/");
}else {
path=new File(Utils.getSDCardPath()+"/Android/data/com.bigzhao.jianrmagicbox/files/res_default/10/");
if (siwtch.isChecked()) {
path = new File(Utils.getSDCardPath() + "/Android/data/com.huanmeng.zhanjian2/files/res_default/10/");
System.out.println("操作对象:覆盖版");
} else {
path = new File(Utils.getSDCardPath() + "/Android/data/com.bigzhao.jianrmagicbox/files/res_default/10/");
System.out.println("操作对象:共存版");
}
if(!path.exists()){
if (!path.exists()) {
path.mkdirs();
}
System.out.println("准备处理zip");
ZipUtils.unzip(listFile,path.getAbsolutePath(),hud);
ZipUtils.unzip(listFile, path.getAbsolutePath(), hud);
break;
}
}
@ -172,9 +172,17 @@ public class MainActivity implements BaseActivityInterface {
hud.dismiss();
}
});
Utils.toast(context,"操作完成");
Utils.toast(context, "操作完成");
}else{
Utils.toast(context, "Cocos2dxPrefsFile.xml处理失败");
hud.dismiss();
}
}
});
} else {
Utils.toast(context, "Cocos2dxPrefsFile.xml文件不存在!");
hud.dismiss();
}
}).start();
}
});