update 优化消息列表检查
This commit is contained in:
@@ -427,7 +427,7 @@ object WeworkGetImpl {
|
|||||||
for (i in 0 until list.childCount) {
|
for (i in 0 until list.childCount) {
|
||||||
val item = list.getChild(i)
|
val item = list.getChild(i)
|
||||||
val tempList = arrayListOf<WeworkMessageBean.ItemMessageBean>()
|
val tempList = arrayListOf<WeworkMessageBean.ItemMessageBean>()
|
||||||
val tvList = AccessibilityUtil.findAllOnceByClazz(item, Views.TextView).mapNotNull { it.text }
|
val tvList = AccessibilityUtil.findAllOnceByClazz(item, Views.TextView).mapNotNull { it.text }.filter { !it.startsWith("@") }
|
||||||
tvList.forEach { tempList.add(WeworkMessageBean.ItemMessageBean(null, it.toString())) }
|
tvList.forEach { tempList.add(WeworkMessageBean.ItemMessageBean(null, it.toString())) }
|
||||||
listBriefList.add(WeworkMessageBean.SubMessageBean(null, null, tempList, null))
|
listBriefList.add(WeworkMessageBean.SubMessageBean(null, null, tempList, null))
|
||||||
//tvList title/time/content
|
//tvList title/time/content
|
||||||
|
|||||||
@@ -238,8 +238,8 @@ object WeworkLoopImpl {
|
|||||||
} else {
|
} else {
|
||||||
lastMessage.itemMessageList.lastOrNull()?.text
|
lastMessage.itemMessageList.lastOrNull()?.text
|
||||||
}
|
}
|
||||||
SPUtils.getInstance("lastSyncMessage").put(title, lastSyncMessage)
|
SPUtils.getInstance("lastSyncMessage").put(titleList[0], lastSyncMessage)
|
||||||
LogUtils.v("lastSyncMessage: $lastSyncMessage")
|
LogUtils.v("lastSyncMessage: ${titleList[0]}: $lastSyncMessage")
|
||||||
if (Constant.enableMediaProject && Constant.pushImage) {
|
if (Constant.enableMediaProject && Constant.pushImage) {
|
||||||
log("image: ${imageSet.size}")
|
log("image: ${imageSet.size}")
|
||||||
if (imageSet.isNotEmpty()) {
|
if (imageSet.isNotEmpty()) {
|
||||||
@@ -471,31 +471,31 @@ object WeworkLoopImpl {
|
|||||||
if (stop) {
|
if (stop) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
val listview = AccessibilityUtil.findOneByClazz(getRoot(), Views.RecyclerView, Views.ListView, Views.ViewGroup)
|
|
||||||
if (listview != null && listview.childCount >= 2) {
|
if (listview != null && listview.childCount >= 2) {
|
||||||
if (checkNoTipMessage(listview) != 1) {
|
val onScrollListener = object : AccessibilityUtil.OnScrollListener() {
|
||||||
AccessibilityUtil.scrollToBottom(WeworkController.weworkService, getRoot(), listener = object : AccessibilityUtil.OnScrollListener() {
|
override fun onScroll(): Boolean {
|
||||||
override fun onScroll(): Boolean {
|
if (hasNewMessage()) {
|
||||||
if (hasNewMessage()) {
|
return true
|
||||||
return true
|
|
||||||
}
|
|
||||||
if (checkNoTipMessage(listview) != 0) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if (checkNoSyncMessage(listview) != 0) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
})
|
if (checkNoTipMessage(listview) == 1) {
|
||||||
LogUtils.v("回到消息列表顶部")
|
return true
|
||||||
for (item in list) {
|
|
||||||
val childCount = item.parent?.parent?.parent?.childCount
|
|
||||||
if (childCount == 4 || childCount == 5) {
|
|
||||||
AccessibilityUtil.clickByNode(WeworkController.weworkService, item)
|
|
||||||
sleep(Constant.POP_WINDOW_INTERVAL / 5)
|
|
||||||
AccessibilityUtil.clickByNode(WeworkController.weworkService, item)
|
|
||||||
}
|
}
|
||||||
|
if (checkNoSyncMessage(listview) != 0) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//滚动前先获取一次
|
||||||
|
onScrollListener.onScroll()
|
||||||
|
AccessibilityUtil.scrollToBottom(WeworkController.weworkService, getRoot(), listener = onScrollListener)
|
||||||
|
LogUtils.v("回到消息列表顶部")
|
||||||
|
for (item in list) {
|
||||||
|
val childCount = item.parent?.parent?.parent?.childCount
|
||||||
|
if (childCount == 4 || childCount == 5) {
|
||||||
|
AccessibilityUtil.clickByNode(WeworkController.weworkService, item)
|
||||||
|
sleep(Constant.POP_WINDOW_INTERVAL / 5)
|
||||||
|
AccessibilityUtil.clickByNode(WeworkController.weworkService, item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -546,7 +546,7 @@ object WeworkLoopImpl {
|
|||||||
val listBriefList = arrayListOf<List<CharSequence>>()
|
val listBriefList = arrayListOf<List<CharSequence>>()
|
||||||
for (i in 0 until list.childCount) {
|
for (i in 0 until list.childCount) {
|
||||||
val item = list.getChild(i)
|
val item = list.getChild(i)
|
||||||
val tvList = AccessibilityUtil.findAllOnceByClazz(item, Views.TextView).mapNotNull { it.text?.toString() }
|
val tvList = AccessibilityUtil.findAllOnceByClazz(item, Views.TextView).mapNotNull { it.text?.toString() }.filter { !it.startsWith("@") }
|
||||||
listBriefList.add(tvList)
|
listBriefList.add(tvList)
|
||||||
//tvList title/time/content
|
//tvList title/time/content
|
||||||
if (tvList.size == 3) {
|
if (tvList.size == 3) {
|
||||||
@@ -584,15 +584,16 @@ object WeworkLoopImpl {
|
|||||||
private fun checkNoSyncMessage(list: AccessibilityNodeInfo): Int {
|
private fun checkNoSyncMessage(list: AccessibilityNodeInfo): Int {
|
||||||
list.refresh()
|
list.refresh()
|
||||||
val listBriefList = arrayListOf<List<CharSequence>>()
|
val listBriefList = arrayListOf<List<CharSequence>>()
|
||||||
|
val titleSet = hashSetOf<String>()
|
||||||
for (i in 0 until list.childCount) {
|
for (i in 0 until list.childCount) {
|
||||||
val item = list.getChild(i)
|
val item = list.getChild(i)
|
||||||
val tvList = AccessibilityUtil.findAllOnceByClazz(item, Views.TextView).mapNotNull { it.text?.toString() }
|
val tvList = AccessibilityUtil.findAllOnceByClazz(item, Views.TextView).mapNotNull { it.text?.toString() }.filter { !it.startsWith("@") }
|
||||||
listBriefList.add(tvList)
|
listBriefList.add(tvList)
|
||||||
//tvList title/time/content
|
//tvList title/time/content
|
||||||
if (tvList.size == 3) {
|
if (tvList.size == 3) {
|
||||||
//只查看最近一周内的消息
|
//只查看最近一周内的消息
|
||||||
val title = tvList[0]
|
val title = tvList[0]
|
||||||
if (title == "群聊") {
|
if (title == "群聊" || !titleSet.add(title)) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if (tvList[1].isBlank() || tvList[1].contains("(刚刚)|(分钟前)|(上午)|(下午)|(昨天)|(星期)|(日程)|(会议)|(:)".toRegex())) {
|
if (tvList[1].isBlank() || tvList[1].contains("(刚刚)|(分钟前)|(上午)|(下午)|(昨天)|(星期)|(日程)|(会议)|(:)".toRegex())) {
|
||||||
|
|||||||
Reference in New Issue
Block a user