update 兼容引用回复

This commit is contained in:
gallonyin
2023-08-19 22:59:10 +08:00
parent a1c570bd1e
commit c7724d9a30
2 changed files with 12 additions and 11 deletions

View File

@@ -115,7 +115,7 @@ object WeworkOperationImpl {
textType, textType,
receivedName, receivedName,
originalContent, originalContent,
"回复" "回复", "引用"
) )
) { ) {
LogUtils.v("开始回复") LogUtils.v("开始回复")

View File

@@ -10,6 +10,7 @@ import org.yameida.worktool.service.sleep
import org.yameida.worktool.utils.AccessibilityUtil.findAllByClazz import org.yameida.worktool.utils.AccessibilityUtil.findAllByClazz
import org.yameida.worktool.utils.AccessibilityUtil.findAllOnceByClazz import org.yameida.worktool.utils.AccessibilityUtil.findAllOnceByClazz
import java.util.* import java.util.*
import kotlin.collections.ArrayList
/** /**
* 消息特征分析工具类 * 消息特征分析工具类
@@ -370,7 +371,7 @@ object WeworkTextUtil {
replyTextType: Int, replyTextType: Int,
replyNick: String?, replyNick: String?,
replyContent: String, replyContent: String,
key: String vararg key: String
): Boolean { ): Boolean {
if (node == null) return false if (node == null) return false
for (i in 0 until node.childCount) { for (i in 0 until node.childCount) {
@@ -387,7 +388,7 @@ object WeworkTextUtil {
if ((replyTextType == WeworkMessageBean.TEXT_TYPE_IMAGE) if ((replyTextType == WeworkMessageBean.TEXT_TYPE_IMAGE)
&& (replyTextType == textTypeFromItem)) { && (replyTextType == textTypeFromItem)) {
LogUtils.d("nameList: $nameList\nreplyContent: $replyContent") LogUtils.d("nameList: $nameList\nreplyContent: $replyContent")
return longClickMessageItem(item, WeworkMessageBean.ROOM_TYPE_INTERNAL_CONTACT, key) return longClickMessageItem(item, WeworkMessageBean.ROOM_TYPE_INTERNAL_CONTACT, *key)
} }
if ((replyTextType == WeworkMessageBean.TEXT_TYPE_FILE || replyTextType == WeworkMessageBean.TEXT_TYPE_VIDEO) if ((replyTextType == WeworkMessageBean.TEXT_TYPE_FILE || replyTextType == WeworkMessageBean.TEXT_TYPE_VIDEO)
&& replyContent.contains("###")) { && replyContent.contains("###")) {
@@ -395,13 +396,13 @@ object WeworkTextUtil {
if (AccessibilityUtil.findOnceByText(backNode, replyContentList[0]) != null if (AccessibilityUtil.findOnceByText(backNode, replyContentList[0]) != null
&& AccessibilityUtil.findOnceByText(backNode, replyContentList[1]) != null) { && AccessibilityUtil.findOnceByText(backNode, replyContentList[1]) != null) {
LogUtils.d("nameList: $nameList\nreplyContent: $replyContent") LogUtils.d("nameList: $nameList\nreplyContent: $replyContent")
return longClickMessageItem(item, WeworkMessageBean.ROOM_TYPE_INTERNAL_GROUP, key) return longClickMessageItem(item, WeworkMessageBean.ROOM_TYPE_INTERNAL_GROUP, *key)
} }
} }
val textNode = AccessibilityUtil.findOnceByText(backNode, replyContent) val textNode = AccessibilityUtil.findOnceByText(backNode, replyContent)
if (textNode != null && replyContent.isNotEmpty()) { if (textNode != null && replyContent.isNotEmpty()) {
LogUtils.d("nameList: $nameList\nreplyContent: $replyContent") LogUtils.d("nameList: $nameList\nreplyContent: $replyContent")
return longClickMessageItem(item, WeworkMessageBean.ROOM_TYPE_INTERNAL_CONTACT, key) return longClickMessageItem(item, WeworkMessageBean.ROOM_TYPE_INTERNAL_CONTACT, *key)
} }
} }
} }
@@ -413,7 +414,7 @@ object WeworkTextUtil {
if ((replyTextType == WeworkMessageBean.TEXT_TYPE_IMAGE) if ((replyTextType == WeworkMessageBean.TEXT_TYPE_IMAGE)
&& (replyTextType == textTypeFromItem)) { && (replyTextType == textTypeFromItem)) {
LogUtils.d("nameList: $nameList\nreplyContent: $replyContent") LogUtils.d("nameList: $nameList\nreplyContent: $replyContent")
return longClickMessageItem(item, WeworkMessageBean.ROOM_TYPE_INTERNAL_GROUP, key) return longClickMessageItem(item, WeworkMessageBean.ROOM_TYPE_INTERNAL_GROUP, *key)
} }
if ((replyTextType == WeworkMessageBean.TEXT_TYPE_FILE || replyTextType == WeworkMessageBean.TEXT_TYPE_VIDEO) if ((replyTextType == WeworkMessageBean.TEXT_TYPE_FILE || replyTextType == WeworkMessageBean.TEXT_TYPE_VIDEO)
&& replyContent.contains("###")) { && replyContent.contains("###")) {
@@ -421,13 +422,13 @@ object WeworkTextUtil {
if (AccessibilityUtil.findOnceByText(backNode, replyContentList[0]) != null if (AccessibilityUtil.findOnceByText(backNode, replyContentList[0]) != null
&& AccessibilityUtil.findOnceByText(backNode, replyContentList[1]) != null) { && AccessibilityUtil.findOnceByText(backNode, replyContentList[1]) != null) {
LogUtils.d("nameList: $nameList\nreplyContent: $replyContent") LogUtils.d("nameList: $nameList\nreplyContent: $replyContent")
return longClickMessageItem(item, WeworkMessageBean.ROOM_TYPE_INTERNAL_GROUP, key) return longClickMessageItem(item, WeworkMessageBean.ROOM_TYPE_INTERNAL_GROUP, *key)
} }
} }
val textNode = AccessibilityUtil.findOnceByText(backNode, replyContent) val textNode = AccessibilityUtil.findOnceByText(backNode, replyContent)
if (textNode != null && replyContent.isNotEmpty()) { if (textNode != null && replyContent.isNotEmpty()) {
LogUtils.d("nameList: $nameList\nreplyContent: $replyContent") LogUtils.d("nameList: $nameList\nreplyContent: $replyContent")
return longClickMessageItem(item, WeworkMessageBean.ROOM_TYPE_INTERNAL_GROUP, key) return longClickMessageItem(item, WeworkMessageBean.ROOM_TYPE_INTERNAL_GROUP, *key)
} }
} }
} }
@@ -480,16 +481,16 @@ object WeworkTextUtil {
return false return false
} }
private fun longClickMessageItem(item: AccessibilityNodeInfo, roomType: Int, key: String): Boolean { private fun longClickMessageItem(item: AccessibilityNodeInfo, roomType: Int, vararg key: String): Boolean {
val backNode = getMessageListNode(item, roomType) val backNode = getMessageListNode(item, roomType)
if (key == "单击") { if ("单击" in key) {
return AccessibilityUtil.clickByNode(WeworkController.weworkService, backNode) return AccessibilityUtil.clickByNode(WeworkController.weworkService, backNode)
} }
AccessibilityUtil.performLongClickWithSon(backNode) AccessibilityUtil.performLongClickWithSon(backNode)
sleep(Constant.POP_WINDOW_INTERVAL) sleep(Constant.POP_WINDOW_INTERVAL)
val optionRvList = findAllByClazz(getRoot(), Views.RecyclerView, Views.ViewGroup) val optionRvList = findAllByClazz(getRoot(), Views.RecyclerView, Views.ViewGroup)
for (optionRv in optionRvList) { for (optionRv in optionRvList) {
val keyTv = AccessibilityUtil.findOnceByText(optionRv, key, exact = true) val keyTv = AccessibilityUtil.findOnceByText(optionRv, *key, exact = true)
if (keyTv != null) { if (keyTv != null) {
AccessibilityUtil.performClick(keyTv) AccessibilityUtil.performClick(keyTv)
return true return true