|
|
@@ -244,12 +244,21 @@ object WeworkOperationImpl {
|
|
|
originalContent: String,
|
|
|
textType: Int,
|
|
|
nameList: List<String>,
|
|
|
- extraText: String? = null
|
|
|
+ extraText: String? = null,
|
|
|
+ maxRetryCount: Int? = null
|
|
|
): Boolean {
|
|
|
val startTime = System.currentTimeMillis()
|
|
|
+ val retryCount = maxRetryCount ?: 2
|
|
|
for (title in LinkedHashSet(titleList)) {
|
|
|
if (WeworkRoomUtil.intoRoom(title) || WeworkRoomUtil.intoRoom(title, fastIn = false)) {
|
|
|
if (!receivedName.isNullOrEmpty()) {
|
|
|
+ AccessibilityUtil.scrollAndFindByText(
|
|
|
+ WeworkController.weworkService,
|
|
|
+ getRoot(),
|
|
|
+ originalContent,
|
|
|
+ exact = true
|
|
|
+ )
|
|
|
+ sleep(Constant.LONG_INTERVAL)
|
|
|
if (WeworkTextUtil.longClickMessageItem(
|
|
|
//聊天消息列表 1ListView 0RecycleView xViewGroup
|
|
|
AccessibilityUtil.findOneByClazz(getRoot(), Views.ListView),
|
|
|
@@ -297,6 +306,19 @@ object WeworkOperationImpl {
|
|
|
return false
|
|
|
}
|
|
|
} else {
|
|
|
+ if (retryCount > 0) {
|
|
|
+ goHome()
|
|
|
+ return relayMessage(
|
|
|
+ message,
|
|
|
+ titleList,
|
|
|
+ receivedName,
|
|
|
+ originalContent,
|
|
|
+ textType,
|
|
|
+ nameList,
|
|
|
+ extraText,
|
|
|
+ retryCount - 1
|
|
|
+ )
|
|
|
+ }
|
|
|
LogUtils.e("$title: 长按条目失败 $originalContent")
|
|
|
uploadCommandResult(
|
|
|
message,
|
|
|
@@ -309,6 +331,13 @@ object WeworkOperationImpl {
|
|
|
return false
|
|
|
}
|
|
|
} else {
|
|
|
+ AccessibilityUtil.scrollAndFindByText(
|
|
|
+ WeworkController.weworkService,
|
|
|
+ getRoot(),
|
|
|
+ originalContent,
|
|
|
+ exact = true
|
|
|
+ )
|
|
|
+ sleep(Constant.LONG_INTERVAL)
|
|
|
if (WeworkTextUtil.longClickMyMessageItem(
|
|
|
//聊天消息列表 1ListView 0RecycleView xViewGroup
|
|
|
AccessibilityUtil.findOneByClazz(getRoot(), Views.ListView),
|
|
|
@@ -353,6 +382,19 @@ object WeworkOperationImpl {
|
|
|
return false
|
|
|
}
|
|
|
} else {
|
|
|
+ if (retryCount > 0) {
|
|
|
+ goHome()
|
|
|
+ return relayMessage(
|
|
|
+ message,
|
|
|
+ titleList,
|
|
|
+ receivedName,
|
|
|
+ originalContent,
|
|
|
+ textType,
|
|
|
+ nameList,
|
|
|
+ extraText,
|
|
|
+ retryCount - 1
|
|
|
+ )
|
|
|
+ }
|
|
|
LogUtils.e("$title: 长按条目失败 $originalContent")
|
|
|
uploadCommandResult(
|
|
|
message,
|
|
|
@@ -2541,7 +2583,8 @@ object WeworkOperationImpl {
|
|
|
originalContent,
|
|
|
textType,
|
|
|
nameList,
|
|
|
- extraText
|
|
|
+ extraText,
|
|
|
+ retryCount
|
|
|
)
|
|
|
}
|
|
|
for (title in LinkedHashSet(titleList)) {
|
|
|
@@ -7060,4 +7103,139 @@ object WeworkOperationImpl {
|
|
|
return false
|
|
|
}
|
|
|
|
|
|
+ fun deleteFriends(message: WeworkMessageBean): Boolean {
|
|
|
+ val startTime = System.currentTimeMillis()
|
|
|
+ goHomeTab("通讯录")
|
|
|
+ sleep(Constant.CHANGE_PAGE_INTERVAL)
|
|
|
+ AccessibilityUtil.scrollToTop(WeworkController.weworkService, getRoot())
|
|
|
+ val customerFlag =
|
|
|
+ AccessibilityUtil.findAllByText(getRoot(), "我的客户","我的学员", exact = true).lastOrNull()
|
|
|
+ if (customerFlag != null) {
|
|
|
+ AccessibilityUtil.performClick(customerFlag)
|
|
|
+ AccessibilityExtraUtil.loadingPage("BaseContentActivity")
|
|
|
+ val list =
|
|
|
+ AccessibilityUtil.findOneByClazz(getRoot(), Views.ListView, Views.RecyclerView)
|
|
|
+ if (list == null) {
|
|
|
+ LogUtils.e("未找到我的客户列表")
|
|
|
+ uploadCommandResult(
|
|
|
+ message,
|
|
|
+ ExecCallbackBean.ERROR_BUTTON,
|
|
|
+ "未找到我的客户列表",
|
|
|
+ startTime
|
|
|
+ )
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ val allCustomer =
|
|
|
+ AccessibilityUtil.findOneByText(getRoot(), "全部微信客户","全部微信学员")
|
|
|
+ if (allCustomer != null) {
|
|
|
+ AccessibilityUtil.performClick(allCustomer)
|
|
|
+ AccessibilityExtraUtil.loadingPage("BaseContentActivity")
|
|
|
+ val oneCustomer =
|
|
|
+ AccessibilityUtil.findOneByText(getRoot(), "单向微信客户","单向微信学员", exact = true)
|
|
|
+ if (oneCustomer != null) {
|
|
|
+ AccessibilityUtil.performClick(oneCustomer)
|
|
|
+ sleep(500)
|
|
|
+ val editCustomer =
|
|
|
+ AccessibilityUtil.findOneByText(getRoot(), "编辑", exact = true)
|
|
|
+ AccessibilityUtil.performClick(editCustomer)
|
|
|
+ val list = AccessibilityUtil.findOneByClazz(
|
|
|
+ getRoot(),
|
|
|
+ Views.ListView,
|
|
|
+ Views.RecyclerView
|
|
|
+ )
|
|
|
+ if (list == null) {
|
|
|
+ LogUtils.e("未找到我的客户列表")
|
|
|
+ uploadCommandResult(
|
|
|
+ message,
|
|
|
+ ExecCallbackBean.ERROR_BUTTON,
|
|
|
+ "未找到我的客户列表",
|
|
|
+ startTime
|
|
|
+ )
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ val set = linkedSetOf<String>()
|
|
|
+ val onScrollListener = object : AccessibilityUtil.OnScrollListener() {
|
|
|
+ override fun onScroll(): Boolean {
|
|
|
+ if (!AccessibilityExtraUtil.loadingPage("BaseContentActivity")) {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ list.refresh()
|
|
|
+ for (i in 0 until list.childCount) {
|
|
|
+ val item = list.getChild(i)
|
|
|
+ if (item.className != Views.RelativeLayout) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ val name = AccessibilityUtil.findOneByClazz(
|
|
|
+ item,
|
|
|
+ Views.TextView
|
|
|
+ )?.text?.toString()
|
|
|
+ ?: continue
|
|
|
+ if (!name.matches("(标签)|(其他外部联系人)|((共?.*个)?客户)".toRegex())) {
|
|
|
+ if (set.size == message.num) {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ if (!set.contains(name)) {
|
|
|
+ AccessibilityUtil.performClick(item)
|
|
|
+ set.add(name)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //滚动前先获取一次
|
|
|
+ onScrollListener.onScroll()
|
|
|
+ AccessibilityUtil.scrollToBottom(
|
|
|
+ WeworkController.weworkService,
|
|
|
+ list,
|
|
|
+ listener = onScrollListener,
|
|
|
+ maxRetry = 100
|
|
|
+ )
|
|
|
+ LogUtils.d("客户数量: ${set.size} 客户列表: ${set.joinToString()}")
|
|
|
+ message.nameList = set.toList()
|
|
|
+ val delete =
|
|
|
+ AccessibilityUtil.findOneByText(getRoot(), "删除")
|
|
|
+ if (delete != null) {
|
|
|
+ AccessibilityUtil.performClick(delete)
|
|
|
+ val deleteConfirm =
|
|
|
+ AccessibilityUtil.findOneByText(getRoot(), "删除联系人")
|
|
|
+ if (deleteConfirm != null) {
|
|
|
+ AccessibilityUtil.performClick(deleteConfirm)
|
|
|
+ uploadCommandResult(message, ExecCallbackBean.SUCCESS, "", startTime)
|
|
|
+ } else {
|
|
|
+ uploadCommandResult(
|
|
|
+ message,
|
|
|
+ ExecCallbackBean.ERROR_TARGET,
|
|
|
+ "找不到确认删除按钮",
|
|
|
+ startTime
|
|
|
+ )
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ uploadCommandResult(
|
|
|
+ message,
|
|
|
+ ExecCallbackBean.ERROR_TARGET,
|
|
|
+ "找不到删除按钮",
|
|
|
+ startTime
|
|
|
+ )
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ uploadCommandResult(
|
|
|
+ message,
|
|
|
+ ExecCallbackBean.ERROR_TARGET,
|
|
|
+ "找不到全部单项客户按钮",
|
|
|
+ startTime
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ uploadCommandResult(
|
|
|
+ message,
|
|
|
+ ExecCallbackBean.ERROR_TARGET,
|
|
|
+ "找不到我的客户和我的学员按钮",
|
|
|
+ startTime
|
|
|
+ )
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ }
|
|
|
}
|