From d78284dc325ddf08d3b2ee5addb4e32ad1354e7a Mon Sep 17 00:00:00 2001 From: Magical Yang Date: Thu, 7 Sep 2023 17:53:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=E6=9D=A5=E8=87=AAcwj851?= =?UTF-8?q?=E7=9A=84pr=EF=BC=8C=E4=BC=98=E5=8C=96=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E5=88=A4=E6=96=AD=EF=BC=9B=E8=B0=83=E6=95=B4=E9=80=81=E9=81=93?= =?UTF-8?q?=E5=85=B7=E9=80=81=E9=BA=A6=E5=AD=90=E9=97=B4=E9=9A=94=EF=BC=9B?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=87=AA=E5=8A=A8=E5=AE=8C=E6=88=90=E7=A5=9E?= =?UTF-8?q?=E5=A5=87=E7=89=A9=E7=A7=8D[=E9=80=81=E5=A5=BD=E5=8F=8B?= =?UTF-8?q?=E5=8D=A1=E7=89=87]=E4=BB=BB=E5=8A=A1=E3=80=82=E9=9B=B6?= =?UTF-8?q?=E9=9B=B6=E6=95=A3=E6=95=A3=E4=BF=AE=E5=A4=8D=E4=BA=86=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E9=97=AE=E9=A2=98=EF=BC=8C=E6=B7=BB=E5=8A=A0=E4=BA=86?= =?UTF-8?q?=E4=B8=80=E4=BA=9B=E5=8A=9F=E8=83=BD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 4 +- .../xposed/quickenergy/AntFarm.java | 2 +- .../xposed/quickenergy/AntForest.java | 87 +++++- .../xposed/quickenergy/AntOcean.java | 47 ++++ .../xposed/quickenergy/AntOrchard.java | 1 + .../xposed/quickenergy/AntStall.java | 173 +++++++++++- .../quickenergy/hook/AntForestRpcCall.java | 42 ++- .../quickenergy/hook/AntOceanRpcCall.java | 15 +- .../quickenergy/hook/AntStallRpcCall.java | 37 ++- .../quickenergy/hook/EcoLifeRpcCall.java | 12 - .../quickenergy/hook/FriendManager.java | 8 +- .../xposed/quickenergy/hook/RpcUtil.java | 2 +- .../xposed/quickenergy/hook/XposedHook.java | 49 +--- .../quickenergy/ui/SettingsActivity.java | 26 +- .../xposed/quickenergy/util/Config.java | 40 ++- .../xposed/quickenergy/util/FileUtils.java | 11 + .../xposed/quickenergy/util/PluginUtils.java | 3 +- .../xposed/quickenergy/util/Statistics.java | 263 ++++++++++++++++-- app/src/main/res/layout/activity_settings.xml | 52 ++-- app/src/main/res/values-zh-rCN/strings.xml | 2 + app/src/main/res/values/strings.xml | 2 + 21 files changed, 738 insertions(+), 140 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 00a8d344d..d13e02642 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { minSdk 21 //noinspection ExpiredTargetSdkVersion targetSdk 29 - versionCode 60 - versionName "1.1.8-fix1" + versionCode 63 + versionName "1.1.9" } buildTypes { release { diff --git a/app/src/main/java/pansong291/xposed/quickenergy/AntFarm.java b/app/src/main/java/pansong291/xposed/quickenergy/AntFarm.java index b0906c549..be8f439b3 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/AntFarm.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/AntFarm.java @@ -1358,7 +1358,7 @@ private static int visitFriend(String userId, int count) { } else { Log.recordLog(jo.getString("memo"), jo.toString()); } - Thread.sleep(200); + Thread.sleep(1000L); } } else { Log.recordLog(jo.getString("memo"), s); diff --git a/app/src/main/java/pansong291/xposed/quickenergy/AntForest.java b/app/src/main/java/pansong291/xposed/quickenergy/AntForest.java index 124107553..e3d89a1bf 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/AntForest.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/AntForest.java @@ -174,6 +174,8 @@ public void run() { } if (Config.antdodoCollect()) { antdodoCollect(); + antdodoReceiveTaskAward(); + antdodoPropList(); } if (!Config.whoYouWantGiveTo().isEmpty() && !FriendIdMap.currentUid.equals(Config.whoYouWantGiveTo().get(0))) { @@ -1169,7 +1171,7 @@ private static void giveProp(String targetUserId) { } else { Log.recordLog(jo.getString("resultDesc"), jo.toString()); } - Thread.sleep(200); + Thread.sleep(1000L); if (holdsNum > 1 || forestPropVOList.length() > 1) { giveProp(targetUserId); } @@ -1286,6 +1288,89 @@ private static void collectAnimalCard() { } } + private static void antdodoReceiveTaskAward() { + try { + String s = AntForestRpcCall.antdodoTaskList(); + JSONObject jo = new JSONObject(s); + if ("SUCCESS".equals(jo.getString("resultCode"))) { + JSONArray taskGroupInfoList = jo.getJSONObject("data").optJSONArray("taskGroupInfoList"); + if (taskGroupInfoList == null) + return; + for (int i = 0; i < taskGroupInfoList.length(); i++) { + JSONObject antdodoTask = taskGroupInfoList.getJSONObject(i); + JSONArray taskInfoList = antdodoTask.getJSONArray("taskInfoList"); + for (int j = 0; j < taskInfoList.length(); j++) { + JSONObject taskInfo = taskInfoList.getJSONObject(j); + JSONObject taskBaseInfo = taskInfo.getJSONObject("taskBaseInfo"); + JSONObject bizInfo = new JSONObject(taskBaseInfo.getString("bizInfo")); + String taskType = taskBaseInfo.getString("taskType"); + String taskTitle = bizInfo.optString("taskTitle", taskType); + String awardCount = bizInfo.optString("awardCount", "1"); + String sceneCode = taskBaseInfo.getString("sceneCode"); + String taskStatus = taskBaseInfo.getString("taskStatus"); + if (TaskStatus.FINISHED.name().equals(taskStatus)) { + JSONObject joAward = new JSONObject( + AntForestRpcCall.antdodoReceiveTaskAward(sceneCode, taskType)); + if (joAward.getBoolean("success")) + Log.forest("任务奖励🎖️[" + taskTitle + "]#" + awardCount + "个"); + else + Log.recordLog("领取失败," + s, joAward.toString()); + } else if (TaskStatus.TODO.name().equals(taskStatus)) { + if ("SEND_FRIEND_CARD".equals(taskType)) { + JSONObject joFinishTask = new JSONObject( + AntForestRpcCall.antdodoFinishTask(sceneCode, taskType)); + if (joFinishTask.getBoolean("success")) { + Log.forest("物种任务🧾️[" + taskTitle + "]"); + antdodoReceiveTaskAward(); + return; + } else { + Log.recordLog("完成任务失败," + taskTitle); + } + } + } + } + } + } else { + Log.recordLog(jo.getString("resultDesc"), s); + } + } catch (Throwable t) { + Log.i(TAG, "antdodoReceiveTaskAward err:"); + Log.printStackTrace(TAG, t); + } + } + + private static void antdodoPropList() { + try { + JSONObject jo = new JSONObject(AntForestRpcCall.antdodoPropList()); + if ("SUCCESS".equals(jo.getString("resultCode"))) { + JSONArray propList = jo.getJSONObject("data").optJSONArray("propList"); + for (int i = 0; i < propList.length(); i++) { + JSONObject prop = propList.getJSONObject(i); + String propType = prop.getString("propType"); + if ("COLLECT_TIMES_7_DAYS".equals(propType)) { + JSONArray propIdList = prop.getJSONArray("propIdList"); + String propId = propIdList.getString(0); + String propName = prop.getJSONObject("propConfig").getString("propName"); + jo = new JSONObject(AntForestRpcCall.antdodoConsumeProp(propId, propType)); + if ("SUCCESS".equals(jo.getString("resultCode"))) { + JSONObject useResult = jo.getJSONObject("data").getJSONObject("useResult"); + JSONObject animal = useResult.getJSONObject("animal"); + String ecosystem = animal.getString("ecosystem"); + String name = animal.getString("name"); + Log.forest("使用道具🎭[" + propName + "]#" + ecosystem + "-" + name); + } else { + Log.recordLog(jo.getString("resultDesc"), jo.toString()); + } + Thread.sleep(1000L); + } + } + } + } catch (Throwable th) { + Log.i(TAG, "antdodoPropList err:"); + Log.printStackTrace(TAG, th); + } + } + /* 巡护保护地 */ private static void UserPatrol() { try { diff --git a/app/src/main/java/pansong291/xposed/quickenergy/AntOcean.java b/app/src/main/java/pansong291/xposed/quickenergy/AntOcean.java index b467070c9..573a940ee 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/AntOcean.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/AntOcean.java @@ -8,6 +8,7 @@ import pansong291.xposed.quickenergy.util.FriendIdMap; import pansong291.xposed.quickenergy.util.Log; import pansong291.xposed.quickenergy.AntFarm.TaskStatus; +import pansong291.xposed.quickenergy.util.StringUtil; /** * @author Constanline @@ -276,6 +277,48 @@ private static void queryOceanPropList() { } } + private static void switchOceanChapter() { + String s = AntOceanRpcCall.queryOceanChapterList(); + try { + JSONObject jo = new JSONObject(s); + if ("SUCCESS".equals(jo.getString("resultCode"))) { + String currentChapterCode = jo.getString("currentChapterCode"); + JSONArray chapterVOs = jo.getJSONArray("userChapterDetailVOList"); + boolean isFinish = false; + String dstChapterCode = ""; + String dstChapterName = ""; + for (int i = 0; i < chapterVOs.length(); i++) { + JSONObject chapterVO = chapterVOs.getJSONObject(i); + int repairedSeaAreaNum = chapterVO.getInt("repairedSeaAreaNum"); + int seaAreaNum = chapterVO.getInt("seaAreaNum"); + if (chapterVO.getString("chapterCode").equals(currentChapterCode)) { + isFinish = repairedSeaAreaNum >= seaAreaNum; + } else { + if (repairedSeaAreaNum >= seaAreaNum || !chapterVO.getBoolean("chapterOpen")) { + continue; + } + dstChapterName = chapterVO.getString("chapterName"); + dstChapterCode = chapterVO.getString("chapterCode"); + } + } + if (isFinish && !StringUtil.isEmpty(dstChapterCode)) { + s = AntOceanRpcCall.switchOceanChapter(dstChapterCode); + jo = new JSONObject(s); + if ("SUCCESS".equals(jo.getString("resultCode"))) { + Log.forest("神奇海洋🐳切换到[" + dstChapterName + "]系列"); + } else { + Log.i(TAG, jo.getString("resultDesc")); + } + } + } else { + Log.i(TAG, jo.getString("resultDesc")); + } + } catch (Throwable t) { + Log.i(TAG, "queryUserRanking err:"); + Log.printStackTrace(TAG, t); + } + } + private static void querySeaAreaDetailList() { try { String s = AntOceanRpcCall.querySeaAreaDetailList(); @@ -318,6 +361,10 @@ private static void queryMiscInfo() { if (homeTipsRefresh.optBoolean("fishCanBeCombined") || homeTipsRefresh.optBoolean("canBeRepaired")) { querySeaAreaDetailList(); } + //此处不确定,因为修复完成好像也会返回false + if (homeTipsRefresh.optBoolean("currentChapterFixed")) { + switchOceanChapter(); + } } else { Log.i(TAG, jo.getString("resultDesc")); } diff --git a/app/src/main/java/pansong291/xposed/quickenergy/AntOrchard.java b/app/src/main/java/pansong291/xposed/quickenergy/AntOrchard.java index 24d5727b8..e6e7a98dc 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/AntOrchard.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/AntOrchard.java @@ -14,6 +14,7 @@ public class AntOrchard { public static void start() { if (!Config.antOrchard()) return; + PluginUtils.invoke(AntOrchard.class, PluginUtils.PluginAction.START); new Thread() { @Override diff --git a/app/src/main/java/pansong291/xposed/quickenergy/AntStall.java b/app/src/main/java/pansong291/xposed/quickenergy/AntStall.java index b7ffeae48..b41f7f9dc 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/AntStall.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/AntStall.java @@ -6,6 +6,7 @@ import pansong291.xposed.quickenergy.util.Config; import pansong291.xposed.quickenergy.util.FriendIdMap; import pansong291.xposed.quickenergy.util.Log; +import pansong291.xposed.quickenergy.util.Statistics; import java.util.*; @@ -48,12 +49,21 @@ private static void home() { return; } + JSONObject astReceivableCoinVO = jo.getJSONObject("astReceivableCoinVO"); + if (astReceivableCoinVO.optBoolean("hasCoin")) { + settleReceivable(); + } + + if (Config.stallThrowManure()) { + throwManure(); + } + JSONObject seatsMap = jo.getJSONObject("seatsMap"); settle(seatsMap); - sendBack(seatsMap); + collectManure(); - // shopList(); + sendBack(seatsMap); if (Config.stallAutoClose()) { closeShop(); @@ -64,6 +74,7 @@ private static void home() { } taskList(); + achieveBeShareP2P(); if (Config.stallDonate()) { roadmap(); @@ -90,6 +101,8 @@ private static void sendBack(String billNo, String seatId, String shopId, String jo = new JSONObject(s); if ("SUCCESS".equals(jo.getString("resultCode"))) { Log.farm("蚂蚁新村⛪请走[" + FriendIdMap.getNameById(shopUserId) + "]的小摊" + (amount > 0 ? "获得金币" + amount : "")); + + inviteOpen(seatId); } else { Log.recordLog("sendBack err:", s); } @@ -102,17 +115,50 @@ private static void sendBack(String billNo, String seatId, String shopId, String } } + private static void inviteOpen(String seatId) { + String s = AntStallRpcCall.rankInviteOpen(); + try { + JSONObject jo = new JSONObject(s); + if ("SUCCESS".equals(jo.getString("resultCode"))) { + JSONArray friendRankList = jo.getJSONArray("friendRankList"); + for (int i = 0; i < friendRankList.length(); i++) { + JSONObject friend = friendRankList.getJSONObject(i); + String friendUserId = friend.getString("userId"); + if (!Config.stallInviteShopList().contains(friendUserId)) { + continue; + } + if (friend.getBoolean("canInviteOpenShop")) { + s = AntStallRpcCall.oneKeyInviteOpenShop(friendUserId, seatId); + jo = new JSONObject(s); + if ("SUCCESS".equals(jo.getString("resultCode"))) { + Log.farm("蚂蚁新村⛪邀请[" + FriendIdMap.getNameById(friendUserId) + "]开店成功"); + } + } + } + } else { + Log.recordLog("inviteOpen err:", s); + } + } catch (Throwable t) { + Log.i(TAG, "inviteOpen err:"); + Log.printStackTrace(TAG, t); + } + } + private static void sendBack(JSONObject seatsMap) { try { for (int i = 1; i <= 2; i++) { JSONObject seat = seatsMap.getJSONObject("GUEST_0" + i); + String seatId = seat.getString("seatId"); + if ("FREE".equals(seat.getString("status"))) { + inviteOpen(seatId); + continue; + } String rentLastUser = seat.getString("rentLastUser"); //白名单直接跳过 if (Config.stallWhiteList().contains(rentLastUser)) { continue; } String rentLastBill = seat.getString("rentLastBill"); - String seatId = seat.getString("seatId"); String rentLastShop = seat.getString("rentLastShop"); //黑名单直接赶走 if (Config.stallBlackList().contains(rentLastUser)) { @@ -343,7 +389,7 @@ private static void taskList() { return; } } else if ("ANTSTALL_P2P_DAILY_SHARER".equals(taskType)) { - // shareP2P(); + shareP2P(); } } } @@ -394,7 +440,7 @@ private static boolean finishTask(String taskType) { String s = AntStallRpcCall.finishTask(FriendIdMap.currentUid + "_" + taskType, taskType); try { JSONObject jo = new JSONObject(s); - if (jo.getBoolean("success")) { + if (jo.getBoolean("success")) { return true; } else { Log.recordLog("finishTask err:", s); @@ -448,6 +494,7 @@ private static void shareP2P() { if (jo.getBoolean("success")) { String shareId = jo.getString("shareId"); /* 保存shareId到Statistics */ + Statistics.stallShareIdToday(FriendIdMap.currentUid, shareId); Log.recordLog("蚂蚁新村⛪[分享助力]"); } else { Log.recordLog("shareP2P err:", s); @@ -458,14 +505,34 @@ private static void shareP2P() { } } - private static void achieveBeShareP2P(String shareId) { + private static void achieveBeShareP2P() { try { - String s = AntStallRpcCall.achieveBeShareP2P(shareId); - JSONObject jo = new JSONObject(s); - if (jo.getBoolean("success")) { - Log.recordLog("蚂蚁新村⛪[助力成功]"); - } else { - Log.recordLog("achieveBeShareP2P err:", s); + if (!Statistics.canStallHelpToday(FriendIdMap.currentUid)) + return; + List UserIdList = Statistics.stallP2PUserIdList(FriendIdMap.currentUid); + for (String uid : UserIdList) { + if (Statistics.canStallBeHelpToday(uid)) { + String shareId = Statistics.getStallShareId(uid); + if (shareId != null && Statistics.canStallP2PHelpToday(uid)) { + String s = AntStallRpcCall.achieveBeShareP2P(shareId); + JSONObject jo = new JSONObject(s); + if (jo.getBoolean("success")) { + Log.farm("新村助力🎈[" + FriendIdMap.getNameById(uid) + "]"); + Statistics.stallHelpToday(FriendIdMap.currentUid, false); + Statistics.stallBeHelpToday(uid, false); + Statistics.stallP2PHelpeToday(uid); + } else if ("600000028".equals(jo.getString("code"))) { + Statistics.stallBeHelpToday(uid, true); + Log.recordLog("被助力次数上限:", uid); + } else if ("600000027".equals(jo.getString("code"))) { + Statistics.stallHelpToday(FriendIdMap.currentUid, true); + Log.recordLog("助力他人次数上限:", FriendIdMap.currentUid); + } else { + Log.recordLog("achieveBeShareP2P err:", s); + } + Thread.sleep(3500L); + } + } } } catch (Throwable t) { Log.i(TAG, "achieveBeShareP2P err:"); @@ -548,4 +615,86 @@ private static void roadmap() { Log.printStackTrace(TAG, t); } } + + private static void collectManure() { + String s = AntStallRpcCall.queryManureInfo(); + try { + JSONObject jo = new JSONObject(s); + if (jo.getBoolean("success")) { + JSONObject astManureInfoVO = jo.getJSONObject("astManureInfoVO"); + if (astManureInfoVO.optBoolean("hasManure")) { + int manure = astManureInfoVO.getInt("manure"); + s = AntStallRpcCall.collectManure(); + jo = new JSONObject(s); + if ("SUCCESS".equals(jo.getString("resultCode"))) { + Log.farm("蚂蚁新村⛪获得肥料" + manure + "g"); + } + } + } else { + Log.recordLog("collectManure err:", s); + } + } catch (Throwable t) { + Log.i(TAG, "collectManure err:"); + Log.printStackTrace(TAG, t); + } + } + + private static void throwManure(JSONArray dynamicList) { + String s = AntStallRpcCall.throwManure(dynamicList); + try { + JSONObject jo = new JSONObject(s); + if ("SUCCESS".equals(jo.getString("resultCode"))) { + Log.farm("蚂蚁新村⛪扔肥料"); + } + } catch (Throwable th) { + Log.i(TAG, "throwManure err:"); + Log.printStackTrace(TAG, th); + } + } + + private static void throwManure() { + String s = AntStallRpcCall.dynamicLoss(); + try { + JSONObject jo = new JSONObject(s); + if ("SUCCESS".equals(jo.getString("resultCode"))) { + JSONArray astLossDynamicVOS = jo.getJSONArray("astLossDynamicVOS"); + JSONArray dynamicList = new JSONArray(); + for (int i = 0; i < astLossDynamicVOS.length(); i++) { + JSONObject lossDynamic = astLossDynamicVOS.getJSONObject(i); + if (lossDynamic.has("specialEmojiVO")) { + continue; + } + JSONObject dynamic = new JSONObject(); + dynamic.put("bizId", lossDynamic.getString("bizId")); + dynamic.put("bizType", lossDynamic.getInt("bizType")); + dynamicList.put(dynamic); + if (dynamicList.length() == 5) { + throwManure(dynamicList); + dynamicList = new JSONArray(); + } + } + if (dynamicList.length() > 0) { + throwManure(dynamicList); + } + } else { + Log.recordLog("throwManure err:", s); + } + } catch (Throwable t) { + Log.i(TAG, "throwManure err:"); + Log.printStackTrace(TAG, t); + } + } + + private static void settleReceivable() { + String s = AntStallRpcCall.settleReceivable(); + try { + JSONObject jo = new JSONObject(s); + if ("SUCCESS".equals(jo.getString("resultCode"))) { + Log.farm("蚂蚁新村⛪收取应收金币"); + } + } catch (Throwable th) { + Log.i(TAG, "settleReceivable err:"); + Log.printStackTrace(TAG, th); + } + } } \ No newline at end of file diff --git a/app/src/main/java/pansong291/xposed/quickenergy/hook/AntForestRpcCall.java b/app/src/main/java/pansong291/xposed/quickenergy/hook/AntForestRpcCall.java index c74d6ebcf..70ec7f2dc 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/hook/AntForestRpcCall.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/hook/AntForestRpcCall.java @@ -10,9 +10,13 @@ public class AntForestRpcCall { private static final String VERSION = "20230710"; + private static String getUniqueId() { + return String.valueOf(System.currentTimeMillis()) + RandomUtils.nextLong(); + } + public static String fillUserRobFlag(String userIdList) { - return RpcUtil.request("alipay.antforest.forest.h5.fillUserRobFlag", - "[{\"userIdList\":" + userIdList + "}]"); + return RpcUtil.request("alipay.antforest.forest.h5.fillUserRobFlag", + "[{\"userIdList\":" + userIdList + "}]"); } public static String queryEnergyRanking() { @@ -193,10 +197,40 @@ public static String antdodoCollect() { "[{}]"); } + public static String antdodoTaskList() { + return RpcUtil.request("alipay.antdodo.rpc.h5.taskList", + "[{}]"); + } + + public static String antdodoFinishTask(String sceneCode, String taskType) { + String uniqueId = getUniqueId(); + return RpcUtil.request("com.alipay.antiep.finishTask", + "[{\"outBizNo\":\"" + uniqueId + "\",\"requestType\":\"rpc\",\"sceneCode\":\"" + + sceneCode + "\",\"source\":\"af-biodiversity\",\"taskType\":\"" + + taskType + "\",\"uniqueId\":\"" + uniqueId + "\"}]"); + } + + public static String antdodoReceiveTaskAward(String sceneCode, String taskType) { + return RpcUtil.request("com.alipay.antiep.receiveTaskAward", + "[{\"ignoreLimit\":0,\"requestType\":\"rpc\",\"sceneCode\":\"" + sceneCode + + "\",\"source\":\"af-biodiversity\",\"taskType\":\"" + taskType + + "\"}]"); + } + + public static String antdodoPropList() { + return RpcUtil.request("alipay.antdodo.rpc.h5.propList", + "[{}]"); + } + + public static String antdodoConsumeProp(String propId, String propType) { + return RpcUtil.request("alipay.antdodo.rpc.h5.consumeProp", + "[{\"propId\":\"" + propId + "\",\"propType\":\"" + propType + "\"}]"); + } + /* 巡护保护地 */ public static String queryUserPatrol() { - return RpcUtil.request("alipay.antforest.forest.h5.queryUserPatrol", - "[{\"source\":\"ant_forest\",\"timezoneId\":\"Asia/Shanghai\"}]"); + return RpcUtil.request("alipay.antforest.forest.h5.queryUserPatrol", + "[{\"source\":\"ant_forest\",\"timezoneId\":\"Asia/Shanghai\"}]"); } public static String patrolGo(int nodeIndex, int patrolId) { diff --git a/app/src/main/java/pansong291/xposed/quickenergy/hook/AntOceanRpcCall.java b/app/src/main/java/pansong291/xposed/quickenergy/hook/AntOceanRpcCall.java index f512f1511..c8268b4ca 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/hook/AntOceanRpcCall.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/hook/AntOceanRpcCall.java @@ -7,7 +7,7 @@ * @since 2023/08/01 */ public class AntOceanRpcCall { - private static final String VERSION = "20230730"; + private static final String VERSION = "20230901"; private static String getUniqueId() { return String.valueOf(System.currentTimeMillis()) + RandomUtils.nextLong(); } @@ -85,6 +85,19 @@ public static String querySeaAreaDetailList() { getUniqueId() + "\"}]"); } + public static String queryOceanChapterList() { + return RpcUtil.request("alipay.antocean.ocean.h5.queryOceanChapterList", + "[{\"source\":\"chInfo_ch_url-https://2021003115672468.h5app.alipay.com/www/atlasOcean.html\",\"uniqueId\":\"" + + getUniqueId() + "\"}]"); + } + + public static String switchOceanChapter(String chapterCode) { + return RpcUtil.request("alipay.antocean.ocean.h5.switchOceanChapter", + "[{\"chapterCode\":\"" + chapterCode + + "\",\"source\":\"chInfo_ch_url-https://2021003115672468.h5app.alipay.com/www/atlasOcean.html\",\"uniqueId\":\"" + + getUniqueId() + "\"}]"); + } + public static String queryMiscInfo() { return RpcUtil.request("alipay.antocean.ocean.h5.queryMiscInfo", "[{\"queryBizTypes\":[\"HOME_TIPS_REFRESH\"],\"source\":\"chInfo_ch_appcenter__chsub_9patch\",\"uniqueId\":\"" + diff --git a/app/src/main/java/pansong291/xposed/quickenergy/hook/AntStallRpcCall.java b/app/src/main/java/pansong291/xposed/quickenergy/hook/AntStallRpcCall.java index 8092d108d..71fcba90d 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/hook/AntStallRpcCall.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/hook/AntStallRpcCall.java @@ -1,5 +1,7 @@ package pansong291.xposed.quickenergy.hook; +import org.json.JSONArray; + import java.util.UUID; /** @@ -188,14 +190,45 @@ public static String shopSendBackPre(String billNo, String seatId, String shopId return RpcUtil.request("com.alipay.antstall.friend.shop.sendback.pre", "[{\"billNo\":\"" + billNo + "\",\"seatId\":\"" + seatId + "\",\"shopId\":\"" + shopId + "\",\"shopUserId\":\"" + shopUserId - + "\",\"source\":\"ch_appcollect__chsub_my-recentlyUsed\",\"systemType\":\"android\",\"version\":\"" + + "\",\"source\":\"ch_appcenter__chsub_9patch\",\"systemType\":\"android\",\"version\":\"" + VERSION + "\"}]"); } public static String shopSendBack(String seatId) { return RpcUtil.request("com.alipay.antstall.friend.shop.sendback", "[{\"seatId\":\"" + seatId - + "\",\"source\":\"ch_appcollect__chsub_my-recentlyUsed\",\"systemType\":\"android\",\"version\":\"" + + "\",\"source\":\"ch_appcenter__chsub_9patch\",\"systemType\":\"android\",\"version\":\"" + + VERSION + "\"}]"); + } + + public static String rankInviteOpen() { + return RpcUtil.request("com.alipay.antstall.rank.invite.open", + "[{\"source\":\"ch_appcenter__chsub_9patch\",\"systemType\":\"android\",\"version\":\"" + + VERSION + "\"}]"); + } + + public static String oneKeyInviteOpenShop(String friendUserId, String mySeatId) { + return RpcUtil.request("com.alipay.antstall.user.shop.oneKeyInviteOpenShop", + "[{\"friendUserId\":\"" + friendUserId + "\",\"mySeatId\":\"" + mySeatId + + "\",\"source\":\"ch_appcenter__chsub_9patch\",\"systemType\":\"android\",\"version\":\"" + + VERSION + "\"}]"); + } + + public static String dynamicLoss() { + return RpcUtil.request("com.alipay.antstall.dynamic.loss", + "[{\"source\":\"ch_appcenter__chsub_9patch\",\"systemType\":\"android\",\"version\":\"" + VERSION + "\"}]"); + } + + public static String throwManure(JSONArray dynamicList) { + return RpcUtil.request("com.alipay.antstall.manure.throwManure", + "[{\"dynamicList\":" + dynamicList + + ",\"sendMsg\":false,\"source\":\"ch_appcenter__chsub_9patch\",\"systemType\":\"android\",\"version\":\"" + + VERSION + "\"}]"); + } + + public static String settleReceivable() { + return RpcUtil.request("com.alipay.antstall.self.settle.receivable", + "[{\"source\":\"ch_appcenter__chsub_9patch\",\"systemType\":\"android\",\"version\":\"" + VERSION + "\"}]"); } } diff --git a/app/src/main/java/pansong291/xposed/quickenergy/hook/EcoLifeRpcCall.java b/app/src/main/java/pansong291/xposed/quickenergy/hook/EcoLifeRpcCall.java index 149c3fe0c..7eaefd31d 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/hook/EcoLifeRpcCall.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/hook/EcoLifeRpcCall.java @@ -20,18 +20,6 @@ public static String tick(String actionId, String channel, String dayPoint, bool return RpcUtil.request("alipay.ecolife.rpc.h5.tick", args1); } - public static String uploadDishImageBeforeMeals(String channel, String dayPoint) { - return RpcUtil.request("alipay.ecolife.rpc.h5.uploadDishImage", - "[{\"channel\":\"" + channel + "\",\"dayPoint\":\"" + dayPoint - + "\",\"source\":\"photo-comparison\",\"uploadParamMap\":{\"AIResult\":[{\"conf\":0.016113121,\"kvPair\":false,\"label\":\"other\",\"pos\":[1,0.2213781,0.0012539185,0.7786219],\"value\":\"\"},{\"conf\":0.00046864362,\"kvPair\":false,\"label\":\"guangpan\",\"pos\":[1,0.2213781,0.0012539185,0.7786219],\"value\":\"\"},{\"conf\":0.9834183,\"kvPair\":false,\"label\":\"feiguangpan\",\"pos\":[1,0.2213781,0.0012539185,0.7786219],\"value\":\"\"}],\"existAIResult\":true,\"imageId\":\"A*khE0QbDOJTsAAAAAAAAAAAAAAQAAAQ\",\"imageUrl\":\"https://mdn.alipayobjects.com/afts/img/A*khE0QbDOJTsAAAAAAAAAAAAAAQAAAQ/original?bz=APM_20000067\",\"operateType\":\"BEFORE_MEALS\"}}]"); - } - - public static String uploadDishImageAfterMeals(String channel, String dayPoint) { - return RpcUtil.request("alipay.ecolife.rpc.h5.uploadDishImage", - "[{\"channel\":\"" + channel + "\",\"dayPoint\":\"" + dayPoint - + "\",\"source\":\"photo-comparison\",\"uploadParamMap\":{\"AIResult\":[{\"conf\":0.00018646188,\"kvPair\":false,\"label\":\"other\",\"pos\":[1,0.2213781,0.0012539185,0.7786219],\"value\":\"\"},{\"conf\":0.9997553,\"kvPair\":false,\"label\":\"guangpan\",\"pos\":[1,0.2213781,0.0012539185,0.7786219],\"value\":\"\"},{\"conf\":0.00005811434,\"kvPair\":false,\"label\":\"feiguangpan\",\"pos\":[1,0.2213781,0.0012539185,0.7786219],\"value\":\"\"}],\"existAIResult\":true,\"imageId\":\"A*-r7VRbaQS_kAAAAAAAAAAAAAAQAAAQ\",\"imageUrl\":\"https://mdn.alipayobjects.com/afts/img/A*-r7VRbaQS_kAAAAAAAAAAAAAAQAAAQ/original?bz=APM_20000067\",\"operateType\":\"AFTER_MEALS\"}}]"); - } - public static String queryDish(String channel, String dayPoint) { return RpcUtil.request("alipay.ecolife.rpc.h5.queryDish", "[{\"channel\":\"" + channel + "\",\"dayPoint\":\"" + dayPoint diff --git a/app/src/main/java/pansong291/xposed/quickenergy/hook/FriendManager.java b/app/src/main/java/pansong291/xposed/quickenergy/hook/FriendManager.java index 6fb87971d..086027a5e 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/hook/FriendManager.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/hook/FriendManager.java @@ -89,7 +89,11 @@ public static void friendWatch(String id, int collectedEnergy) { private static void friendWatchSingle(String id, int collectedEnergy) throws JSONException { JSONObject joSingle = joFriendWatch.optJSONObject(id); if (joSingle == null) { - return; + joSingle = new JSONObject(); + joSingle.put("name", FriendIdMap.getNameById(id)); + joSingle.put("allGet", 0); + joSingle.put("startTime", TimeUtil.getDateStr()); + joFriendWatch.put(id, joSingle); } joSingle.put("weekGet", joSingle.optInt("weekGet", 0) + collectedEnergy); FileUtils.write2File(joFriendWatch.toString(), FileUtils.getFriendWatchFile()); @@ -109,7 +113,7 @@ private static void friendWatchNewWeek() { joSingle.put("name", FriendIdMap.getNameById(id)); joSingle.put("allGet", joSingle.optInt("allGet", 0) + joSingle.optInt("weekGet", 0)); joSingle.put("weekGet", 0); - if (joSingle.has("startTime")) { + if (!joSingle.has("startTime")) { joSingle.put("startTime", dateStr); } joFriendWatch.put(id, joSingle); diff --git a/app/src/main/java/pansong291/xposed/quickenergy/hook/RpcUtil.java b/app/src/main/java/pansong291/xposed/quickenergy/hook/RpcUtil.java index 24fa373be..a502dddf3 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/hook/RpcUtil.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/hook/RpcUtil.java @@ -107,7 +107,7 @@ public static String request(String args0, String args1) { } } } - } else if (msg.contains("请求不合法")) { + } else if (msg.contains("[1004]") && "alipay.antmember.forest.h5.collectEnergy".equals(args0)) { if (Config.waitWhenException() > 0) { long waitTime = System.currentTimeMillis() + Config.waitWhenException(); RuntimeInfo.getInstance().put(RuntimeInfo.RuntimeInfoKey.ForestPauseTime, waitTime); diff --git a/app/src/main/java/pansong291/xposed/quickenergy/hook/XposedHook.java b/app/src/main/java/pansong291/xposed/quickenergy/hook/XposedHook.java index 0737b6949..9c168c8de 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/hook/XposedHook.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/hook/XposedHook.java @@ -72,14 +72,10 @@ protected void beforeHookedMethod(MethodHookParam param) { private static void initHandler() { Log.recordLog("尝试初始化"); - if (handler == null) { - handler = new Handler(); - if (Config.startAt7()) { - Config.setAlarm7(AntForestToast.context); - } - } if (runnable == null) { - FriendManager.fillUser(XposedHook.classLoader); + if (!StringUtil.isEmpty(FriendIdMap.currentUid)) { + FriendManager.fillUser(XposedHook.classLoader); + } runnable = new Runnable() { @Override @@ -121,6 +117,12 @@ public void run() { } try { AntForestToast.show("芝麻粒加载成功"); + if (handler == null) { + handler = new Handler(); + if (Config.startAt7()) { + Config.setAlarm7(AntForestToast.context); + } + } handler.removeCallbacks(runnable); AntForest.stop(); AntForestNotification.stop(service, false); @@ -158,16 +160,10 @@ protected void afterHookedMethod(MethodHookParam param) { try { XposedHelpers.findAndHookMethod( "android.app.Service", loader, "onCreate", new XC_MethodHook() { - ClassLoader loader; - - public XC_MethodHook setData(ClassLoader cl) { - loader = cl; - return this; - } @SuppressLint("WakelockTimeout") @Override - protected void afterHookedMethod(MethodHookParam param) throws Throwable { + protected void afterHookedMethod(MethodHookParam param) { Service service = (Service) param.thisObject; if (!ClassMember.CURRENT_USING_SERVICE.equals(service.getClass().getCanonicalName())) { return; @@ -177,7 +173,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { registerBroadcastReceiver(service); XposedHook.service = service; AntForestToast.context = service.getApplicationContext(); - RpcUtil.init(loader); + RpcUtil.init(XposedHook.classLoader); if (Config.stayAwake()) { PowerManager pm = (PowerManager) service.getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, service.getClass().getName()); @@ -190,9 +186,8 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { } } initHandler(); - super.afterHookedMethod(param); } - }.setData(loader)); + }); Log.i(TAG, "hook onCreate successfully"); } catch (Throwable t) { Log.i(TAG, "hook onCreate err:"); @@ -213,7 +208,6 @@ protected void afterHookedMethod(MethodHookParam param) { AntForestNotification.stop(service, false); AntForestNotification.setContentText("支付宝前台服务被销毁"); Log.recordLog("支付宝前台服务被销毁", ""); - handler.removeCallbacks(runnable); alarmHook(AntForestToast.context, 3000, false); } }); @@ -327,25 +321,6 @@ public void onReceive(Context context, Intent intent) { restartHook(AntForestToast.context, force); } else if ("com.eg.android.AlipayGphone.xqe.test".equals(action)) { Log.recordLog("收到测试消息"); - try { - Class clsConfigService = XposedHelpers.findClass("com.alibaba.health.pedometer.core.datasource.sensor.core.ConfigService", XposedHook.classLoader); - - Object step_prevent_across_day_step = XposedHelpers.callStaticMethod(clsConfigService, "getBoolean", - "step_prevent_across_day_step", false); - Log.recordLog("step_prevent_across_day_step:" + step_prevent_across_day_step); - - Object step_prevent_across_day_time = XposedHelpers.callStaticMethod(clsConfigService, "getInt", - "step_prevent_across_day_time", 1); - Log.recordLog("step_prevent_across_day_time:" + step_prevent_across_day_time); - - Class cls = XposedHelpers.findClass("com.alibaba.health.pedometer.core.trigger.TriggerPointAgent", XposedHook.classLoader); - Object instance = XposedHelpers.callStaticMethod(cls, "getInstance"); - Object ts = XposedHelpers.callMethod(instance, "getTimeStamp"); - Log.recordLog("ts:" + ts); - } catch (Throwable th) { - Log.printStackTrace(TAG, th); - } - // alarmHook(AntForestToast.context, 3000, true); } else if ("com.eg.android.AlipayGphone.xqe.cancelAlarm7".equals(action)) { Config.cancelAlarm7(AntForestToast.context, false); diff --git a/app/src/main/java/pansong291/xposed/quickenergy/ui/SettingsActivity.java b/app/src/main/java/pansong291/xposed/quickenergy/ui/SettingsActivity.java index dc875c88c..67fceef37 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/ui/SettingsActivity.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/ui/SettingsActivity.java @@ -44,7 +44,8 @@ public class SettingsActivity extends Activity { sw_kitchen, sw_antOcean, sw_userPatrol, sw_animalConsumeProp, sw_antOrchard, sw_receiveOrchardTaskAward, sw_enableOnGoing, sw_backupRuntime, sw_collectSesame, sw_zcjSignIn, sw_merchantKmdk, sw_acceptGift, sw_enableStall, sw_stallAutoClose, sw_stallAutoOpen, sw_stallAutoTask, sw_stallReceiveAward, - sw_stallOpenType, sw_stallDonate, sw_chickenDiary, sw_collectGiftBox, sw_stallInviteRegister; + sw_stallOpenType, sw_stallDonate, sw_chickenDiary, sw_collectGiftBox, sw_stallInviteRegister, + sw_stallThrowManure; @Override protected void onCreate(Bundle savedInstanceState) { @@ -219,6 +220,7 @@ private void initSwitch() { sw_stallOpenType = findViewById(R.id.sw_stallOpenType); sw_stallDonate = findViewById(R.id.sw_stallDonate); sw_stallInviteRegister = findViewById(R.id.sw_stallInviteRegister); + sw_stallThrowManure = findViewById(R.id.sw_stallThrowManure); } @Override @@ -290,6 +292,7 @@ protected void onResume() { sw_stallOpenType.setChecked(Config.stallOpenType()); sw_stallDonate.setChecked(Config.stallDonate()); sw_stallInviteRegister.setChecked(Config.stallInviteRegister()); + sw_stallThrowManure.setChecked(Config.stallThrowManure()); } @SuppressLint("NonConstantResourceId") @@ -552,6 +555,10 @@ public void onClick(View v) { case R.id.sw_stallInviteRegister: Config.setStallInviteRegister(sw.isChecked()); break; + + case R.id.sw_stallThrowManure: + Config.setStallThrowManure(sw.isChecked()); + break; } } else if (v instanceof Button) { Button btn = (Button) v; @@ -690,19 +697,6 @@ public void onClick(View v) { EditDialog.showEditDialog(this, btn.getText(), EditDialog.EditMode.ANIMAL_SLEEP_TIME); break; - case R.id.btn_donation_developer: - new AlertDialog.Builder(this) - .setView(R.layout.donation_view) - .setPositiveButton("关闭", null) - .create().show(); - break; - - case R.id.btn_donation_xqe_developer: - Intent it2 = new Intent(Intent.ACTION_VIEW, Uri.parse( - "alipays://platformapi/startapp?saId=10000007&qrcode=https%3A%2F%2Fqr.alipay.com%2Ftsx00339eflkuhhtfctcn48")); - startActivity(it2); - break; - case R.id.btn_minExchangeCount: EditDialog.showEditDialog(this, btn.getText(), EditDialog.EditMode.MIN_EXCHANGE_COUNT); break; @@ -749,6 +743,10 @@ public void onClick(View v) { case R.id.btn_stallSelfOpenTime: EditDialog.showEditDialog(this, btn.getText(), EditDialog.EditMode.STALL_SELF_OPEN_TIME); break; + + case R.id.btn_stallInviteShopList: + ListDialog.show(this, btn.getText(), AlipayUser.getList(), Config.stallInviteShopList(), null); + break; } } } diff --git a/app/src/main/java/pansong291/xposed/quickenergy/util/Config.java b/app/src/main/java/pansong291/xposed/quickenergy/util/Config.java index 744f5dd94..67fadf116 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/util/Config.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/util/Config.java @@ -124,6 +124,8 @@ public CharSequence nickName() { public static final String jn_stallSelfOpenTime = "tallSelfOpenTime"; public static final String jn_stallDonate = "stallDonate"; public static final String jn_stallInviteRegister = "stallInviteRegister"; + public static final String jn_stallThrowManure = "stallThrowManure"; + public static final String jn_stallInviteShopList = "stallInviteShopList"; /* other */ public static final String jn_receivePoint = "receivePoint"; @@ -254,6 +256,8 @@ public CharSequence nickName() { private int stallSelfOpenTime; private boolean stallDonate; private boolean stallInviteRegister; + private boolean stallThrowManure; + private List stallInviteShopList; /* other */ private boolean receivePoint; @@ -1104,10 +1108,23 @@ public static void setStallInviteRegister(boolean b) { hasChanged = true; } + public static List stallInviteShopList() { + return getConfig().stallInviteShopList; + } + public static boolean stallInviteRegister() { return getConfig().stallInviteRegister; } + public static void setStallThrowManure(boolean b) { + getConfig().stallThrowManure = b; + hasChanged = true; + } + + public static boolean stallThrowManure() { + return getConfig().stallThrowManure; + } + /* other */ public static void setReceivePoint(boolean b) { getConfig().receivePoint = b; @@ -1387,6 +1404,8 @@ public static Config defInit() { c.stallSelfOpenTime = 120; c.stallDonate = false; c.stallInviteRegister = false; + c.stallThrowManure = false; + c.stallInviteShopList = new ArrayList<>(); c.receivePoint = true; c.openTreasureBox = true; @@ -1833,6 +1852,16 @@ public static Config json2Config(String json) { config.stallInviteRegister = jo.optBoolean(jn_stallInviteRegister, true); + config.stallThrowManure = jo.optBoolean(jn_stallThrowManure, false); + + config.stallInviteShopList = new ArrayList<>(); + if (jo.has(jn_stallInviteShopList)) { + ja = jo.getJSONArray(jn_stallInviteShopList); + for (int i = 0; i < ja.length(); i++) { + config.stallInviteShopList.add(ja.getString(i)); + } + } + /* other */ config.receivePoint = jo.optBoolean(jn_receivePoint, true); Log.i(TAG, jn_receivePoint + ":" + config.receivePoint); @@ -1879,7 +1908,7 @@ public static Config json2Config(String json) { Log.printStackTrace(TAG, t); if (json != null) { Log.i(TAG, "配置文件格式有误,已重置配置文件并备份原文件"); - Log.infoChanged("配置文件格式有误,已重置配置文件并备份原文件", json); + Log.infoChanged(TAG, "配置文件格式有误,已重置配置文件并备份原文件"); FileUtils.write2File(json, FileUtils.getBackupFile(FileUtils.getConfigFile())); } config = defInit(); @@ -1887,8 +1916,7 @@ public static Config json2Config(String json) { String formatted = config2Json(config); if (!formatted.equals(json)) { Log.i(TAG, "重新格式化 config.json"); - Log.infoChanged("重新格式化 config.json,原", json); - Log.infoChanged("重新格式化 config.json,新", formatted); + Log.infoChanged(TAG, "重新格式化 config.json"); FileUtils.write2File(formatted, FileUtils.getConfigFile()); } return config; @@ -2159,6 +2187,12 @@ public static String config2Json(Config config) { jo.put(jn_stallSelfOpenTime, config.stallSelfOpenTime); jo.put(jn_stallDonate, config.stallDonate); jo.put(jn_stallInviteRegister, config.stallInviteRegister); + jo.put(jn_stallThrowManure, config.stallThrowManure); + ja = new JSONArray(); + for (int i = 0; i < config.stallInviteShopList.size(); i++) { + ja.put(config.stallInviteShopList.get(i)); + } + jo.put(jn_stallInviteShopList, ja); /* other */ jo.put(jn_receivePoint, config.receivePoint); diff --git a/app/src/main/java/pansong291/xposed/quickenergy/util/FileUtils.java b/app/src/main/java/pansong291/xposed/quickenergy/util/FileUtils.java index 3057db825..c6f7a9ba3 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/util/FileUtils.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/util/FileUtils.java @@ -119,6 +119,11 @@ public static File getConfigFile() { public static File getConfigFile(String userId) { if (!configFileMap.containsKey("Default")) { File configFile = new File(getMainDirectoryFile(), "config.json"); + if (configFile.exists()) { + Log.i(TAG, "读:" + configFile.canRead() + ";写:" + configFile.canWrite()); + } else { + Log.i(TAG, "config.json文件不存在"); + } configFileMap.put("Default", configFile); } if (!StringUtil.isEmpty(userId)) { @@ -189,6 +194,12 @@ public static File getStatisticsFile() { statisticsFile = new File(getMainDirectoryFile(), "statistics.json"); if (statisticsFile.exists() && statisticsFile.isDirectory()) statisticsFile.delete(); + + if (statisticsFile.exists()) { + Log.i(TAG, "读:" + statisticsFile.canRead() + ";写:" + statisticsFile.canWrite()); + } else { + Log.i(TAG, "statisticsFile.json文件不存在"); + } } return statisticsFile; } diff --git a/app/src/main/java/pansong291/xposed/quickenergy/util/PluginUtils.java b/app/src/main/java/pansong291/xposed/quickenergy/util/PluginUtils.java index 6f9b0f4f7..8b3eaa3a6 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/util/PluginUtils.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/util/PluginUtils.java @@ -35,8 +35,7 @@ public static void invoke(Class cls, PluginAction action) { if (!pluginMap.containsKey(pluginName)) { try { plugin = (AbsPlugin) Class.forName(pluginName).newInstance(); - } catch (Throwable e) { - Log.printStackTrace(pluginName, e); + } catch (Throwable ignored) { } pluginMap.put(pluginName, plugin); } else { diff --git a/app/src/main/java/pansong291/xposed/quickenergy/util/Statistics.java b/app/src/main/java/pansong291/xposed/quickenergy/util/Statistics.java index a8980e354..bf7c188a1 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/util/Statistics.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/util/Statistics.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.HashSet; +import java.util.List; import java.util.Set; import org.json.JSONArray; @@ -77,6 +78,26 @@ public VisitFriendLog(String id) { } } + private static class StallShareIdLog { + String userId; + String shareId; + + public StallShareIdLog(String uid, String sid) { + userId = uid; + shareId = sid; + } + } + + private static class StallHelpedCountLog { + String userId; + int helpedCount = 0; + int beHelpedCount = 0; + + public StallHelpedCountLog(String id) { + userId = id; + } + } + private static final String TAG = Statistics.class.getCanonicalName(); private static final String jn_year = "year", jn_month = "month", jn_day = "day", jn_collected = "collected", jn_helped = "helped", jn_watered = "watered", @@ -86,7 +107,9 @@ public VisitFriendLog(String id) { jn_memberSignInList = "memberSignInList", jn_kbSignIn = "kbSignIn", jn_exchangeDoubleCard = "exchangeDoubleCard", jn_exchangeTimes = "exchangeTimes", jn_dailyAnswerList = "dailyAnswerList", jn_doubleTimes = "doubleTimes", - jn_SpreadManureList = "SpreadManureList", jn_protectBubbleList = "protectBubbleList"; + jn_spreadManureList = "spreadManureList", jn_protectBubbleList = "protectBubbleList", + jn_stallShareIdList = "stallShareIdList", jn_stallP2PHelpedList = "stallP2PHelpedList", + jn_stallHelpedCountList = "stallHelpedCountList"; private TimeStatistics year; private TimeStatistics month; @@ -111,9 +134,12 @@ public VisitFriendLog(String id) { private String questionHint; private ArrayList feedFriendLogList; private ArrayList visitFriendLogList; + private ArrayList stallShareIdLogList; + private ArrayList stallHelpedCountLogList; private Set dailyAnswerList; private ArrayList donationEggList; - private ArrayList SpreadManureList; + private ArrayList spreadManureList; + private ArrayList stallP2PHelpedList; // other private ArrayList memberSignInList; @@ -433,6 +459,124 @@ public static void visitFriendToday(String id, int count) { save(); } + public static List stallP2PUserIdList(String uid) { + List p2pUserIdList = new ArrayList<>(); + Statistics stat = getStatistics(); + for (int i = 0; i < stat.stallShareIdLogList.size(); i++) + if (!stat.stallShareIdLogList.get(i).userId.equals(uid)) { + p2pUserIdList.add(stat.stallShareIdLogList.get(i).userId); + } + return p2pUserIdList; + } + + public static void stallShareIdToday(String uid, String sid) { + Statistics stat = getStatistics(); + StallShareIdLog ssil; + int index = -1; + for (int i = 0; i < stat.stallShareIdLogList.size(); i++) + if (stat.stallShareIdLogList.get(i).userId.equals(uid)) { + index = i; + break; + } + if (index < 0) { + ssil = new StallShareIdLog(uid, sid); + stat.stallShareIdLogList.add(ssil); + } else { + ssil = stat.stallShareIdLogList.get(index); + } + ssil.shareId = sid; + save(); + } + + public static String getStallShareId(String uid) { + Statistics stat = getStatistics(); + int index = -1; + for (int i = 0; i < stat.stallShareIdLogList.size(); i++) + if (stat.stallShareIdLogList.get(i).userId.equals(uid)) { + index = i; + break; + } + if (index < 0) { + return null; + } else { + return stat.stallShareIdLogList.get(index).shareId; + } + } + + public static boolean canStallHelpToday(String id) { + Statistics stat = getStatistics(); + int index = -1; + for (int i = 0; i < stat.stallHelpedCountLogList.size(); i++) + if (stat.stallHelpedCountLogList.get(i).userId.equals(id)) { + index = i; + break; + } + if (index < 0) + return true; + StallHelpedCountLog shcl = stat.stallHelpedCountLogList.get(index); + return shcl.helpedCount < 3; + } + + public static void stallHelpToday(String id, boolean limited) { + Statistics stat = getStatistics(); + StallHelpedCountLog shcl; + int index = -1; + for (int i = 0; i < stat.stallHelpedCountLogList.size(); i++) + if (stat.stallHelpedCountLogList.get(i).userId.equals(id)) { + index = i; + break; + } + if (index < 0) { + shcl = new StallHelpedCountLog(id); + stat.stallHelpedCountLogList.add(shcl); + } else { + shcl = stat.stallHelpedCountLogList.get(index); + } + if (limited) { + shcl.helpedCount = 3; + } else { + shcl.helpedCount += 1; + } + save(); + } + + public static boolean canStallBeHelpToday(String id) { + Statistics stat = getStatistics(); + int index = -1; + for (int i = 0; i < stat.stallHelpedCountLogList.size(); i++) + if (stat.stallHelpedCountLogList.get(i).userId.equals(id)) { + index = i; + break; + } + if (index < 0) + return true; + StallHelpedCountLog shcl = stat.stallHelpedCountLogList.get(index); + return shcl.beHelpedCount < 3; + } + + public static void stallBeHelpToday(String id, boolean limited) { + Statistics stat = getStatistics(); + StallHelpedCountLog shcl; + int index = -1; + for (int i = 0; i < stat.stallHelpedCountLogList.size(); i++) + if (stat.stallHelpedCountLogList.get(i).userId.equals(id)) { + index = i; + break; + } + if (index < 0) { + shcl = new StallHelpedCountLog(id); + stat.stallHelpedCountLogList.add(shcl); + } else { + shcl = stat.stallHelpedCountLogList.get(index); + } + if (limited) { + shcl.beHelpedCount = 3; + } else { + shcl.beHelpedCount += 1; + } + save(); + } + public static boolean canMemberSignInToday(String uid) { Statistics stat = getStatistics(); return !stat.memberSignInList.contains(uid); @@ -461,13 +605,28 @@ public static void donationEgg(String uid) { public static boolean canSpreadManureToday(String uid) { Statistics stat = getStatistics(); - return !stat.SpreadManureList.contains(uid); + return !stat.spreadManureList.contains(uid); } public static void spreadManureToday(String uid) { Statistics stat = getStatistics(); - if (!stat.SpreadManureList.contains(uid)) { - stat.SpreadManureList.add(uid); + if (!stat.spreadManureList.contains(uid)) { + stat.spreadManureList.add(uid); + save(); + } + } + + public static boolean canStallP2PHelpToday(String uid) { + uid = FriendIdMap.currentUid + "-" + uid; + Statistics stat = getStatistics(); + return !stat.stallP2PHelpedList.contains(uid); + } + + public static void stallP2PHelpeToday(String uid) { + uid = FriendIdMap.currentUid + "-" + uid; + Statistics stat = getStatistics(); + if (!stat.stallP2PHelpedList.contains(uid)) { + stat.stallP2PHelpedList.add(uid); save(); } } @@ -619,6 +778,7 @@ public static void resetToday() { } private static void dayClear() { + Log.infoChanged(TAG,"重置 statistics.json"); Statistics stat = getStatistics(); stat.waterFriendLogList.clear(); stat.cooperateWaterList.clear(); @@ -631,9 +791,11 @@ private static void dayClear() { stat.answerQuestionList.clear(); stat.feedFriendLogList.clear(); stat.visitFriendLogList.clear(); + stat.stallHelpedCountLogList.clear(); stat.questionHint = null; stat.donationEggList.clear(); - stat.SpreadManureList.clear(); + stat.spreadManureList.clear(); + stat.stallP2PHelpedList.clear(); stat.memberSignInList.clear(); stat.kbSignIn = 0; stat.exchangeDoubleCard = 0; @@ -660,14 +822,20 @@ private static Statistics defInit() { stat.answerQuestionList = new ArrayList<>(); if (stat.donationEggList == null) stat.donationEggList = new ArrayList<>(); - if (stat.SpreadManureList == null) - stat.SpreadManureList = new ArrayList<>(); + if (stat.spreadManureList == null) + stat.spreadManureList = new ArrayList<>(); + if (stat.stallP2PHelpedList == null) + stat.stallP2PHelpedList = new ArrayList<>(); if (stat.memberSignInList == null) stat.memberSignInList = new ArrayList<>(); if (stat.feedFriendLogList == null) stat.feedFriendLogList = new ArrayList<>(); if (stat.visitFriendLogList == null) stat.visitFriendLogList = new ArrayList<>(); + if (stat.stallShareIdLogList == null) + stat.stallShareIdLogList = new ArrayList<>(); + if (stat.stallHelpedCountLogList == null) + stat.stallHelpedCountLogList = new ArrayList<>(); if (stat.ancientTreeCityCodeList == null) stat.ancientTreeCityCodeList = new ArrayList<>(); if (stat.syncStepList == null) @@ -852,6 +1020,29 @@ private static Statistics json2Statistics(String json) { } } + stat.stallShareIdLogList = new ArrayList<>(); + if (jo.has(jn_stallShareIdList)) { + JSONArray ja = jo.getJSONArray(jn_stallShareIdList); + for (int i = 0; i < ja.length(); i++) { + JSONArray jaa = ja.getJSONArray(i); + StallShareIdLog ssil = new StallShareIdLog(jaa.getString(0), jaa.getString(1)); + stat.stallShareIdLogList.add(ssil); + } + } + + stat.stallHelpedCountLogList = new ArrayList<>(); + if (jo.has(jn_stallHelpedCountList)) { + JSONArray ja = jo.getJSONArray(jn_stallHelpedCountList); + for (int i = 0; i < ja.length(); i++) { + JSONArray jaa = ja.getJSONArray(i); + StallHelpedCountLog shcl = new StallHelpedCountLog(jaa.getString(0)); + shcl.helpedCount = jaa.getInt(1); + shcl.beHelpedCount = jaa.getInt(2); + stat.stallHelpedCountLogList.add(shcl); + + } + } + stat.donationEggList = new ArrayList<>(); if (jo.has(jn_donationEggList)) { JSONArray ja = jo.getJSONArray(jn_donationEggList); @@ -861,11 +1052,20 @@ private static Statistics json2Statistics(String json) { } } - stat.SpreadManureList = new ArrayList<>(); - if (jo.has(jn_SpreadManureList)) { - JSONArray ja = jo.getJSONArray(jn_SpreadManureList); + stat.spreadManureList = new ArrayList<>(); + if (jo.has(jn_spreadManureList)) { + JSONArray ja = jo.getJSONArray(jn_spreadManureList); for (int i = 0; i < ja.length(); i++) { - stat.SpreadManureList.add(ja.getString(i)); + stat.spreadManureList.add(ja.getString(i)); + + } + } + + stat.stallP2PHelpedList = new ArrayList<>(); + if (jo.has(jn_stallP2PHelpedList)) { + JSONArray ja = jo.getJSONArray(jn_stallP2PHelpedList); + for (int i = 0; i < ja.length(); i++) { + stat.stallP2PHelpedList.add(ja.getString(i)); } } @@ -904,7 +1104,7 @@ private static Statistics json2Statistics(String json) { Log.printStackTrace(TAG, t); if (json != null) { Log.i(TAG, "统计文件格式有误,已重置统计文件并备份原文件"); - Log.infoChanged("统计文件格式有误,已重置统计文件并备份原文件", json); + Log.infoChanged(TAG, "统计文件格式有误,已重置统计文件并备份原文件"); FileUtils.write2File(json, FileUtils.getBackupFile(FileUtils.getStatisticsFile())); } stat = defInit(); @@ -912,7 +1112,7 @@ private static Statistics json2Statistics(String json) { String formatted = statistics2Json(stat); if (!formatted.equals(json)) { Log.i(TAG, "重新格式化 statistics.json"); - Log.infoChanged("重新格式化 statistics.json", json); + Log.infoChanged(TAG, "重新格式化 statistics.json"); FileUtils.write2File(formatted, FileUtils.getStatisticsFile()); } return stat; @@ -1040,6 +1240,27 @@ private static String statistics2Json(Statistics stat) { } jo.put(Config.jn_visitFriendList, ja); + ja = new JSONArray(); + for (int i = 0; i < stat.stallShareIdLogList.size(); i++) { + StallShareIdLog ssil = stat.stallShareIdLogList.get(i); + JSONArray jaa = new JSONArray(); + jaa.put(ssil.userId); + jaa.put(ssil.shareId); + ja.put(jaa); + } + jo.put(jn_stallShareIdList, ja); + + ja = new JSONArray(); + for (int i = 0; i < stat.stallHelpedCountLogList.size(); i++) { + StallHelpedCountLog shcl = stat.stallHelpedCountLogList.get(i); + JSONArray jaa = new JSONArray(); + jaa.put(shcl.userId); + jaa.put(shcl.helpedCount); + jaa.put(shcl.beHelpedCount); + ja.put(jaa); + } + jo.put(jn_stallHelpedCountList, ja); + ja = new JSONArray(); for (int i = 0; i < stat.donationEggList.size(); i++) { ja.put(stat.donationEggList.get(i)); @@ -1047,10 +1268,16 @@ private static String statistics2Json(Statistics stat) { jo.put(jn_donationEggList, ja); ja = new JSONArray(); - for (int i = 0; i < stat.SpreadManureList.size(); i++) { - ja.put(stat.SpreadManureList.get(i)); + for (int i = 0; i < stat.spreadManureList.size(); i++) { + ja.put(stat.spreadManureList.get(i)); + } + jo.put(jn_spreadManureList, ja); + + ja = new JSONArray(); + for (int i = 0; i < stat.stallP2PHelpedList.size(); i++) { + ja.put(stat.stallP2PHelpedList.get(i)); } - jo.put(jn_SpreadManureList, ja); + jo.put(jn_stallP2PHelpedList, ja); ja = new JSONArray(); for (int i = 0; i < stat.memberSignInList.size(); i++) { @@ -1080,7 +1307,7 @@ private static String statistics2Json(Statistics stat) { private static void save() { String json = statistics2Json(getStatistics()); - Log.infoChanged("保存 statistics.json", json); + Log.infoChanged(TAG,"保存 statistics.json"); FileUtils.write2File(json, FileUtils.getStatisticsFile()); } diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 416e3251e..51d00c23f 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -1132,6 +1132,30 @@ android:minHeight="50dp" android:id="@+id/sw_stallInviteRegister" /> + + +