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

新增:长按插件可卸载插件
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,36 +180,39 @@ 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) {
jianNiangs=new ArrayList<>(); jianNiangs = new ArrayList<>();
JSONArray array=new JSONArray(Utils.readFile(Utils.getAppPath() + "/jdata/shipCardWu.json")); JSONArray array = new JSONArray(Utils.readFile(Utils.getAppPath() + "/jdata/shipCardWu.json"));
for (int i = 0; i < array.length(); i++) { for (int i = 0; i < array.length(); i++) {
JSONObject json=array.getJSONObject(i); JSONObject json = array.getJSONObject(i);
JianNiang jianNiang= JSON.parseObject(json.toString(),JianNiang.class); JianNiang jianNiang = JSON.parseObject(json.toString(), JianNiang.class);
jianNiangs.add(jianNiang); jianNiangs.add(jianNiang);
} }
System.out.println("缓存舰娘数:"+jianNiangs.size()); System.out.println("缓存舰娘数:" + jianNiangs.size());
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
getInit(); getInit();
} }
} }
public static List<ShipEquipmnt> reloadEquipmnts() { public static List<ShipEquipmnt> reloadEquipmnts() {
try { try {
if(equipmnts==null){ if (equipmnts == null) {
equipmnts=new ArrayList<>(); equipmnts = new ArrayList<>();
JSONArray array=new JSONArray(Utils.readFile(Utils.getAppPath() + "/jdata/shipEquipmnt.json")); JSONArray array = new JSONArray(Utils.readFile(Utils.getAppPath() + "/jdata/shipEquipmnt.json"));
for (int i = 0; i < array.length(); i++) { for (int i = 0; i < array.length(); i++) {
JSONObject json=array.getJSONObject(i); JSONObject json = array.getJSONObject(i);
ShipEquipmnt jianNiang= JSON.parseObject(json.toString(),ShipEquipmnt.class); ShipEquipmnt jianNiang = JSON.parseObject(json.toString(), ShipEquipmnt.class);
equipmnts.add(jianNiang); equipmnts.add(jianNiang);
} }
System.out.println("缓存装备数:"+equipmnts.size()); System.out.println("缓存装备数:" + equipmnts.size());
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -214,22 +220,24 @@ public class JianRUtils {
} }
return equipmnts; return equipmnts;
} }
public static ShipEquipmnt getEquipmnt(int cid,int type){
try{ public static ShipEquipmnt getEquipmnt(int cid, int type) {
List<ShipEquipmnt>equipmnts=reloadEquipmnts(); try {
List<ShipEquipmnt> equipmnts = reloadEquipmnts();
for (ShipEquipmnt equipmnt : equipmnts) { for (ShipEquipmnt equipmnt : equipmnts) {
if(equipmnt.getCid()==cid){ if (equipmnt.getCid() == cid) {
return equipmnt; return equipmnt;
} }
if(equipmnt.getType()==type){ if (equipmnt.getType() == type) {
return equipmnt; return equipmnt;
} }
} }
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
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 {
@ -265,11 +273,32 @@ public class JianRUtils {
@Override @Override
public void over(boolean isOver) { public void over(boolean isOver) {
new Thread(()->{ new Thread(() -> {
JianRUtils.reloadJianNiang(); JianRUtils.reloadJianNiang();
JianRUtils.reloadEquipmnts(); JianRUtils.reloadEquipmnts();
}).start(); }).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";
}
}
} }

View File

@ -218,9 +218,9 @@ public class Utils {
public static boolean writerFile(String srcFile, String data) { public static boolean writerFile(String srcFile, String data) {
File file = new File(srcFile); 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()) { if (!path.exists()) {
path.mkdirs(); path.mkdirs();
} }
try { try {
PrintWriter writer = new PrintWriter(file); PrintWriter writer = new PrintWriter(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;
} }
@ -415,22 +417,22 @@ public class Utils {
} }
static void Base64Decode(String base64, File file) { static void Base64Decode(String base64, File file) {
try{ try {
byte[] b=Base64.decode(base64,Base64.DEFAULT); byte[] b = Base64.decode(base64, Base64.DEFAULT);
if(!file.exists()){ if (!file.exists()) {
file.createNewFile(); file.createNewFile();
} }
FileOutputStream outputStream=new FileOutputStream(file); FileOutputStream outputStream = new FileOutputStream(file);
outputStream.write(b); outputStream.write(b);
outputStream.flush(); outputStream.flush();
outputStream.close(); outputStream.close();
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
public static String getVersion() { public static String getVersion() {
String versionName=null; String versionName = null;
try { try {
PackageManager pm = Application.application.getPackageManager(); PackageManager pm = Application.application.getPackageManager();
PackageInfo pi = pm.getPackageInfo(Application.application.getPackageName(), 0); PackageInfo pi = pm.getPackageInfo(Application.application.getPackageName(), 0);
@ -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;
@ -30,41 +33,52 @@ public class ConfigActivity extends AppCompatActivity {
} }
private void initView() { 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.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, config));
listView.setOnItemClickListener((parent, view, position, id) -> { listView.setOnItemClickListener((parent, view, position, id) -> {
Intent intent=null; Intent intent = null;
switch (position){ switch (position) {
case 0: case 0:
RootUtils.setRootInstallModel(ConfigActivity.this); RootUtils.setRootInstallModel(ConfigActivity.this);
break; break;
case 1: case 1:
Utils.initImageLoader(ConfigActivity.this).clearDiskCache(); Utils.initImageLoader(ConfigActivity.this).clearDiskCache();
Toast.makeText(ConfigActivity.this,"",Toast.LENGTH_LONG).show(); Toast.makeText(ConfigActivity.this, "", Toast.LENGTH_LONG).show();
break; break;
case 2: case 2:
intent=new Intent(this,WebActivity.class); intent = new Intent(this, WebActivity.class);
intent.putExtra("url", HttpApi.HOME_URL+"../html/join.jsp"); intent.putExtra("url", HttpApi.HOME_URL + "../html/join.jsp");
break; break;
case 3: case 3:
intent=new Intent(this,WebActivity.class); intent = new Intent(this, WebActivity.class);
intent.putExtra("url", HttpApi.HOME_URL+"../html/about.jsp"); intent.putExtra("url", HttpApi.HOME_URL + "../html/about.jsp");
break; break;
case 4: 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; break;
} }
if(intent!=null){ if (intent != null) {
startActivity(intent); startActivity(intent);
} }
}); });
} }
private void initCofig(){
config=new ArrayList<>(); private void initCofig() {
config = new ArrayList<>();
config.add("设置ROOT安装模式"); config.add("设置ROOT安装模式");
config.add("清空图片缓存"); config.add("清空图片缓存");
config.add("加群"); config.add("加群");
config.add("关于我们"); config.add("关于我们");
config.add("开源项目协议"); config.add("开源项目协议");
config.add("切换专用客户端版本");
} }
} }