fix 工作台优先使用click
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package org.yameida.worktool.service
|
package org.yameida.worktool.service
|
||||||
|
|
||||||
|
import android.os.Build
|
||||||
import android.view.accessibility.AccessibilityNodeInfo
|
import android.view.accessibility.AccessibilityNodeInfo
|
||||||
import org.yameida.worktool.Constant
|
import org.yameida.worktool.Constant
|
||||||
import org.yameida.worktool.model.WeworkMessageBean
|
import org.yameida.worktool.model.WeworkMessageBean
|
||||||
@@ -274,7 +275,11 @@ object WeworkOperationImpl {
|
|||||||
goHomeTab("工作台")
|
goHomeTab("工作台")
|
||||||
val node = AccessibilityUtil.scrollAndFindByText(getRoot(), "微盘")
|
val node = AccessibilityUtil.scrollAndFindByText(getRoot(), "微盘")
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
AccessibilityUtil.performClick(node)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
AccessibilityUtil.clickByNode(WeworkController.weworkService, node)
|
||||||
|
} else {
|
||||||
|
AccessibilityUtil.performClick(node)
|
||||||
|
}
|
||||||
val buttonList = AccessibilityUtil.findAllByClazz(getRoot(), Views.Button)
|
val buttonList = AccessibilityUtil.findAllByClazz(getRoot(), Views.Button)
|
||||||
if (buttonList.size >= 4) {
|
if (buttonList.size >= 4) {
|
||||||
AccessibilityUtil.performClick(buttonList[2])
|
AccessibilityUtil.performClick(buttonList[2])
|
||||||
@@ -316,7 +321,11 @@ object WeworkOperationImpl {
|
|||||||
goHomeTab("工作台")
|
goHomeTab("工作台")
|
||||||
val node = AccessibilityUtil.scrollAndFindByText(getRoot(), "微盘")
|
val node = AccessibilityUtil.scrollAndFindByText(getRoot(), "微盘")
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
AccessibilityUtil.performClick(node)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
AccessibilityUtil.clickByNode(WeworkController.weworkService, node)
|
||||||
|
} else {
|
||||||
|
AccessibilityUtil.performClick(node)
|
||||||
|
}
|
||||||
val buttonList = AccessibilityUtil.findAllByClazz(getRoot(), Views.Button)
|
val buttonList = AccessibilityUtil.findAllByClazz(getRoot(), Views.Button)
|
||||||
if (buttonList.size >= 4) {
|
if (buttonList.size >= 4) {
|
||||||
AccessibilityUtil.performClick(buttonList[2])
|
AccessibilityUtil.performClick(buttonList[2])
|
||||||
@@ -623,12 +632,14 @@ object WeworkOperationImpl {
|
|||||||
*/
|
*/
|
||||||
private fun createGroup(): Boolean {
|
private fun createGroup(): Boolean {
|
||||||
goHomeTab("工作台")
|
goHomeTab("工作台")
|
||||||
val textViewGroup = AccessibilityUtil.scrollAndFindByText(getRoot(), "客户群", "居民群")
|
val groupTv = AccessibilityUtil.scrollAndFindByText(getRoot(), "客户群", "居民群")
|
||||||
if (AccessibilityUtil.performClick(textViewGroup)) {
|
?: return false
|
||||||
|
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.N
|
||||||
|
&& AccessibilityUtil.clickByNode(WeworkController.weworkService, groupTv))
|
||||||
|
|| AccessibilityUtil.performClick(groupTv)) {
|
||||||
LogUtils.d("进入客户群应用")
|
LogUtils.d("进入客户群应用")
|
||||||
val textView = AccessibilityUtil.findOneByText(getRoot(), "创建一个客户群", "创建一个居民群")
|
val textView = AccessibilityUtil.findOneByText(getRoot(), "创建一个客户群", "创建一个居民群")
|
||||||
AccessibilityUtil.performClick(textView)
|
return AccessibilityUtil.performClick(textView)
|
||||||
return true
|
|
||||||
} else {
|
} else {
|
||||||
LogUtils.d("未找到客户群应用")
|
LogUtils.d("未找到客户群应用")
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -381,7 +381,7 @@ object AccessibilityUtil {
|
|||||||
var currentTime = startTime
|
var currentTime = startTime
|
||||||
while (currentTime - startTime <= timeout) {
|
while (currentTime - startTime <= timeout) {
|
||||||
val result = findOnceByText(node, *textList, exact = exact)
|
val result = findOnceByText(node, *textList, exact = exact)
|
||||||
LogUtils.v("text: $textList result == null: ${result == null}")
|
LogUtils.v("text: ${textList.joinToString()} result == null: ${result == null}")
|
||||||
if (result != null) return result
|
if (result != null) return result
|
||||||
sleep(SHORT_INTERVAL)
|
sleep(SHORT_INTERVAL)
|
||||||
if (root) {
|
if (root) {
|
||||||
@@ -391,7 +391,7 @@ object AccessibilityUtil {
|
|||||||
}
|
}
|
||||||
currentTime = System.currentTimeMillis()
|
currentTime = System.currentTimeMillis()
|
||||||
}
|
}
|
||||||
Log.e(tag, "findOneByText: not found: $textList")
|
Log.e(tag, "findOneByText: not found: ${textList.joinToString()}")
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,7 +402,7 @@ object AccessibilityUtil {
|
|||||||
): AccessibilityNodeInfo? {
|
): AccessibilityNodeInfo? {
|
||||||
if (node == null) return null
|
if (node == null) return null
|
||||||
val textNodeList = findAllOnceByText(node, *textList, exact = exact)
|
val textNodeList = findAllOnceByText(node, *textList, exact = exact)
|
||||||
LogUtils.v("text: $textList count: " + textNodeList.size)
|
LogUtils.v("text: ${textList.joinToString()} count: " + textNodeList.size)
|
||||||
if (exact) return textNodeList[0]
|
if (exact) return textNodeList[0]
|
||||||
else if (textNodeList.size > 0) {
|
else if (textNodeList.size > 0) {
|
||||||
for (textNode in textNodeList) {
|
for (textNode in textNodeList) {
|
||||||
@@ -436,7 +436,7 @@ object AccessibilityUtil {
|
|||||||
var currentTime = startTime
|
var currentTime = startTime
|
||||||
while (currentTime - startTime <= timeout) {
|
while (currentTime - startTime <= timeout) {
|
||||||
val result = findAllOnceByText(node, *textList, exact = exact)
|
val result = findAllOnceByText(node, *textList, exact = exact)
|
||||||
LogUtils.v("text: $textList count: " + result.size)
|
LogUtils.v("text: ${textList.joinToString()} count: " + result.size)
|
||||||
if (result.size >= minSize) return result
|
if (result.size >= minSize) return result
|
||||||
sleep(SHORT_INTERVAL)
|
sleep(SHORT_INTERVAL)
|
||||||
if (root) {
|
if (root) {
|
||||||
@@ -446,7 +446,7 @@ object AccessibilityUtil {
|
|||||||
}
|
}
|
||||||
currentTime = System.currentTimeMillis()
|
currentTime = System.currentTimeMillis()
|
||||||
}
|
}
|
||||||
Log.e(tag, "findAllByText: not found: $textList")
|
Log.e(tag, "findAllByText: not found: ${textList.joinToString()}")
|
||||||
return arrayListOf()
|
return arrayListOf()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user