update 主动加好友优化;真@提醒;双击获取未读消息;获取我的信息优化
This commit is contained in:
@@ -9,8 +9,8 @@ android {
|
|||||||
applicationId "org.yameida.worktool"
|
applicationId "org.yameida.worktool"
|
||||||
minSdkVersion 23
|
minSdkVersion 23
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
versionCode 2
|
versionCode 211
|
||||||
versionName "2.0"
|
versionName "2.1"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,6 +139,8 @@ public class WeworkMessageBean {
|
|||||||
public String receivedName;
|
public String receivedName;
|
||||||
//内容移除了@me
|
//内容移除了@me
|
||||||
public String receivedContent;
|
public String receivedContent;
|
||||||
|
//想要at的昵称
|
||||||
|
public String at;
|
||||||
//原始内容text
|
//原始内容text
|
||||||
public String originalContent;
|
public String originalContent;
|
||||||
//多选(转发等)
|
//多选(转发等)
|
||||||
@@ -231,6 +233,7 @@ public class WeworkMessageBean {
|
|||||||
public String corporation;
|
public String corporation;
|
||||||
public String phone;
|
public String phone;
|
||||||
public String job;
|
public String job;
|
||||||
|
public String sumInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
//添加好友
|
//添加好友
|
||||||
|
|||||||
@@ -42,12 +42,13 @@ object WeworkController {
|
|||||||
* @see WeworkMessageBean.SEND_MESSAGE
|
* @see WeworkMessageBean.SEND_MESSAGE
|
||||||
* @param message#titleList 房间名称
|
* @param message#titleList 房间名称
|
||||||
* @param message#receivedContent 回复内容
|
* @param message#receivedContent 回复内容
|
||||||
|
* @param message#at 要at的昵称
|
||||||
* @see WeworkMessageBean.TEXT_TYPE
|
* @see WeworkMessageBean.TEXT_TYPE
|
||||||
*/
|
*/
|
||||||
@RequestMapping
|
@RequestMapping
|
||||||
fun sendMessage(message: WeworkMessageBean): Boolean {
|
fun sendMessage(message: WeworkMessageBean): Boolean {
|
||||||
LogUtils.d("sendMessage(): ${message.titleList} ${message.receivedContent}")
|
LogUtils.d("sendMessage(): ${message.titleList} ${message.receivedContent} ${message.at}")
|
||||||
return WeworkOperationImpl.sendMessage(message.titleList, message.receivedContent)
|
return WeworkOperationImpl.sendMessage(message.titleList, message.receivedContent, message.at)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import org.yameida.worktool.model.WeworkMessageBean
|
|||||||
import org.yameida.worktool.utils.AccessibilityUtil
|
import org.yameida.worktool.utils.AccessibilityUtil
|
||||||
import org.yameida.worktool.utils.Views
|
import org.yameida.worktool.utils.Views
|
||||||
import org.yameida.worktool.utils.WeworkRoomUtil
|
import org.yameida.worktool.utils.WeworkRoomUtil
|
||||||
|
import java.lang.StringBuilder
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取数据类型 500 实现类
|
* 获取数据类型 500 实现类
|
||||||
@@ -55,13 +56,34 @@ object WeworkGetImpl {
|
|||||||
sleep(Constant.CHANGE_PAGE_INTERVAL)
|
sleep(Constant.CHANGE_PAGE_INTERVAL)
|
||||||
val newFirstTv = AccessibilityUtil.findOneByClazz(getRoot(), Views.TextView)
|
val newFirstTv = AccessibilityUtil.findOneByClazz(getRoot(), Views.TextView)
|
||||||
val nickname = newFirstTv?.text?.toString()
|
val nickname = newFirstTv?.text?.toString()
|
||||||
AccessibilityUtil.performClick(firstTv)
|
|
||||||
if (nickname != null) {
|
if (nickname != null) {
|
||||||
|
var corp: String? = null
|
||||||
|
val info = StringBuilder()
|
||||||
|
if (AccessibilityUtil.performClick(newFirstTv)) {
|
||||||
|
sleep(Constant.CHANGE_PAGE_INTERVAL)
|
||||||
|
val rv = AccessibilityUtil.findOneByClazz(getRoot(), Views.RecyclerView)
|
||||||
|
if (rv != null && rv.childCount > 0) {
|
||||||
|
val myInfoLayout = rv.getChild(0)
|
||||||
|
val tvList = AccessibilityUtil.findAllByClazz(myInfoLayout, Views.TextView)
|
||||||
|
.filter { it.text != null }
|
||||||
|
if (tvList.isNotEmpty()) {
|
||||||
|
corp = tvList[0].text.toString()
|
||||||
|
tvList.forEach { info.append(it.text).append("-") }
|
||||||
|
info.setLength(info.length - 1)
|
||||||
|
LogUtils.v("corp", corp)
|
||||||
|
LogUtils.v("info", info.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Constant.myName = nickname
|
Constant.myName = nickname
|
||||||
LogUtils.d("我的昵称: ${Constant.myName}")
|
LogUtils.d("我的昵称: ${Constant.myName}")
|
||||||
val weworkMessageBean = WeworkMessageBean()
|
val weworkMessageBean = WeworkMessageBean()
|
||||||
weworkMessageBean.type = WeworkMessageBean.GET_MY_INFO
|
weworkMessageBean.type = WeworkMessageBean.GET_MY_INFO
|
||||||
weworkMessageBean.myInfo = WeworkMessageBean.MyInfo().apply { name = nickname }
|
weworkMessageBean.myInfo = WeworkMessageBean.MyInfo().apply {
|
||||||
|
name = nickname
|
||||||
|
corporation = corp
|
||||||
|
sumInfo = info.toString()
|
||||||
|
}
|
||||||
WeworkController.weworkService.webSocketManager.send(weworkMessageBean)
|
WeworkController.weworkService.webSocketManager.send(weworkMessageBean)
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -200,12 +200,31 @@ object WeworkLoopImpl {
|
|||||||
private fun getChatroomList(): Boolean {
|
private fun getChatroomList(): Boolean {
|
||||||
if (Constant.autoReply == 0) return true
|
if (Constant.autoReply == 0) return true
|
||||||
if (!isAtHome()) return true
|
if (!isAtHome()) return true
|
||||||
if (logIndex % 3 == 0) {
|
|
||||||
AccessibilityUtil.performScrollUp(getRoot(), 0)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
AccessibilityUtil.performScrollUp(getRoot(), 0)
|
val list = AccessibilityUtil.findAllOnceByText(getRoot(), "消息", exact = true)
|
||||||
AccessibilityUtil.performScrollUp(getRoot(), 0)
|
for (item in list) {
|
||||||
} else if (logIndex % 120 < 3) {
|
if (item.parent.parent.parent.childCount == 5) {
|
||||||
AccessibilityUtil.performScrollDown(getRoot(), 0)
|
if (item.parent.childCount > 1) {
|
||||||
|
LogUtils.d("消息有红点")
|
||||||
|
AccessibilityUtil.clickByNode(WeworkController.weworkService, item)
|
||||||
|
sleep(100)
|
||||||
|
AccessibilityUtil.clickByNode(WeworkController.weworkService, item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (logIndex % 120 == 0) {
|
||||||
|
goHomeTab("通讯录")
|
||||||
|
goHomeTab("消息")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (logIndex % 3 == 0) {
|
||||||
|
AccessibilityUtil.performScrollUp(getRoot(), 0)
|
||||||
|
AccessibilityUtil.performScrollUp(getRoot(), 0)
|
||||||
|
AccessibilityUtil.performScrollUp(getRoot(), 0)
|
||||||
|
} else if (logIndex % 120 < 3) {
|
||||||
|
AccessibilityUtil.performScrollDown(getRoot(), 0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!isAtHome()) return true
|
if (!isAtHome()) return true
|
||||||
if (logIndex++ % 15 == 0) {
|
if (logIndex++ % 15 == 0) {
|
||||||
|
|||||||
@@ -21,12 +21,13 @@ object WeworkOperationImpl {
|
|||||||
* 在房间内发送消息
|
* 在房间内发送消息
|
||||||
* @param titleList 房间名称
|
* @param titleList 房间名称
|
||||||
* @param receivedContent 回复内容
|
* @param receivedContent 回复内容
|
||||||
|
* @param at 要at的昵称
|
||||||
* @see WeworkMessageBean.TEXT_TYPE
|
* @see WeworkMessageBean.TEXT_TYPE
|
||||||
*/
|
*/
|
||||||
fun sendMessage(titleList: List<String>, receivedContent: String): Boolean {
|
fun sendMessage(titleList: List<String>, receivedContent: String, at: String? = null): Boolean {
|
||||||
for (title in titleList) {
|
for (title in titleList) {
|
||||||
if (WeworkRoomUtil.intoRoom(title)) {
|
if (WeworkRoomUtil.intoRoom(title)) {
|
||||||
sendChatMessage(receivedContent)
|
sendChatMessage(receivedContent, at = at)
|
||||||
LogUtils.d("$title: 发送成功")
|
LogUtils.d("$title: 发送成功")
|
||||||
} else {
|
} else {
|
||||||
LogUtils.d("$title: 发送失败")
|
LogUtils.d("$title: 发送失败")
|
||||||
@@ -440,8 +441,9 @@ object WeworkOperationImpl {
|
|||||||
AccessibilityUtil.findTextAndClick(getRoot(), "搜索手机号添加")
|
AccessibilityUtil.findTextAndClick(getRoot(), "搜索手机号添加")
|
||||||
AccessibilityUtil.findTextInput(getRoot(), friend.phone.trim())
|
AccessibilityUtil.findTextInput(getRoot(), friend.phone.trim())
|
||||||
if (AccessibilityUtil.findTextAndClick(getRoot(), "网络查找手机")) {
|
if (AccessibilityUtil.findTextAndClick(getRoot(), "网络查找手机")) {
|
||||||
val bothUsedTv = AccessibilityUtil.findOneByText(getRoot(), "对方同时使用", timeout = 2000)
|
val bothUsedTv = AccessibilityUtil.findOneByText(getRoot(), "对方同时使用", "标签", "电话")
|
||||||
if (bothUsedTv != null) {
|
val bothUsedText = bothUsedTv?.text
|
||||||
|
if (bothUsedText != null && bothUsedText.contains("对方同时使用")) {
|
||||||
AccessibilityUtil.performClick(
|
AccessibilityUtil.performClick(
|
||||||
AccessibilityUtil.findOnceByClazz(
|
AccessibilityUtil.findOnceByClazz(
|
||||||
AccessibilityUtil.findBackNode(bothUsedTv),
|
AccessibilityUtil.findBackNode(bothUsedTv),
|
||||||
@@ -449,72 +451,72 @@ object WeworkOperationImpl {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
if (AccessibilityUtil.findOneByText(getRoot(), "标签", "电话") != null) {
|
||||||
LogUtils.e("未找到查找手机选项")
|
var markTv = AccessibilityUtil.findOnceByText(getRoot(), "设置备注和描述")
|
||||||
}
|
if (markTv == null) {
|
||||||
if (AccessibilityUtil.findOneByText(getRoot(), "标签") != null) {
|
markTv = AccessibilityUtil.findOnceByText(getRoot(), "企业")
|
||||||
var markTv = AccessibilityUtil.findOnceByText(getRoot(), "设置备注和描述")
|
}
|
||||||
if (markTv == null) {
|
if (markTv == null) {
|
||||||
markTv = AccessibilityUtil.findOnceByText(getRoot(), "企业")
|
markTv = AccessibilityUtil.findOnceByText(getRoot(), "描述")
|
||||||
}
|
}
|
||||||
if (markTv == null) {
|
//设置备注
|
||||||
markTv = AccessibilityUtil.findOnceByText(getRoot(), "描述")
|
if (markTv != null && (friend.markName != null
|
||||||
}
|
|| friend.markCorp != null || friend.markExtra != null)
|
||||||
//设置备注
|
) {
|
||||||
if (markTv != null && (friend.markName != null
|
AccessibilityUtil.performClick(markTv)
|
||||||
|| friend.markCorp != null || friend.markExtra != null)
|
val etList =
|
||||||
) {
|
AccessibilityUtil.findAllByClazz(getRoot(), Views.EditText, minSize = 5)
|
||||||
AccessibilityUtil.performClick(markTv)
|
if (etList.size >= 5) {
|
||||||
val etList =
|
if (friend.markName != null) {
|
||||||
AccessibilityUtil.findAllByClazz(getRoot(), Views.EditText, minSize = 5)
|
AccessibilityUtil.editTextInput(etList[0], friend.markName)
|
||||||
if (etList.size >= 5) {
|
}
|
||||||
if (friend.markName != null) {
|
if (friend.markCorp != null) {
|
||||||
AccessibilityUtil.editTextInput(etList[0], friend.markName)
|
AccessibilityUtil.editTextInput(etList[1], friend.markCorp)
|
||||||
|
}
|
||||||
|
if (friend.markExtra != null) {
|
||||||
|
AccessibilityUtil.editTextInput(etList[4], friend.markExtra)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (friend.markCorp != null) {
|
AccessibilityUtil.findTextAndClick(getRoot(), "保存")
|
||||||
AccessibilityUtil.editTextInput(etList[1], friend.markCorp)
|
}
|
||||||
}
|
//设置标签
|
||||||
if (friend.markExtra != null) {
|
if (!friend.tagList.isNullOrEmpty()) {
|
||||||
AccessibilityUtil.editTextInput(etList[4], friend.markExtra)
|
if (AccessibilityUtil.findTextAndClick(getRoot(), "标签")) {
|
||||||
|
setFriendTags(friend.tagList)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AccessibilityUtil.findTextAndClick(getRoot(), "保存")
|
//添加联系人
|
||||||
}
|
val imageView =
|
||||||
//设置标签
|
AccessibilityUtil.findOneByClazz(getRoot(), Views.ImageView)
|
||||||
if (!friend.tagList.isNullOrEmpty()) {
|
if (imageView != null) {
|
||||||
if (AccessibilityUtil.findTextAndClick(getRoot(), "标签")) {
|
val textViewList = AccessibilityUtil.findAllOnceByClazz(
|
||||||
setFriendTags(friend.tagList)
|
imageView.parent,
|
||||||
|
Views.TextView
|
||||||
|
)
|
||||||
|
val filter =
|
||||||
|
textViewList.filter { it.text != null && it.text.toString() != "微信" }
|
||||||
|
if (filter.isNotEmpty()) {
|
||||||
|
val tvNick = filter[0]
|
||||||
|
LogUtils.d("好友昵称或备注名: " + tvNick.text)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if (AccessibilityUtil.findTextAndClick(getRoot(), "添加为联系人")) {
|
||||||
//添加联系人
|
LogUtils.d("添加好友成功: " + friend.phone)
|
||||||
val imageView =
|
if (AccessibilityUtil.findTextAndClick(getRoot(), "发送添加邀请", "发送申请")) {
|
||||||
AccessibilityUtil.findOneByClazz(getRoot(), Views.ImageView)
|
LogUtils.d("发送添加邀请成功: " + friend.phone)
|
||||||
if (imageView != null) {
|
}
|
||||||
val textViewList = AccessibilityUtil.findAllOnceByClazz(
|
} else {
|
||||||
imageView.parent,
|
if (AccessibilityUtil.findOnceByText(getRoot(), "发消息") != null) {
|
||||||
Views.TextView
|
LogUtils.e("已经添加联系人,请勿重复添加")
|
||||||
)
|
} else {
|
||||||
val filter =
|
LogUtils.e("未找到添加为联系人")
|
||||||
textViewList.filter { it.text != null && it.text.toString() != "微信" }
|
}
|
||||||
if (filter.isNotEmpty()) {
|
|
||||||
val tvNick = filter[0]
|
|
||||||
LogUtils.d("好友昵称或备注名: " + tvNick.text)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (AccessibilityUtil.findTextAndClick(getRoot(), "添加为联系人")) {
|
|
||||||
LogUtils.d("添加好友成功: " + friend.phone)
|
|
||||||
if (AccessibilityUtil.findTextAndClick(getRoot(), "发送添加邀请", "发送申请")) {
|
|
||||||
LogUtils.d("发送添加邀请成功: " + friend.phone)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (AccessibilityUtil.findOnceByText(getRoot(), "发消息") != null) {
|
LogUtils.e("未找到标签")
|
||||||
LogUtils.e("已经添加联系人,请勿重复添加")
|
|
||||||
} else {
|
|
||||||
LogUtils.e("未找到添加为联系人")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LogUtils.e("未找到标签")
|
LogUtils.e("未找到查找手机选项")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LogUtils.e("未找到添加客户按钮")
|
LogUtils.e("未找到添加客户按钮")
|
||||||
@@ -821,10 +823,29 @@ object WeworkOperationImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送消息
|
* 发送消息+@at
|
||||||
*/
|
*/
|
||||||
private fun sendChatMessage(text: String, prefix: String = "") {
|
private fun sendChatMessage(text: String, prefix: String = "", at: String? = null) {
|
||||||
if (AccessibilityUtil.findTextInput(getRoot(), prefix + text)) {
|
var atFailed = false
|
||||||
|
if (!at.isNullOrEmpty()) {
|
||||||
|
AccessibilityUtil.findTextInput(getRoot(), "@")
|
||||||
|
val atFlag = AccessibilityUtil.findOneByText(getRoot(), "选择提醒的人", timeout = 2000)
|
||||||
|
if (atFlag != null) {
|
||||||
|
val rv = AccessibilityUtil.findOneByClazz(getRoot(), Views.RecyclerView)
|
||||||
|
AccessibilityUtil.findTextInput(getRoot(), at)
|
||||||
|
val atNode = AccessibilityUtil.findOneByText(rv, at, root = false, timeout = 2000)
|
||||||
|
if (atNode != null) {
|
||||||
|
AccessibilityUtil.performClick(atNode)
|
||||||
|
} else {
|
||||||
|
LogUtils.e("未找到at人: $at")
|
||||||
|
atFailed = true
|
||||||
|
backPress()
|
||||||
|
}
|
||||||
|
sleep(Constant.POP_WINDOW_INTERVAL)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val content = if (atFailed) "@$at $prefix$text" else "$prefix$text"
|
||||||
|
if (AccessibilityUtil.findTextInput(getRoot(), content, append = !atFailed)) {
|
||||||
val sendButton = AccessibilityUtil.findAllByClazz(getRoot(), Views.Button)
|
val sendButton = AccessibilityUtil.findAllByClazz(getRoot(), Views.Button)
|
||||||
.firstOrNull { it.text == "发送" }
|
.firstOrNull { it.text == "发送" }
|
||||||
if (sendButton != null) {
|
if (sendButton != null) {
|
||||||
|
|||||||
@@ -76,24 +76,21 @@ object AccessibilityUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//寻找第一个EditView编辑框并输入文本
|
//寻找第一个EditView编辑框并输入文本
|
||||||
fun findTextInput(nodeInfo: AccessibilityNodeInfo?, text: String, root: Boolean = true): Boolean {
|
fun findTextInput(nodeInfo: AccessibilityNodeInfo?, text: String, root: Boolean = true, append: Boolean = false): Boolean {
|
||||||
if (root) {
|
val editText = if (root) {
|
||||||
val editText = findOneByClazz(nodeInfo, "android.widget.EditText") ?: return false
|
findOneByClazz(nodeInfo, "android.widget.EditText") ?: return false
|
||||||
val arguments = Bundle()
|
|
||||||
arguments.putCharSequence(
|
|
||||||
AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE,
|
|
||||||
text
|
|
||||||
)
|
|
||||||
editText.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, arguments)
|
|
||||||
} else {
|
} else {
|
||||||
val editText = findOnceByClazz(nodeInfo, "android.widget.EditText") ?: return false
|
findOnceByClazz(nodeInfo, "android.widget.EditText") ?: return false
|
||||||
val arguments = Bundle()
|
|
||||||
arguments.putCharSequence(
|
|
||||||
AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE,
|
|
||||||
text
|
|
||||||
)
|
|
||||||
editText.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, arguments)
|
|
||||||
}
|
}
|
||||||
|
editText.refresh()
|
||||||
|
val oldText = if (editText.text != null) editText.text.toString() else ""
|
||||||
|
LogUtils.v("findTextInput oldText: $oldText")
|
||||||
|
val arguments = Bundle()
|
||||||
|
arguments.putCharSequence(
|
||||||
|
AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE,
|
||||||
|
if (append) (oldText + text) else text
|
||||||
|
)
|
||||||
|
editText.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, arguments)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -710,15 +707,15 @@ object AccessibilityUtil {
|
|||||||
val builder = GestureDescription.Builder()
|
val builder = GestureDescription.Builder()
|
||||||
val path = Path()
|
val path = Path()
|
||||||
path.moveTo(point.x.toFloat(), point.y.toFloat())
|
path.moveTo(point.x.toFloat(), point.y.toFloat())
|
||||||
builder.addStroke(StrokeDescription(path, 0L, 100L))
|
builder.addStroke(StrokeDescription(path, 0L, 10L))
|
||||||
val gesture = builder.build()
|
val gesture = builder.build()
|
||||||
return service.dispatchGesture(gesture, object : GestureResultCallback() {
|
return service.dispatchGesture(gesture, object : GestureResultCallback() {
|
||||||
override fun onCompleted(gestureDescription: GestureDescription) {
|
override fun onCompleted(gestureDescription: GestureDescription) {
|
||||||
LogUtils.e("click okk onCompleted")
|
LogUtils.d("click okk onCompleted")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCancelled(gestureDescription: GestureDescription) {
|
override fun onCancelled(gestureDescription: GestureDescription) {
|
||||||
LogUtils.e("click okk onCancelled")
|
LogUtils.d("click okk onCancelled")
|
||||||
}
|
}
|
||||||
}, null)
|
}, null)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user