From 8e5775b45b35fa53d0cd6e039d128f164d960fe0 Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Wed, 1 Apr 2020 18:00:52 +0800 Subject: [PATCH] =?UTF-8?q?2.4=20=E5=8F=91=E7=89=88=E5=89=8D=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=20=E6=96=B0=E5=A2=9E=E6=82=AC=E6=B5=AE=E7=AA=97?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/caches/build_file_checksums.ser | Bin 647 -> 647 bytes app/build.gradle | 2 +- .../Adapters/MagicTeamDataAdapter.java | 13 +- .../jianr_mg/Adapters/MainUtilsAdapter.java | 5 +- .../java/com/yutou/jianr_mg/Application.java | 14 +- .../yutou/jianr_mg/Databases/ModDatabase.java | 3 +- .../GameDataFragments/WarFragment.java | 3 +- .../WarLogFragments/DaytimeFragment.java | 7 +- .../jianr_mg/Fragments/UtilsFragments.java | 3 +- .../com/yutou/jianr_mg/LoadingActivity.java | 4 +- .../com/yutou/jianr_mg/Network/HttpApi.java | 2 +- .../com/yutou/jianr_mg/Network/HttpUtils.java | 2 +- .../com/yutou/jianr_mg/Tools/ExcelUtils.java | 2 +- .../com/yutou/jianr_mg/Tools/JianRUtils.java | 12 +- .../java/com/yutou/jianr_mg/Tools/Log.java | 4 +- .../com/yutou/jianr_mg/Tools/ModUtils.java | 4 +- .../com/yutou/jianr_mg/Tools/RootUtils.java | 4 +- .../com/yutou/jianr_mg/Tools/SocketTools.java | 10 +- .../com/yutou/jianr_mg/Tools/ZipUtils.java | 2 +- .../jianr_mg/services/MagicBoxService.java | 19 +-- .../jianr_mg/services/WindowsService.java | 146 ++++++++++-------- .../yutou/jianr_mg/views/BaseActivity.java | 4 +- .../jianr_mg/views/DownloadListActivity.java | 3 +- .../yutou/jianr_mg/views/ExcelActivity.java | 5 +- .../jianr_mg/views/FavoritesActivity.java | 4 +- .../jianr_mg/views/GameDataActivity.java | 5 +- .../com/yutou/jianr_mg/views/HomeHeader.java | 6 +- .../yutou/jianr_mg/views/MapTopActivity.java | 3 +- .../com/yutou/jianr_mg/views/WarView.java | 15 +- .../jianr_mg/views/WindowsStartActivity.java | 145 +++++++++++++++-- .../res/layout/activity_windows_start.xml | 10 ++ .../harmony/Activitys/MainActivity.java | 15 +- .../com/jianrmod/plugins/harmony/Log.java | 61 ++++++++ .../plugins/harmony/Tools/ZipUtils.java | 3 +- .../Activitys/Utils/PluginHttpTools.java | 10 +- .../plugins/Activitys/Utils/PlugsAdTools.java | 2 +- 36 files changed, 384 insertions(+), 168 deletions(-) create mode 100644 harmony/src/main/java/com/jianrmod/plugins/harmony/Log.java diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 2b71aaac2c7bd227b23764ce83f5299edc1d91e7..d92805a73bfdd05ec7cc1dd031be8ab8d60bddd3 100644 GIT binary patch delta 36 ucmV+<0NekE1&0NYm;^NULSm7ecMuozc9MMG*;u%cdH9)apJ}rr0b~Iv{}5>a delta 36 scmZo?ZD*Y@gGFmszUIU^ (Float.valueOf(data.getHpMax()) / 2)) { ClipDrawable d = new ClipDrawable(new ColorDrawable(Color.DKGRAY), Gravity.START, ClipDrawable.HORIZONTAL); item.hpBar.setProgressDrawable(d); - System.out.println(data.getTitle()+"设置颜色:绿色"+data.getHp()+"/"+data.getHpMax()); + Log.i(data.getTitle()+"设置颜色:绿色"+data.getHp()+"/"+data.getHpMax()); } else if (Float.valueOf(data.getHp()) < (Float.valueOf(data.getHpMax()) / 2)&&Float.valueOf(data.getHp()) >= (Float.valueOf(data.getHpMax()) / 2/ 2)) { ClipDrawable d = new ClipDrawable(new ColorDrawable(Color.YELLOW), Gravity.START, ClipDrawable.HORIZONTAL); item.hpBar.setProgressDrawable(d); - System.out.println(data.getTitle()+"设置颜色:黄色"+data.getHp()+"/"+data.getHpMax()); + Log.i(data.getTitle()+"设置颜色:黄色"+data.getHp()+"/"+data.getHpMax()); } else if (Float.valueOf(data.getHp()) < (Float.valueOf(data.getHpMax()) / 2/ 2) ) { ClipDrawable d = new ClipDrawable(new ColorDrawable(Color.RED), Gravity.START, ClipDrawable.HORIZONTAL); item.hpBar.setProgressDrawable(d); - System.out.println(data.getTitle()+"设置颜色:红色"+data.getHp()+"/"+data.getHpMax()); + Log.i(data.getTitle()+"设置颜色:红色"+data.getHp()+"/"+data.getHpMax()); }else{ - System.out.println("没有设置颜色"); + Log.i("没有设置颜色"); } if(data.getTitle().equals("凰")){ item.hpBar.setMax(100); item.hpBar.setProgress(86); - System.out.println("赤城的参数"+getHp(data.getHp(),data.getHpMax())+" "+(Float.valueOf(data.getHp()) > (Float.valueOf(data.getHpMax()) / 2))); + Log.i("赤城的参数"+getHp(data.getHp(),data.getHpMax())+" "+(Float.valueOf(data.getHp()) > (Float.valueOf(data.getHpMax()) / 2))); }else item.hpBar.setProgress((int) getHp(data.getHp(),data.getHpMax())); @@ -280,7 +281,7 @@ public class MagicTeamDataAdapter extends BaseAdapter { msg.append(equipmnt.getDesc()); i=msg.toString().split("\n").length; textView.setText(msg.toString()); - // System.out.println(equipmnt.toString()); + // Log.i(equipmnt.toString()); }else{ textView.setText("Not Equipmnt Info"); } diff --git a/app/src/main/java/com/yutou/jianr_mg/Adapters/MainUtilsAdapter.java b/app/src/main/java/com/yutou/jianr_mg/Adapters/MainUtilsAdapter.java index 56daea4..81f3670 100644 --- a/app/src/main/java/com/yutou/jianr_mg/Adapters/MainUtilsAdapter.java +++ b/app/src/main/java/com/yutou/jianr_mg/Adapters/MainUtilsAdapter.java @@ -12,6 +12,7 @@ import com.yutou.jianr_mg.Data.AppData; import com.yutou.jianr_mg.Data.MAppTools; import com.yutou.jianr_mg.R; import com.yutou.jianr_mg.Tools.JianRUtils; +import com.yutou.jianr_mg.Tools.Log; import com.yutou.jianr_mg.Tools.Utils; import com.yutou.jianr_mg.views.BaseActivity; @@ -78,13 +79,13 @@ public class MainUtilsAdapter extends RecyclerAdapter { getContext().startService(intent); break; case "localActivity": - System.out.println("数据:" + data.toString()); + Log.i("数据:" + data.toString()); intent = new Intent(getContext(), BaseActivity.class); intent.putExtra("activityName", main); intent.putExtra("jar", data.getUrl().split("/")[data.getUrl().split("/").length - 1]); intent.putExtra("name", data.getName()); intent.putExtra("url", data.getUrl()); - System.out.println("插件数据:" + data.getUrl().split("/")[data.getUrl().split("/").length - 1]); + Log.i("插件数据:" + data.getUrl().split("/")[data.getUrl().split("/").length - 1]); if (data.getParameter() != null) { intent.putExtra("parameter", data.getParameter()); } diff --git a/app/src/main/java/com/yutou/jianr_mg/Application.java b/app/src/main/java/com/yutou/jianr_mg/Application.java index 9edb2ca..524e43b 100644 --- a/app/src/main/java/com/yutou/jianr_mg/Application.java +++ b/app/src/main/java/com/yutou/jianr_mg/Application.java @@ -51,7 +51,7 @@ public class Application extends android.app.Application { super.onCreate(); Application.application = this; // BlockCanary.install(this, new AppBlockCanaryContext()).start(); - System.out.println("开始初始化"); + Log.i("开始初始化"); init(); initPlugs(); @@ -61,7 +61,7 @@ public class Application extends android.app.Application { initTx(); - System.out.println("初始化结束"); + Log.i("初始化结束"); } private void initUmeng() { @@ -72,12 +72,12 @@ public class Application extends android.app.Application { pushAgent.register(new IUmengRegisterCallback() { @Override public void onSuccess(String s) { - System.out.println("友盟推送注册成功:" + s); + Log.i("友盟推送注册成功:" + s); } @Override public void onFailure(String s, String s1) { - System.out.println("友盟推送注册失败:" + s + "(" + s1 + ")"); + Log.i("友盟推送注册失败:" + s + "(" + s1 + ")"); } }); pushAgent.setMessageHandler(new UmengMessageHandler() { @@ -102,7 +102,7 @@ public class Application extends android.app.Application { QbSdk.initX5Environment(this, new QbSdk.PreInitCallback() { @Override public void onCoreInitFinished() { - System.out.println("QDSDK初始化失败"); + Log.i("QDSDK初始化失败"); } @Override @@ -131,7 +131,7 @@ public class Application extends android.app.Application { if (file.getName().contains(".jar")) { DexClassLoader dexClassLoader = new DexClassLoader(file.getAbsolutePath(), dex.getAbsolutePath(), null, getClassLoader()); plugsin.put(file.getName(), dexClassLoader); - System.out.println("加载插件:"+file.getName()); + Log.i("加载插件:"+file.getName()); // AppData.plugsin.put(file.getName(), dexClassLoader); } } @@ -148,7 +148,7 @@ public class Application extends android.app.Application { } String appid = (String) plugsin.get(file.getName()).loadClass("com.yutou.jianr_mg.plugins.Data").getField("appId").get(null); String md5 = Utils.getFileMD5(file); - System.out.println("MD5:" + md5); + Log.i("MD5:" + md5); JSONObject plugs = new JSONObject(); plugs.put("appid", appid); plugs.put("md5", md5); diff --git a/app/src/main/java/com/yutou/jianr_mg/Databases/ModDatabase.java b/app/src/main/java/com/yutou/jianr_mg/Databases/ModDatabase.java index 293499f..da29d0c 100644 --- a/app/src/main/java/com/yutou/jianr_mg/Databases/ModDatabase.java +++ b/app/src/main/java/com/yutou/jianr_mg/Databases/ModDatabase.java @@ -8,6 +8,7 @@ import android.database.sqlite.SQLiteOpenHelper; import com.yutou.jianr_mg.Application; import com.yutou.jianr_mg.Data.MGamePackname; import com.yutou.jianr_mg.Data.TMod; +import com.yutou.jianr_mg.Tools.Log; import java.util.ArrayList; import java.util.List; @@ -146,7 +147,7 @@ public class ModDatabase extends SQLiteOpenHelper { } cursor.close(); } - System.out.println(list.size()); + Log.i(list.size()+""); return list; } public int getModVersion(TMod mod){ diff --git a/app/src/main/java/com/yutou/jianr_mg/Fragments/GameDataFragments/WarFragment.java b/app/src/main/java/com/yutou/jianr_mg/Fragments/GameDataFragments/WarFragment.java index 79d9705..22e806f 100644 --- a/app/src/main/java/com/yutou/jianr_mg/Fragments/GameDataFragments/WarFragment.java +++ b/app/src/main/java/com/yutou/jianr_mg/Fragments/GameDataFragments/WarFragment.java @@ -16,6 +16,7 @@ import com.yutou.jianr_mg.Adapters.GameDataAdapters.WarAdapter; import com.yutou.jianr_mg.Data.AppData; import com.yutou.jianr_mg.Databases.JianRDataDataBase; import com.yutou.jianr_mg.R; +import com.yutou.jianr_mg.Tools.Log; import org.angmarch.views.NiceSpinner; import org.json.JSONObject; @@ -157,7 +158,7 @@ public class WarFragment extends Fragment { return; } - System.out.println(">>>>>>"+item.getInt("mapId")); + Log.i(">>>>>>"+item.getInt("mapId")); if(Objects.requireNonNull(maps.get("DealNode")).getString("type").equals("DealNode")) { getItem(i, srcList); } diff --git a/app/src/main/java/com/yutou/jianr_mg/Fragments/GameDataFragments/WarLogFragments/DaytimeFragment.java b/app/src/main/java/com/yutou/jianr_mg/Fragments/GameDataFragments/WarLogFragments/DaytimeFragment.java index 5b09962..c89f0f3 100644 --- a/app/src/main/java/com/yutou/jianr_mg/Fragments/GameDataFragments/WarLogFragments/DaytimeFragment.java +++ b/app/src/main/java/com/yutou/jianr_mg/Fragments/GameDataFragments/WarLogFragments/DaytimeFragment.java @@ -14,6 +14,7 @@ import android.widget.ListView; import com.umeng.commonsdk.debug.W; import com.yutou.jianr_mg.Fragments.GameDataFragments.WarLogFragments.Adapters.DaytimeListViewAdapter; +import com.yutou.jianr_mg.Tools.Log; import org.json.JSONArray; import org.json.JSONException; @@ -97,11 +98,11 @@ public class DaytimeFragment extends Fragment implements WarLogInterface{ List list = new ArrayList<>(); try { JSONArray nightAttacks = new JSONObject(json.getJSONObject("WarReport").getString("message")).getJSONObject("extraProgress").getJSONArray("nightAttacks"); - System.out.println("--------->夜战数量:"+nightAttacks.length()); + Log.i("--------->夜战数量:"+nightAttacks.length()); for (int i = 0; i < nightAttacks.length(); i++) { - System.out.println(nightAttacks.getJSONObject(i)); + Log.i(nightAttacks.getJSONObject(i).toString()); WarData warData=WarData.getInstance(WarData.NIGHT_WAR,nightAttacks.getJSONObject(i),warReport); - System.out.println(warData.toString()); + Log.i(warData.toString()); list.add(warData); } } catch (Exception e) { diff --git a/app/src/main/java/com/yutou/jianr_mg/Fragments/UtilsFragments.java b/app/src/main/java/com/yutou/jianr_mg/Fragments/UtilsFragments.java index 21a6bb5..2c0d0a7 100644 --- a/app/src/main/java/com/yutou/jianr_mg/Fragments/UtilsFragments.java +++ b/app/src/main/java/com/yutou/jianr_mg/Fragments/UtilsFragments.java @@ -19,6 +19,7 @@ import com.yutou.jianr_mg.Interfaces.HttpInterface; import com.yutou.jianr_mg.Network.HttpApi; import com.yutou.jianr_mg.Network.HttpUtils; import com.yutou.jianr_mg.R; +import com.yutou.jianr_mg.Tools.Log; import org.json.JSONObject; @@ -143,7 +144,7 @@ public class UtilsFragments extends Fragment { } } private void setData() { - System.out.println(datas.size()); + Log.i(datas.size()+""); if(datas.size()>0){ adapter.addAll(datas); recyclerView.dismissSwipeRefresh(); diff --git a/app/src/main/java/com/yutou/jianr_mg/LoadingActivity.java b/app/src/main/java/com/yutou/jianr_mg/LoadingActivity.java index 8cbc4cd..aed81da 100644 --- a/app/src/main/java/com/yutou/jianr_mg/LoadingActivity.java +++ b/app/src/main/java/com/yutou/jianr_mg/LoadingActivity.java @@ -79,7 +79,7 @@ public class LoadingActivity extends AppCompatActivity { protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); AppData.debug=true; - System.out.println("update"); + Log.i("update"); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_loading); @@ -435,7 +435,7 @@ public class LoadingActivity extends AppCompatActivity { if (requestCode == AppPermissions.REQUEST_CODE) { for (String permission : AppPermissions.permissions) { if (ActivityCompat.checkSelfPermission(this, permission) != PackageManager.PERMISSION_GRANTED) { - System.out.println(permission); + Log.i(permission); flag = false; break; } diff --git a/app/src/main/java/com/yutou/jianr_mg/Network/HttpApi.java b/app/src/main/java/com/yutou/jianr_mg/Network/HttpApi.java index e997b08..a10312f 100644 --- a/app/src/main/java/com/yutou/jianr_mg/Network/HttpApi.java +++ b/app/src/main/java/com/yutou/jianr_mg/Network/HttpApi.java @@ -9,7 +9,7 @@ public class HttpApi { // public static final String HOME = "http://192.168.31.92:8080/"; //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.1.151:8080/"; //公司 + // public static final String HOME = "http://192.168.1.151:8080/"; //公司 public static final String HOME_URL=HOME+"android/"; //服务器 public static final String MOD_ALL = "mod/all.do"; diff --git a/app/src/main/java/com/yutou/jianr_mg/Network/HttpUtils.java b/app/src/main/java/com/yutou/jianr_mg/Network/HttpUtils.java index b493d3b..49741e5 100644 --- a/app/src/main/java/com/yutou/jianr_mg/Network/HttpUtils.java +++ b/app/src/main/java/com/yutou/jianr_mg/Network/HttpUtils.java @@ -148,7 +148,7 @@ public class HttpUtils { while (!downloadFileInerface.downloading(getNameFromUrl(url), progress, total)) { Thread.sleep(10); } - System.out.println("下载:" + progress); + Log.i("下载:" + progress); } fos.flush(); // 下载完成 diff --git a/app/src/main/java/com/yutou/jianr_mg/Tools/ExcelUtils.java b/app/src/main/java/com/yutou/jianr_mg/Tools/ExcelUtils.java index 77965d4..220a561 100644 --- a/app/src/main/java/com/yutou/jianr_mg/Tools/ExcelUtils.java +++ b/app/src/main/java/com/yutou/jianr_mg/Tools/ExcelUtils.java @@ -28,7 +28,7 @@ public class ExcelUtils { bundle.putString("filePath", file.getAbsolutePath()); bundle.putString("tempPath", Utils.getAppPath()+ "/" + "TbsReaderTemp"); boolean flag= tbs.preOpen("xlsx", false); - System.out.println("打开文件:"+flag); + Log.i("打开文件:"+flag); tbs.openFile(bundle); } public void close(){ diff --git a/app/src/main/java/com/yutou/jianr_mg/Tools/JianRUtils.java b/app/src/main/java/com/yutou/jianr_mg/Tools/JianRUtils.java index 9a3994b..8967ff8 100644 --- a/app/src/main/java/com/yutou/jianr_mg/Tools/JianRUtils.java +++ b/app/src/main/java/com/yutou/jianr_mg/Tools/JianRUtils.java @@ -127,7 +127,7 @@ public class JianRUtils { public static List getNightUserTeam(JSONObject json) { List data = getUserTeam(json); - System.out.println("用户数量:" + data.size()); + Log.i("用户数量:" + data.size()); try { JSONObject warRepoot = json.getJSONObject("warResult"); JSONArray selfShips = warRepoot.getJSONArray("selfShipResults"); @@ -148,11 +148,11 @@ public class JianRUtils { try { JSONObject warRepoot = json.getJSONObject("warResult"); JSONArray selfShips = warRepoot.getJSONArray("enemyShipResults"); - System.out.println("血量参数:" + selfShips.length()); + Log.i("血量参数:" + selfShips.length()); for (int i = 0; i < selfShips.length(); i++) { JSONObject js = selfShips.getJSONObject(i); - System.out.println("敌方血量:" + js.getInt("hp")); - System.out.println("敌方数量:" + data.size()); + Log.i("敌方血量:" + js.getInt("hp")); + Log.i("敌方数量:" + data.size()); TeamData ut = data.get(i); ut.setHp(js.getInt("hp") + ""); data.set(i, ut); @@ -211,7 +211,7 @@ public class JianRUtils { JianNiang jianNiang = JSON.parseObject(json.toString(), JianNiang.class); jianNiangs.add(jianNiang); } - System.out.println("缓存舰娘数:" + jianNiangs.size()); + Log.i("缓存舰娘数:" + jianNiangs.size()); } } catch (Exception e) { e.printStackTrace(); @@ -273,7 +273,7 @@ public class JianRUtils { ShipEquipmnt jianNiang = JSON.parseObject(json.toString(), ShipEquipmnt.class); equipmnts.add(jianNiang); } - System.out.println("缓存装备数:" + equipmnts.size()); + Log.i("缓存装备数:" + equipmnts.size()); } } catch (Exception e) { e.printStackTrace(); diff --git a/app/src/main/java/com/yutou/jianr_mg/Tools/Log.java b/app/src/main/java/com/yutou/jianr_mg/Tools/Log.java index d59a74e..ded3fb9 100644 --- a/app/src/main/java/com/yutou/jianr_mg/Tools/Log.java +++ b/app/src/main/java/com/yutou/jianr_mg/Tools/Log.java @@ -23,7 +23,7 @@ public class Log { */ public static void i(String str) { if(LOG) - System.out.println(str); + System.out.println(str); } /** * 错误输出带标题 @@ -41,7 +41,7 @@ public class Log { */ public static void i(String title,String str) { if(LOG) - System.out.println("["+title+"]"+str); + Log.i("["+title+"]"+str); } /** diff --git a/app/src/main/java/com/yutou/jianr_mg/Tools/ModUtils.java b/app/src/main/java/com/yutou/jianr_mg/Tools/ModUtils.java index f940b90..4ca8d46 100644 --- a/app/src/main/java/com/yutou/jianr_mg/Tools/ModUtils.java +++ b/app/src/main/java/com/yutou/jianr_mg/Tools/ModUtils.java @@ -61,7 +61,7 @@ public class ModUtils { private TMod mod; public static ModUtils init(Context context) { - System.out.println("调用魔改管理器"); + Log.i("调用魔改管理器"); try { if (modUtils == null) { modUtils = new ModUtils(); @@ -271,7 +271,7 @@ public class ModUtils { public void getData(String data,Object src) { JSONObject json= (JSONObject) src; try { - System.out.println(">>>>"+((String[])json.get("args"))[0]); + Log.i(">>>>"+((String[])json.get("args"))[0]); } catch (JSONException e) { e.printStackTrace(); } diff --git a/app/src/main/java/com/yutou/jianr_mg/Tools/RootUtils.java b/app/src/main/java/com/yutou/jianr_mg/Tools/RootUtils.java index 472dab3..a80ca61 100644 --- a/app/src/main/java/com/yutou/jianr_mg/Tools/RootUtils.java +++ b/app/src/main/java/com/yutou/jianr_mg/Tools/RootUtils.java @@ -86,7 +86,7 @@ public class RootUtils { println("chmod +x" + Application.application.getFilesDir() + "/files/busybox"); isBusyBox=tmp; } - System.out.println("尝试获取ROOT权限"); + Log.i("尝试获取ROOT权限"); } catch (Exception e) { e.printStackTrace(); } @@ -118,7 +118,7 @@ public class RootUtils { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { result = localProcess.waitFor(500, TimeUnit.MILLISECONDS); }else{ - System.out.println("b"); + Log.i("b"); resultCode=localProcess.waitFor(); } localDataOutputStream.close(); diff --git a/app/src/main/java/com/yutou/jianr_mg/Tools/SocketTools.java b/app/src/main/java/com/yutou/jianr_mg/Tools/SocketTools.java index e4879b5..aee653d 100644 --- a/app/src/main/java/com/yutou/jianr_mg/Tools/SocketTools.java +++ b/app/src/main/java/com/yutou/jianr_mg/Tools/SocketTools.java @@ -119,7 +119,7 @@ public class SocketTools { dialog.dismiss(); new Thread(() -> { try { - System.out.println("地址:"+editText.getText().toString()+" 端口:2336"); + Log.i("地址:"+editText.getText().toString()+" 端口:2336"); Socket socket=new Socket(editText.getText().toString().trim(),2336); linkService(socket); @@ -144,9 +144,9 @@ public class SocketTools { KProgressHUD dhud=Utils.showLoading(context,null,"传输中"); dhud.show(); new Thread(() -> { - System.out.println("开始传输:"); + Log.i("开始传输:"); linkService(socket); - System.out.println("传输完毕"); + Log.i("传输完毕"); AppData.handler.post(()->{dhud.dismiss();dialog.dismiss();}); dhud.dismiss(); }).start(); @@ -233,7 +233,7 @@ public class SocketTools { baos.flush(); String tmp = baos.toString(); baos.close(); - System.out.println(tmp); + Log.i(tmp); if (tmp.equals("ok")) { flag = false; AppData.handler.post(()->hud.dismiss()); @@ -280,7 +280,7 @@ public class SocketTools { // TODO: handle exception } } - System.out.println("保存路径:"+file.getAbsolutePath()); + Log.i("保存路径:"+file.getAbsolutePath()); Utils.Base64Decode(sb.toString(), file); AppData.handler.post(()->{hud.dismiss();Utils.toast(context,"重启盒子生效");}); } catch (Exception e) { diff --git a/app/src/main/java/com/yutou/jianr_mg/Tools/ZipUtils.java b/app/src/main/java/com/yutou/jianr_mg/Tools/ZipUtils.java index 1396702..c02685e 100644 --- a/app/src/main/java/com/yutou/jianr_mg/Tools/ZipUtils.java +++ b/app/src/main/java/com/yutou/jianr_mg/Tools/ZipUtils.java @@ -20,7 +20,7 @@ public class ZipUtils { if (!descDirPath.exists()) { descDirPath.mkdirs(); } - System.out.println("文件:" + zipFile.exists()); + Log.i("文件:" + zipFile.exists()); try { ZipFile _zipFile = new ZipFile(zipFile); //_zipFile.setFileNameCharset("GBK"); //设置编码格式(支持中文) diff --git a/app/src/main/java/com/yutou/jianr_mg/services/MagicBoxService.java b/app/src/main/java/com/yutou/jianr_mg/services/MagicBoxService.java index 1704eb7..f165743 100644 --- a/app/src/main/java/com/yutou/jianr_mg/services/MagicBoxService.java +++ b/app/src/main/java/com/yutou/jianr_mg/services/MagicBoxService.java @@ -11,6 +11,7 @@ import com.yutou.jianr_mg.Application; import com.yutou.jianr_mg.Data.AppData; import com.yutou.jianr_mg.Databases.JianRDataDataBase; import com.yutou.jianr_mg.Tools.JianRUtils; +import com.yutou.jianr_mg.Tools.Log; import com.yutou.jianr_mg.Tools.Utils; import com.yutou.jianr_mg.views.WarView; @@ -49,7 +50,7 @@ public class MagicBoxService { public static MagicBoxService init() { JianRUtils.readClientVersionIsbigzhao(Application.application); if (!Utils.getApplicationPackName(Application.application, AppData.magicPackageName)) { - System.out.println("没有安装客户端"); + Log.i("没有安装客户端"); return null; } if (magicBoxService == null) { @@ -61,14 +62,14 @@ public class MagicBoxService { private ServiceConnection connection; private void initMagicBox() { - System.out.println("绑定大钊客户端"); + Log.i("绑定大钊客户端"); isClose = false; connection = new ServiceConnection() { JianRDataDataBase dataBase; @Override public void onServiceConnected(ComponentName componentName, IBinder iBinder) { - System.out.println("链接大钊客户端"); + Log.i("链接大钊客户端"); if (!Utils.testStringIsNull(dataName, dataType)) { dataBase = JianRDataDataBase.init(); } @@ -78,7 +79,7 @@ public class MagicBoxService { @Override public void run() { if (isClose) { - System.out.println("关闭连接"); + Log.i("关闭连接"); cancel(); return; } @@ -93,7 +94,7 @@ public class MagicBoxService { magicBoxInterface.getData(boxBinder.getVersion() + ""); } else { String[] args=(String[]) order.get("args"); - System.out.println("执行:"+order.getString("action")+" "+args[0]+" > "+args[1]); + Log.i("执行:"+order.getString("action")+" "+args[0]+" > "+args[1]); magicBoxInterface.getData(boxBinder.action_remote(order.getString("action"),args ),order); } }catch (Exception e){ @@ -148,8 +149,8 @@ public class MagicBoxService { boxInterface.getData(json2.toString()); } } - // System.out.println("str = "+str); - // System.out.println("str2 = "+str2); + // Log.i("str = "+str); + // Log.i("str2 = "+str2); } catch (Exception e) { e.printStackTrace(); } @@ -160,7 +161,7 @@ public class MagicBoxService { @Override public void onServiceDisconnected(ComponentName componentName) { - System.out.println("大钊客户端连接失败:" + componentName.flattenToString()); + Log.i("大钊客户端连接失败:" + componentName.flattenToString()); isClose = true; } }; @@ -177,7 +178,7 @@ public class MagicBoxService { intent.setAction(com.bigzhao.jianrmagicbox.IMagicBoxBinder.ACTION_SERVICE); intent.setPackage(AppData.magicPackageName); boolean tmp = Application.application.bindService(intent, connection, BIND_AUTO_CREATE); - System.out.println("重新绑定结果:" + tmp); + Log.i("重新绑定结果:" + tmp); } catch (Exception e) { e.printStackTrace(); } diff --git a/app/src/main/java/com/yutou/jianr_mg/services/WindowsService.java b/app/src/main/java/com/yutou/jianr_mg/services/WindowsService.java index cd6a265..d8c4933 100644 --- a/app/src/main/java/com/yutou/jianr_mg/services/WindowsService.java +++ b/app/src/main/java/com/yutou/jianr_mg/services/WindowsService.java @@ -13,9 +13,11 @@ import android.os.Build; import android.os.Handler; import android.os.IBinder; import android.provider.Settings; + import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; import androidx.constraintlayout.widget.ConstraintLayout; + import android.util.DisplayMetrics; import android.view.Gravity; import android.view.KeyEvent; @@ -36,6 +38,7 @@ import android.widget.SeekBar; import com.yutou.jianr_mg.Data.AppData; import com.yutou.jianr_mg.R; import com.yutou.jianr_mg.Tools.ExcelUtils; +import com.yutou.jianr_mg.Tools.Log; import com.yutou.jianr_mg.Tools.Utils; import com.yutou.jianr_mg.views.ExcelActivity; import com.yutou.jianr_mg.views.WarView; @@ -65,8 +68,8 @@ public class WindowsService extends Service { private ExcelUtils excel; private File excelFile; private Context context; - private boolean input_flag = false,saveData=false; - private String dataType,dataName; + private boolean input_flag = false, saveData = false; + private String dataType, dataName; private WarView warView; private class MyBinder extends Binder { @@ -87,9 +90,9 @@ public class WindowsService extends Service { public int onStartCommand(Intent intent, int flags, int startId) { if (intent != null) { saveData = intent.getBooleanExtra("saveData", false); - dataName=intent.getStringExtra("dataName"); - dataType=intent.getStringExtra("dataType"); - System.out.println("接收到配置,开关 = "+saveData+" name = "+dataName+" type = "+dataType); + dataName = intent.getStringExtra("dataName"); + dataType = intent.getStringExtra("dataType"); + Log.i("接收到配置,开关 = " + saveData + " name = " + dataName + " type = " + dataType); } return super.onStartCommand(intent, flags, startId); @@ -99,10 +102,10 @@ public class WindowsService extends Service { @Override public void onCreate() { super.onCreate(); - System.out.println("触发悬浮窗"); + Log.i("触发悬浮窗"); context = WindowsService.this; handler = new Handler(); - warView=new WarView(context,null,webW,handler); + warView = new WarView(context, null, webW, handler); try { SharedPreferences sp = getSharedPreferences(ExcelActivity.excelName, MODE_PRIVATE); excelFile = new File(sp.getString("default", "null.xlsx")); @@ -132,7 +135,8 @@ public class WindowsService extends Service { timer = new Timer(); timer.schedule(new TimerTask() { boolean isRuntime = false; - boolean listener=true; + boolean listener = true; + @Override public void run() { MagicBoxService boxService = MagicBoxService.init(); @@ -140,8 +144,8 @@ public class WindowsService extends Service { Utils.toast(context, "未安装专用客户端,部分功能将无法使用"); cancel(); return; - }else{ - boxService.setSaveData(saveData,dataName,dataType); + } else { + boxService.setSaveData(saveData, dataName, dataType); } try { JSONObject json = new JSONObject(); @@ -154,8 +158,8 @@ public class WindowsService extends Service { isRuntime = true; } }); - if(listener) { - listener=false; + if (listener) { + listener = false; } handler.post(() -> { if (isRuntime) { @@ -210,10 +214,10 @@ public class WindowsService extends Service { Utils.toast(context, "专用客户端未安装(仅限共存版)"); } else { Utils.toast(context, "专用客户端未启动"); - MagicBoxService service= MagicBoxService.init(); - if(service!=null){ - service.startService(); - } + MagicBoxService service = MagicBoxService.init(); + if (service != null) { + service.startService(); + } } } }); @@ -242,31 +246,33 @@ public class WindowsService extends Service { } } - private int webW=0,webH=0; + + private int webW = 0, webH = 0; + private void reloadUi() { - if(webView.getLayoutParams().width>0) { + if (webView.getLayoutParams().width > 0) { webW = webView.getLayoutParams().width; webH = webView.getLayoutParams().height; - contextLayout.getLayoutParams().width=webW; + contextLayout.getLayoutParams().width = webW; } int pushSize = Utils.getPixelsFromDp(AppData.activity, 10); int sideSize = Utils.getPixelsFromDp(AppData.activity, 45); - int webSize =contextLayout.getLayoutParams().width; + int webSize = contextLayout.getLayoutParams().width; if (side.getVisibility() == View.GONE) { sideSize = 0; } if (contextLayout.getVisibility() == View.GONE) { webSize = 0; } - if(webSize<0){ + if (webSize < 0) { } - System.out.println("push size:" + pushSize); - System.out.println("side size:" + sideSize); - System.out.println("webs size:" + webSize); - params.width =pushSize + sideSize +webSize; - System.out.println("悬浮窗大小:" + params.width+" push="+pushSize+" side="+sideSize+" wr="+webSize+" wit="+Utils.getMetrics(AppData.activity).widthPixels); + Log.i("push size:" + pushSize); + Log.i("side size:" + sideSize); + Log.i("webs size:" + webSize); + params.width = pushSize + sideSize + webSize; + Log.i("悬浮窗大小:" + params.width + " push=" + pushSize + " side=" + sideSize + " wr=" + webSize + " wit=" + Utils.getMetrics(AppData.activity).widthPixels); windowManager.updateViewLayout(mainLayout, params); initWebUi(); } @@ -279,12 +285,12 @@ public class WindowsService extends Service { // 横屏 width = metrics.widthPixels; width = (int) (width - (width * 0.1)); - System.out.println("横屏"); + Log.i("横屏"); } else { // 竖屏 width = metrics.widthPixels; width = (int) (width - (width * 0.2)); - System.out.println("竖屏"); + Log.i("竖屏"); } webView.getLayoutParams().width = width; } @@ -299,7 +305,7 @@ public class WindowsService extends Service { webView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { - System.out.println("加载网页:" + url); + Log.i("加载网页:" + url); view.loadUrl(url); return true; } @@ -343,17 +349,22 @@ public class WindowsService extends Service { strategy.setTag(204); strategy.setOnClickListener(new ButtonOnClick()); - list.add(bbs); - list.add(strategy); - list.add(address); - list.add(input); + SharedPreferences winShared = this.getSharedPreferences("windowsConfig", Context.MODE_PRIVATE); + if (winShared.getBoolean("bbs", true)) + list.add(bbs); + if (winShared.getBoolean("strategy", true)) + list.add(strategy); + if (winShared.getBoolean("address", true)) + list.add(address); + if (winShared.getBoolean("input", true)) + list.add(input); // list.add(bookmark); return list; } private List