Skip to content

Commit

Permalink
update 优化群名识别;优化进群速度
Browse files Browse the repository at this point in the history
  • Loading branch information
gallonyin committed Sep 23, 2023
1 parent eabf9ec commit 1e11713
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
3 changes: 3 additions & 0 deletions app/src/main/java/org/yameida/worktool/Constant.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ object Constant {
val transformation = "AES/CBC/PKCS7Padding"
val wssRegex = "^wss".toRegex()
val wsRegex = "^ws".toRegex()
val suffixString = "(-.*)?(…)?(\\(\\d+\\))?$"
val suffixRegex = "(-.*)?(…)?(\\(\\d+\\))?$"
val digitalRegex = "\\(\\d+\\)\$".toRegex()
var weworkCorpName: String
get() = SPUtils.getInstance().getString("weworkCorpName", "")
set(value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1651,7 +1651,7 @@ object WeworkOperationImpl {
val selectListView = AccessibilityUtil.findOneByClazz(getRoot(), Views.ListView)
val reverseRegexTitle = RegexHelper.reverseRegexTitle(trimTitle)
val regex1 = (if (Constant.friendRemarkStrict) "^$reverseRegexTitle" else "^(微信昵称:)|((企业)?邮箱:)?$reverseRegexTitle") +
(if (needTrim) ".*?" else "(-.*)?(…)?(\\(.*?\\))?$")
(if (needTrim) ".*?" else Constant.suffixString)
val regex2 = ".*?\\($reverseRegexTitle\\)$"
val regex = "($regex1)|($regex2)"
val matchSelect = AccessibilityUtil.findOneByTextRegex(
Expand Down Expand Up @@ -1766,7 +1766,7 @@ object WeworkOperationImpl {
val selectListView = AccessibilityUtil.findOneByClazz(getRoot(), Views.ListView)
val reverseRegexTitle = RegexHelper.reverseRegexTitle(trimTitle)
val regex1 = (if (Constant.friendRemarkStrict) "^$reverseRegexTitle" else "^(微信昵称:)|((企业)?邮箱:)?$reverseRegexTitle") +
(if (needTrim) ".*?" else "(-.*)?(…)?(\\(.*?\\))?$")
(if (needTrim) ".*?" else Constant.suffixString)
val regex2 = ".*?\\($reverseRegexTitle\\)$"
val regex = "($regex1)|($regex2)"
val matchSelect = AccessibilityUtil.findOneByTextRegex(
Expand Down Expand Up @@ -2184,7 +2184,7 @@ object WeworkOperationImpl {
val selectListView = AccessibilityUtil.findOneByClazz(getRoot(), Views.ListView, Views.RecyclerView, Views.ViewGroup, minChildCount = 2)
val reverseRegexTitle = RegexHelper.reverseRegexTitle(trimTitle)
val regex1 = (if (Constant.friendRemarkStrict) "^$reverseRegexTitle" else "^(微信昵称:)|((企业)?邮箱:)?$reverseRegexTitle") +
(if (needTrim) ".*?" else "(-.*)?(…)?(\\(.*?\\))?$")
(if (needTrim) ".*?" else Constant.suffixString)
val regex2 = ".*?\\($reverseRegexTitle\\)$"
val regex = "($regex1)|($regex2)"
val matchSelect = AccessibilityUtil.findOneByTextRegex(
Expand Down Expand Up @@ -2225,7 +2225,7 @@ object WeworkOperationImpl {
return selectResult
}
val confirmButton =
AccessibilityUtil.findOneByTextRegex(getRoot(), "^确定(\\(.*?\\))?\$")
AccessibilityUtil.findOneByTextRegex(getRoot(), "^确定(\\(\\d+\\))?\$")
if (confirmButton != null) {
AccessibilityUtil.performClick(confirmButton)
sleep(Constant.POP_WINDOW_INTERVAL)
Expand All @@ -2237,7 +2237,7 @@ object WeworkOperationImpl {
LogUtils.d("extraText: $extraText")
AccessibilityUtil.findTextInput(getRoot(), extraText)
}
val sendButton = AccessibilityUtil.findOneByTextRegex(getRoot(), "^发送(\\(.*?\\))?\$")
val sendButton = AccessibilityUtil.findOneByTextRegex(getRoot(), "^发送(\\(\\d+\\))?\$")
if (sendButton != null) {
AccessibilityUtil.performClick(sendButton)
selectResult.result = true
Expand Down Expand Up @@ -2423,7 +2423,7 @@ object WeworkOperationImpl {
val selectListView = AccessibilityUtil.findOneByClazz(getRoot(), Views.ListView, Views.RecyclerView, Views.ViewGroup, minChildCount = 2, firstChildClazz = Views.TextView)
val reverseRegexTitle = RegexHelper.reverseRegexTitle(trimTitle)
val regex1 = (if (Constant.friendRemarkStrict) "^$reverseRegexTitle" else "^(微信昵称:)|((企业)?邮箱:)?$reverseRegexTitle") +
(if (needTrim) ".*?" else "(-.*)?(…)?(\\(.*?\\))?$")
(if (needTrim) ".*?" else Constant.suffixString)
val regex2 = ".*?\\($reverseRegexTitle\\)$"
val regex = "($regex1)|($regex2)"
val matchSelect = AccessibilityUtil.findOneByTextRegex(
Expand Down Expand Up @@ -2485,7 +2485,7 @@ object WeworkOperationImpl {
AccessibilityUtil.findTextAndClick(getRoot(), "聊天记录")
}
val confirmButton =
AccessibilityUtil.findOneByTextRegex(getRoot(), "^确定(\\(.*?\\))?\$")
AccessibilityUtil.findOneByTextRegex(getRoot(), "^确定(\\(\\d+\\))?\$")
if (confirmButton != null) {
AccessibilityUtil.performClick(confirmButton)
if (AccessibilityExtraUtil.loadingPage("CustomDialog", timeout = Constant.POP_WINDOW_INTERVAL)) {
Expand Down Expand Up @@ -2584,7 +2584,7 @@ object WeworkOperationImpl {
val selectListView = AccessibilityUtil.findOneByClazz(getRoot(), Views.ListView, Views.RecyclerView, Views.ViewGroup, minChildCount = 2, firstChildClazz = Views.RelativeLayout)
val reverseRegexTitle = RegexHelper.reverseRegexTitle(trimTitle)
val regex1 = (if (Constant.friendRemarkStrict) "^$reverseRegexTitle" else "^(微信昵称:)|((企业)?邮箱:)?$reverseRegexTitle") +
(if (needTrim) ".*?" else "(-.*)?(…)?(\\(.*?\\))?$")
(if (needTrim) ".*?" else Constant.suffixString)
val regex2 = ".*?\\($reverseRegexTitle\\)$"
val regex = "($regex1)|($regex2)"
val matchSelect = AccessibilityUtil.findOneByTextRegex(
Expand Down Expand Up @@ -2936,7 +2936,7 @@ object WeworkOperationImpl {
val selectListView = AccessibilityUtil.findOneByClazz(getRoot(), Views.ListView)
val reverseRegexTitle = RegexHelper.reverseRegexTitle(trimTitle)
val regex1 = (if (Constant.friendRemarkStrict) "^$reverseRegexTitle" else "^(微信昵称:)|((企业)?邮箱:)?$reverseRegexTitle") +
(if (needTrim) ".*?" else "(-.*)?(…)?(\\(.*?\\))?$")
(if (needTrim) ".*?" else Constant.suffixString)
val regex2 = ".*?\\($reverseRegexTitle\\)$"
val regex = "($regex1)|($regex2)"
val matchSelect = AccessibilityUtil.findOneByTextRegex(
Expand Down
19 changes: 10 additions & 9 deletions app/src/main/java/org/yameida/worktool/utils/WeworkRoomUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ object WeworkRoomUtil {
for (textView in textViewList) {
if (!textView.text.isNullOrBlank()) {
val text = textView.text.toString()
titleList.add(text.replace("\\(\\d+\\)$".toRegex(), ""))
if (noCut && text.contains("\\(\\d+\\)$".toRegex())) {
titleList.add(text.replace(Constant.digitalRegex, ""))
if (noCut && text.contains(Constant.digitalRegex)) {
titleList.add(text)
}
}
Expand Down Expand Up @@ -92,7 +92,7 @@ object WeworkRoomUtil {
AccessibilityUtil.performClick(item)
LogUtils.d("快捷进入房间: $title")
AccessibilityUtil.waitForPageMissing("WwMainActivity", "GlobalSearchActivity")
sleep(Constant.CHANGE_PAGE_INTERVAL)
AccessibilityExtraUtil.loadingPage("ExternalGroupMessageListActivity", "ExternalWechatUserMessageListActivity", "MessageListActivity", timeout = Constant.CHANGE_PAGE_INTERVAL)
return checkRoom(title, strict = false)
}
}
Expand All @@ -116,7 +116,7 @@ object WeworkRoomUtil {
val selectListView = findOneByClazz(getRoot(), Views.ListView)
val reverseRegexTitle = RegexHelper.reverseRegexTitle(trimTitle)
val regex1 = (if (Constant.friendRemarkStrict) "^$reverseRegexTitle" else "^(微信昵称:)|((企业)?邮箱:)?$reverseRegexTitle") +
(if (needTrim) ".*?" else "(-.*)?(…)?(\\(.*?\\))?$")
(if (needTrim) ".*?" else Constant.suffixString)
val regex2 = ".*?\\($reverseRegexTitle\\)$"
val regex = "($regex1)|($regex2)"
val searchResult = AccessibilityUtil.findAllByTextRegex(
Expand All @@ -137,7 +137,7 @@ object WeworkRoomUtil {
val title = text?.text?.toString() ?: title
LogUtils.d("进入房间: $title")
AccessibilityUtil.waitForPageMissing("WwMainActivity", "GlobalSearchActivity")
sleep(Constant.CHANGE_PAGE_INTERVAL)
AccessibilityExtraUtil.loadingPage("ExternalGroupMessageListActivity", "ExternalWechatUserMessageListActivity", "MessageListActivity", timeout = Constant.CHANGE_PAGE_INTERVAL)
return checkRoom(title, strict = false)
} else {
LogUtils.e("搜索到已退出群聊")
Expand Down Expand Up @@ -278,10 +278,11 @@ object WeworkRoomUtil {
return false
}
val roomType = getRoomType()
val dealTitle = title.replace("", "").replace("\\(.*?\\)".toRegex(), "")
val dealTitle = title.replace(Constant.suffixRegex, "")
LogUtils.v("dealTitle: $dealTitle", "titleList: ${titleList.joinToString()}")
if (roomType != WeworkMessageBean.ROOM_TYPE_UNKNOWN
&& (titleList.count { dealTitle == it.replace("", "").replace("\\(.*?\\)".toRegex(), "") } > 0
|| (!strict && titleList.count { dealTitle.contains(it.replace("", "").replace("\\(.*?\\)".toRegex(), "")) } > 0))
&& (titleList.count { dealTitle == it.replace(Constant.suffixRegex, "") } > 0
|| (!strict && titleList.count { dealTitle.contains(it.replace(Constant.suffixRegex, "")) } > 0))
) {
intoRoomPreInit()
LogUtils.d("当前正在房间")
Expand All @@ -295,7 +296,7 @@ object WeworkRoomUtil {
* 群名最后有(\d)显示群人数
*/
private fun isGroupChat(roomTitle: ArrayList<String>): Boolean {
return roomTitle.size > 1 && roomTitle[1].contains("\\(\\d+\\)$".toRegex())
return roomTitle.size > 1 && roomTitle[1].contains(Constant.digitalRegex)
}

/**
Expand Down

0 comments on commit 1e11713

Please sign in to comment.