update 优化自动加入群聊;settings页自动跳转

This commit is contained in:
gallonyin
2023-05-05 21:14:03 +08:00
parent 8475204292
commit 359dbcde91
5 changed files with 14 additions and 11 deletions

View File

@@ -126,7 +126,7 @@ fun getRoot(ignoreCheck: Boolean): AccessibilityNodeInfo {
WeworkController.weworkService.currentPackage = root.packageName?.toString() ?: ""
if (System.currentTimeMillis() % 30 == 0L) {
error("当前不在企业微信: ${root.packageName}")
if (!root.packageName.contains("(worktool)|(settings)".toRegex())) {
if (!root.packageName.contains("worktool")) {
if (!FloatWindowHelper.isPause) {
ToastUtils.show("当前不在企业微信: ${root.packageName}\n尝试跳转到企业微信")
Utils.getApp().packageManager.getLaunchIntentForPackage(Constant.PACKAGE_NAMES)

View File

@@ -183,7 +183,7 @@ object WeworkLoopImpl {
for (i in 0 until list.childCount) {
val item = list.getChild(childCount - 1 - i)
if (item != null && item.childCount > 0) {
messageList.add(parseChatMessageItem(item, titleList, roomType, false))
messageList.add(parseChatMessageItem(item, titleList, roomType))
}
}
}
@@ -198,7 +198,7 @@ object WeworkLoopImpl {
for (i in 0 until childCount) {
val item = list2.getChild(childCount - 1 - i)
if (item != null && item.childCount > 0) {
val chatMessageItem = parseChatMessageItem(item, titleList, roomType, imageCheck)
val chatMessageItem = parseChatMessageItem(item, titleList, roomType, imageCheck, lastParse = true)
if (chatMessageItem.imageRepeat == true) {
chatMessageItem.imageRepeat = null
imageCheck = false
@@ -215,7 +215,7 @@ object WeworkLoopImpl {
for (i in 0 until list2.childCount) {
val item = list2.getChild(childCount - 1 - i)
if (item != null && item.childCount > 0) {
val chatMessageItem = parseChatMessageItem(item, titleList, roomType, imageCheck)
val chatMessageItem = parseChatMessageItem(item, titleList, roomType, imageCheck, lastParse = true)
if (chatMessageItem.sender == 0 && chatMessageItem.textType == WeworkMessageBean.TEXT_TYPE_IMAGE) {
imageCheck = false
}
@@ -627,7 +627,8 @@ object WeworkLoopImpl {
node: AccessibilityNodeInfo,
titleList: ArrayList<String>,
roomType: Int,
imageCheck: Boolean
imageCheck: Boolean = false,
lastParse: Boolean = false
): WeworkMessageBean.SubMessageBean {
val message: WeworkMessageBean.SubMessageBean
val nameList = arrayListOf<String>()
@@ -671,14 +672,14 @@ object WeworkLoopImpl {
}
if (textType == WeworkMessageBean.TEXT_TYPE_LINK) {
val tempList = itemMessageList.filter { it.feature != 0 }
if (tempList.size == 2 && tempList[0].text.contains("邀请你加入群聊")
if (lastParse && tempList.size == 2 && tempList[0].text.contains("邀请你加入群聊")
&& SPUtils.getInstance("groupInvite").getInt(tempList[1].text, 0) == 0) {
LogUtils.d("邀请你加入群聊: ${tempList[1].text}")
AccessibilityUtil.performClickWithSon(relativeLayoutContent)
if (AccessibilityExtraUtil.loadingPage("JsWebActivity")) {
val tvButton = AccessibilityUtil.findOneByText(getRoot(), "我知道了", "加入群聊", "你已接受过此邀请,无法再次加入", exact = true)
val tvButton = AccessibilityUtil.findOneByText(getRoot(), "我知道了", "加入群聊", "你已接受过此邀请,无法再次加入", "你已接受邀请", exact = true)
val text = tvButton?.text?.toString()
if (text == "我知道了" || text == "你已接受过此邀请,无法再次加入") {
if (text == "我知道了" || text?.startsWith("你已接受") == true) {
backPress()
SPUtils.getInstance("groupInvite").put(tempList[1].text, 1)
error("加入群聊失败: ${tempList[1].text}")
@@ -687,9 +688,11 @@ object WeworkLoopImpl {
SPUtils.getInstance("groupInvite").put(tempList[1].text, 1)
LogUtils.d("加入群聊: ${tempList[1].text}")
log("加入群聊: ${tempList[1].text}")
//该房间的信息读取任务会被强制中断并跳转到新房间且返回无效
} else {
LogUtils.e("加入群聊异常: ${tempList[1].text}")
error("加入群聊异常: ${tempList[1].text}")
backPress()
}
}
}

View File

@@ -972,8 +972,7 @@ object WeworkOperationImpl {
val parseChatMessageItem = WeworkLoopImpl.parseChatMessageItem(
item,
titleList,
WeworkMessageBean.ROOM_TYPE_EXTERNAL_GROUP,
false
WeworkMessageBean.ROOM_TYPE_EXTERNAL_GROUP
)
if (parseChatMessageItem.itemMessageList.find { it.feature == 2 && it.text?.toString() == startTime.toString() } != null) {
start = true

View File

@@ -96,6 +96,7 @@ class WeworkService : AccessibilityService() {
currentPackage = event.packageName?.toString() ?: ""
val className = event.className?.toString() ?: ""
if (className.contains(currentPackage)) {
LogUtils.d("更新当前页面: currentPackage: ${event.packageName} className: ${event.className}")
currentClass = className
}
}

View File

@@ -31,7 +31,7 @@ public class WebSocketManager {
private static final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
public static Map<String, WebSocketManager> webSocketManager = new ConcurrentHashMap<>();
private static final int reconnectInt = 5000; //毫秒
private static final long heartBeatRate = 10; //秒
private static final long heartBeatRate = 5; //秒
private Map<String, Long> messageIdMap = new ConcurrentHashMap<>();
private ScheduledFuture task;
private WebSocket socket;