Skip to content

Commit

Permalink
修复保护古树开关,古树地区增加长沙,添加浇水克数配置,神奇海洋添加迎回海洋生物、拾取碎片
Browse files Browse the repository at this point in the history
  • Loading branch information
constanline committed Aug 2, 2023
1 parent 98fc54c commit 8e31ae3
Show file tree
Hide file tree
Showing 17 changed files with 147 additions and 49 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
- [x] 好友昵称
- [ ] 神奇海洋
- [ ] 蚂蚁新村
- [ ] 绿色营收
- [ ] 高版本API存储问题


***目前没有大小号、号码切换的计划***
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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() {
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -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);
}
}
Expand All @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
48 changes: 46 additions & 2 deletions app/src/main/java/pansong291/xposed/quickenergy/AntOcean.java
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
Expand Down Expand Up @@ -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"));
}
}
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() + "\"}]");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -35,6 +30,7 @@ public static List<AreaCode> getList() {
"{\"cityCode\":\"330100\",\"cityName\":\"杭州市\"}," +
"{\"cityCode\":\"350100\",\"cityName\":\"福州市\"}," +
"{\"cityCode\":\"370100\",\"cityName\":\"济南市\"}," +
"{\"cityCode\":\"430100\",\"cityName\":\"长沙市\"}," +
"{\"cityCode\":\"440100\",\"cityName\":\"广州市\"}" +
"]";
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
64 changes: 43 additions & 21 deletions app/src/main/java/pansong291/xposed/quickenergy/util/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -132,6 +132,7 @@ public CharSequence nickName()
private boolean receiveForestTaskAward;
private List<String> waterFriendList;
private List<Integer> waterCountList;
private int waterFriendCount;
private boolean cooperateWater;
private List<String> cooperateWaterList;
private List<String> syncStepList;
Expand Down Expand Up @@ -471,6 +472,17 @@ public static List<Integer> 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;
Expand Down Expand Up @@ -508,6 +520,26 @@ public static List<String> 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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<>();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -1084,6 +1104,7 @@ public static Config json2Config(String json)
}
}
}
config.waterFriendCount = jo.optInt(jn_waterFriendCount, 66);

config.cooperateWater = jo.optBoolean(jn_cooperateWater, true);

Expand Down Expand Up @@ -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);

Expand Down
Loading

0 comments on commit 8e31ae3

Please sign in to comment.