上线专用客户端修复工具

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