update 兼容企微4.1.8;好友信息/群信息/拉人/踢人
This commit is contained in:
@@ -554,7 +554,6 @@ object WeworkController {
|
||||
/**
|
||||
* 获取好友信息
|
||||
* @see WeworkMessageBean.GET_FRIEND_INFO
|
||||
* TODO
|
||||
* @param message#selectList 好友名列表
|
||||
*/
|
||||
@RequestMapping
|
||||
|
||||
@@ -18,6 +18,7 @@ object WeworkGetImpl {
|
||||
|
||||
/**
|
||||
* 获取群信息
|
||||
* @see WeworkMessageBean.GET_GROUP_INFO
|
||||
* @param selectList 群名列表 为空时去群管理页查询并返回群聊页
|
||||
*/
|
||||
fun getGroupInfo(message: WeworkMessageBean, selectList: List<String>): Boolean {
|
||||
@@ -32,6 +33,7 @@ object WeworkGetImpl {
|
||||
|
||||
/**
|
||||
* 获取好友信息
|
||||
* @see WeworkMessageBean.GET_FRIEND_INFO
|
||||
* @param selectList 好友名列表
|
||||
*/
|
||||
fun getFriendInfo(message: WeworkMessageBean, selectList: List<String>): Boolean {
|
||||
@@ -340,14 +342,15 @@ object WeworkGetImpl {
|
||||
val count = tvCount.text.toString().replace("人", "")
|
||||
weworkMessageBean.groupNumber = count.toIntOrNull()
|
||||
}
|
||||
val gridView = AccessibilityUtil.findOneByClazz(getRoot(), Views.GridView)
|
||||
val gridView = AccessibilityUtil.findOnceByClazz(getRoot(), Views.GridView)
|
||||
if (gridView != null && gridView.childCount >= 2) {
|
||||
LogUtils.i("获取群成员 使用GridView")
|
||||
val tvOwnerName = AccessibilityUtil.findOnceByClazz(gridView.getChild(0), Views.TextView)
|
||||
if (tvOwnerName != null && tvOwnerName.text != null) {
|
||||
LogUtils.d("群主: " + tvOwnerName.text)
|
||||
weworkMessageBean.groupOwner = tvOwnerName.text.toString()
|
||||
}
|
||||
if (weworkMessageBean.groupNumber ?: 0 <= 8) {
|
||||
if ((weworkMessageBean.groupNumber ?: 0) <= 8) {
|
||||
val set = linkedSetOf<String>()
|
||||
for (i in 0 until gridView.childCount) {
|
||||
val item = gridView.getChild(i)
|
||||
@@ -358,6 +361,28 @@ object WeworkGetImpl {
|
||||
LogUtils.d("群成员: ${set.joinToString()}")
|
||||
weworkMessageBean.nameList = set.toList()
|
||||
}
|
||||
} else {
|
||||
LogUtils.i("获取群成员 使用RecyclerView")
|
||||
val recyclerViewList = AccessibilityUtil.findAllOnceByClazz(getRoot(), Views.RecyclerView)
|
||||
if (recyclerViewList.size >= 2 && recyclerViewList[1].childCount >= 2) {
|
||||
val rvList = recyclerViewList[1]
|
||||
val tvOwnerName = AccessibilityUtil.findOnceByClazz(rvList.getChild(0), Views.TextView)
|
||||
if (tvOwnerName != null && tvOwnerName.text != null) {
|
||||
LogUtils.d("群主: " + tvOwnerName.text)
|
||||
weworkMessageBean.groupOwner = tvOwnerName.text.toString()
|
||||
}
|
||||
if ((weworkMessageBean.groupNumber ?: 0) <= 8) {
|
||||
val set = linkedSetOf<String>()
|
||||
for (i in 0 until rvList.childCount) {
|
||||
val item = rvList.getChild(i)
|
||||
val name = AccessibilityUtil.findOnceByClazz(item, Views.TextView)?.text?.toString()
|
||||
?: continue
|
||||
set.add(name)
|
||||
}
|
||||
LogUtils.d("群成员: ${set.joinToString()}")
|
||||
weworkMessageBean.nameList = set.toList()
|
||||
}
|
||||
}
|
||||
}
|
||||
val tvAnnouncementFlag = AccessibilityUtil.findOnceByText(getRoot(), "群公告", exact = true)
|
||||
val tvAnnouncement = AccessibilityUtil.findBackNode(tvAnnouncementFlag)
|
||||
|
||||
@@ -2100,7 +2100,9 @@ object WeworkOperationImpl {
|
||||
): Boolean {
|
||||
if (selectList.isNullOrEmpty()) return true
|
||||
if (WeworkRoomUtil.intoGroupManager()) {
|
||||
val gridView = AccessibilityUtil.findOneByClazz(getRoot(), Views.GridView)
|
||||
AccessibilityUtil.findOneByText(getRoot(), "全部群成员", "微信用户创建", timeout = Constant.CHANGE_PAGE_INTERVAL)
|
||||
?: return false
|
||||
val gridView = AccessibilityUtil.findOnceByClazz(getRoot(), Views.GridView)
|
||||
if (gridView != null && gridView.childCount >= 2) {
|
||||
val tvEmptySize = AccessibilityUtil.findAllOnceByClazz(gridView, Views.TextView)
|
||||
.filter { it.text == null }.size
|
||||
@@ -2108,13 +2110,31 @@ object WeworkOperationImpl {
|
||||
if (tvEmptySize == 0) {
|
||||
return true
|
||||
} else if (tvEmptySize == 1 || tvEmptySize == 2) {
|
||||
LogUtils.d("点击拉人按钮")
|
||||
AccessibilityUtil.performClick(gridView.getChild(gridView.childCount - tvEmptySize))
|
||||
}
|
||||
} else {
|
||||
val recyclerViewList = AccessibilityUtil.findAllOnceByClazz(getRoot(), Views.RecyclerView)
|
||||
if (recyclerViewList.size >= 2 && recyclerViewList[1].childCount >= 2) {
|
||||
val rvList = recyclerViewList[1]
|
||||
var ivEmptySize = 0
|
||||
for (i in 0 until rvList.childCount) {
|
||||
if (rvList.getChild(i).childCount == 1) {
|
||||
ivEmptySize++
|
||||
}
|
||||
}
|
||||
if (ivEmptySize == 0) {
|
||||
return true
|
||||
} else if (ivEmptySize == 1 || ivEmptySize == 2) {
|
||||
LogUtils.d("点击拉人按钮")
|
||||
AccessibilityUtil.performClick(rvList.getChild(rvList.childCount - ivEmptySize))
|
||||
}
|
||||
} else {
|
||||
LogUtils.e("未找到添加成员按钮")
|
||||
error("未找到添加成员按钮")
|
||||
return false
|
||||
}
|
||||
}
|
||||
//群详情列表
|
||||
val list = AccessibilityUtil.findOneByClazz(getRoot(), Views.ListView)
|
||||
if (list != null) {
|
||||
@@ -2223,7 +2243,10 @@ object WeworkOperationImpl {
|
||||
private fun groupRemoveMember(removeList: List<String>?): Boolean {
|
||||
if (removeList.isNullOrEmpty()) return true
|
||||
if (WeworkRoomUtil.intoGroupManager()) {
|
||||
val gridView = AccessibilityUtil.findOneByClazz(getRoot(), Views.GridView)
|
||||
AccessibilityUtil.findOneByText(getRoot(), "全部群成员", "微信用户创建", timeout = Constant.CHANGE_PAGE_INTERVAL)
|
||||
?: return false
|
||||
var ivEmptySize = 0
|
||||
val gridView = AccessibilityUtil.findOnceByClazz(getRoot(), Views.GridView)
|
||||
if (gridView != null && gridView.childCount >= 2) {
|
||||
val tvEmptySize = AccessibilityUtil.findAllOnceByClazz(gridView, Views.TextView)
|
||||
.filter { it.text == null }.size
|
||||
@@ -2233,20 +2256,39 @@ object WeworkOperationImpl {
|
||||
error("未找到踢人按钮")
|
||||
return true
|
||||
} else if (tvEmptySize == 2) {
|
||||
LogUtils.d("点击踢人按钮")
|
||||
AccessibilityUtil.performClick(gridView.getChild(gridView.childCount - 1))
|
||||
}
|
||||
} else {
|
||||
val recyclerViewList = AccessibilityUtil.findAllOnceByClazz(getRoot(), Views.RecyclerView)
|
||||
if (recyclerViewList.size >= 2 && recyclerViewList[1].childCount >= 2) {
|
||||
val rvList = recyclerViewList[1]
|
||||
for (i in 0 until rvList.childCount) {
|
||||
if (rvList.getChild(i).childCount == 1) {
|
||||
ivEmptySize++
|
||||
}
|
||||
}
|
||||
if (ivEmptySize <= 1) {
|
||||
LogUtils.e("未找到踢人按钮")
|
||||
error("未找到踢人按钮")
|
||||
return true
|
||||
} else if (ivEmptySize == 2) {
|
||||
LogUtils.d("点击踢人按钮")
|
||||
AccessibilityUtil.performClick(rvList.getChild(rvList.childCount - 1))
|
||||
}
|
||||
} else {
|
||||
LogUtils.e("未找到删除成员按钮")
|
||||
error("未找到删除成员按钮")
|
||||
return false
|
||||
}
|
||||
}
|
||||
//群详情列表
|
||||
val list = AccessibilityUtil.findOneByClazz(getRoot(), Views.ListView)
|
||||
if (list != null) {
|
||||
val frontNode = AccessibilityUtil.findFrontNode(list, 2)
|
||||
val textViewList = AccessibilityUtil.findAllOnceByClazz(frontNode, Views.TextView)
|
||||
if (textViewList.size >= 2) {
|
||||
val multiButton = textViewList.lastOrNull()
|
||||
val multiButton = if (ivEmptySize == 0) textViewList.lastOrNull() else textViewList[textViewList.size - 2]
|
||||
var count = 0
|
||||
for (select in LinkedHashSet(removeList)) {
|
||||
val needTrim = select.contains(Constant.regTrimTitle)
|
||||
|
||||
@@ -184,7 +184,7 @@ object WeworkRoomUtil {
|
||||
* @return true 成功进入好友详情页
|
||||
*/
|
||||
fun intoFriendDetail(): Boolean {
|
||||
if (AccessibilityUtil.findOnceByText(getRoot(), "设置聊天背景") != null) {
|
||||
if (AccessibilityUtil.findOneByText(getRoot(), "设置聊天背景", timeout = Constant.CHANGE_PAGE_INTERVAL) != null) {
|
||||
return true
|
||||
}
|
||||
//同群详情列表
|
||||
@@ -211,14 +211,31 @@ object WeworkRoomUtil {
|
||||
fun getFriendName(): ArrayList<String> {
|
||||
val titleList = arrayListOf<String>()
|
||||
if (intoFriendDetail()) {
|
||||
val gridView = findOneByClazz(getRoot(), Views.GridView)
|
||||
if (AccessibilityUtil.findOneByText(getRoot(), "设置聊天背景", timeout = Constant.CHANGE_PAGE_INTERVAL) != null) {
|
||||
LogUtils.e("获取好友名称失败 校验未进入好友详情页")
|
||||
return titleList
|
||||
}
|
||||
val gridView = AccessibilityUtil.findOnceByClazz(getRoot(), Views.GridView)
|
||||
if (gridView != null && gridView.childCount >= 2) {
|
||||
LogUtils.i("获取好友名称 使用GridView")
|
||||
val tvList = findAllOnceByClazz(gridView.getChild(0), Views.TextView)
|
||||
for (textView in tvList) {
|
||||
if (textView.text != null) {
|
||||
titleList.add(textView.text.toString())
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LogUtils.i("获取好友名称 使用RecyclerView")
|
||||
val recyclerViewList = AccessibilityUtil.findAllOnceByClazz(getRoot(), Views.RecyclerView)
|
||||
if (recyclerViewList.size >= 2 && recyclerViewList[1].childCount >= 2) {
|
||||
val rvList = recyclerViewList[1]
|
||||
val tvList = findAllOnceByClazz(rvList.getChild(0), Views.TextView)
|
||||
for (textView in tvList) {
|
||||
if (textView.text != null) {
|
||||
titleList.add(textView.text.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
backPress()
|
||||
LogUtils.d("获取好友名称成功 ${titleList.joinToString()}")
|
||||
|
||||
Reference in New Issue
Block a user