新增:设置-切换专用客户端版本

新增:长按插件可卸载插件
This commit is contained in:
Yutousama 2019-06-13 10:34:38 +08:00
parent 0bc3283def
commit d20e3b04ae
9 changed files with 154 additions and 43 deletions

View File

@ -28,6 +28,13 @@ public class BaseViewHolder<T> extends RecyclerView.ViewHolder{
onItemViewClick(mData); onItemViewClick(mData);
} }
}); });
itemView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
onItemViewLongClick(mData);
return true;
}
});
} }
public void onInitializeView() { public void onInitializeView() {
@ -55,5 +62,8 @@ public class BaseViewHolder<T> extends RecyclerView.ViewHolder{
public void onItemViewClick(T data) { public void onItemViewClick(T data) {
}
public void onItemViewLongClick(T data){
} }
} }

View File

@ -12,6 +12,7 @@ import android.widget.TextView;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.kaopiz.kprogresshud.KProgressHUD; import com.kaopiz.kprogresshud.KProgressHUD;
import com.nostra13.universalimageloader.core.ImageLoader; 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.Interfaces.ModInterface;
import com.yutou.jianr_mg.R; import com.yutou.jianr_mg.R;
import com.yutou.jianr_mg.Tools.ModUtils; import com.yutou.jianr_mg.Tools.ModUtils;
@ -104,7 +105,7 @@ public class WarAdapter extends RecyclerAdapter<List<Map<String, JSONObject>>> {
@Override @Override
public void onItemViewClick(List<Map<String, JSONObject>> data) { public void onItemViewClick(List<Map<String, JSONObject>> data) {
super.onItemViewClick(data); super.onItemViewClick(data);
Utils.toast(getContext(),"详细内容正在咕,敬请期待"); Utils.toast(getContext(),"详细内容正在咕,敬请期待:"+ AppData.magicPackageName);
/* JSONArray array=new JSONArray(); /* JSONArray array=new JSONArray();
for (Map<String, JSONObject> datum : data) { for (Map<String, JSONObject> datum : data) {
try { try {

View File

@ -11,11 +11,13 @@ import com.yutou.jianr_mg.Application;
import com.yutou.jianr_mg.Data.AppData; import com.yutou.jianr_mg.Data.AppData;
import com.yutou.jianr_mg.Data.MAppTools; import com.yutou.jianr_mg.Data.MAppTools;
import com.yutou.jianr_mg.R; 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.Tools.Utils;
import com.yutou.jianr_mg.views.BaseActivity; import com.yutou.jianr_mg.views.BaseActivity;
import cn.lemon.view.adapter.BaseViewHolder; import cn.lemon.view.adapter.BaseViewHolder;
import cn.lemon.view.adapter.RecyclerAdapter; import cn.lemon.view.adapter.RecyclerAdapter;
import me.drakeet.materialdialog.MaterialDialog;
public class MainUtilsAdapter extends RecyclerAdapter<MAppTools> { public class MainUtilsAdapter extends RecyclerAdapter<MAppTools> {
private ImageLoader imageLoader; private ImageLoader imageLoader;
@ -94,5 +96,31 @@ public class MainUtilsAdapter extends RecyclerAdapter<MAppTools> {
Utils.toast(getContext(), "启动失败,请升级至最新版本或联系管理员"); 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();
}
}
}
} }
} }

View File

@ -41,6 +41,7 @@ public class MainActivity extends AppCompatActivity {
ActivitysManager.finishActivity(LoadingActivity.class); ActivitysManager.finishActivity(LoadingActivity.class);
initViews(); initViews();
JianRUtils.downlaodInit(true); JianRUtils.downlaodInit(true);
JianRUtils.readClientVersionIsbigzhao(this);
new Thread(()->{ new Thread(()->{
JianRUtils.reloadJianNiang(); JianRUtils.reloadJianNiang();
JianRUtils.reloadEquipmnts(); JianRUtils.reloadEquipmnts();

View File

@ -5,10 +5,11 @@ package com.yutou.jianr_mg.Network;
*/ */
public class HttpApi { public class HttpApi {
public static final String HOME="http://jianr.jianrmod.cn/"; // 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.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.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 HOME_URL=HOME+"android/"; //服务器
public static final String MOD_ALL = "mod/all.do"; public static final String MOD_ALL = "mod/all.do";

View File

@ -1,5 +1,8 @@
package com.yutou.jianr_mg.Tools; package com.yutou.jianr_mg.Tools;
import android.content.Context;
import android.content.SharedPreferences;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.yutou.jianr_mg.Application; import com.yutou.jianr_mg.Application;
import com.yutou.jianr_mg.Data.AppData; import com.yutou.jianr_mg.Data.AppData;
@ -177,8 +180,10 @@ public class JianRUtils {
} }
return data; return data;
} }
private static List<JianNiang> jianNiangs; private static List<JianNiang> jianNiangs;
private static List<ShipEquipmnt> equipmnts; private static List<ShipEquipmnt> equipmnts;
public static void reloadJianNiang() { public static void reloadJianNiang() {
try { try {
if (jianNiangs == null) { if (jianNiangs == null) {
@ -196,6 +201,7 @@ public class JianRUtils {
getInit(); getInit();
} }
} }
public static List<ShipEquipmnt> reloadEquipmnts() { public static List<ShipEquipmnt> reloadEquipmnts() {
try { try {
if (equipmnts == null) { if (equipmnts == null) {
@ -214,6 +220,7 @@ public class JianRUtils {
} }
return equipmnts; return equipmnts;
} }
public static ShipEquipmnt getEquipmnt(int cid, int type) { public static ShipEquipmnt getEquipmnt(int cid, int type) {
try { try {
List<ShipEquipmnt> equipmnts = reloadEquipmnts(); List<ShipEquipmnt> equipmnts = reloadEquipmnts();
@ -230,6 +237,7 @@ public class JianRUtils {
} }
return null; return null;
} }
public static void getInit() { public static void getInit() {
File file = new File(Utils.getAppPath() + "/getInitConfigs"); File file = new File(Utils.getAppPath() + "/getInitConfigs");
try { try {
@ -272,4 +280,25 @@ public class JianRUtils {
} }
}); });
} }
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";
}
}
} }

View File

@ -265,8 +265,10 @@ public class Utils {
} }
public static boolean getApplicationPackName(Context context, String packName) { public static boolean getApplicationPackName(Context context, String packName) {
List<PackageInfo> packages = context.getPackageManager().getInstalledPackages(0); List<PackageInfo> packages = context.getPackageManager().getInstalledPackages(0);
for (PackageInfo info : packages) { for (PackageInfo info : packages) {
System.out.println("被检测的包名:" + packName + " 当前包名:" + info.packageName);
if (info.packageName.equals(packName)) { if (info.packageName.equals(packName)) {
return true; return true;
} }
@ -440,4 +442,27 @@ public class Utils {
} }
return versionName; 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();
}
}
}
}
} }

