Skip to content

Commit

Permalink
合并来自cwj851的pr,一些细节更新。
Browse files Browse the repository at this point in the history
  • Loading branch information
constanline committed Aug 10, 2023
1 parent d2be132 commit a215576
Show file tree
Hide file tree
Showing 36 changed files with 1,405 additions and 715 deletions.
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 {
minSdk 21
//noinspection ExpiredTargetSdkVersion
targetSdk 29
versionCode 44
versionName "1.0.18-fix1"
versionCode 45
versionName "1.0.19"
}
buildTypes {
release {
Expand Down
17 changes: 10 additions & 7 deletions app/src/main/java/pansong291/xposed/quickenergy/AncientTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
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 @@ -32,7 +31,7 @@ public void run() {
}
private static void home() {
List<String> list = Config.getAncientTreeAreaCodeList();
if (list.size() == 0) {
if (list.isEmpty()) {
return;
}
for (String code : list) {
Expand All @@ -41,11 +40,15 @@ private static void home() {
JSONObject jo = new JSONObject(s);
if (jo.getString("resultCode").equals("SUCCESS")) {
JSONObject data = jo.getJSONObject("data");
JSONObject targetDistrictDetailInfo = data.getJSONObject("targetDistrictDetailInfo");
JSONObject districtInfo = targetDistrictDetailInfo.getJSONObject("districtInfo");
String cityCode = districtInfo.getString("cityCode");
JSONArray ancientTreeList = targetDistrictDetailInfo.getJSONArray("ancientTreeList");
projectDetail(cityCode, ancientTreeList);
if (data.has("targetDistrictDetailInfo")) {
JSONObject targetDistrictDetailInfo = data.getJSONObject("targetDistrictDetailInfo");
JSONObject districtInfo = targetDistrictDetailInfo.getJSONObject("districtInfo");
String cityCode = districtInfo.getString("cityCode");
JSONArray ancientTreeList = targetDistrictDetailInfo.getJSONArray("ancientTreeList");
projectDetail(cityCode, ancientTreeList);
} else {
Log.recordLog("targetDistrictDetailInfo不存在", s);
}
firstTime = false;
}
} catch (Throwable t) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void run() {
s = AntCooperateRpcCall.queryUserCooperatePlantList();
}
JSONObject jo = new JSONObject(s);
if (jo.getString("resultCode").equals("SUCCESS")) {
if ("SUCCESS".equals(jo.getString("resultCode"))) {
int userCurrentEnergy = jo.getInt("userCurrentEnergy");
JSONArray ja = jo.getJSONArray("cooperatePlants");
for (int i = 0; i < ja.length(); i++) {
Expand Down Expand Up @@ -80,7 +80,7 @@ private static void cooperateWater(String uid, String coopId, int count, String
try {
String s = AntCooperateRpcCall.cooperateWater(uid, coopId, count);
JSONObject jo = new JSONObject(s);
if (jo.getString("resultCode").equals("SUCCESS")) {
if ("SUCCESS".equals(jo.getString("resultCode"))) {
Log.forest("合种浇水🚿[" + name + "]" + jo.getString("barrageText"));
Statistics.cooperateWaterToday(FriendIdMap.currentUid, coopId);
} else {
Expand Down
92 changes: 41 additions & 51 deletions app/src/main/java/pansong291/xposed/quickenergy/AntFarm.java

Large diffs are not rendered by default.

372 changes: 296 additions & 76 deletions app/src/main/java/pansong291/xposed/quickenergy/AntForest.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ public class AntForestNotification {
private static Notification.Builder builder;
private static boolean isStart = false;

private AntForestNotification() {}
private AntForestNotification() {
}

public static void start(Context context) {
initNotification(context);
if (!isStart) {
if(context instanceof Service)
((Service)context).startForeground(NOTIFICATION_ID, mNotification);
if (context instanceof Service)
((Service) context).startForeground(NOTIFICATION_ID, mNotification);
else
getNotificationManager(context).notify(NOTIFICATION_ID, mNotification);
isStart = true;
Expand All @@ -36,9 +37,9 @@ public static void start(Context context) {
}

public static void stop(Context context, boolean remove) {
if(isStart) {
if(context instanceof Service)
((Service)context).stopForeground(remove);
if (isStart) {
if (context instanceof Service)
((Service) context).stopForeground(remove);
else
getNotificationManager(context).cancel(NOTIFICATION_ID);
isStart = false;
Expand All @@ -47,20 +48,20 @@ public static void stop(Context context, boolean remove) {
}

private static NotificationManager getNotificationManager(Context context) {
if(mNotifyManager == null)
if (mNotifyManager == null)
mNotifyManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
return mNotifyManager;
}

private static void initNotification(Context context) {
if(mNotification == null) {
if (mNotification == null) {
Intent it = new Intent(Intent.ACTION_VIEW);
it.setData(Uri.parse("alipays://platformapi/startapp?appId="));
PendingIntent pi = PendingIntent.getActivity(context, 0, it,
PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT);

if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID, "芝麻粒能量提醒",
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID, "仙人掌能量提醒",
NotificationManager.IMPORTANCE_LOW);
notificationChannel.enableLights(false);
notificationChannel.enableVibration(false);
Expand Down Expand Up @@ -88,7 +89,7 @@ public static void setContentText(CharSequence cs) {
cs = "请求不合法,等待至" + DateFormat.getDateTimeInstance().format(Config.forestPauseTime());
}
mNotification = builder.setContentText(cs).build();
if(mNotifyManager != null)
if (mNotifyManager != null)
mNotifyManager.notify(NOTIFICATION_ID, mNotification);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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;
Expand All @@ -15,7 +16,7 @@ public class AntForestToast {

public static void show(CharSequence cs) {
try {
if(context != null && Config.showToast()) {
if (context != null && Config.showToast()) {
XposedHook.handler.post(
new Runnable() {
CharSequence cs;
Expand All @@ -28,15 +29,17 @@ public Runnable setData(CharSequence c) {
@Override
public void run() {
try {
Toast.makeText(context, cs, Toast.LENGTH_SHORT).show();
} catch(Throwable t) {
Toast toast = Toast.makeText(context, cs, Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER, 0, Config.toastOffsetY());
toast.show();
} catch (Throwable t) {
Log.i(TAG, "show.run err:");
Log.printStackTrace(TAG, t);
}
}
}.setData(cs));
}
} catch(Throwable t) {
} catch (Throwable t) {
Log.i(TAG, "show err:");
Log.printStackTrace(TAG, t);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void run() {
if (Statistics.canMemberSignInToday()) {
String s = AntMemberRpcCall.memberSignIn();
JSONObject jo = new JSONObject(s);
if (jo.getString("resultCode").equals("SUCCESS")) {
if ("SUCCESS".equals(jo.getString("resultCode"))) {
Log.other("每日签到📅[" + jo.getString("signinPoint") + "积分]#已签到" + jo.getString("signinSumDay")
+ "天");
Statistics.memberSignInToday();
Expand Down Expand Up @@ -70,7 +70,7 @@ private static void queryPointCert(int page, int pageSize) {
try {
String s = AntMemberRpcCall.queryPointCert(page, pageSize);
JSONObject jo = new JSONObject(s);
if (jo.getString("resultCode").equals("SUCCESS")) {
if ("SUCCESS".equals(jo.getString("resultCode"))) {
boolean hasNextPage = jo.getBoolean("hasNextPage");
JSONArray jaCertList = jo.getJSONArray("certList");
for (int i = 0; i < jaCertList.length(); i++) {
Expand All @@ -80,7 +80,7 @@ private static void queryPointCert(int page, int pageSize) {
int pointAmount = jo.getInt("pointAmount");
s = AntMemberRpcCall.receivePointByUser(id);
jo = new JSONObject(s);
if (jo.getString("resultCode").equals("SUCCESS")) {
if ("SUCCESS".equals(jo.getString("resultCode"))) {
Log.other("领取奖励🎖️[" + bizTitle + "]#" + pointAmount + "积分");
} else {
Log.recordLog(jo.getString("resultDesc"), s);
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/java/pansong291/xposed/quickenergy/AntOcean.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ private static void queryHomePage() {
try {
JSONObject joHomePage = new JSONObject(AntOceanRpcCall.queryHomePage());
if ("SUCCESS".equals(joHomePage.getString("resultCode"))) {
if (Config.collectEnergy() && joHomePage.has("bubbleVOList")) {
collectEnergy(joHomePage.getJSONArray("bubbleVOList"));
}
// if (Config.collectEnergy() && joHomePage.has("bubbleVOList")) {
// collectEnergy(joHomePage.getJSONArray("bubbleVOList"));
// }

JSONObject userInfoVO = joHomePage.getJSONObject("userInfoVO");
int rubbishNumber = userInfoVO.optInt("rubbishNumber");
Expand Down Expand Up @@ -371,7 +371,7 @@ private static void doOceanDailyTask() {
try {
String s = AntOceanRpcCall.queryTaskList();
JSONObject jo = new JSONObject(s);
if (jo.getString("resultCode").equals("SUCCESS")) {
if ("SUCCESS".equals(jo.getString("resultCode"))) {
JSONArray jaTaskList = jo.getJSONArray("antOceanTaskVOList");
for (int i = 0; i < jaTaskList.length(); i++) {
jo = jaTaskList.getJSONObject(i);
Expand Down Expand Up @@ -403,7 +403,7 @@ private static void receiveTaskAward() {
try {
String s = AntOceanRpcCall.queryTaskList();
JSONObject jo = new JSONObject(s);
if (jo.getString("resultCode").equals("SUCCESS")) {
if ("SUCCESS".equals(jo.getString("resultCode"))) {
JSONArray jaTaskList = jo.getJSONArray("antOceanTaskVOList");
for (int i = 0; i < jaTaskList.length(); i++) {
jo = jaTaskList.getJSONObject(i);
Expand All @@ -416,7 +416,7 @@ private static void receiveTaskAward() {
if (jo.getBoolean("success")) {
String taskTitle = bizInfo.optString("taskTitle", taskType);
String taskDesc = bizInfo.optString("taskDesc", taskType);
Log.forest("领取奖励🎖️[" + taskTitle + "]#" + taskDesc );
Log.forest("领取奖励🎖️[" + taskTitle + "]#" + taskDesc);
} else {
Log.recordLog(jo.getString("desc"), jo.toString());
}
Expand Down
Loading

0 comments on commit a215576

Please sign in to comment.