From ebbc54c437c1a889d271b335903d5db49c386cd7 Mon Sep 17 00:00:00 2001 From: Magical Yang Date: Tue, 10 Oct 2023 15:03:24 +0800 Subject: [PATCH 01/29] =?UTF-8?q?=E6=94=B6=E5=8F=96=E5=A4=8D=E6=B4=BB?= =?UTF-8?q?=E9=87=91=E7=90=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 4 +- .../xposed/quickenergy/AntForest.java | 41 ++-- .../xposed/quickenergy/data/RuntimeInfo.java | 51 +++-- .../quickenergy/hook/AntForestRpcCall.java | 4 + .../quickenergy/hook/AntOrchardRpcCall.java | 2 +- .../xposed/quickenergy/hook/XposedHook.java | 22 ++- .../xposed/quickenergy/util/Config.java | 186 +++++++++--------- .../xposed/quickenergy/util/FileUtils.java | 8 +- 8 files changed, 173 insertions(+), 145 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index bfe9fd635..7729057a6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { minSdk 21 //noinspection ExpiredTargetSdkVersion targetSdk 29 - versionCode 67 - versionName "1.2.1" + versionCode 69 + versionName "1.2.2" } buildTypes { release { diff --git a/app/src/main/java/pansong291/xposed/quickenergy/AntForest.java b/app/src/main/java/pansong291/xposed/quickenergy/AntForest.java index 681a154a6..5c8ba91d3 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/AntForest.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/AntForest.java @@ -403,25 +403,42 @@ private static void canCollectSelfEnergy() { if (wateringBubbles.length() > 0) { int collected = 0; for (int i = 0; i < wateringBubbles.length(); i++) { - String str = AntForestRpcCall.collectEnergy("jiaoshui", selfId, - wateringBubbles.getJSONObject(i).getLong("id")); - JSONObject joEnergy = new JSONObject(str); - if ("SUCCESS".equals(joEnergy.getString("resultCode"))) { - JSONArray bubbles = joEnergy.getJSONArray("bubbles"); - for (int j = 0; j < bubbles.length(); j++) { - collected = bubbles.getJSONObject(j).getInt("collectedEnergy"); + JSONObject wateringBubble = wateringBubbles.getJSONObject(i); + String bizType = wateringBubble.getString("bizType"); + if ("jiaoshui".equals(bizType)) { + String str = AntForestRpcCall.collectEnergy(bizType, selfId, + wateringBubble.getLong("id")); + JSONObject joEnergy = new JSONObject(str); + if ("SUCCESS".equals(joEnergy.getString("resultCode"))) { + JSONArray bubbles = joEnergy.getJSONArray("bubbles"); + for (int j = 0; j < bubbles.length(); j++) { + collected = bubbles.getJSONObject(j).getInt("collectedEnergy"); + } + if (collected > 0) { + totalCollected += collected; + Statistics.addData(Statistics.DataType.COLLECTED, collected); + String msg = "收取金球🍯浇水[" + collected + "g]"; + Log.forest(msg); + AntForestToast.show(msg); + } else { + Log.recordLog("收取[我]的浇水金球失败", ""); + } + } else { + Log.recordLog("收取[我]的浇水金球失败:" + joEnergy.getString("resultDesc"), str); } - if (collected > 0) { + } else if ("fuhuo".equals(bizType)) { + String str = AntForestRpcCall.collectRebornEnergy(); + JSONObject joEnergy = new JSONObject(str); + if ("SUCCESS".equals(joEnergy.getString("resultCode"))) { + collected = joEnergy.getInt("energy"); totalCollected += collected; Statistics.addData(Statistics.DataType.COLLECTED, collected); - String msg = "收取金球🍯[" + collected + "g]"; + String msg = "收取金球🍯复活[" + collected + "g]"; Log.forest(msg); AntForestToast.show(msg); } else { - Log.recordLog("收取[我]的金球失败", ""); + Log.recordLog("收取[我]的复活金球失败:" + joEnergy.getString("resultDesc"), str); } - } else { - Log.recordLog("收取[我]的金球失败:" + joEnergy.getString("resultDesc"), str); } Thread.sleep(1000L); } diff --git a/app/src/main/java/pansong291/xposed/quickenergy/data/RuntimeInfo.java b/app/src/main/java/pansong291/xposed/quickenergy/data/RuntimeInfo.java index a899b4e4e..84ec4572e 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/data/RuntimeInfo.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/data/RuntimeInfo.java @@ -1,12 +1,11 @@ package pansong291.xposed.quickenergy.data; +import org.json.JSONException; import org.json.JSONObject; import pansong291.xposed.quickenergy.util.FileUtils; import pansong291.xposed.quickenergy.util.FriendIdMap; +import pansong291.xposed.quickenergy.util.Log; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; import java.util.Objects; /** @@ -14,6 +13,7 @@ * @since 2023/08/18 */ public class RuntimeInfo { + private static final String TAG = RuntimeInfo.class.getCanonicalName(); private static RuntimeInfo instance; @@ -21,7 +21,9 @@ public class RuntimeInfo { private final String userId; - private final Map map; + private JSONObject joAll; + + private JSONObject joCurrent; public enum RuntimeInfoKey { ForestPauseTime @@ -36,41 +38,38 @@ public static RuntimeInfo getInstance() { private RuntimeInfo() { userId = FriendIdMap.currentUid; String content = FileUtils.readFromFile(FileUtils.runtimeInfoFile()); - map = new HashMap<>(); try { - JSONObject jo = new JSONObject(content); - if (jo.has(userId)) { - JSONObject userInfo = jo.getJSONObject(userId); - for (Iterator it = userInfo.keys(); it.hasNext(); ) { - String key = it.next(); - map.put(key, userInfo.get(key)); - } + joAll = new JSONObject(content); + if (!joAll.has(userId)) { + joAll.put(userId, new JSONObject()); } + joCurrent = joAll.getJSONObject(userId); } catch (Exception ignored) { } } - public Object get(RuntimeInfoKey key) { - if (!map.containsKey(key.name())) { - return null; - } - return map.get(key.name()); + public void save() { + FileUtils.write2File(joAll.toString(), FileUtils.runtimeInfoFile()); + } + + public Object get(RuntimeInfoKey key) throws JSONException { + return joCurrent.opt(key.name()); } public String getString(RuntimeInfoKey key) { - if (!map.containsKey(key.name())) { - return null; - } - return (String) map.get(key.name()); + return joCurrent.optString(key.name()); } public Long getLong(RuntimeInfoKey key) { - if (!map.containsKey(key.name())) { - return 0L; - } - return (Long) map.get(key.name()); + return joCurrent.optLong(key.name(), 0L); } public void put(RuntimeInfoKey key, Object value) { - map.put(key.name(), value); + try { + joCurrent.put(key.name(), value); + } catch (JSONException e) { + Log.i(TAG, "put err:"); + Log.printStackTrace(TAG, e); + } + save(); } } 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 ad44ec2d1..935e139c3 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/hook/AntForestRpcCall.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/hook/AntForestRpcCall.java @@ -50,6 +50,10 @@ public static String collectEnergy(String bizType, String userId, long bubbleId) return RpcUtil.request("alipay.antmember.forest.h5.collectEnergy", args1); } + public static String collectRebornEnergy() { + return RpcUtil.request("alipay.antforest.forest.h5.collectRebornEnergy", "[{\"source\":\"chInfo_ch_appcenter__chsub_9patch\"}]"); + } + public static String transferEnergy(String targetUser, String bizNo, int energyId) { return RpcUtil.request("alipay.antmember.forest.h5.transferEnergy", "[{\"bizNo\":\"" + bizNo + UUID.randomUUID().toString() + "\",\"energyId\":" + energyId + diff --git a/app/src/main/java/pansong291/xposed/quickenergy/hook/AntOrchardRpcCall.java b/app/src/main/java/pansong291/xposed/quickenergy/hook/AntOrchardRpcCall.java index f45f379b9..f6c7b53dd 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/hook/AntOrchardRpcCall.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/hook/AntOrchardRpcCall.java @@ -1,7 +1,7 @@ package pansong291.xposed.quickenergy.hook; public class AntOrchardRpcCall { - private static final String VERSION = "0.1.2308151427.44"; + private static final String VERSION = "0.1.2309201826.34"; public static String orchardIndex() { return RpcUtil.request("com.alipay.antfarm.orchardIndex", 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 c9762e02b..dbb5d19bb 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/hook/XposedHook.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/hook/XposedHook.java @@ -60,15 +60,17 @@ protected void beforeHookedMethod(MethodHookParam param) { }); } - if (!isHooked && ClassMember.PACKAGE_NAME.equals(lpparam.packageName)) { - RuntimeInfo.process = lpparam.packageName; - isHooked = true; - Log.i(TAG, lpparam.packageName); - classLoader = lpparam.classLoader; - hookRpcCall(); - hookStep(); - hookService(lpparam.classLoader); - PluginUtils.invoke(XposedHook.class, PluginUtils.PluginAction.INIT); + if (ClassMember.PACKAGE_NAME.equals(lpparam.processName) && ClassMember.PACKAGE_NAME.equals(lpparam.packageName)) { + if (!isHooked) { + RuntimeInfo.process = lpparam.packageName; + isHooked = true; + Log.i(TAG, lpparam.packageName); + classLoader = lpparam.classLoader; + hookRpcCall(); + hookStep(); + hookService(lpparam.classLoader); + PluginUtils.invoke(XposedHook.class, PluginUtils.PluginAction.INIT); + } } } @@ -143,6 +145,7 @@ private void hookService(ClassLoader loader) { "onResume", new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) { + Log.i(TAG, "Activity onResume"); RpcUtil.isInterrupted = false; AntForestNotification.setContentText("运行中..."); String targetUid = RpcUtil.getUserId(loader); @@ -171,6 +174,7 @@ protected void afterHookedMethod(MethodHookParam param) { if (!ClassMember.CURRENT_USING_SERVICE.equals(service.getClass().getCanonicalName())) { return; } + Log.i(TAG, "Service onCreate"); RpcUtil.isInterrupted = false; AntForestNotification.setContentText("运行中..."); registerBroadcastReceiver(service); 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 08e90c55a..618060ae6 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/util/Config.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/util/Config.java @@ -1469,59 +1469,59 @@ public static Config json2Config(String json) { config = new Config(); config.immediateEffect = jo.optBoolean(jn_immediateEffect, true); - Log.i(TAG, jn_immediateEffect + ":" + config.immediateEffect); + //Log.i(TAG, jn_immediateEffect + ":" + config.immediateEffect); config.recordLog = jo.optBoolean(jn_recordLog, true); - Log.i(TAG, jn_recordLog + ":" + config.recordLog); + //Log.i(TAG, jn_recordLog + ":" + config.recordLog); config.showToast = jo.optBoolean(jn_showToast, true); - Log.i(TAG, jn_showToast + ":" + config.showToast); + //Log.i(TAG, jn_showToast + ":" + config.showToast); config.toastOffsetY = jo.optInt(jn_toastOffsetY, 0); - Log.i(TAG, jn_toastOffsetY + ":" + config.toastOffsetY); + //Log.i(TAG, jn_toastOffsetY + ":" + config.toastOffsetY); config.stayAwake = jo.optBoolean(jn_stayAwake, true); - Log.i(TAG, jn_stayAwake + ":" + config.stayAwake); + //Log.i(TAG, jn_stayAwake + ":" + config.stayAwake); config.stayAwakeType = XposedHook.StayAwakeType .valueOf(jo.optString(jn_stayAwakeType, XposedHook.StayAwakeType.BROADCAST.name())); - Log.i(TAG, jn_stayAwakeType + ":" + config.stayAwakeType); + //Log.i(TAG, jn_stayAwakeType + ":" + config.stayAwakeType); config.stayAwakeTarget = XposedHook.StayAwakeTarget .valueOf(jo.optString(jn_stayAwakeTarget, XposedHook.StayAwakeTarget.SERVICE.name())); - Log.i(TAG, jn_stayAwakeTarget + ":" + config.stayAwakeTarget); + //Log.i(TAG, jn_stayAwakeTarget + ":" + config.stayAwakeTarget); config.timeoutRestart = jo.optBoolean(jn_timeoutRestart, true); - Log.i(TAG, jn_timeoutRestart + ":" + config.timeoutRestart); + //Log.i(TAG, jn_timeoutRestart + ":" + config.timeoutRestart); config.timeoutType = XposedHook.StayAwakeType .valueOf(jo.optString(jn_timeoutType, XposedHook.StayAwakeType.BROADCAST.name())); - Log.i(TAG, jn_timeoutType + ":" + config.timeoutType); + //Log.i(TAG, jn_timeoutType + ":" + config.timeoutType); config.startAt7 = jo.optBoolean(jn_startAt7, false); - Log.i(TAG, jn_startAt7 + ":" + config.startAt7); + //Log.i(TAG, jn_startAt7 + ":" + config.startAt7); config.enableOnGoing = jo.optBoolean(jn_enableOnGoing, false); - Log.i(TAG, jn_enableOnGoing + ":" + config.enableOnGoing); + //Log.i(TAG, jn_enableOnGoing + ":" + config.enableOnGoing); config.backupRuntime = jo.optBoolean(jn_backupRuntime, false); - Log.i(TAG, jn_backupRuntime + ":" + config.backupRuntime); + //Log.i(TAG, jn_backupRuntime + ":" + config.backupRuntime); /* forest */ config.collectEnergy = jo.optBoolean(jn_collectEnergy, false); - Log.i(TAG, jn_collectEnergy + ":" + config.collectEnergy); + //Log.i(TAG, jn_collectEnergy + ":" + config.collectEnergy); config.collectWateringBubble = jo.optBoolean(jn_collectWateringBubble, true); - Log.i(TAG, jn_collectWateringBubble + ":" + config.collectWateringBubble); + //Log.i(TAG, jn_collectWateringBubble + ":" + config.collectWateringBubble); config.collectProp = jo.optBoolean(jn_collectProp, true); - Log.i(TAG, jn_collectProp + ":" + config.collectProp); + //Log.i(TAG, jn_collectProp + ":" + config.collectProp); config.checkInterval = jo.optInt(jn_checkInterval, 720_000); - Log.i(TAG, jn_checkInterval + ":" + config.checkInterval); + //Log.i(TAG, jn_checkInterval + ":" + config.checkInterval); config.waitWhenException = jo.optInt(jn_waitWhenException, 60 * 60 * 1000); - Log.i(TAG, jn_waitWhenException + ":" + config.waitWhenException); + //Log.i(TAG, jn_waitWhenException + ":" + config.waitWhenException); config.limitCollect = jo.optBoolean("limitCollect", true); Log.i(TAG, "limitCollect" + ":" + config.limitCollect); @@ -1538,25 +1538,25 @@ public static Config json2Config(String json) { Log.i(TAG, "doubleCountLimit" + ":" + config.doubleCountLimit); config.advanceTime = jo.optInt(jn_advanceTime, 0); - Log.i(TAG, jn_advanceTime + ":" + config.advanceTime); + //Log.i(TAG, jn_advanceTime + ":" + config.advanceTime); config.collectInterval = jo.optInt(jn_collectInterval, 100); - Log.i(TAG, jn_collectInterval + ":" + config.collectInterval); + //Log.i(TAG, jn_collectInterval + ":" + config.collectInterval); config.collectTimeout = jo.optInt(jn_collectTimeout, 2_000); - Log.i(TAG, jn_collectTimeout + ":" + config.collectTimeout); + //Log.i(TAG, jn_collectTimeout + ":" + config.collectTimeout); config.returnWater33 = jo.optInt(jn_ReturnWater33); - Log.i(TAG, jn_ReturnWater33 + ":" + config.returnWater33); + //Log.i(TAG, jn_ReturnWater33 + ":" + config.returnWater33); config.returnWater18 = jo.optInt(jn_ReturnWater18); - Log.i(TAG, jn_ReturnWater18 + ":" + config.returnWater18); + //Log.i(TAG, jn_ReturnWater18 + ":" + config.returnWater18); config.returnWater10 = jo.optInt(jn_ReturnWater10); - Log.i(TAG, jn_ReturnWater10 + ":" + config.returnWater10); + //Log.i(TAG, jn_ReturnWater10 + ":" + config.returnWater10); config.helpFriendCollect = jo.optBoolean(jn_helpFriendCollect, true); - Log.i(TAG, jn_helpFriendCollect + ":" + config.helpFriendCollect); + //Log.i(TAG, jn_helpFriendCollect + ":" + config.helpFriendCollect); config.dontCollectList = new ArrayList<>(); if (jo.has(jn_dontCollectList)) { @@ -1565,7 +1565,7 @@ public static Config json2Config(String json) { config.dontCollectList.add(ja.getString(i)); } } - Log.i(TAG, jn_dontCollectList + ":" + String.join(",", config.dontCollectList)); + //Log.i(TAG, jn_dontCollectList + ":" + String.join(",", config.dontCollectList)); config.dontHelpCollectList = new ArrayList<>(); if (jo.has(jn_dontHelpCollectList)) { @@ -1574,10 +1574,10 @@ public static Config json2Config(String json) { config.dontHelpCollectList.add(ja.getString(i)); } } - Log.i(TAG, jn_dontHelpCollectList + ":" + String.join(",", config.dontHelpCollectList)); + //Log.i(TAG, jn_dontHelpCollectList + ":" + String.join(",", config.dontHelpCollectList)); config.receiveForestTaskAward = jo.optBoolean(jn_receiveForestTaskAward, true); - Log.i(TAG, jn_receiveForestTaskAward + ":" + config.receiveForestTaskAward); + //Log.i(TAG, jn_receiveForestTaskAward + ":" + config.receiveForestTaskAward); config.waterFriendList = new ArrayList<>(); config.waterCountList = new ArrayList<>(); @@ -1594,13 +1594,13 @@ public static Config json2Config(String json) { } } } - Log.i(TAG, jn_waterFriendList + ":" + String.join(",", config.waterFriendList)); + //Log.i(TAG, jn_waterFriendList + ":" + String.join(",", config.waterFriendList)); config.waterFriendCount = jo.optInt(jn_waterFriendCount, 66); - Log.i(TAG, jn_waterFriendCount + ":" + config.waterFriendCount); + //Log.i(TAG, jn_waterFriendCount + ":" + config.waterFriendCount); config.cooperateWater = jo.optBoolean(jn_cooperateWater, true); - Log.i(TAG, jn_cooperateWater + ":" + config.cooperateWater); + //Log.i(TAG, jn_cooperateWater + ":" + config.cooperateWater); config.cooperateWaterList = new ArrayList<>(); config.cooperateWaterNumList = new ArrayList<>(); @@ -1612,10 +1612,10 @@ public static Config json2Config(String json) { config.cooperateWaterNumList.add(jaa.getInt(1)); } } - Log.i(TAG, jn_cooperateWaterList + ":" + String.join(",", config.cooperateWaterList)); + //Log.i(TAG, jn_cooperateWaterList + ":" + String.join(",", config.cooperateWaterList)); config.ancientTree = jo.optBoolean(jn_ancientTree, true); - Log.i(TAG, jn_ancientTree + ":" + config.ancientTree); + //Log.i(TAG, jn_ancientTree + ":" + config.ancientTree); config.ancientTreeCityCodeList = new ArrayList<>(); if (jo.has(jn_ancientTreeAreaCodeList)) { @@ -1624,10 +1624,10 @@ public static Config json2Config(String json) { config.ancientTreeCityCodeList.add(ja.getString(i)); } } - Log.i(TAG, jn_ancientTreeAreaCodeList + ":" + String.join(",", config.ancientTreeCityCodeList)); + //Log.i(TAG, jn_ancientTreeAreaCodeList + ":" + String.join(",", config.ancientTreeCityCodeList)); config.energyRain = jo.optBoolean(jn_energyRain, true); - Log.i(TAG, jn_energyRain + ":" + config.energyRain); + //Log.i(TAG, jn_energyRain + ":" + config.energyRain); config.giveEnergyRainList = new ArrayList<>(); if (jo.has(jn_giveEnergyRainList)) { @@ -1637,10 +1637,10 @@ public static Config json2Config(String json) { config.giveEnergyRainList.add(jaa.getString(0)); } } - Log.i(TAG, jn_giveEnergyRainList + ":" + String.join(",", config.giveEnergyRainList)); + //Log.i(TAG, jn_giveEnergyRainList + ":" + String.join(",", config.giveEnergyRainList)); config.reserve = jo.optBoolean(jn_reserve, true); - Log.i(TAG, jn_reserve + ":" + config.reserve); + //Log.i(TAG, jn_reserve + ":" + config.reserve); config.reserveList = new ArrayList<>(); config.reserveCountList = new ArrayList<>(); @@ -1657,10 +1657,10 @@ public static Config json2Config(String json) { } } } - Log.i(TAG, jn_reserveList + ":" + String.join(",", config.reserveList)); + //Log.i(TAG, jn_reserveList + ":" + String.join(",", config.reserveList)); config.beach = jo.optBoolean(jn_beach, true); - Log.i(TAG, jn_beach + ":" + config.beach); + //Log.i(TAG, jn_beach + ":" + config.beach); config.beachList = new ArrayList<>(); config.beachCountList = new ArrayList<>(); @@ -1677,7 +1677,7 @@ public static Config json2Config(String json) { } } } - Log.i(TAG, jn_beachList + ":" + String.join(",", config.beachList)); + //Log.i(TAG, jn_beachList + ":" + String.join(",", config.beachList)); config.exchangeEnergyDoubleClick = jo.optBoolean("exchangeEnergyDoubleClick", false); Log.i(TAG, "exchangeEnergyDoubleClick" + ":" + config.exchangeEnergyDoubleClick); @@ -1686,37 +1686,37 @@ public static Config json2Config(String json) { Log.i(TAG, "exchangeEnergyDoubleClickCount" + ":" + config.exchangeEnergyDoubleClickCount); config.ancientTreeOnlyWeek = jo.optBoolean(jn_ancientTreeOnlyWeek, true); - Log.i(TAG, jn_ancientTreeOnlyWeek + ":" + config.ancientTreeOnlyWeek); + //Log.i(TAG, jn_ancientTreeOnlyWeek + ":" + config.ancientTreeOnlyWeek); config.antdodoCollect = jo.optBoolean(jn_antdodoCollect, true); - Log.i(TAG, jn_antdodoCollect + ":" + config.antdodoCollect); + //Log.i(TAG, jn_antdodoCollect + ":" + config.antdodoCollect); config.antOcean = jo.optBoolean(jn_antOcean, true); - Log.i(TAG, jn_antOcean + ":" + config.antOcean); + //Log.i(TAG, jn_antOcean + ":" + config.antOcean); config.userPatrol = jo.optBoolean(jn_userPatrol, true); - Log.i(TAG, jn_userPatrol + ":" + config.userPatrol); + //Log.i(TAG, jn_userPatrol + ":" + config.userPatrol); config.animalConsumeProp = jo.optBoolean(jn_animalConsumeProp, true); - Log.i(TAG, jn_animalConsumeProp + ":" + config.animalConsumeProp); + //Log.i(TAG, jn_animalConsumeProp + ":" + config.animalConsumeProp); config.collectGiftBox = jo.optBoolean(jn_collectGiftBox, true); - Log.i(TAG, jn_collectGiftBox + ":" + config.collectGiftBox); + //Log.i(TAG, jn_collectGiftBox + ":" + config.collectGiftBox); config.totalCertCount = jo.optBoolean(jn_totalCertCount, false); /* farm */ config.enableFarm = jo.optBoolean(jn_enableFarm, true); - Log.i(TAG, jn_enableFarm + ":" + config.enableFarm); + //Log.i(TAG, jn_enableFarm + ":" + config.enableFarm); config.rewardFriend = jo.optBoolean(jn_rewardFriend, true); - Log.i(TAG, jn_rewardFriend + ":" + config.rewardFriend); + //Log.i(TAG, jn_rewardFriend + ":" + config.rewardFriend); config.sendBackAnimal = jo.optBoolean(jn_sendBackAnimal, true); - Log.i(TAG, jn_sendBackAnimal + ":" + config.sendBackAnimal); + //Log.i(TAG, jn_sendBackAnimal + ":" + config.sendBackAnimal); config.sendType = SendType.valueOf(jo.optString(jn_sendType, SendType.HIT.name())); - Log.i(TAG, jn_sendType + ":" + config.sendType); + //Log.i(TAG, jn_sendType + ":" + config.sendType); config.dontSendFriendList = new ArrayList<>(); if (jo.has(jn_dontSendFriendList)) { @@ -1725,41 +1725,41 @@ public static Config json2Config(String json) { config.dontSendFriendList.add(ja.getString(i)); } } - Log.i(TAG, jn_dontSendFriendList + ":" + String.join(",", config.dontSendFriendList)); + //Log.i(TAG, jn_dontSendFriendList + ":" + String.join(",", config.dontSendFriendList)); config.recallAnimalType = RecallAnimalType .valueOf(jo.optString(jn_recallAnimalType, RecallAnimalType.ALWAYS.name())); - Log.i(TAG, jn_recallAnimalType + ":" + config.recallAnimalType); + //Log.i(TAG, jn_recallAnimalType + ":" + config.recallAnimalType); config.receiveFarmToolReward = jo.optBoolean(jn_receiveFarmToolReward, true); - Log.i(TAG, jn_receiveFarmToolReward + ":" + config.receiveFarmToolReward); + //Log.i(TAG, jn_receiveFarmToolReward + ":" + config.receiveFarmToolReward); config.recordFarmGame = jo.optBoolean(jn_recordFarmGame, true); - Log.i(TAG, jn_recordFarmGame + ":" + config.recordFarmGame); + //Log.i(TAG, jn_recordFarmGame + ":" + config.recordFarmGame); config.kitchen = jo.optBoolean(jn_kitchen, true); - Log.i(TAG, jn_kitchen + ":" + config.kitchen); + //Log.i(TAG, jn_kitchen + ":" + config.kitchen); config.useNewEggTool = jo.optBoolean(jn_useNewEggTool, true); - Log.i(TAG, jn_useNewEggTool + ":" + config.useNewEggTool); + //Log.i(TAG, jn_useNewEggTool + ":" + config.useNewEggTool); config.harvestProduce = jo.optBoolean(jn_harvestProduce, true); - Log.i(TAG, jn_harvestProduce + ":" + config.harvestProduce); + //Log.i(TAG, jn_harvestProduce + ":" + config.harvestProduce); config.donation = jo.optBoolean(jn_donation, true); - Log.i(TAG, jn_donation + ":" + config.donation); + //Log.i(TAG, jn_donation + ":" + config.donation); config.answerQuestion = jo.optBoolean(jn_answerQuestion, true); - Log.i(TAG, jn_answerQuestion + ":" + config.answerQuestion); + //Log.i(TAG, jn_answerQuestion + ":" + config.answerQuestion); config.receiveFarmTaskAward = jo.optBoolean(jn_receiveFarmTaskAward, true); - Log.i(TAG, jn_receiveFarmTaskAward + ":" + config.receiveFarmTaskAward); + //Log.i(TAG, jn_receiveFarmTaskAward + ":" + config.receiveFarmTaskAward); config.feedAnimal = jo.optBoolean(jn_feedAnimal, true); - Log.i(TAG, jn_feedAnimal + ":" + config.feedAnimal); + //Log.i(TAG, jn_feedAnimal + ":" + config.feedAnimal); config.useAccelerateTool = jo.optBoolean(jn_useAccelerateTool, true); - Log.i(TAG, jn_useAccelerateTool + ":" + config.useAccelerateTool); + //Log.i(TAG, jn_useAccelerateTool + ":" + config.useAccelerateTool); config.feedFriendAnimalList = new ArrayList<>(); config.feedFriendCountList = new ArrayList<>(); @@ -1776,16 +1776,16 @@ public static Config json2Config(String json) { } } } - Log.i(TAG, jn_feedFriendAnimalList + ":" + String.join(",", config.feedFriendAnimalList)); + //Log.i(TAG, jn_feedFriendAnimalList + ":" + String.join(",", config.feedFriendAnimalList)); config.farmGameTime = Arrays.asList(jo.optString(jn_farmGameTime, "2200-2400").split(",")); - Log.i(TAG, jn_farmGameTime + ":" + config.farmGameTime); + //Log.i(TAG, jn_farmGameTime + ":" + config.farmGameTime); config.animalSleepTime = Arrays.asList(jo.optString(jn_animalSleepTime, "2200-2400,0000-0559").split(",")); - Log.i(TAG, jn_animalSleepTime + ":" + config.animalSleepTime); + //Log.i(TAG, jn_animalSleepTime + ":" + config.animalSleepTime); config.notifyFriend = jo.optBoolean(jn_notifyFriend, false); - Log.i(TAG, jn_notifyFriend + ":" + config.notifyFriend); + //Log.i(TAG, jn_notifyFriend + ":" + config.notifyFriend); config.dontNotifyFriendList = new ArrayList<>(); if (jo.has(jn_dontNotifyFriendList)) { @@ -1794,7 +1794,7 @@ public static Config json2Config(String json) { config.dontNotifyFriendList.add(ja.getString(i)); } } - Log.i(TAG, jn_dontNotifyFriendList + ":" + String.join(",", config.dontNotifyFriendList)); + //Log.i(TAG, jn_dontNotifyFriendList + ":" + String.join(",", config.dontNotifyFriendList)); config.whoYouWantGiveTo = new ArrayList<>(); if (jo.has(jn_whoYouWantGiveTo)) { @@ -1803,7 +1803,7 @@ public static Config json2Config(String json) { config.whoYouWantGiveTo.add(ja.getString(i)); } } - Log.i(TAG, jn_whoYouWantGiveTo + ":" + String.join(",", config.whoYouWantGiveTo)); + //Log.i(TAG, jn_whoYouWantGiveTo + ":" + String.join(",", config.whoYouWantGiveTo)); config.sendFriendCard = new ArrayList<>(); if (jo.has(jn_sendFriendCard)) { @@ -1814,7 +1814,7 @@ public static Config json2Config(String json) { } config.acceptGift = jo.optBoolean(jn_acceptGift, true); - Log.i(TAG, jn_acceptGift + ":" + config.acceptGift); + //Log.i(TAG, jn_acceptGift + ":" + config.acceptGift); config.visitFriendList = new ArrayList<>(); config.visitFriendCountList = new ArrayList<>(); @@ -1831,36 +1831,36 @@ public static Config json2Config(String json) { } } } - Log.i(TAG, jn_visitFriendList + ":" + String.join(",", config.visitFriendList)); + //Log.i(TAG, jn_visitFriendList + ":" + String.join(",", config.visitFriendList)); config.chickenDiary = jo.optBoolean(jn_chickenDiary, true); config.antOrchard = jo.optBoolean(jn_antOrchard, true); - Log.i(TAG, jn_antOrchard + ":" + config.antOrchard); + //Log.i(TAG, jn_antOrchard + ":" + config.antOrchard); config.receiveOrchardTaskAward = jo.optBoolean(jn_receiveOrchardTaskAward, true); - Log.i(TAG, jn_receiveOrchardTaskAward + ":" + config.receiveOrchardTaskAward); + //Log.i(TAG, jn_receiveOrchardTaskAward + ":" + config.receiveOrchardTaskAward); config.orchardSpreadManureCount = jo.optInt(jn_orchardSpreadManureCount, 0); - Log.i(TAG, jn_orchardSpreadManureCount + ":" + config.orchardSpreadManureCount); + //Log.i(TAG, jn_orchardSpreadManureCount + ":" + config.orchardSpreadManureCount); config.enableStall = jo.optBoolean(jn_enableStall, false); - Log.i(TAG, jn_enableStall + ":" + config.enableStall); + //Log.i(TAG, jn_enableStall + ":" + config.enableStall); config.stallAutoClose = jo.optBoolean(jn_stallAutoClose, false); - Log.i(TAG, jn_stallAutoClose + ":" + config.stallAutoClose); + //Log.i(TAG, jn_stallAutoClose + ":" + config.stallAutoClose); config.stallAutoOpen = jo.optBoolean(jn_stallAutoOpen, false); - Log.i(TAG, jn_stallAutoOpen + ":" + config.stallAutoOpen); + //Log.i(TAG, jn_stallAutoOpen + ":" + config.stallAutoOpen); config.stallAutoTask = jo.optBoolean(jn_stallAutoTask, true); - Log.i(TAG, jn_stallAutoTask + ":" + config.stallAutoTask); + //Log.i(TAG, jn_stallAutoTask + ":" + config.stallAutoTask); config.stallReceiveAward = jo.optBoolean(jn_stallReceiveAward, true); - Log.i(TAG, jn_stallReceiveAward + ":" + config.stallReceiveAward); + //Log.i(TAG, jn_stallReceiveAward + ":" + config.stallReceiveAward); config.stallOpenType = jo.optBoolean(jn_stallOpenType, true); - Log.i(TAG, jn_stallOpenType + ":" + config.stallOpenType); + //Log.i(TAG, jn_stallOpenType + ":" + config.stallOpenType); config.stallOpenList = new ArrayList<>(); if (jo.has(jn_stallOpenList)) { @@ -1906,49 +1906,49 @@ public static Config json2Config(String json) { /* other */ config.receivePoint = jo.optBoolean(jn_receivePoint, true); - Log.i(TAG, jn_receivePoint + ":" + config.receivePoint); + //Log.i(TAG, jn_receivePoint + ":" + config.receivePoint); config.openTreasureBox = jo.optBoolean(jn_openTreasureBox, true); - Log.i(TAG, jn_openTreasureBox + ":" + config.openTreasureBox); + //Log.i(TAG, jn_openTreasureBox + ":" + config.openTreasureBox); config.receiveCoinAsset = jo.optBoolean(jn_receiveCoinAsset, true); - Log.i(TAG, jn_receiveCoinAsset + ":" + config.receiveCoinAsset); + //Log.i(TAG, jn_receiveCoinAsset + ":" + config.receiveCoinAsset); config.donateCharityCoin = jo.optBoolean(jn_donateCharityCoin, false); - Log.i(TAG, jn_donateCharityCoin + ":" + config.donateCharityCoin); + //Log.i(TAG, jn_donateCharityCoin + ":" + config.donateCharityCoin); config.minExchangeCount = jo.optInt(jn_minExchangeCount); - Log.i(TAG, jn_minExchangeCount + ":" + config.minExchangeCount); + //Log.i(TAG, jn_minExchangeCount + ":" + config.minExchangeCount); config.latestExchangeTime = jo.optInt(jn_latestExchangeTime, 21); - Log.i(TAG, jn_latestExchangeTime + ":" + config.latestExchangeTime); + //Log.i(TAG, jn_latestExchangeTime + ":" + config.latestExchangeTime); config.syncStepCount = jo.optInt(jn_syncStepCount, 22000); - Log.i(TAG, jn_syncStepCount + ":" + config.syncStepCount); + //Log.i(TAG, jn_syncStepCount + ":" + config.syncStepCount); config.kbSignIn = jo.optBoolean(jn_kbSignIn, true); - Log.i(TAG, jn_kbSignIn + ":" + config.kbSignIn); + //Log.i(TAG, jn_kbSignIn + ":" + config.kbSignIn); config.ecoLifeTick = jo.optBoolean(jn_ecoLifeTick, true); - Log.i(TAG, jn_ecoLifeTick + ":" + config.ecoLifeTick); + //Log.i(TAG, jn_ecoLifeTick + ":" + config.ecoLifeTick); config.tiyubiz = jo.optBoolean(jn_tiyubiz, true); - Log.i(TAG, jn_tiyubiz + ":" + config.tiyubiz); + //Log.i(TAG, jn_tiyubiz + ":" + config.tiyubiz); config.insBlueBeanExchange = jo.optBoolean(jn_insBlueBeanExchange, true); - Log.i(TAG, jn_insBlueBeanExchange + ":" + config.insBlueBeanExchange); + //Log.i(TAG, jn_insBlueBeanExchange + ":" + config.insBlueBeanExchange); config.collectSesame = jo.optBoolean(jn_collectSesame, true); - Log.i(TAG, jn_collectSesame + ":" + config.collectSesame); + //Log.i(TAG, jn_collectSesame + ":" + config.collectSesame); config.zcjSignIn = jo.optBoolean(jn_zcjSignIn, true); - Log.i(TAG, jn_zcjSignIn + ":" + config.zcjSignIn); + //Log.i(TAG, jn_zcjSignIn + ":" + config.zcjSignIn); config.merchantKmdk = jo.optBoolean(jn_merchantKmdk, true); - Log.i(TAG, jn_merchantKmdk + ":" + config.merchantKmdk); + //Log.i(TAG, jn_merchantKmdk + ":" + config.merchantKmdk); config.greenFinance = jo.optBoolean(jn_greenFinance, false); - Log.i(TAG, jn_greenFinance + ":" + config.greenFinance); + //Log.i(TAG, jn_greenFinance + ":" + config.greenFinance); } catch (Throwable t) { Log.printStackTrace(TAG, t); if (json != null) { 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 cadac3c82..4dbd87c78 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/util/FileUtils.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/util/FileUtils.java @@ -330,7 +330,10 @@ public static void setCertCount(String userId, String dateString, int certCount) } public static String readFromFile(File f) { - if (f.exists() && !f.canRead()) { + if (!f.exists()) { + return ""; + } + if (!f.canRead()) { AntForestToast.show(f.getName() + "没有读取权限!", true); return ""; } @@ -345,8 +348,9 @@ public static String readFromFile(File f) { } } catch (Throwable t) { Log.printStackTrace(TAG, t); + } finally { + close(fr, f); } - close(fr, f); return result.toString(); } From 905038082dcd2e206386cd38f1ef8196a3741f18 Mon Sep 17 00:00:00 2001 From: Magical Yang Date: Wed, 11 Oct 2023 09:11:23 +0800 Subject: [PATCH 02/29] =?UTF-8?q?=E4=BF=AE=E5=A4=8DRuntimeInfo=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 4 ++-- .../xposed/quickenergy/data/RuntimeInfo.java | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 7729057a6..1b99776a6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { minSdk 21 //noinspection ExpiredTargetSdkVersion targetSdk 29 - versionCode 69 - versionName "1.2.2" + versionCode 70 + versionName "1.2.2-fix1" } buildTypes { release { diff --git a/app/src/main/java/pansong291/xposed/quickenergy/data/RuntimeInfo.java b/app/src/main/java/pansong291/xposed/quickenergy/data/RuntimeInfo.java index 84ec4572e..965142f9c 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/data/RuntimeInfo.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/data/RuntimeInfo.java @@ -40,11 +40,20 @@ private RuntimeInfo() { String content = FileUtils.readFromFile(FileUtils.runtimeInfoFile()); try { joAll = new JSONObject(content); + } catch (Exception ignored) { + joAll = new JSONObject(); + } + try { if (!joAll.has(userId)) { joAll.put(userId, new JSONObject()); } + } catch (Exception ignored) { + } + try { joCurrent = joAll.getJSONObject(userId); - } catch (Exception ignored) { } + } catch (Exception ignored) { + joCurrent = new JSONObject(); + } } public void save() { @@ -66,6 +75,7 @@ public Long getLong(RuntimeInfoKey key) { public void put(RuntimeInfoKey key, Object value) { try { joCurrent.put(key.name(), value); + joAll.put(userId, joCurrent); } catch (JSONException e) { Log.i(TAG, "put err:"); Log.printStackTrace(TAG, e); From b7fb12df1ff749515e6f76d2174bbaf5d802f2b6 Mon Sep 17 00:00:00 2001 From: "Vincent Qiu (HOHO``)" Date: Sun, 19 Nov 2023 21:33:04 +0800 Subject: [PATCH 03/29] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=A7=8B=E7=BB=88?= =?UTF-8?q?=E4=B8=AD=E6=96=87=E8=AF=AD=E8=A8=80=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 应用跟随系统语言,英文语言系统情况下部分文字长度表达不够直观展示,增加一个始终中文选项独立于系统语言。 --- .../quickenergy/ui/HtmlViewerActivity.java | 2 ++ .../xposed/quickenergy/ui/MainActivity.java | 6 ++++++ .../quickenergy/ui/SettingsActivity.java | 19 +++++++++++++++-- .../xposed/quickenergy/util/Config.java | 18 ++++++++++++++++ .../xposed/quickenergy/util/LanguageUtil.java | 21 +++++++++++++++++++ app/src/main/res/layout/activity_settings.xml | 10 +++++++++ app/src/main/res/values-zh-rCN/strings.xml | 2 ++ app/src/main/res/values/strings.xml | 2 ++ 8 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/pansong291/xposed/quickenergy/util/LanguageUtil.java diff --git a/app/src/main/java/pansong291/xposed/quickenergy/ui/HtmlViewerActivity.java b/app/src/main/java/pansong291/xposed/quickenergy/ui/HtmlViewerActivity.java index 19a06170f..b78dd8b95 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/ui/HtmlViewerActivity.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/ui/HtmlViewerActivity.java @@ -14,6 +14,7 @@ import android.widget.ProgressBar; import android.widget.Toast; import pansong291.xposed.quickenergy.R; +import pansong291.xposed.quickenergy.util.LanguageUtil; public class HtmlViewerActivity extends Activity { MyWebView mWebView; @@ -22,6 +23,7 @@ public class HtmlViewerActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + LanguageUtil.setLocale(this); setContentView(R.layout.activity_html_viewer); mWebView = findViewById(R.id.mwv_webview); diff --git a/app/src/main/java/pansong291/xposed/quickenergy/ui/MainActivity.java b/app/src/main/java/pansong291/xposed/quickenergy/ui/MainActivity.java index 1a7a7090c..83c522e73 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/ui/MainActivity.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/ui/MainActivity.java @@ -10,6 +10,7 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; +import android.content.res.Configuration; import android.net.Uri; import android.os.Bundle; import android.view.Menu; @@ -17,15 +18,18 @@ import android.view.View; import android.widget.TextView; import android.widget.Toast; + import pansong291.xposed.quickenergy.R; import pansong291.xposed.quickenergy.data.RuntimeInfo; import pansong291.xposed.quickenergy.entity.FriendWatch; import pansong291.xposed.quickenergy.util.Config; import pansong291.xposed.quickenergy.util.FileUtils; +import pansong291.xposed.quickenergy.util.LanguageUtil; import pansong291.xposed.quickenergy.util.PermissionUtil; import pansong291.xposed.quickenergy.util.Statistics; import java.util.ArrayList; +import java.util.Locale; public class MainActivity extends Activity { TextView tvStatistics; @@ -63,6 +67,7 @@ private static boolean isExpModuleActive(Context context) { } return isExp; } + /** * 判断当前应用是否是debug状态 */ @@ -78,6 +83,7 @@ public static boolean isApkInDebug(Context context) { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + LanguageUtil.setLocale(this); setContentView(R.layout.activity_main); RuntimeInfo.process = "app"; 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 5ae2f64c7..abf5f1e0a 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/ui/SettingsActivity.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/ui/SettingsActivity.java @@ -2,6 +2,7 @@ import android.annotation.SuppressLint; import android.app.Activity; +import android.content.res.Configuration; import android.os.Bundle; import android.view.GestureDetector; import android.view.MotionEvent; @@ -12,6 +13,9 @@ import android.widget.Switch; import android.widget.TabHost; import android.widget.Toast; + +import java.util.Locale; + import pansong291.xposed.quickenergy.R; import pansong291.xposed.quickenergy.entity.*; import pansong291.xposed.quickenergy.util.*; @@ -30,7 +34,7 @@ public class SettingsActivity extends Activity { private Animation slideRightIn; private Animation slideRightOut; - Switch sw_immediateEffect, sw_recordLog, sw_showToast, sw_stayAwake, sw_timeoutRestart, sw_startAt7, + Switch sw_immediateEffect, sw_recordLog, sw_showToast, sw_stayAwake, sw_timeoutRestart, sw_startAt7, sw_language_simplified_chinese, sw_collectWateringBubble, sw_collectProp, sw_collectEnergy, sw_helpFriendCollect, sw_receiveForestTaskAward, sw_cooperateWater, sw_energyRain, sw_enableFarm, sw_rewardFriend, sw_sendBackAnimal, sw_receiveFarmToolReward, sw_useNewEggTool, sw_harvestProduce, sw_donation, sw_answerQuestion, @@ -47,6 +51,7 @@ public class SettingsActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + LanguageUtil.setLocale(this); setContentView(R.layout.activity_settings); setTitle(R.string.settings); @@ -61,8 +66,10 @@ protected void onCreate(Bundle savedInstanceState) { BeachIdMap.shouldReload = true; initSwitch(); + } + @Override public boolean dispatchTouchEvent(MotionEvent event) { if (gestureDetector.onTouchEvent(event)) { @@ -98,7 +105,7 @@ private void initFlipper() { gestureDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() { @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, - float velocityY) { + float velocityY) { if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH) return false; int lastView = tabHost.getCurrentTab(); @@ -159,6 +166,7 @@ private void initSwitch() { sw_startAt7 = findViewById(R.id.sw_startAt7); sw_enableOnGoing = findViewById(R.id.sw_enableOnGoing); sw_backupRuntime = findViewById(R.id.sw_backupRuntime); + sw_language_simplified_chinese = findViewById(R.id.sw_languageSimplifiedChinese); sw_collectEnergy = findViewById(R.id.sw_collectEnergy); sw_collectWateringBubble = findViewById(R.id.sw_collectWateringBubble); @@ -233,6 +241,7 @@ protected void onResume() { sw_startAt7.setChecked(Config.startAt7()); sw_enableOnGoing.setChecked(Config.enableOnGoing()); sw_backupRuntime.setChecked(Config.backupRuntime()); + sw_language_simplified_chinese.setChecked(Config.languageSimplifiedChinese()); sw_collectEnergy.setChecked(Config.collectEnergy()); sw_collectWateringBubble.setChecked(Config.collectWateringBubble()); @@ -333,6 +342,12 @@ public void onClick(View v) { Config.setBackupRuntime(sw.isChecked()); break; + case R.id.sw_languageSimplifiedChinese: + Config.setLanguageSimplifiedChinese(sw.isChecked()); + // 提示需要重启 language_simplified_chinese_need_restart + Toast.makeText(this, R.string.language_simplified_chinese_need_restart, Toast.LENGTH_SHORT).show(); + break; + case R.id.sw_collectEnergy: Config.setCollectEnergy(sw.isChecked()); 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 618060ae6..74339c796 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/util/Config.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/util/Config.java @@ -43,6 +43,7 @@ public CharSequence nickName() { public static final String jn_startAt7 = "startAt7"; public static final String jn_enableOnGoing = "enableOnGoing"; public static final String jn_backupRuntime = "backupRuntime"; + public static final String jn_languageSimplifiedChinese = "languageSimplifiedChinese"; /* forest */ public static final String jn_collectEnergy = "collectEnergy"; @@ -163,6 +164,8 @@ public CharSequence nickName() { private boolean startAt7; private boolean enableOnGoing; private boolean backupRuntime; + private boolean languageSimplifiedChinese; + /* forest */ private boolean collectEnergy; @@ -395,10 +398,19 @@ public static void setBackupRuntime(boolean b) { hasChanged = true; } + public static void setLanguageSimplifiedChinese(boolean b) { + getConfig().languageSimplifiedChinese = b; + hasChanged = true; + } + public static boolean backupRuntime() { return getConfig().backupRuntime; } + public static boolean languageSimplifiedChinese() { + return getConfig().languageSimplifiedChinese; + } + /* forest */ public static void setCollectEnergy(boolean b) { getConfig().collectEnergy = b; @@ -1324,6 +1336,7 @@ public static Config defInit() { c.startAt7 = false; c.enableOnGoing = false; c.backupRuntime = false; + c.languageSimplifiedChinese = false; c.collectEnergy = false; c.collectWateringBubble = true; @@ -1507,6 +1520,9 @@ public static Config json2Config(String json) { config.backupRuntime = jo.optBoolean(jn_backupRuntime, false); //Log.i(TAG, jn_backupRuntime + ":" + config.backupRuntime); + config.languageSimplifiedChinese = jo.optBoolean(jn_languageSimplifiedChinese, false); + //Log.i(TAG, jn_languageSimplifiedChinese + ":" + config.languageSimplifiedChinese); + /* forest */ config.collectEnergy = jo.optBoolean(jn_collectEnergy, false); //Log.i(TAG, jn_collectEnergy + ":" + config.collectEnergy); @@ -1998,6 +2014,8 @@ public static String config2Json(Config config) { jo.put(jn_backupRuntime, config.backupRuntime); + jo.put(jn_languageSimplifiedChinese, config.languageSimplifiedChinese); + /* forest */ jo.put(jn_collectEnergy, config.collectEnergy); diff --git a/app/src/main/java/pansong291/xposed/quickenergy/util/LanguageUtil.java b/app/src/main/java/pansong291/xposed/quickenergy/util/LanguageUtil.java new file mode 100644 index 000000000..d1ebd022e --- /dev/null +++ b/app/src/main/java/pansong291/xposed/quickenergy/util/LanguageUtil.java @@ -0,0 +1,21 @@ +package pansong291.xposed.quickenergy.util; + +import android.content.res.Configuration; + +import java.util.Locale; + +import android.content.Context; + + +public class LanguageUtil { + public static void setLocale(Context context) { + if (Config.languageSimplifiedChinese()) { + // 忽略系统语言,强制使用简体中文 + Locale locale = new Locale("zh", "CN"); // 简体中文的区域代码 + Locale.setDefault(locale); + Configuration config = new Configuration(); + config.locale = locale; + context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics()); + } + } +} diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index e2dc72fda..57eac1c61 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -175,6 +175,16 @@ android:onClick="onClick" android:minHeight="50dp" android:id="@+id/sw_backupRuntime" /> + + 安心豆兑换时光加速器 开启状态栏禁删 备份runtime日志 + 界面始终使用中文 + 重启当前app生效 施肥 收取施肥任务奖励 施肥次数 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index dd1945c11..76aebf1b7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -123,6 +123,8 @@ Ins blue bean exchange Enable on going Backup runtime log + Chinese Language + Need to restart the app to take effect Ant orchard Receive orchard task award Orchard spread manure count From abce87515df7995a6321a256aceace9d2f8f238e Mon Sep 17 00:00:00 2001 From: Magical Yang Date: Tue, 21 Nov 2023 14:20:21 +0800 Subject: [PATCH 04/29] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E9=94=AE?= =?UTF-8?q?=E6=94=B6=E8=83=BD=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 +- .../xposed/quickenergy/AntForest.java | 84 ++++++++++++++++++- .../quickenergy/hook/AntForestRpcCall.java | 10 +++ .../quickenergy/ui/SettingsActivity.java | 8 +- .../xposed/quickenergy/util/Config.java | 17 ++++ app/src/main/res/layout/activity_settings.xml | 10 +++ app/src/main/res/values-zh-rCN/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 8 files changed, 128 insertions(+), 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 1b99776a6..9e5aeafe4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,7 +9,7 @@ android { //noinspection ExpiredTargetSdkVersion targetSdk 29 versionCode 70 - versionName "1.2.2-fix1" + versionName "1.2.3-beta2" } buildTypes { release { diff --git a/app/src/main/java/pansong291/xposed/quickenergy/AntForest.java b/app/src/main/java/pansong291/xposed/quickenergy/AntForest.java index 5c8ba91d3..55170ae53 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/AntForest.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/AntForest.java @@ -522,6 +522,10 @@ private static void canCollectEnergy(String userId) { Log.recordLog("异常等待中,暂不执行检测!", ""); return; } + if (Config.getDontCollectList().contains(userId)) { + Log.recordLog("不偷取[" + FriendIdMap.getNameById(userId) + "]", ", userId=" + userId); + return; + } try { long start = System.currentTimeMillis(); String s = AntForestRpcCall.queryFriendHomePage(userId); @@ -556,15 +560,17 @@ private static void canCollectEnergy(String userId) { } } int collected = 0; + List batchIdList = new ArrayList<>(); for (int i = 0; i < jaBubbles.length(); i++) { JSONObject bubble = jaBubbles.getJSONObject(i); long bubbleId = bubble.getLong("id"); switch (CollectStatus.valueOf(bubble.getString("collectStatus"))) { case AVAILABLE: - if (Config.getDontCollectList().contains(userId)) - Log.recordLog("不偷取[" + FriendIdMap.getNameById(userId) + "]", ", userId=" + userId); - else + if (Config.batchRobEnergy()) { + batchIdList.add(String.valueOf(bubbleId)); + } else { collected += collectEnergy(userId, bubbleId, bizNo); + } break; case WAITING: @@ -578,6 +584,10 @@ private static void canCollectEnergy(String userId) { break; } } + if (Config.batchRobEnergy()) { + if (!batchIdList.isEmpty()) + batchRobEnergy(userId, batchIdList, null); + } collectedEnergy += collected; onForestEnd(); } else { @@ -668,6 +678,74 @@ private static int collectEnergy(String userId, long bubbleId, String bizNo) { return collectEnergy(userId, bubbleId, bizNo, null); } + private static int batchRobEnergy(String userId, List bubbleId, String extra) { + if (RuntimeInfo.getInstance().getLong(RuntimeInfo.RuntimeInfoKey.ForestPauseTime) > System + .currentTimeMillis()) { + Log.recordLog("异常等待中,暂不收取能量!", ""); + return 0; + } + int collected = 0; + try { + while (checkCollectLimited()) { + Thread.sleep(1000); + } + } catch (Throwable th) { + Log.printStackTrace("到达分钟限制,等待失败!", th); + return 0; + } + try { + String s = "{\"resultCode\": \"FAILED\"}"; + if (Config.collectInterval() > 0) { + synchronized (collectLock) { + while (System.currentTimeMillis() - lastCollectTime < Config.collectInterval()) { + Thread.sleep(System.currentTimeMillis() - lastCollectTime); + } + if (Config.doubleCard() && doubleEndTime < System.currentTimeMillis()) { + if (Config.isDoubleCardTime() && !selfId.equals(userId) && Statistics.canDoubleToday()) { + useDoubleCard(); + } + } + s = AntForestRpcCall.batchRobEnergy(userId, bubbleId); + lastCollectTime = System.currentTimeMillis(); + } + } + JSONObject jo = new JSONObject(s); + if ("SUCCESS".equals(jo.getString("resultCode"))) { + offerCollectQueue(); + JSONArray jaBubbles = jo.getJSONArray("bubbles"); + bubbleId = new ArrayList<>(); + for (int i = 0; i < jaBubbles.length(); i++) { + JSONObject bubble = jaBubbles.getJSONObject(i); + if (bubble.getBoolean("canBeRobbedAgain")) { + bubbleId.add(String.valueOf(bubble.getLong("id"))); + } + collected += bubble.getInt("collectedEnergy"); + } + if (collected > 0) { + FriendManager.friendWatch(userId, collected); + totalCollected += collected; + Statistics.addData(Statistics.DataType.COLLECTED, collected); + String str = "收取能量🪂[" + FriendIdMap.getNameById(userId) + "]#" + collected + "g" + + (StringUtil.isEmpty(extra) ? "" : "[" + extra + "]"); + Log.forest(str); + AntForestToast.show(str); + } else { + Log.recordLog("收取[" + FriendIdMap.getNameById(userId) + "]的能量失败", + ",UserID:" + userId + ",BubbleId:" + bubbleId); + } + if (!bubbleId.isEmpty()) { + collected += batchRobEnergy(userId, bubbleId, "双击卡"); + } + } else { + Log.recordLog("[" + FriendIdMap.getNameById(userId) + "]" + jo.getString("resultDesc"), s); + } + } catch (Throwable t) { + Log.i(TAG, "collectEnergy err:"); + Log.printStackTrace(TAG, t); + } + return collected; + } + private static int collectEnergy(String userId, long bubbleId, String bizNo, String extra) { if (RuntimeInfo.getInstance().getLong(RuntimeInfo.RuntimeInfoKey.ForestPauseTime) > System .currentTimeMillis()) { 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 935e139c3..9785d2a28 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/hook/AntForestRpcCall.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/hook/AntForestRpcCall.java @@ -4,6 +4,8 @@ import pansong291.xposed.quickenergy.util.RandomUtils; +import java.util.Collections; +import java.util.List; import java.util.UUID; public class AntForestRpcCall { @@ -50,6 +52,14 @@ public static String collectEnergy(String bizType, String userId, long bubbleId) return RpcUtil.request("alipay.antmember.forest.h5.collectEnergy", args1); } + public static String batchRobEnergy(String userId, List bubbleId) { + String args1; + args1 = "[{\"bizType\":\"\",\"bubbleIds\":[" + String.join(",", bubbleId) + + "],\"fromAct\":\"BATCH_ROB_ENERGY\",\"source\":\"chInfo_ch_appcenter__chsub_9patch\",\"userId\":\"" + userId + "\",\"version\":\"" + + VERSION + "\"}]"; + return RpcUtil.request("alipay.antmember.forest.h5.collectEnergy", args1); + } + public static String collectRebornEnergy() { return RpcUtil.request("alipay.antforest.forest.h5.collectRebornEnergy", "[{\"source\":\"chInfo_ch_appcenter__chsub_9patch\"}]"); } 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 5ae2f64c7..58ac4a3a4 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/ui/SettingsActivity.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/ui/SettingsActivity.java @@ -42,7 +42,7 @@ public class SettingsActivity extends Activity { 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_stallThrowManure, sw_greenFinance, sw_totalCertCount; + sw_stallThrowManure, sw_greenFinance, sw_totalCertCount, sw_batchRobEnergy; @Override protected void onCreate(Bundle savedInstanceState) { @@ -162,6 +162,7 @@ private void initSwitch() { sw_collectEnergy = findViewById(R.id.sw_collectEnergy); sw_collectWateringBubble = findViewById(R.id.sw_collectWateringBubble); + sw_batchRobEnergy = findViewById(R.id.sw_batchRobEnergy); sw_collectProp = findViewById(R.id.sw_collectProp); sw_helpFriendCollect = findViewById(R.id.sw_helpFriendCollect); sw_receiveForestTaskAward = findViewById(R.id.sw_receiveForestTaskAward); @@ -236,6 +237,7 @@ protected void onResume() { sw_collectEnergy.setChecked(Config.collectEnergy()); sw_collectWateringBubble.setChecked(Config.collectWateringBubble()); + sw_batchRobEnergy.setChecked(Config.batchRobEnergy()); sw_collectProp.setChecked(Config.collectProp()); sw_helpFriendCollect.setChecked(Config.helpFriendCollect()); sw_receiveForestTaskAward.setChecked(Config.receiveForestTaskAward()); @@ -341,6 +343,10 @@ public void onClick(View v) { Config.setCollectWateringBubble(sw.isChecked()); break; + case R.id.sw_batchRobEnergy: + Config.setBatchRobEnergy(sw.isChecked()); + break; + case R.id.sw_collectProp: Config.setCollectProp(sw.isChecked()); 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 618060ae6..e0b3d1173 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/util/Config.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/util/Config.java @@ -49,6 +49,7 @@ public CharSequence nickName() { public static final String jn_ancientTreeCityCodeList = "ancientTreeCityCodeList"; public static final String jn_collectWateringBubble = "collectWateringBubble"; + public static final String jn_batchRobEnergy = "batchRobEnergy"; public static final String jn_collectProp = "collectProp"; public static final String jn_ReturnWater33 = "returnWater30"; public static final String jn_ReturnWater18 = "returnWater20"; @@ -169,6 +170,8 @@ public CharSequence nickName() { private int checkInterval; private boolean collectWateringBubble; + + private boolean batchRobEnergy; private boolean collectProp; private boolean limitCollect; private int limitCount; @@ -418,6 +421,15 @@ public static boolean collectWateringBubble() { return getConfig().collectWateringBubble; } + public static void setBatchRobEnergy(boolean b) { + getConfig().batchRobEnergy = b; + hasChanged = true; + } + + public static boolean batchRobEnergy() { + return getConfig().batchRobEnergy; + } + public static void setCollectProp(boolean b) { getConfig().collectProp = b; hasChanged = true; @@ -1327,6 +1339,7 @@ public static Config defInit() { c.collectEnergy = false; c.collectWateringBubble = true; + c.batchRobEnergy = false; c.collectProp = true; c.checkInterval = 720_000; c.waitWhenException = 60 * 60 * 1000; @@ -1514,6 +1527,8 @@ public static Config json2Config(String json) { config.collectWateringBubble = jo.optBoolean(jn_collectWateringBubble, true); //Log.i(TAG, jn_collectWateringBubble + ":" + config.collectWateringBubble); + config.batchRobEnergy = jo.optBoolean(jn_batchRobEnergy, false); + config.collectProp = jo.optBoolean(jn_collectProp, true); //Log.i(TAG, jn_collectProp + ":" + config.collectProp); @@ -2003,6 +2018,8 @@ public static String config2Json(Config config) { jo.put(jn_collectWateringBubble, config.collectWateringBubble); + jo.put(jn_batchRobEnergy, config.batchRobEnergy); + jo.put(jn_collectProp, config.collectProp); jo.put(jn_checkInterval, config.checkInterval); diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index e2dc72fda..85ce56611 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -217,6 +217,16 @@ android:minHeight="50dp" android:id="@+id/sw_collectWateringBubble" /> + + 开启绿色经营 记录证书总数 送好友卡片(赠送当前图鉴所有卡片) + 一键收能量 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index dd1945c11..b0b22ed92 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -152,5 +152,6 @@ Green finance Total cert count Send friend card + Batch rob energy From 4863f6fdc394b5c459829481396da07de6f94604 Mon Sep 17 00:00:00 2001 From: "Vincent Qiu (HOHO``)" Date: Wed, 29 Nov 2023 20:43:41 +0800 Subject: [PATCH 05/29] Fixed not working for alipay version 10.5.53 after android 11 --- .../java/pansong291/xposed/quickenergy/util/FileUtils.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 4dbd87c78..b4122cf77 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/util/FileUtils.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/util/FileUtils.java @@ -3,6 +3,7 @@ import android.os.Environment; import pansong291.xposed.quickenergy.AntForestToast; import pansong291.xposed.quickenergy.data.RuntimeInfo; +import pansong291.xposed.quickenergy.hook.ClassMember; import java.io.Closeable; import java.io.File; @@ -49,7 +50,8 @@ private static void copyFile(File srcDir, File dstDir, String filename) { @SuppressWarnings("deprecation") public static File getMainDirectoryFile() { if (mainDirectory == null) { - File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS); + String storageDirStr = Environment.getExternalStorageDirectory() + File.separator + "Android" + File.separator + "media" + File.separator + ClassMember.PACKAGE_NAME; + File storageDir = new File(storageDirStr); if (!storageDir.exists()) { storageDir.mkdirs(); } From 473b29211a4fa2e08ace7876281c629437c47689 Mon Sep 17 00:00:00 2001 From: Magical Yang Date: Fri, 1 Dec 2023 16:10:39 +0800 Subject: [PATCH 06/29] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=A3=9E=E8=A1=8C?= =?UTF-8?q?=E8=B5=9B=EF=BC=8C=E8=B0=83=E6=95=B4=E4=BC=9A=E5=91=98=E7=AD=BE?= =?UTF-8?q?=E5=88=B0=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 4 +-- .../xposed/quickenergy/AntFarm.java | 18 +++++++--- .../xposed/quickenergy/AntMember.java | 2 +- .../quickenergy/hook/AntFarmRpcCall.java | 36 +++++++++++++------ .../quickenergy/hook/AntMemberRpcCall.java | 5 +-- .../xposed/quickenergy/hook/XposedHook.java | 2 ++ 6 files changed, 47 insertions(+), 20 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 9e5aeafe4..3690c8cbf 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { minSdk 21 //noinspection ExpiredTargetSdkVersion targetSdk 29 - versionCode 70 - versionName "1.2.3-beta2" + versionCode 71 + versionName "1.2.3-beta4" } 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 be8f439b3..ace88db90 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/AntFarm.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/AntFarm.java @@ -53,9 +53,9 @@ public CharSequence nickName() { } public enum GameType { - starGame, jumpGame; + starGame, jumpGame, flyGame; - public static final CharSequence[] gameNames = { "星星球", "登山赛" }; + public static final CharSequence[] gameNames = { "星星球", "登山赛", "飞行赛" }; public CharSequence gameName() { return gameNames[ordinal()]; @@ -227,6 +227,7 @@ public void run() { } if (Config.recordFarmGame() && Config.isFarmGameTime()) { + recordFarmGame(GameType.flyGame); recordFarmGame(GameType.starGame); recordFarmGame(GameType.jumpGame); } @@ -677,9 +678,12 @@ private static void recordFarmGame(GameType gameType) { try { JSONObject jo = new JSONObject(AntFarmRpcCall.initFarmGame(gameType.name())); if ("SUCCESS".equals(jo.getString("memo"))) { - JSONObject gameAward = jo.getJSONObject("gameAward"); - if (gameAward.getBoolean("level3Get")) + if (jo.getJSONObject("gameAward").getBoolean("level3Get")) { return; + } + if (jo.optInt("remainingGameCount", 1) == 0) { + return; + } jo = new JSONObject(AntFarmRpcCall.recordFarmGame(gameType.name())); if ("SUCCESS".equals(jo.getString("memo"))) { JSONArray awardInfos = jo.getJSONArray("awardInfos"); @@ -688,7 +692,13 @@ private static void recordFarmGame(GameType gameType) { jo = awardInfos.getJSONObject(i); award.append(jo.getString("awardName")).append("*").append(jo.getInt("awardCount")); } + if (jo.has("receiveFoodCount")) { + award.append(";肥料*").append(jo.getString("receiveFoodCount")); + } Log.farm("庄园游戏🎮[" + gameType.gameName() + "]#" + award); + if (jo.optInt("remainingGameCount", 0) > 0) { + recordFarmGame(gameType); + } } else { Log.i(TAG, jo.toString()); } diff --git a/app/src/main/java/pansong291/xposed/quickenergy/AntMember.java b/app/src/main/java/pansong291/xposed/quickenergy/AntMember.java index 524a8b42d..4ca86a6eb 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/AntMember.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/AntMember.java @@ -23,7 +23,7 @@ public void run() { while (FriendIdMap.currentUid == null || FriendIdMap.currentUid.isEmpty()) Thread.sleep(100); if (Statistics.canMemberSignInToday(FriendIdMap.currentUid)) { - String s = AntMemberRpcCall.memberSignIn(); + String s = AntMemberRpcCall.queryMemberSigninCalendar(); JSONObject jo = new JSONObject(s); if ("SUCCESS".equals(jo.getString("resultCode"))) { Log.other("每日签到📅[" + jo.getString("signinPoint") + "积分]#已签到" + jo.getString("signinSumDay") diff --git a/app/src/main/java/pansong291/xposed/quickenergy/hook/AntFarmRpcCall.java b/app/src/main/java/pansong291/xposed/quickenergy/hook/AntFarmRpcCall.java index c403ca0c5..0077f4fdc 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/hook/AntFarmRpcCall.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/hook/AntFarmRpcCall.java @@ -181,26 +181,28 @@ public static String sign() { } public static String initFarmGame(String gameType) { + if ("flyGame".equals(gameType)) { + return RpcUtil.request("com.alipay.antfarm.initFarmGame", + "[{\"gameType\":\"flyGame\",\"requestType\":\"RPC\",\"sceneCode\":\"FLAYGAME\"," + + "\"source\":\"FARM_game_yundongfly\",\"toolTypes\":\"ACCELERATETOOL,SHARETOOL,NONE\",\"version\":\"\"}]"); + } return RpcUtil.request("com.alipay.antfarm.initFarmGame", "[{\"gameType\":\"" + gameType + "\",\"requestType\":\"NORMAL\",\"sceneCode\":\"ANTFARM\",\"source\":\"H5\",\"toolTypes\":\"STEALTOOL,ACCELERATETOOL,SHARETOOL\"}]"); } - public static int RandomScore(String str) { - if ("starGame".equals(str)) { - return RandomUtils.nextInt(200, 300); - - } else if ("jumpGame".equals(str)) { - return RandomUtils.nextInt(150, 170) * 10; - } else { - return 210; - } - } - public static String recordFarmGame(String gameType) { String uuid = getUuid(); String md5String = getMD5(uuid); int score = RandomScore(gameType); + if ("flyGame".equals(gameType)) { + int foodCount = score / 50; + return RpcUtil.request("com.alipay.antfarm.recordFarmGame", + "[{\"foodCount\":" + foodCount + ",\"gameType\":\"flyGame\",\"md5\":\"" + md5String + + "\",\"requestType\":\"RPC\",\"sceneCode\":\"FLAYGAME\",\"score\":" + score + + ",\"source\":\"ANTFARM\",\"toolTypes\":\"ACCELERATETOOL,SHARETOOL,NONE\",\"uuid\":\"" + uuid + + "\",\"version\":\"\"}]"); + } return RpcUtil.request("com.alipay.antfarm.recordFarmGame", "[{\"gameType\":\"" + gameType + "\",\"md5\":\"" + md5String + "\",\"requestType\":\"NORMAL\",\"sceneCode\":\"ANTFARM\",\"score\":" + score @@ -208,6 +210,18 @@ public static String recordFarmGame(String gameType) { + "\"}]"); } + public static int RandomScore(String str) { + if ("starGame".equals(str)) { + return RandomUtils.nextInt(200, 300); + } else if ("jumpGame".equals(str)) { + return RandomUtils.nextInt(150, 170) * 10; + } else if ("flyGame".equals(str)) { + return RandomUtils.nextInt(5000, 8000); + } else { + return 210; + } + } + private static String getUuid() { StringBuilder sb = new StringBuilder(); for (String str : UUID.randomUUID().toString().split("-")) { diff --git a/app/src/main/java/pansong291/xposed/quickenergy/hook/AntMemberRpcCall.java b/app/src/main/java/pansong291/xposed/quickenergy/hook/AntMemberRpcCall.java index 585f39e19..ead8bf537 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/hook/AntMemberRpcCall.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/hook/AntMemberRpcCall.java @@ -13,9 +13,10 @@ public static String receivePointByUser(String certId) { return RpcUtil.request("alipay.antmember.biz.rpc.member.h5.receivePointByUser", args1); } - public static String memberSignIn() { + public static String queryMemberSigninCalendar() { String args1 = "[{}]"; - return RpcUtil.request("alipay.antmember.biz.rpc.member.h5.memberSignin", args1); + return RpcUtil.request("com.alipay.amic.biz.rpc.signin.h5.queryMemberSigninCalendar", + "[{\"autoSignIn\":true,\"invitorUserId\":\"\",\"sceneCode\":\"QUERY\"}]"); } /* 安心豆 */ 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 dbb5d19bb..81750975e 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/hook/XposedHook.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/hook/XposedHook.java @@ -1,6 +1,7 @@ package pansong291.xposed.quickenergy.hook; import android.annotation.SuppressLint; +import android.app.Activity; import android.app.AlarmManager; import android.app.PendingIntent; import android.app.Service; @@ -147,6 +148,7 @@ private void hookService(ClassLoader loader) { protected void afterHookedMethod(MethodHookParam param) { Log.i(TAG, "Activity onResume"); RpcUtil.isInterrupted = false; + PermissionUtil.requestPermissions((Activity) param.thisObject); AntForestNotification.setContentText("运行中..."); String targetUid = RpcUtil.getUserId(loader); if (targetUid == null || targetUid.equals(FriendIdMap.currentUid)) { From 744217859a1d1cfb6141f7cdd76c0bcb8b417546 Mon Sep 17 00:00:00 2001 From: Magical Yang Date: Mon, 4 Dec 2023 10:48:21 +0800 Subject: [PATCH 07/29] =?UTF-8?q?=E5=90=88=E5=B9=B6=E4=BA=86=E6=9D=A5?= =?UTF-8?q?=E8=87=AAnov30th=E7=9A=84pr=EF=BC=8C=E6=9C=AC=E6=AC=A1=E5=90=88?= =?UTF-8?q?=E5=B9=B6=E5=BE=85=E8=A7=82=E5=AF=9F=E4=B8=8B=E6=AC=A1=E6=AD=A3?= =?UTF-8?q?=E5=BC=8F=E7=89=88=E6=9C=AC=E6=9B=B4=E6=96=B0=E5=89=8D=E5=86=B3?= =?UTF-8?q?=E5=AE=9A=E6=98=AF=E5=90=A6=E4=BF=9D=E7=95=99=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 +- .../pansong291/xposed/quickenergy/AntForestToast.java | 1 - .../pansong291/xposed/quickenergy/util/FileUtils.java | 8 +++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 3690c8cbf..eb471d2d3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,7 +9,7 @@ android { //noinspection ExpiredTargetSdkVersion targetSdk 29 versionCode 71 - versionName "1.2.3-beta4" + versionName "1.2.3-beta6" } buildTypes { release { diff --git a/app/src/main/java/pansong291/xposed/quickenergy/AntForestToast.java b/app/src/main/java/pansong291/xposed/quickenergy/AntForestToast.java index e66a6f4f4..a8891e16e 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/AntForestToast.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/AntForestToast.java @@ -2,7 +2,6 @@ import android.annotation.SuppressLint; import android.content.Context; -import android.view.Gravity; import android.widget.Toast; import pansong291.xposed.quickenergy.util.Config; import pansong291.xposed.quickenergy.util.Log; 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 b4122cf77..824caed10 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/util/FileUtils.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/util/FileUtils.java @@ -50,7 +50,9 @@ private static void copyFile(File srcDir, File dstDir, String filename) { @SuppressWarnings("deprecation") public static File getMainDirectoryFile() { if (mainDirectory == null) { - String storageDirStr = Environment.getExternalStorageDirectory() + File.separator + "Android" + File.separator + "media" + File.separator + ClassMember.PACKAGE_NAME; + String storageDirStr = + Environment.getExternalStorageDirectory() + File.separator + "Android" + File.separator + "media" + + File.separator + ClassMember.PACKAGE_NAME; File storageDir = new File(storageDirStr); if (!storageDir.exists()) { storageDir.mkdirs(); @@ -371,7 +373,7 @@ public synchronized static void append2RuntimeLogFile(String s) { public static boolean write2File(String s, File f) { if (f.exists() && !f.canWrite()) { - AntForestToast.show(f.getName() + "没有写入权限!", true); + AntForestToast.show(f.getAbsoluteFile() + "没有写入权限!", true); return false; } boolean success = false; @@ -391,7 +393,7 @@ public static boolean write2File(String s, File f) { public static boolean append2File(String s, File f) { if (f.exists() && !f.canWrite()) { - AntForestToast.show(f.getName() + "没有写入权限!", true); + AntForestToast.show(f.getAbsoluteFile() + "没有写入权限!", true); return false; } boolean success = false; From aaa086705baa36568ee5c76e4e9697f00e330280 Mon Sep 17 00:00:00 2001 From: Magical Yang Date: Mon, 4 Dec 2023 11:00:25 +0800 Subject: [PATCH 08/29] =?UTF-8?q?=E5=8F=AF=E6=A0=B9=E6=8D=AEDownload?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E4=B8=8B=E6=98=AF=E5=90=A6=E5=AD=98=E5=9C=A8?= =?UTF-8?q?useMedia(=E7=9B=AE=E5=BD=95/=E6=96=87=E4=BB=B6)=E6=9D=A5?= =?UTF-8?q?=E5=86=B3=E5=AE=9A=E6=98=AF=E5=90=A6=E4=BD=BF=E7=94=A8Media?= =?UTF-8?q?=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xposed/quickenergy/util/FileUtils.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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 824caed10..b38ecabf1 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/util/FileUtils.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/util/FileUtils.java @@ -50,13 +50,17 @@ private static void copyFile(File srcDir, File dstDir, String filename) { @SuppressWarnings("deprecation") public static File getMainDirectoryFile() { if (mainDirectory == null) { - String storageDirStr = - Environment.getExternalStorageDirectory() + File.separator + "Android" + File.separator + "media" + - File.separator + ClassMember.PACKAGE_NAME; - File storageDir = new File(storageDirStr); + File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS); if (!storageDir.exists()) { storageDir.mkdirs(); } + File useMedia = new File(storageDir, "useMedia"); + if (useMedia.exists()) { + String storageDirStr = Environment.getExternalStorageDirectory() + File.separator + "Android" + + File.separator + "media" + File.separator + ClassMember.PACKAGE_NAME; + storageDir = new File(storageDirStr); + } + mainDirectory = new File(storageDir, "xqe"); if (!mainDirectory.exists()) { mainDirectory.mkdirs(); From e4b8691409b142beab98038ef6f7c93d0cc08c17 Mon Sep 17 00:00:00 2001 From: "Vincent Qiu (HOHO``)" Date: Tue, 5 Dec 2023 22:11:27 +0800 Subject: [PATCH 09/29] =?UTF-8?q?=E6=B7=BB=E5=8A=A0Hook=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E5=AE=9D=E6=8E=A8=E8=8D=90=E5=BA=94=E7=94=A8=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=8B=BE=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 3 +++ app/src/main/res/values/arrays.xml | 5 +++++ 2 files changed, 8 insertions(+) create mode 100644 app/src/main/res/values/arrays.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 061091f9e..de84dbf5d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -28,6 +28,9 @@ android:name="xposedminversion" android:value="54"/> + + + + + com.eg.android.AlipayGphone + + \ No newline at end of file From adab21aac9b914038fb3eb2215d98f82863fe0f5 Mon Sep 17 00:00:00 2001 From: Magical Yang Date: Wed, 6 Dec 2023 15:45:31 +0800 Subject: [PATCH 10/29] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=96=B0=E7=89=88?= =?UTF-8?q?=E5=B0=8F=E9=B8=A1=E8=B4=B4=E8=B4=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xposed/quickenergy/AntFarm.java | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/pansong291/xposed/quickenergy/AntFarm.java b/app/src/main/java/pansong291/xposed/quickenergy/AntFarm.java index ace88db90..da973655b 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/AntFarm.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/AntFarm.java @@ -1,6 +1,7 @@ package pansong291.xposed.quickenergy; import org.json.JSONArray; +import org.json.JSONException; import org.json.JSONObject; import pansong291.xposed.quickenergy.hook.AntFarmRpcCall; import pansong291.xposed.quickenergy.util.*; @@ -1317,8 +1318,6 @@ private static void drawLotteryPlus(JSONObject lotteryPlusInfo) { private static void visit() { try { - String s, memo; - JSONObject jo; for (int i = 0; i < Config.getVisitFriendList().size(); i++) { String userId = Config.getVisitFriendList().get(i); if (userId.equals(FriendIdMap.currentUid)) @@ -1396,27 +1395,34 @@ private static void acceptGift() { } } + private static void diaryTietie(String queryDayStr, String roleId) throws JSONException { + JSONObject jo = new JSONObject(AntFarmRpcCall.diaryTietie(queryDayStr, roleId)); + if ("SUCCESS".equals(jo.getString("memo"))) { + String prizeType = jo.getString("prizeType"); + int prizeNum = jo.optInt("prizeNum", 0); + Log.farm("贴贴小鸡💞[" + prizeType + "*" + prizeNum + "]"); + } else { + Log.i(jo.getString("memo"), jo.toString()); + } + } + private static void queryChickenDiary(String queryDayStr) { try { JSONObject jo = new JSONObject(AntFarmRpcCall.queryChickenDiary(queryDayStr)); if ("SUCCESS".equals(jo.getString("resultCode"))) { + if (!jo.getBoolean("hasTietie")) { + diaryTietie(queryDayStr, "NEW"); + return; + } JSONObject chickenDiary = jo.getJSONObject("data").getJSONObject("chickenDiary"); - String diaryDateStr = chickenDiary.getString("diaryDateStr"); if (!chickenDiary.has("tietieStatus")) return; JSONObject tietieStatus = chickenDiary.getJSONObject("tietieStatus"); - Iterator it = tietieStatus.keys(); + Iterator it = tietieStatus.keys(); while (it.hasNext()) { - String key = (String) it.next(); + String key = it.next(); if (tietieStatus.optBoolean(key, false)) { - jo = new JSONObject(AntFarmRpcCall.diaryTietie(diaryDateStr, key)); - if ("SUCCESS".equals(jo.getString("memo"))) { - String prizeType = jo.getString("prizeType"); - int prizeNum = jo.optInt("prizeNum", 0); - Log.farm("贴贴小鸡💞[" + prizeType + "*" + prizeNum + "]"); - } else { - Log.i(jo.getString("memo"), jo.toString()); - } + diaryTietie(queryDayStr, key); } } } else { From 102bee7a5a4da620ae8616f9c9d1633f968fb1d9 Mon Sep 17 00:00:00 2001 From: acooler15 Date: Mon, 6 Nov 2023 20:23:40 +0800 Subject: [PATCH 11/29] =?UTF-8?q?=E6=94=B6=E5=8F=96=E5=A5=BD=E5=8F=8B?= =?UTF-8?q?=E5=A4=8D=E6=B4=BB=E5=9B=9E=E8=B5=A0=E7=9A=84=E9=87=91=E7=90=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xposed/quickenergy/AntForest.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/src/main/java/pansong291/xposed/quickenergy/AntForest.java b/app/src/main/java/pansong291/xposed/quickenergy/AntForest.java index 55170ae53..03fb1114c 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/AntForest.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/AntForest.java @@ -439,6 +439,28 @@ private static void canCollectSelfEnergy() { } else { Log.recordLog("收取[我]的复活金球失败:" + joEnergy.getString("resultDesc"), str); } + } else if ("baohuhuizeng".equals(bizType)) { + String friendId = wateringBubble.getString("userId"); + String str = AntForestRpcCall.collectEnergy(bizType, selfId, + wateringBubble.getLong("id")); + JSONObject joEnergy = new JSONObject(str); + if ("SUCCESS".equals(joEnergy.getString("resultCode"))) { + JSONArray bubbles = joEnergy.getJSONArray("bubbles"); + for (int j = 0; j < bubbles.length(); j++) { + collected = bubbles.getJSONObject(j).getInt("collectedEnergy"); + } + if (collected > 0) { + totalCollected += collected; + Statistics.addData(Statistics.DataType.COLLECTED, collected); + String msg = "收取金球🍯[" + FriendIdMap.getNameById(friendId) + "]复活回赠[" + collected + "g]"; + Log.forest(msg); + AntForestToast.show(msg); + } else { + Log.recordLog("收取[" + FriendIdMap.getNameById(friendId) + "]的复活回赠金球失败", ""); + } + } else { + Log.recordLog("收取[" + FriendIdMap.getNameById(friendId) + "]的复活回赠金球失败:" + joEnergy.getString("resultDesc"), str); + } } Thread.sleep(1000L); } From 5b4e691b6c194a7ab33fa04b6311e8db4dc49287 Mon Sep 17 00:00:00 2001 From: acooler15 Date: Sun, 7 Jan 2024 01:57:32 +0000 Subject: [PATCH 12/29] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E2=80=9C=E5=A4=9A?= =?UTF-8?q?=E9=80=89=E2=80=9D=E5=92=8C=E2=80=9C=E5=8F=8D=E9=80=89=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xposed/quickenergy/ui/ListAdapter.java | 23 ++++++++++- .../xposed/quickenergy/ui/ListDialog.java | 38 +++++++++++++++++-- app/src/main/res/layout/dialog_list.xml | 32 ++++++++++++++++ app/src/main/res/values-zh-rCN/strings.xml | 3 ++ app/src/main/res/values/strings.xml | 3 ++ 5 files changed, 94 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/pansong291/xposed/quickenergy/ui/ListAdapter.java b/app/src/main/java/pansong291/xposed/quickenergy/ui/ListAdapter.java index eccb8c2e5..7ae0c914c 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/ui/ListAdapter.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/ui/ListAdapter.java @@ -66,8 +66,7 @@ public void setSelectedList(List l) { } } - public int - findLast(CharSequence cs) { + public int findLast(CharSequence cs) { if (list == null || list.isEmpty()) return -1; if (!cs.equals(findWord)) { @@ -116,6 +115,26 @@ public void exitFind() { findIndex = -1; } + public void selectAll(){ + selects.clear(); + for(IdAndName ai:list){ + selects.add(ai.id); + } + notifyDataSetChanged(); + } + + public void SelectInvert(){ + List newSelects = new ArrayList<>(); + for(IdAndName ai:list){ + if(!selects.contains(ai.id)){ + newSelects.add(ai.id); + } + } + selects.clear(); + selects.addAll(newSelects); + notifyDataSetChanged(); + } + @Override public int getCount() { return list == null ? 0 : list.size(); diff --git a/app/src/main/java/pansong291/xposed/quickenergy/ui/ListDialog.java b/app/src/main/java/pansong291/xposed/quickenergy/ui/ListDialog.java index 4d11ecfbc..b9798e511 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/ui/ListDialog.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/ui/ListDialog.java @@ -14,6 +14,7 @@ import android.widget.EditText; import android.widget.ListView; import android.widget.Toast; +import android.widget.RelativeLayout; import java.util.List; import pansong291.xposed.quickenergy.R; import pansong291.xposed.quickenergy.entity.AlipayUser; @@ -26,7 +27,8 @@ public class ListDialog { static AlertDialog listDialog; - static Button btn_find_last, btn_find_next; + static Button btn_find_last, btn_find_next, + btn_select_all, btn_select_invert; static EditText edt_find; static ListView lv_list; static List selectedList; @@ -42,6 +44,8 @@ public class ListDialog { static AlertDialog optionsDialog; static AlertDialog deleteDialog; + static RelativeLayout layout_batch_process; + public enum ListType { RADIO, CHECK, SHOW } @@ -77,7 +81,7 @@ private static AlertDialog getListDialog(Context c) { listDialog = new AlertDialog.Builder(c) .setTitle("title") .setView(getListView(c)) - .setPositiveButton(c.getString(R.string.ok), null) + .setPositiveButton(c.getString(R.string.close), null) .create(); listDialog.setOnShowListener( new OnShowListener() { @@ -90,6 +94,9 @@ public OnShowListener setContext(Context c) { @Override public void onShow(DialogInterface p1) { + AlertDialog d = (AlertDialog) p1; + layout_batch_process = d.findViewById(R.id.layout_batch_process); + layout_batch_process.setVisibility(listType==ListType.CHECK&&countList==null?View.VISIBLE:View.GONE); ListAdapter.get(c).notifyDataSetChanged(); } }.setContext(c)); @@ -98,11 +105,19 @@ public void onShow(DialogInterface p1) { private static View getListView(Context c) { View v = LayoutInflater.from(c).inflate(R.layout.dialog_list, null); - OnBtnClickListener onBtnClickListener = new OnBtnClickListener(); + btn_find_last = v.findViewById(R.id.btn_find_last); btn_find_next = v.findViewById(R.id.btn_find_next); + btn_select_all = v.findViewById(R.id.btn_select_all); + btn_select_invert = v.findViewById(R.id.btn_select_invert); + + OnBtnClickListener onBtnClickListener = new OnBtnClickListener(); + BatchBtnOnClickListener batchBtnOnClickListener = new BatchBtnOnClickListener(); btn_find_last.setOnClickListener(onBtnClickListener); btn_find_next.setOnClickListener(onBtnClickListener); + btn_select_all.setOnClickListener(batchBtnOnClickListener); + btn_select_invert.setOnClickListener(batchBtnOnClickListener); + edt_find = v.findViewById(R.id.edt_find); lv_list = v.findViewById(R.id.lv_list); lv_list.setAdapter(ListAdapter.get(c)); @@ -351,4 +366,21 @@ public void onClick(View p1) { } } + static class BatchBtnOnClickListener implements View.OnClickListener { + @SuppressLint("NonConstantResourceId") + @Override + public void onClick(View p1) { + ListAdapter la = ListAdapter.get(p1.getContext()); + switch (p1.getId()) { + case R.id.btn_select_all: + la.selectAll(); + break; + case R.id.btn_select_invert: + la.SelectInvert(); + break; + } + Config.hasChanged = true; + } + } + } diff --git a/app/src/main/res/layout/dialog_list.xml b/app/src/main/res/layout/dialog_list.xml index 3bddfbf12..c0b755244 100644 --- a/app/src/main/res/layout/dialog_list.xml +++ b/app/src/main/res/layout/dialog_list.xml @@ -5,6 +5,38 @@ android:layout_height="match_parent" android:orientation="vertical"> + + +