From 83373395a241079a9ed4b32389096e77375ec7fa Mon Sep 17 00:00:00 2001 From: gallonyin Date: Mon, 27 Feb 2023 23:53:50 +0800 Subject: [PATCH 1/2] =?UTF-8?q?update=20=E6=8E=A8=E9=80=81=E5=9B=BE?= =?UTF-8?q?=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../worktool/service/WeworkLoopImpl.kt | 19 ++++++---- .../org/yameida/worktool/utils/HttpUtil.kt | 36 ++++++++++++++----- 2 files changed, 40 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/org/yameida/worktool/service/WeworkLoopImpl.kt b/app/src/main/java/org/yameida/worktool/service/WeworkLoopImpl.kt index 9e2c570..1bb5e01 100644 --- a/app/src/main/java/org/yameida/worktool/service/WeworkLoopImpl.kt +++ b/app/src/main/java/org/yameida/worktool/service/WeworkLoopImpl.kt @@ -132,7 +132,7 @@ object WeworkLoopImpl { for (i in 0 until list.childCount) { val item = list.getChild(i) if (item != null && item.childCount > 0) { - messageList.add(parseChatMessageItem(item, titleList, roomType)) + messageList.add(parseChatMessageItem(item, titleList, roomType, false)) } } } @@ -144,7 +144,7 @@ object WeworkLoopImpl { for (i in 0 until list2.childCount) { val item = list2.getChild(i) if (item != null && item.childCount > 0) { - messageList2.add(parseChatMessageItem(item, titleList, roomType)) + messageList2.add(parseChatMessageItem(item, titleList, roomType, true)) } } } @@ -163,7 +163,13 @@ object WeworkLoopImpl { null ) ) - SPUtils.getInstance("lastSyncMessage").put(title, messageList.last().itemMessageList.lastOrNull()?.text) + val lastMessage = messageList.last() + val lastSyncMessage = if (lastMessage.textType == 2) { + "[图片]" + } else { + lastMessage.itemMessageList.lastOrNull()?.text + } + SPUtils.getInstance("lastSyncMessage").put(title, lastSyncMessage) //推测是否回复并在房间等待指令 if (needInfer) { val lastMessage = messageList.lastOrNull() @@ -467,7 +473,7 @@ object WeworkLoopImpl { continue } if (SPUtils.getInstance("noSyncMessage").getString(title) != lastSyncMessage) { - LogUtils.e("发现不一致消息: $tvList") + LogUtils.e("发现不一致消息: $tvList $lastSyncMessage") error("发现不一致消息: $tvList $lastSyncMessage") SPUtils.getInstance("noSyncMessage").put(title, lastSyncMessage) if (AccessibilityUtil.performClick(item)) { @@ -493,7 +499,8 @@ object WeworkLoopImpl { private fun parseChatMessageItem( node: AccessibilityNodeInfo, titleList: ArrayList, - roomType: Int + roomType: Int, + doubleCheck: Boolean ): WeworkMessageBean.SubMessageBean { val message: WeworkMessageBean.SubMessageBean val nameList = arrayListOf() @@ -537,7 +544,7 @@ object WeworkLoopImpl { } message = WeworkMessageBean.SubMessageBean(0, textType, itemMessageList, nameList) //图片类型特殊处理 - if (Constant.pushImage && textType == 2) { + if (doubleCheck && Constant.pushImage && textType == 2) { val lastPicCreateTime = MultiFileObserver.lastPicCreateTime val lastPicPath = MultiFileObserver.lastPicPath LogUtils.d("发现图片类型应该点击") diff --git a/app/src/main/java/org/yameida/worktool/utils/HttpUtil.kt b/app/src/main/java/org/yameida/worktool/utils/HttpUtil.kt index 3d24fb5..2f9687e 100644 --- a/app/src/main/java/org/yameida/worktool/utils/HttpUtil.kt +++ b/app/src/main/java/org/yameida/worktool/utils/HttpUtil.kt @@ -1,17 +1,16 @@ package org.yameida.worktool.utils -import com.blankj.utilcode.util.AppUtils -import com.blankj.utilcode.util.GsonUtils -import com.blankj.utilcode.util.LogUtils -import com.blankj.utilcode.util.ToastUtils +import com.blankj.utilcode.util.* import com.lzy.okgo.OkGo import com.lzy.okgo.callback.StringCallback import com.lzy.okgo.model.Response import model.UpdateConfig +import org.json.JSONObject import org.yameida.worktool.Constant import org.yameida.worktool.R import org.yameida.worktool.model.network.CheckUpdateResult import org.yameida.worktool.model.network.GetMyConfigResult +import org.yameida.worktool.service.log import update.UpdateAppUtils import java.io.File @@ -112,19 +111,38 @@ object HttpUtil { /** * 推送图片 */ - fun pushImage(url: String, groupName: String, receivedName: String?, imagePath: String) { + fun pushImage(url: String, titleList: List, receivedName: String?, imagePath: String, roomType: Int) { + val json = JSONObject() + if (receivedName != null) { + json.put("receivedName", receivedName) + json.put("groupName", titleList.lastOrNull()) + if (titleList.size > 1) { + json.put("groupRemark", titleList.first()) + } else { + json.put("groupRemark", null) + } + } else { + json.put("receivedName", titleList.lastOrNull() { !it.contains("@") } ?: "") + json.put("groupName", null) + json.put("groupRemark", null) + } + json.put("image", EncodeUtils.base64Encode2String(File(imagePath).readBytes())) + json.put("robotId", Constant.robotId) + json.put("roomType", roomType) + json.put("atMe", false) + json.put("textType", 2) OkGo.post(url) - .params("groupName", groupName) - .params("receivedName", receivedName ?: "") - .params("image", File(imagePath)) + .upJson(json) .execute(object : StringCallback() { override fun onSuccess(response: Response) { - LogUtils.d("推送图片成功: $groupName $receivedName $imagePath") + LogUtils.d("推送图片成功: ${titleList.joinToString()} $receivedName $imagePath") + log("推送图片成功: ${titleList.joinToString()} $receivedName $imagePath") } override fun onError(response: Response) { ToastUtils.showLong("推送图片失败") LogUtils.e("推送图片失败") + error("推送图片失败: $${titleList.joinToString()} $receivedName $imagePath") } }) } From 24c89b1c81cff197137c2abfe477d4295f2d9c25 Mon Sep 17 00:00:00 2001 From: gallonyin Date: Tue, 28 Feb 2023 23:19:22 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix=20=E7=A7=BB=E9=99=A4=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/yameida/worktool/service/WeworkOperationImpl.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/src/main/java/org/yameida/worktool/service/WeworkOperationImpl.kt b/app/src/main/java/org/yameida/worktool/service/WeworkOperationImpl.kt index 9fd8b13..44eaee0 100644 --- a/app/src/main/java/org/yameida/worktool/service/WeworkOperationImpl.kt +++ b/app/src/main/java/org/yameida/worktool/service/WeworkOperationImpl.kt @@ -587,7 +587,6 @@ object WeworkOperationImpl { if (shareToWorkButton != null && WeworkController.weworkService.currentPackage != Constant.PACKAGE_NAMES) { LogUtils.e("尝试手势点击!!!!!") - AccessibilityUtil.printNodeClazzTree(shareToWorkButton) AccessibilityUtil.clickByNode(WeworkController.weworkService, shareToWorkButton) sleep(Constant.CHANGE_PAGE_INTERVAL) shareToWorkButton = AccessibilityUtil.findOnceByText(getRoot(true), "发送给同事") @@ -663,7 +662,6 @@ object WeworkOperationImpl { if (shareToWorkButton != null && WeworkController.weworkService.currentPackage != Constant.PACKAGE_NAMES) { LogUtils.e("尝试手势点击!!!!!") - AccessibilityUtil.printNodeClazzTree(shareToWorkButton) AccessibilityUtil.clickByNode(WeworkController.weworkService, shareToWorkButton) sleep(Constant.CHANGE_PAGE_INTERVAL) shareToWorkButton = AccessibilityUtil.findOnceByText(getRoot(true), "发送给同事")