Skip to content

Commit

Permalink
fix 踢人失败循环
Browse files Browse the repository at this point in the history
  • Loading branch information
gallonyin committed Sep 16, 2023
1 parent 1bc4de3 commit 88c89a5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
21 changes: 17 additions & 4 deletions app/src/main/java/org/yameida/worktool/service/GlobalMethod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -170,24 +170,37 @@ fun getRoot(ignoreCheck: Boolean, share: Boolean = false): AccessibilityNodeInfo
*/
fun backPress() {
val clazz = WeworkController.weworkService.currentClass
val textView = AccessibilityUtil.findOnceByClazz(getRoot(), Views.TextView)
val root = getRoot()
val textView = AccessibilityUtil.findOnceByClazz(root, Views.TextView)
if (textView != null && textView.text.isNullOrBlank() && AccessibilityUtil.performClick(textView, retry = false)) {
LogUtils.v("找到回退按钮")
} else {
val ivButton = AccessibilityUtil.findOnceByClazz(getRoot(), Views.ImageView)
if (AccessibilityUtil.findOnceByText(root, "移出成员") != null) {
val list = AccessibilityUtil.findOneByClazz(root, Views.RecyclerView, Views.ListView)
if (list != null) {
val frontNode = AccessibilityUtil.findFrontNode(list)
val textViewList = AccessibilityUtil.findAllOnceByClazz(frontNode, Views.TextView)
if (textViewList.size >= 2) {
val closeButton: AccessibilityNodeInfo = textViewList[textViewList.size - 1]
AccessibilityUtil.performClick(closeButton)
}
}
return
}
val ivButton = AccessibilityUtil.findOnceByClazz(root, Views.ImageView)
if (ivButton != null && ivButton.isClickable && AccessibilityUtil.findFrontNode(ivButton) == null) {
LogUtils.d("未找到回退按钮 点击第一个IV按钮")
AccessibilityUtil.performClick(ivButton, retry = false)
} else {
LogUtils.d("未找到回退按钮 点击第一个BT按钮")
val button = AccessibilityUtil.findOnceByClazz(getRoot(), Views.Button)
val button = AccessibilityUtil.findOnceByClazz(root, Views.Button)
if (button != null && button.childCount > 0) {
AccessibilityUtil.performClick(button.getChild(0), retry = false)
} else if (button != null) {
AccessibilityUtil.performClick(button, retry = false)
} else {
LogUtils.d("未找到BT按钮")
val confirm = AccessibilityUtil.findOnceByText(getRoot(), "不保存", "确定", "我知道了", "暂不进入", "不用了", "取消", "暂不", "关闭", "退出", "留在企业微信", exact = true)
val confirm = AccessibilityUtil.findOnceByText(root, "不保存", "确定", "我知道了", "暂不进入", "不用了", "取消", "暂不", "关闭", "退出", "留在企业微信", exact = true)
if (confirm != null) {
LogUtils.d("尝试点击确定/我知道了/暂不进入")
AccessibilityUtil.performClick(confirm)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2456,6 +2456,7 @@ object WeworkOperationImpl {
error("拉人失败 找不到: $select")
}
}
val noResult = AccessibilityUtil.findOnceByText(getRoot(), "无搜索结果", exact = true) != null
val textView = AccessibilityUtil.findOnceByClazz(getRoot(), Views.TextView)
if (textView != null && textView.text.isNullOrBlank()) {
AccessibilityUtil.performClick(textView)
Expand All @@ -2468,7 +2469,6 @@ object WeworkOperationImpl {
selectResult.failList.add(select)
LogUtils.e("未搜索到结果: $select")
error("未搜索到结果: $select")
val noResult = AccessibilityUtil.findOnceByText(getRoot(), "无搜索结果", exact = true) != null
LogUtils.e("企微: 无搜索结果: $noResult")
if (Constant.groupStrict) return selectResult
}
Expand Down Expand Up @@ -2606,6 +2606,7 @@ object WeworkOperationImpl {
}
}
}
val noResult = AccessibilityUtil.findOnceByText(getRoot(), "无搜索结果", exact = true) != null
val textView = AccessibilityUtil.findOnceByClazz(getRoot(), Views.TextView)
if (textView != null && textView.text.isNullOrBlank()) {
AccessibilityUtil.performClick(textView)
Expand All @@ -2618,14 +2619,14 @@ object WeworkOperationImpl {
selectResult.failList.add(select)
LogUtils.e("未搜索到结果: $select")
error("未搜索到结果: $select")
val noResult = AccessibilityUtil.findOnceByText(getRoot(), "无搜索结果", exact = true) != null
LogUtils.e("企微: 无搜索结果: $noResult")
//待踢人已经不在群里的不算失败
// if (Constant.groupStrict) return false
}
}
if (count == 0) {
while (AccessibilityUtil.findOnceByText(getRoot(), "全部群成员", "微信用户创建") == null && !isAtHome()) {
var retry = 3
while (retry-- > 0 && WeworkController.weworkService.currentClass == "com.tencent.wework.choosecontact.controller.CommonChooseListActivity") {
backPress()
}
LogUtils.d("移出0人")
Expand Down

0 comments on commit 88c89a5

Please sign in to comment.