diff --git a/app/src/main/java/org/yameida/worktool/service/GlobalMethod.kt b/app/src/main/java/org/yameida/worktool/service/GlobalMethod.kt index 306da55..019d096 100644 --- a/app/src/main/java/org/yameida/worktool/service/GlobalMethod.kt +++ b/app/src/main/java/org/yameida/worktool/service/GlobalMethod.kt @@ -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) 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 e825c40..f5b2b2f 100644 --- a/app/src/main/java/org/yameida/worktool/service/WeworkOperationImpl.kt +++ b/app/src/main/java/org/yameida/worktool/service/WeworkOperationImpl.kt @@ -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) @@ -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 } @@ -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) @@ -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人")