View File

@ -10,6 +10,7 @@ import com.bigzhao.jianrmagicbox.aidl.IMagicBoxBinder;
import com.yutou.jianr_mg.Application; import com.yutou.jianr_mg.Application;
import com.yutou.jianr_mg.Data.AppData; import com.yutou.jianr_mg.Data.AppData;
import com.yutou.jianr_mg.Databases.JianRDataDataBase; 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.Tools.Utils;
import com.yutou.jianr_mg.views.WarView; import com.yutou.jianr_mg.views.WarView;
@ -46,6 +47,7 @@ public class MagicBoxService {
} }
public static MagicBoxService init() { public static MagicBoxService init() {
JianRUtils.readClientVersionIsbigzhao(Application.application);
if (!Utils.getApplicationPackName(Application.application, AppData.magicPackageName)) { if (!Utils.getApplicationPackName(Application.application, AppData.magicPackageName)) {
System.out.println("没有安装客户端"); System.out.println("没有安装客户端");
return null; return null;

View File

@ -9,8 +9,11 @@ import android.widget.ArrayAdapter;
import android.widget.ListView; import android.widget.ListView;
import android.widget.Toast; 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.Network.HttpApi;
import com.yutou.jianr_mg.R; 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.RootUtils;
import com.yutou.jianr_mg.Tools.Utils; import com.yutou.jianr_mg.Tools.Utils;
@ -53,12 +56,22 @@ public class ConfigActivity extends AppCompatActivity {
case 4: case 4:
intent = new Intent(this, LicenseActivity.class); intent = new Intent(this, LicenseActivity.class);
break; 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); startActivity(intent);
} }
}); });
} }
private void initCofig() { private void initCofig() {
config = new ArrayList<>(); config = new ArrayList<>();
config.add("设置ROOT安装模式"); config.add("设置ROOT安装模式");
@ -66,5 +79,6 @@ public class ConfigActivity extends AppCompatActivity {
config.add("加群"); config.add("加群");
config.add("关于我们"); config.add("关于我们");
config.add("开源项目协议"); config.add("开源项目协议");
config.add("切换专用客户端版本");
} }
} }