update 特殊符号兼容;修复执行多条消息丢失

This commit is contained in:
gallonyin
2022-10-25 16:59:24 +08:00
parent a0f0168a30
commit 28d6004777
5 changed files with 60 additions and 4 deletions

View File

@@ -72,4 +72,32 @@ data class ExecCallbackBean(
const val ERROR_OTHER = 501000
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
if (!super.equals(other)) return false
other as ExecCallbackBean
if (rawMsg != other.rawMsg) return false
if (errorCode != other.errorCode) return false
if (errorReason != other.errorReason) return false
if (runTime != other.runTime) return false
if (timeCost != other.timeCost) return false
return true
}
override fun hashCode(): Int {
var result = super.hashCode()
result = 31 * result + (rawMsg?.hashCode() ?: 0)
result = 31 * result + errorCode
result = 31 * result + errorReason.hashCode()
result = 31 * result + runTime.hashCode()
result = 31 * result + timeCost.hashCode()
return result
}
}

View File

@@ -82,6 +82,7 @@ object MyLooper {
WeworkController.enableLoopRunning = true
} else {
WeworkController.mainLoopRunning = false
LogUtils.v("加入指令到执行队列", GsonUtils.toJson(message))
getInstance().sendMessage(Message.obtain().apply {
what = message.type * message.hashCode()
obj = message.apply { messageId = messageList.messageId }

View File

@@ -733,7 +733,8 @@ object WeworkOperationImpl {
AccessibilityUtil.findTextInput(getRoot(), trimTitle)
sleep(Constant.CHANGE_PAGE_INTERVAL)
val selectListView = AccessibilityUtil.findOneByClazz(getRoot(), Views.ListView, Views.RecyclerView, Views.ViewGroup, minChildCount = 2)
val regex = "^$trimTitle" + if (needTrim) ".*?" else "(-.*)?(…)?(\\(.*?\\))?$"
val reverseRegexTitle = RegexHelper.reverseRegexTitle(trimTitle)
val regex = "^$reverseRegexTitle" + if (needTrim) ".*?" else "(-.*)?(…)?(\\(.*?\\))?$"
val matchSelect = AccessibilityUtil.findOneByTextRegex(
selectListView,
regex,
@@ -882,7 +883,8 @@ object WeworkOperationImpl {
AccessibilityUtil.findTextInput(getRoot(), trimTitle)
sleep(Constant.POP_WINDOW_INTERVAL)
val selectListView = AccessibilityUtil.findOneByClazz(getRoot(), Views.ListView, Views.RecyclerView, Views.ViewGroup, minChildCount = 2, firstChildClazz = Views.TextView)
val regex = "^$trimTitle" + if (needTrim) ".*?" else "(-.*)?(…)?(\\(.*?\\))?$"
val reverseRegexTitle = RegexHelper.reverseRegexTitle(trimTitle)
val regex = "^$reverseRegexTitle" + if (needTrim) ".*?" else "(-.*)?(…)?(\\(.*?\\))?$"
val matchSelect = AccessibilityUtil.findOneByTextRegex(
selectListView,
regex,
@@ -976,7 +978,8 @@ object WeworkOperationImpl {
AccessibilityUtil.findTextInput(getRoot(), trimTitle)
sleep(Constant.POP_WINDOW_INTERVAL)
val selectListView = AccessibilityUtil.findOneByClazz(getRoot(), Views.ListView, Views.RecyclerView, Views.ViewGroup, minChildCount = 2, firstChildClazz = Views.RelativeLayout)
val regex = "^$trimTitle" + if (needTrim) ".*?" else "(-.*)?(…)?(\\(.*?\\))?$"
val reverseRegexTitle = RegexHelper.reverseRegexTitle(trimTitle)
val regex = "^$reverseRegexTitle" + if (needTrim) ".*?" else "(-.*)?(…)?(\\(.*?\\))?$"
val matchSelect = AccessibilityUtil.findOneByTextRegex(
selectListView,
regex,

View File

@@ -0,0 +1,23 @@
package org.yameida.worktool.utils
object RegexHelper {
fun reverseRegexTitle(string: String): String {
return string.replace("\\", "\\\\")
.replace("*", "\\*")
.replace("+", "\\+")
.replace(".", "\\.")
.replace("[", "\\[")
.replace("]", "\\]")
.replace("?", "\\?")
.replace("^", "\\^")
.replace("$", "\\$")
.replace("{", "\\{")
.replace("}", "\\}")
.replace("|", "\\|")
// .replace("-", "\\-") //企微自身限制
// .replace("(", "\\(") //企微自身限制
// .replace(")", "\\)") //企微自身限制
}
}

View File

@@ -104,7 +104,8 @@ object WeworkRoomUtil {
sleep(Constant.CHANGE_PAGE_INTERVAL)
//消息页搜索结果列表
val selectListView = findOneByClazz(getRoot(), Views.ListView)
val regex = "^$trimTitle" + if (needTrim) ".*?" else "(-.*)?(…)?(\\(.*?\\))?$"
val reverseRegexTitle = RegexHelper.reverseRegexTitle(trimTitle)
val regex = "^$reverseRegexTitle" + if (needTrim) ".*?" else "(-.*)?(…)?(\\(.*?\\))?$"
val searchResult = AccessibilityUtil.findOneByTextRegex(
selectListView,
regex,