diff --git a/app/src/main/java/org/yameida/worktool/service/WeworkGetImpl.kt b/app/src/main/java/org/yameida/worktool/service/WeworkGetImpl.kt index ee05e22..9630942 100644 --- a/app/src/main/java/org/yameida/worktool/service/WeworkGetImpl.kt +++ b/app/src/main/java/org/yameida/worktool/service/WeworkGetImpl.kt @@ -373,7 +373,7 @@ object WeworkGetImpl { } } if (saveAddress) { - val tvAddressFlag = AccessibilityUtil.scrollAndFindByText(WeworkController.weworkService, getRoot(), "保存到通讯录") + val tvAddressFlag = AccessibilityUtil.scrollAndFindByText(WeworkController.weworkService, getRoot(), "保存到通讯录", exact = true) val tvAddress = AccessibilityUtil.findBackNode(tvAddressFlag, minChildCount = 1) val addressDesc = AccessibilityUtil.findOnceByDesc(tvAddress, "false", "true", exact = true) if (addressDesc?.contentDescription == "false") { 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 a13c24c..9f0213e 100644 --- a/app/src/main/java/org/yameida/worktool/service/WeworkOperationImpl.kt +++ b/app/src/main/java/org/yameida/worktool/service/WeworkOperationImpl.kt @@ -403,7 +403,7 @@ object WeworkOperationImpl { ): Boolean { val startTime = System.currentTimeMillis() goHomeTab("工作台") - val node = AccessibilityUtil.scrollAndFindByText(WeworkController.weworkService, getRoot(), "微盘") + val node = AccessibilityUtil.scrollAndFindByText(WeworkController.weworkService, getRoot(), "微盘", exact = true) if (node != null) { AccessibilityUtil.performClick(node) sleep(Constant.POP_WINDOW_INTERVAL) @@ -478,7 +478,7 @@ object WeworkOperationImpl { ): Boolean { val startTime = System.currentTimeMillis() goHomeTab("工作台") - val node = AccessibilityUtil.scrollAndFindByText(WeworkController.weworkService, getRoot(), "微盘") + val node = AccessibilityUtil.scrollAndFindByText(WeworkController.weworkService, getRoot(), "微盘", exact = true) if (node != null) { AccessibilityUtil.performClick(node) sleep(Constant.POP_WINDOW_INTERVAL) @@ -1565,7 +1565,7 @@ object WeworkOperationImpl { fun clockIn(message: WeworkMessageBean): Boolean { val startTime = System.currentTimeMillis() goHomeTab("工作台") - val node = AccessibilityUtil.scrollAndFindByText(WeworkController.weworkService, getRoot(), "打卡") + val node = AccessibilityUtil.scrollAndFindByText(WeworkController.weworkService, getRoot(), "打卡", exact = true) if (node != null) { AccessibilityUtil.performClick(node) sleep(Constant.POP_WINDOW_INTERVAL) @@ -1761,7 +1761,7 @@ object WeworkOperationImpl { */ private fun createGroup(): Boolean { goHomeTab("工作台") - val node = AccessibilityUtil.scrollAndFindByText(WeworkController.weworkService, getRoot(), "客户群", "居民群", "学员群") + val node = AccessibilityUtil.scrollAndFindByText(WeworkController.weworkService, getRoot(), "客户群", "居民群", "学员群", exact = true) if (node != null) { AccessibilityUtil.performClick(node) sleep(Constant.POP_WINDOW_INTERVAL) diff --git a/app/src/main/java/org/yameida/worktool/utils/AccessibilityUtil.kt b/app/src/main/java/org/yameida/worktool/utils/AccessibilityUtil.kt index 30d1c88..994d7e5 100644 --- a/app/src/main/java/org/yameida/worktool/utils/AccessibilityUtil.kt +++ b/app/src/main/java/org/yameida/worktool/utils/AccessibilityUtil.kt @@ -259,16 +259,17 @@ object AccessibilityUtil { service: AccessibilityService, nodeInfo: AccessibilityNodeInfo, vararg textList: String, + exact: Boolean = false, maxRetry: Int = 3 ): AccessibilityNodeInfo? { - val node = findOnceByText(nodeInfo, *textList) + val node = findOnceByText(nodeInfo, *textList, exact = exact) if (node != null) { return node } var index = 0 while (index++ < maxRetry) { performScrollDown(nodeInfo, 0) - val node = findOnceByText(nodeInfo, *textList) + val node = findOnceByText(nodeInfo, *textList, exact = exact) if (node != null) { return node } @@ -276,7 +277,7 @@ object AccessibilityUtil { index = 0 while (index++ < maxRetry * 2) { performScrollUp(nodeInfo, 0) - val node = findOnceByText(nodeInfo, *textList) + val node = findOnceByText(nodeInfo, *textList, exact = exact) if (node != null) { return node } @@ -288,7 +289,7 @@ object AccessibilityUtil { index = 0 while (index++ < maxRetry * 2) { scrollByXY(service, width / 2, (height / 2.2).toInt(), 0, -height / 3) - val node = findOnceByText(nodeInfo, *textList) + val node = findOnceByText(nodeInfo, *textList, exact = exact) if (node != null) { return node } @@ -296,7 +297,7 @@ object AccessibilityUtil { index = 0 while (index++ < maxRetry * 3) { scrollByXY(service, width / 2, (height / 2.2).toInt(), 0, height / 3) - val node = findOnceByText(nodeInfo, *textList) + val node = findOnceByText(nodeInfo, *textList, exact = exact) if (node != null) { return node }