Merge branch 'master' of https://github.com/gallonyin/worktool
This commit is contained in:
@@ -132,7 +132,7 @@ object WeworkLoopImpl {
|
|||||||
for (i in 0 until list.childCount) {
|
for (i in 0 until list.childCount) {
|
||||||
val item = list.getChild(i)
|
val item = list.getChild(i)
|
||||||
if (item != null && item.childCount > 0) {
|
if (item != null && item.childCount > 0) {
|
||||||
messageList.add(parseChatMessageItem(item, titleList, roomType))
|
messageList.add(parseChatMessageItem(item, titleList, roomType, false))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,7 @@ object WeworkLoopImpl {
|
|||||||
for (i in 0 until list2.childCount) {
|
for (i in 0 until list2.childCount) {
|
||||||
val item = list2.getChild(i)
|
val item = list2.getChild(i)
|
||||||
if (item != null && item.childCount > 0) {
|
if (item != null && item.childCount > 0) {
|
||||||
messageList2.add(parseChatMessageItem(item, titleList, roomType))
|
messageList2.add(parseChatMessageItem(item, titleList, roomType, true))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -163,7 +163,13 @@ object WeworkLoopImpl {
|
|||||||
null
|
null
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
SPUtils.getInstance("lastSyncMessage").put(title, messageList.last().itemMessageList.lastOrNull()?.text)
|
val lastMessage = messageList.last()
|
||||||
|
val lastSyncMessage = if (lastMessage.textType == 2) {
|
||||||
|
"[图片]"
|
||||||
|
} else {
|
||||||
|
lastMessage.itemMessageList.lastOrNull()?.text
|
||||||
|
}
|
||||||
|
SPUtils.getInstance("lastSyncMessage").put(title, lastSyncMessage)
|
||||||
//推测是否回复并在房间等待指令
|
//推测是否回复并在房间等待指令
|
||||||
if (needInfer) {
|
if (needInfer) {
|
||||||
val lastMessage = messageList.lastOrNull()
|
val lastMessage = messageList.lastOrNull()
|
||||||
@@ -467,7 +473,7 @@ object WeworkLoopImpl {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if (SPUtils.getInstance("noSyncMessage").getString(title) != lastSyncMessage) {
|
if (SPUtils.getInstance("noSyncMessage").getString(title) != lastSyncMessage) {
|
||||||
LogUtils.e("发现不一致消息: $tvList")
|
LogUtils.e("发现不一致消息: $tvList $lastSyncMessage")
|
||||||
error("发现不一致消息: $tvList $lastSyncMessage")
|
error("发现不一致消息: $tvList $lastSyncMessage")
|
||||||
SPUtils.getInstance("noSyncMessage").put(title, lastSyncMessage)
|
SPUtils.getInstance("noSyncMessage").put(title, lastSyncMessage)
|
||||||
if (AccessibilityUtil.performClick(item)) {
|
if (AccessibilityUtil.performClick(item)) {
|
||||||
@@ -493,7 +499,8 @@ object WeworkLoopImpl {
|
|||||||
private fun parseChatMessageItem(
|
private fun parseChatMessageItem(
|
||||||
node: AccessibilityNodeInfo,
|
node: AccessibilityNodeInfo,
|
||||||
titleList: ArrayList<String>,
|
titleList: ArrayList<String>,
|
||||||
roomType: Int
|
roomType: Int,
|
||||||
|
doubleCheck: Boolean
|
||||||
): WeworkMessageBean.SubMessageBean {
|
): WeworkMessageBean.SubMessageBean {
|
||||||
val message: WeworkMessageBean.SubMessageBean
|
val message: WeworkMessageBean.SubMessageBean
|
||||||
val nameList = arrayListOf<String>()
|
val nameList = arrayListOf<String>()
|
||||||
@@ -537,7 +544,7 @@ object WeworkLoopImpl {
|
|||||||
}
|
}
|
||||||
message = WeworkMessageBean.SubMessageBean(0, textType, itemMessageList, nameList)
|
message = WeworkMessageBean.SubMessageBean(0, textType, itemMessageList, nameList)
|
||||||
//图片类型特殊处理
|
//图片类型特殊处理
|
||||||
if (Constant.pushImage && textType == 2) {
|
if (doubleCheck && Constant.pushImage && textType == 2) {
|
||||||
val lastPicCreateTime = MultiFileObserver.lastPicCreateTime
|
val lastPicCreateTime = MultiFileObserver.lastPicCreateTime
|
||||||
val lastPicPath = MultiFileObserver.lastPicPath
|
val lastPicPath = MultiFileObserver.lastPicPath
|
||||||
LogUtils.d("发现图片类型应该点击")
|
LogUtils.d("发现图片类型应该点击")
|
||||||
|
|||||||
@@ -587,7 +587,6 @@ object WeworkOperationImpl {
|
|||||||
if (shareToWorkButton != null
|
if (shareToWorkButton != null
|
||||||
&& WeworkController.weworkService.currentPackage != Constant.PACKAGE_NAMES) {
|
&& WeworkController.weworkService.currentPackage != Constant.PACKAGE_NAMES) {
|
||||||
LogUtils.e("尝试手势点击!!!!!")
|
LogUtils.e("尝试手势点击!!!!!")
|
||||||
AccessibilityUtil.printNodeClazzTree(shareToWorkButton)
|
|
||||||
AccessibilityUtil.clickByNode(WeworkController.weworkService, shareToWorkButton)
|
AccessibilityUtil.clickByNode(WeworkController.weworkService, shareToWorkButton)
|
||||||
sleep(Constant.CHANGE_PAGE_INTERVAL)
|
sleep(Constant.CHANGE_PAGE_INTERVAL)
|
||||||
shareToWorkButton = AccessibilityUtil.findOnceByText(getRoot(true), "发送给同事")
|
shareToWorkButton = AccessibilityUtil.findOnceByText(getRoot(true), "发送给同事")
|
||||||
@@ -663,7 +662,6 @@ object WeworkOperationImpl {
|
|||||||
if (shareToWorkButton != null
|
if (shareToWorkButton != null
|
||||||
&& WeworkController.weworkService.currentPackage != Constant.PACKAGE_NAMES) {
|
&& WeworkController.weworkService.currentPackage != Constant.PACKAGE_NAMES) {
|
||||||
LogUtils.e("尝试手势点击!!!!!")
|
LogUtils.e("尝试手势点击!!!!!")
|
||||||
AccessibilityUtil.printNodeClazzTree(shareToWorkButton)
|
|
||||||
AccessibilityUtil.clickByNode(WeworkController.weworkService, shareToWorkButton)
|
AccessibilityUtil.clickByNode(WeworkController.weworkService, shareToWorkButton)
|
||||||
sleep(Constant.CHANGE_PAGE_INTERVAL)
|
sleep(Constant.CHANGE_PAGE_INTERVAL)
|
||||||
shareToWorkButton = AccessibilityUtil.findOnceByText(getRoot(true), "发送给同事")
|
shareToWorkButton = AccessibilityUtil.findOnceByText(getRoot(true), "发送给同事")
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
package org.yameida.worktool.utils
|
package org.yameida.worktool.utils
|
||||||
|
|
||||||
import com.blankj.utilcode.util.AppUtils
|
import com.blankj.utilcode.util.*
|
||||||
import com.blankj.utilcode.util.GsonUtils
|
|
||||||
import com.blankj.utilcode.util.LogUtils
|
|
||||||
import com.blankj.utilcode.util.ToastUtils
|
|
||||||
import com.lzy.okgo.OkGo
|
import com.lzy.okgo.OkGo
|
||||||
import com.lzy.okgo.callback.StringCallback
|
import com.lzy.okgo.callback.StringCallback
|
||||||
import com.lzy.okgo.model.Response
|
import com.lzy.okgo.model.Response
|
||||||
import model.UpdateConfig
|
import model.UpdateConfig
|
||||||
|
import org.json.JSONObject
|
||||||
import org.yameida.worktool.Constant
|
import org.yameida.worktool.Constant
|
||||||
import org.yameida.worktool.R
|
import org.yameida.worktool.R
|
||||||
import org.yameida.worktool.model.network.CheckUpdateResult
|
import org.yameida.worktool.model.network.CheckUpdateResult
|
||||||
import org.yameida.worktool.model.network.GetMyConfigResult
|
import org.yameida.worktool.model.network.GetMyConfigResult
|
||||||
|
import org.yameida.worktool.service.log
|
||||||
import update.UpdateAppUtils
|
import update.UpdateAppUtils
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@@ -112,19 +111,38 @@ object HttpUtil {
|
|||||||
/**
|
/**
|
||||||
* 推送图片
|
* 推送图片
|
||||||
*/
|
*/
|
||||||
fun pushImage(url: String, groupName: String, receivedName: String?, imagePath: String) {
|
fun pushImage(url: String, titleList: List<String>, receivedName: String?, imagePath: String, roomType: Int) {
|
||||||
|
val json = JSONObject()
|
||||||
|
if (receivedName != null) {
|
||||||
|
json.put("receivedName", receivedName)
|
||||||
|
json.put("groupName", titleList.lastOrNull())
|
||||||
|
if (titleList.size > 1) {
|
||||||
|
json.put("groupRemark", titleList.first())
|
||||||
|
} else {
|
||||||
|
json.put("groupRemark", null)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
json.put("receivedName", titleList.lastOrNull() { !it.contains("@") } ?: "")
|
||||||
|
json.put("groupName", null)
|
||||||
|
json.put("groupRemark", null)
|
||||||
|
}
|
||||||
|
json.put("image", EncodeUtils.base64Encode2String(File(imagePath).readBytes()))
|
||||||
|
json.put("robotId", Constant.robotId)
|
||||||
|
json.put("roomType", roomType)
|
||||||
|
json.put("atMe", false)
|
||||||
|
json.put("textType", 2)
|
||||||
OkGo.post<String>(url)
|
OkGo.post<String>(url)
|
||||||
.params("groupName", groupName)
|
.upJson(json)
|
||||||
.params("receivedName", receivedName ?: "")
|
|
||||||
.params("image", File(imagePath))
|
|
||||||
.execute(object : StringCallback() {
|
.execute(object : StringCallback() {
|
||||||
override fun onSuccess(response: Response<String>) {
|
override fun onSuccess(response: Response<String>) {
|
||||||
LogUtils.d("推送图片成功: $groupName $receivedName $imagePath")
|
LogUtils.d("推送图片成功: ${titleList.joinToString()} $receivedName $imagePath")
|
||||||
|
log("推送图片成功: ${titleList.joinToString()} $receivedName $imagePath")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onError(response: Response<String>) {
|
override fun onError(response: Response<String>) {
|
||||||
ToastUtils.showLong("推送图片失败")
|
ToastUtils.showLong("推送图片失败")
|
||||||
LogUtils.e("推送图片失败")
|
LogUtils.e("推送图片失败")
|
||||||
|
error("推送图片失败: $${titleList.joinToString()} $receivedName $imagePath")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user