From 8e31ae3cfb8e708cdd1d95c0fa04213d475296be Mon Sep 17 00:00:00 2001 From: Magical Yang Date: Wed, 2 Aug 2023 20:00:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BF=9D=E6=8A=A4=E5=8F=A4?= =?UTF-8?q?=E6=A0=91=E5=BC=80=E5=85=B3=EF=BC=8C=E5=8F=A4=E6=A0=91=E5=9C=B0?= =?UTF-8?q?=E5=8C=BA=E5=A2=9E=E5=8A=A0=E9=95=BF=E6=B2=99=EF=BC=8C=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=B5=87=E6=B0=B4=E5=85=8B=E6=95=B0=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=EF=BC=8C=E7=A5=9E=E5=A5=87=E6=B5=B7=E6=B4=8B=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=BF=8E=E5=9B=9E=E6=B5=B7=E6=B4=8B=E7=94=9F=E7=89=A9=E3=80=81?= =?UTF-8?q?=E6=8B=BE=E5=8F=96=E7=A2=8E=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 + app/build.gradle | 4 +- .../xposed/quickenergy/AncientTree.java | 9 +-- .../xposed/quickenergy/AntForest.java | 3 +- .../xposed/quickenergy/AntOcean.java | 48 +++++++++++++- .../quickenergy/hook/AntOceanRpcCall.java | 10 +++ .../xposed/quickenergy/ui/AreaCode.java | 6 +- .../xposed/quickenergy/ui/EditDialog.java | 11 +++- .../xposed/quickenergy/ui/ListAdapter.java | 2 +- .../quickenergy/ui/SettingsActivity.java | 4 ++ .../xposed/quickenergy/util/Config.java | 64 +++++++++++++------ .../xposed/quickenergy/util/FileUtils.java | 8 ++- .../xposed/quickenergy/util/FriendIdMap.java | 2 +- .../xposed/quickenergy/util/Log.java | 6 -- app/src/main/res/layout/include_settings.xml | 13 ++++ app/src/main/res/values-zh-rCN/strings.xml | 3 +- app/src/main/res/values/strings.xml | 1 + 17 files changed, 147 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index c3a253e95..b640f97a9 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,8 @@ - [x] 好友昵称 - [ ] 神奇海洋 - [ ] 蚂蚁新村 +- [ ] 绿色营收 +- [ ] 高版本API存储问题 ***目前没有大小号、号码切换的计划*** diff --git a/app/build.gradle b/app/build.gradle index 34338ed39..9c0af0084 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { minSdkVersion 23 //noinspection ExpiredTargetSdkVersion targetSdkVersion 29 - versionCode 27 - versionName "1.0.10" + versionCode 29 + versionName "1.0.12" } buildTypes { release { diff --git a/app/src/main/java/pansong291/xposed/quickenergy/AncientTree.java b/app/src/main/java/pansong291/xposed/quickenergy/AncientTree.java index 082dc22cc..8d8806806 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/AncientTree.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/AncientTree.java @@ -6,6 +6,7 @@ import pansong291.xposed.quickenergy.hook.AncientTreeRpcCall; import pansong291.xposed.quickenergy.util.Config; import pansong291.xposed.quickenergy.util.Log; +import pansong291.xposed.quickenergy.util.Statistics; import java.util.List; @@ -19,7 +20,7 @@ public class AncientTree { private static boolean firstTime = true; public static void start() { - if (!firstTime) { + if (!Config.ancientTree() || !firstTime || !Config.isAncientTreeWeek()) { return; } new Thread() { @@ -48,7 +49,7 @@ private static void home() { firstTime = false; } } catch (Throwable t) { - Log.i(TAG, "homePage err:"); + Log.i(TAG, "home err:"); Log.printStackTrace(TAG, t); } } @@ -73,7 +74,7 @@ private static void protect(JSONObject projectDetail) throws JSONException { Log.forest("[保护古树]消耗" + protectExpense + "能量保护古树\"" + name + "\"成功"); } } catch (Throwable t) { - Log.i(TAG, "homePage err:"); + Log.i(TAG, "protect err:"); Log.printStackTrace(TAG, t); } } @@ -93,7 +94,7 @@ private static void projectDetail(String cityCode, JSONArray ancientTreeList) th protect(jo); } } catch (Throwable t) { - Log.i(TAG, "homePage err:"); + Log.i(TAG, "projectDetail err:"); Log.printStackTrace(TAG, t); } } diff --git a/app/src/main/java/pansong291/xposed/quickenergy/AntForest.java b/app/src/main/java/pansong291/xposed/quickenergy/AntForest.java index 3ee9c70bc..f14bf1aa5 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/AntForest.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/AntForest.java @@ -578,8 +578,7 @@ private static void waterFriendEnergy(String userId, int count) { String bizNo = jo.getString("bizNo"); jo = jo.getJSONObject("userEnergy"); String userName = jo.getString("displayName"); - Log.recordLog("尝试对【" + userName + "】浇水66g" + count + "次【" + bizNo + "】"); - count = returnFriendWater(userId, userName, bizNo, count, 66); + count = returnFriendWater(userId, userName, bizNo, count, Config.waterFriendCount()); if (count > 0) Statistics.waterFriendToday(userId, count); } else { Log.recordLog(jo.getString("resultDesc"), s); diff --git a/app/src/main/java/pansong291/xposed/quickenergy/AntOcean.java b/app/src/main/java/pansong291/xposed/quickenergy/AntOcean.java index 0eb2f6b02..115ef52a9 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/AntOcean.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/AntOcean.java @@ -57,6 +57,14 @@ private static void queryHomePage() { int rubbishNumber = userInfoVO.optInt("rubbishNumber"); String userId = userInfoVO.getString("userId"); cleanOcean(userId, rubbishNumber); + + JSONObject ipVO = userInfoVO.optJSONObject("ipVO"); + if (ipVO != null) { + int surprisePieceNum = ipVO.optInt("surprisePieceNum", 0); + if (surprisePieceNum > 0) { + ipOpenSurprise(); + } + } } else { Log.i(TAG, joHomePage.getString("resultDesc")); } @@ -115,14 +123,50 @@ private static void cleanOcean(String userId, int rubbishNumber) { } } + private static void ipOpenSurprise() { + try { + String s = AntOceanRpcCall.ipOpenSurprise(); + JSONObject jo = new JSONObject(s); + if ("SUCCESS".equals(jo.getString("resultCode"))) { + JSONArray rewardVOS = jo.getJSONArray("surpriseRewardVOS"); + checkReward(rewardVOS); + } else { + Log.i(TAG, jo.getString("resultDesc")); + } + } catch(Throwable t) { + Log.i(TAG, "ipOpenSurprise err:"); + Log.printStackTrace(TAG, t); + } + } + private static void checkReward(JSONArray rewards) { try { for (int i = 0; i < rewards.length(); i++) { - JSONObject cleanReward = rewards.getJSONObject(i); - JSONArray attachReward = cleanReward.getJSONArray("attachRewardBOList"); + JSONObject reward = rewards.getJSONObject(i); + JSONArray attachReward = reward.getJSONArray("attachRewardBOList"); if (attachReward.length() > 0) { Log.forest("【神奇海洋】获取碎片奖励"); + boolean canCombine = true; + for (int j = 0; j < attachReward.length(); j++) { + JSONObject detail = attachReward.getJSONObject(j); + if (detail.optInt("count") == 0) { + canCombine = false; + break; + } + } + if (canCombine && reward.optBoolean("unlock", false)) { + String fishId = reward.getString("id"); + String s = AntOceanRpcCall.combineFish(fishId); + JSONObject jo = new JSONObject(s); + if ("SUCCESS".equals(jo.getString("resultCode"))) { + JSONObject fishDetailVO = jo.getJSONObject("fishDetailVO"); + String name = fishDetailVO.getString("name"); + Log.forest("【神奇海洋】合成海洋生物" + name); + } else { + Log.i(TAG, jo.getString("resultDesc")); + } + } } } 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 44a3b2ffa..685b3dfcf 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/hook/AntOceanRpcCall.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/hook/AntOceanRpcCall.java @@ -26,4 +26,14 @@ public static String cleanOcean(String userId) { return RpcUtil.request("alipay.antocean.ocean.h5.cleanOcean", "[{\"cleanedUserId\":\"" + userId + "\",\"source\":\"ANT_FOREST\",\"uniqueId\":\"" + getUniqueId() + "\"}]"); } + + public static String combineFish(String fishId) { + return RpcUtil.request("alipay.antocean.ocean.h5.combineFish", "[{\"fishId\":\"" + fishId + + "\",\"source\":\"ANT_FOREST\",\"uniqueId\":\"" + getUniqueId() + "\"}]"); + } + + public static String ipOpenSurprise() { + return RpcUtil.request("alipay.antocean.ocean.h5.ipOpenSurprise", + "[{\"source\":\"chInfo_ch_appcenter__chsub_9patch\",\"uniqueId\":\"" + getUniqueId() + "\"}]"); + } } diff --git a/app/src/main/java/pansong291/xposed/quickenergy/ui/AreaCode.java b/app/src/main/java/pansong291/xposed/quickenergy/ui/AreaCode.java index b14965dd5..73892dacc 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/ui/AreaCode.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/ui/AreaCode.java @@ -3,16 +3,11 @@ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; -import pansong291.xposed.quickenergy.AntFarm; -import pansong291.xposed.quickenergy.util.CooperationIdMap; import pansong291.xposed.quickenergy.util.FileUtils; import pansong291.xposed.quickenergy.util.Log; -import pansong291.xposed.quickenergy.util.StringUtil; import java.util.ArrayList; import java.util.List; -import java.util.Map; -import java.util.Set; public class AreaCode extends IdAndName { private static final String TAG = AreaCode.class.getCanonicalName(); @@ -35,6 +30,7 @@ public static List getList() { "{\"cityCode\":\"330100\",\"cityName\":\"杭州市\"}," + "{\"cityCode\":\"350100\",\"cityName\":\"福州市\"}," + "{\"cityCode\":\"370100\",\"cityName\":\"济南市\"}," + + "{\"cityCode\":\"430100\",\"cityName\":\"长沙市\"}," + "{\"cityCode\":\"440100\",\"cityName\":\"广州市\"}" + "]"; try { diff --git a/app/src/main/java/pansong291/xposed/quickenergy/ui/EditDialog.java b/app/src/main/java/pansong291/xposed/quickenergy/ui/EditDialog.java index 5943eb3de..f8701783b 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/ui/EditDialog.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/ui/EditDialog.java @@ -11,7 +11,7 @@ public class EditDialog { public enum EditMode { CHECK_INTERVAL, THREAD_COUNT, ADVANCE_TIME, COLLECT_INTERVAL, LIMIT_COUNT, DOUBLE_CARD_TIME, - COLLECT_TIMEOUT, RETURN_WATER_30, RETURN_WATER_20, RETURN_WATER_10, ANIMAL_SLEEP_TIME, + COLLECT_TIMEOUT, RETURN_WATER_30, RETURN_WATER_20, RETURN_WATER_10, WATER_FRIEND_COUNT, ANIMAL_SLEEP_TIME, MIN_EXCHANGE_COUNT, LATEST_EXCHANGE_TIME, SYNC_STEP_COUNT, WAIT_WHEN_EXCEPTION ,EXCHANGE_ENERGY_DOUBLE_CLICK_COUNT } private static EditMode mode; @@ -89,6 +89,11 @@ public void onClick(DialogInterface p1, int p2) { Config.setReturnWater10(i); break; + case WATER_FRIEND_COUNT: + if(i >= 0) + Config.setWaterFriendCount(i); + break; + case ANIMAL_SLEEP_TIME: Config.setAnimalSleepTime(edt.getText().toString()); break; @@ -163,6 +168,10 @@ public void onClick(DialogInterface p1, int p2) { str = String.valueOf(Config.returnWater10()); break; + case WATER_FRIEND_COUNT: + str = String.valueOf(Config.waterFriendCount()); + break; + case ANIMAL_SLEEP_TIME: str = Config.animalSleepTime(); break; 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 bb5cc1ad4..04dee6bdb 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/ui/ListAdapter.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/ui/ListAdapter.java @@ -124,7 +124,7 @@ public View getView(int p1, View p2, ViewGroup p3) { vh = (ViewHolder)p2.getTag(); } - IdAndName ai = (IdAndName) list.get(p1); + IdAndName ai = list.get(p1); vh.tv.setText(ai.name); vh.tv.setTextColor(findIndex == p1 ? Color.RED: Color.BLACK); vh.cb.setChecked(selects != null && selects.contains(ai.id)); 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 e321af0a9..9f1969abd 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/ui/SettingsActivity.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/ui/SettingsActivity.java @@ -332,6 +332,10 @@ public void onClick(View v) { ListDialog.show(this, btn.getText(), AlipayUser.getList(), Config.getWaterFriendList(), Config.getWaterCountList()); break; + case R.id.btn_waterFriendCount: + EditDialog.showEditDialog(this, btn.getText(), EditDialog.EditMode.WATER_FRIEND_COUNT); + break; + case R.id.btn_cooperateWaterList: ListDialog.show(this, btn.getText(), CooperateUser.getList(), Config.getCooperateWaterList(), Config.getcooperateWaterNumList()); 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 861ee0143..c995d0aa6 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/util/Config.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/util/Config.java @@ -5,9 +5,8 @@ import pansong291.xposed.quickenergy.AntFarm.SendType; import pansong291.xposed.quickenergy.hook.XposedHook; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +import java.text.SimpleDateFormat; +import java.util.*; public class Config { @@ -53,6 +52,7 @@ public CharSequence nickName() public static final String jn_collectTimeout = "collectTimeout"; public static final String jn_receiveForestTaskAward = "receiveForestTaskAward"; public static final String jn_waterFriendList = "waterFriendList"; + public static final String jn_waterFriendCount = "waterFriendCount"; public static final String jn_cooperateWater = "cooperateWater"; public static final String jn_cooperateWaterList = "cooperateWaterList"; public static final String jn_ancientTree = "ancientTree"; @@ -132,6 +132,7 @@ public CharSequence nickName() private boolean receiveForestTaskAward; private List waterFriendList; private List waterCountList; + private int waterFriendCount; private boolean cooperateWater; private List cooperateWaterList; private List syncStepList; @@ -471,6 +472,17 @@ public static List getWaterCountList() return getConfig().waterCountList; } + + public static void setWaterFriendCount(int i) + { + getConfig().waterFriendCount = i; + hasChanged = true; + } + + public static int waterFriendCount() + { + return getConfig().waterFriendCount; + } public static void setCooperateWater(boolean b) { getConfig().cooperateWater = b; @@ -508,6 +520,26 @@ public static List getAncientTreeAreaCodeList() return getConfig().ancientTreeAreaCodeList; } + public static void setAncientTreeOnlyWeek(boolean b) + { + getConfig().ancientTreeOnlyWeek = b; + hasChanged = true; + } + + public static boolean ancientTreeOnlyWeek() + { + return getConfig().ancientTreeOnlyWeek; + } + + public static boolean isAncientTreeWeek() { + if (!ancientTreeOnlyWeek()) { + return true; + } + SimpleDateFormat sdf_week = new SimpleDateFormat("EEEE", Locale.getDefault()); + String week = sdf_week.format(new Date()); + return "星期一".equals(week) || "星期三".equals(week) || "星期五".equals(week); + } + public static void setReserve(boolean b) { getConfig().reserve = b; @@ -563,17 +595,6 @@ public static void setExchangeEnergyDoubleClickCount(int exchangeEnergyDoubleCli hasChanged = true; } - public static void setAncientTreeOnlyWeek(boolean b) - { - getConfig().ancientTreeOnlyWeek = b; - hasChanged = true; - } - - public static boolean ancientTreeOnlyWeek() - { - return getConfig().ancientTreeOnlyWeek; - } - public static void setAntdodoCollect(boolean b) { getConfig().antdodoCollect = b; @@ -901,8 +922,8 @@ private static Config getConfig() { if(config == null || shouldReload && config.immediateEffect) { shouldReload = false; String confJson = null; - if(FileUtils.getConfigFile().exists()) - confJson = FileUtils.readFromFile(FileUtils.getConfigFile()); + if (FileUtils.getConfigFile(FriendIdMap.currentUid).exists()) + confJson = FileUtils.readFromFile(FileUtils.getConfigFile(FriendIdMap.currentUid)); config = json2Config(confJson); } return config; @@ -942,6 +963,7 @@ public static Config defInit() c.receiveForestTaskAward = true; if(c.waterFriendList == null) c.waterFriendList = new ArrayList<>(); if(c.waterCountList == null) c.waterCountList = new ArrayList<>(); + c.waterFriendCount = 66; c.cooperateWater = true; if(c.cooperateWaterList == null) c.cooperateWaterList = new ArrayList<>(); if(c.syncStepList == null) c.syncStepList = new ArrayList<>(); @@ -995,11 +1017,9 @@ public static boolean saveConfigFile() { return FileUtils.write2File(config2Json(config), FileUtils.getConfigFile()); } - public static Config json2Config(String json) - { - Config config = null; - try - { + public static Config json2Config(String json) { + Config config; + try { JSONObject jo = new JSONObject(json); JSONArray ja, jaa; config = new Config(); @@ -1084,6 +1104,7 @@ public static Config json2Config(String json) } } } + config.waterFriendCount = jo.optInt(jn_waterFriendCount, 66); config.cooperateWater = jo.optBoolean(jn_cooperateWater, true); @@ -1321,6 +1342,7 @@ public static String config2Json(Config config) { ja.put(jaa); } jo.put(jn_waterFriendList, ja); + jo.put(jn_waterFriendCount, config.waterFriendCount); jo.put(jn_cooperateWater, config.cooperateWater); 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 4582f5445..13d7a9d84 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/util/FileUtils.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/util/FileUtils.java @@ -14,7 +14,7 @@ public class FileUtils private static final String TAG = FileUtils.class.getCanonicalName(); private static File mainDirectory; private static File configDirectory; - private static Map configFileMap = new HashMap<>(); + private static final Map configFileMap = new HashMap<>(); private static File friendIdMapFile; private static File cooperationIdMapFile; private static File reserveIdMapFile; @@ -45,12 +45,12 @@ public static File getMainDirectoryFile() { return mainDirectory; } + @SuppressWarnings("deprecation") public static File getConfigDirectoryFile() { if(configDirectory == null) { configDirectory = new File(Environment.getExternalStorageDirectory(), "xqe/config"); if(configDirectory.exists()) { - if(configDirectory.isFile()) - { + if(configDirectory.isFile()) { configDirectory.delete(); configDirectory.mkdirs(); } @@ -86,6 +86,8 @@ public static File getConfigFile(String userId) { configFileMap.put(userId, configFile); return configFile; } + } else { + return configFileMap.get(userId); } } return configFileMap.get("Default"); diff --git a/app/src/main/java/pansong291/xposed/quickenergy/util/FriendIdMap.java b/app/src/main/java/pansong291/xposed/quickenergy/util/FriendIdMap.java index aae8b89d2..3ac591868 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/util/FriendIdMap.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/util/FriendIdMap.java @@ -10,7 +10,7 @@ public class FriendIdMap { public static boolean shouldReload = false; - public static String currentUid; + public static String currentUid = null; private static Map idMap; private static boolean hasChanged = false; diff --git a/app/src/main/java/pansong291/xposed/quickenergy/util/Log.java b/app/src/main/java/pansong291/xposed/quickenergy/util/Log.java index 03bb9c6de..0f8f06e6f 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/util/Log.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/util/Log.java @@ -55,10 +55,4 @@ public static String getFormatTime() { return getFormatDateTime().split(" ")[1]; } - public static boolean isAncientTreeWeek() { - SimpleDateFormat sdf_week = new SimpleDateFormat("EEEE", Locale.getDefault()); - String week = sdf_week.format(new Date()); - return "星期一".equals(week) || "星期三".equals(week) || "星期五".equals(week); - } - } diff --git a/app/src/main/res/layout/include_settings.xml b/app/src/main/res/layout/include_settings.xml index aa7165f05..fef53b9ee 100644 --- a/app/src/main/res/layout/include_settings.xml +++ b/app/src/main/res/layout/include_settings.xml @@ -315,6 +315,19 @@ android:id="@+id/btn_waterFriendList" android:paddingStart="8dp"/> +