feat: 增强好友信息采集并更新应用主题

- 新增好友通过后自动采集微信号、企业、部门等详细信息并上传服务端
- 单聊消息列表新增联系人详细信息字段
- 更新应用名称为AwinWorkTool并统一相关文本显示
- 重构颜色配置,采用AI风格青色主题,提升视觉体验
- 更新后端协议文档,补充好友信息和消息列表的数据结构说明
This commit is contained in:
2026-03-24 17:44:47 +08:00
parent 344c0ad710
commit 51f961bb8e
8 changed files with 329 additions and 25 deletions

View File

@@ -166,3 +166,133 @@ WorkTool 使用 WebSocket 协议与服务端进行长连接通信。
* 8: 链接 (TEXT_TYPE_LINK) * 8: 链接 (TEXT_TYPE_LINK)
* 9: 文件 (TEXT_TYPE_FILE) * 9: 文件 (TEXT_TYPE_FILE)
* 15: 引用回复 (TEXT_TYPE_REPLY) * 15: 引用回复 (TEXT_TYPE_REPLY)
## 附录:自动通过好友请求
当 APP 开启"自动通过好友请求"开关后,有新好友添加成功时会主动上传好友信息到服务端。
### 上传时机
* 自动通过好友请求成功后
* 手动通过好友请求成功后
### 消息类型
* **Type**: `502` (GET_FRIEND_INFO)
### 数据结构
```json
{
"type": 502,
"friend": {
"name": "张三", // 好友昵称
"newFriend": true, // 标记为新好友
"wechatId": "zhangsan123", // 微信号
"phone": "13800138000", // 手机号
"corpName": "XX科技有限公司", // 企业名称
"department": "技术部", // 部门
"position": "工程师", // 职位
"email": "zhangsan@example.com", // 邮箱
"markName": "张工", // 备注名
"gender": 1, // 性别: 1男 2女 0未知
"leavingMsg": "请求添加好友时的留言" // 留言/验证消息
}
}
```
### 服务端接收示例
服务端只需监听 WebSocket 消息,当 `type=502``friend.newFriend=true` 时,表示有新好友添加成功。
---
## 附录:接收消息列表 (101)
客户端监听到新消息时,会主动上传消息列表到服务端。
### 消息类型
* **Type**: `101` (TYPE_RECEIVE_MESSAGE_LIST)
### 数据结构(群聊)
```json
{
"type": 101,
"roomType": 1,
"titleList": ["技术交流群"],
"messageList": [
{
"sender": 0,
"textType": 1,
"nameList": ["张三"],
"itemMessageList": [
{"feature": 2, "text": "你好,这是消息内容"}
]
},
{
"sender": 1,
"textType": 1,
"itemMessageList": [
{"feature": 2, "text": "收到"}
]
}
]
}
```
### 数据结构(单聊)
```json
{
"type": 101,
"roomType": 2,
"titleList": ["张三"],
"contact": {
"name": "张三",
"wechatId": "zhangsan123",
"phone": "13800138000",
"corpName": "XX科技有限公司",
"department": "技术部",
"position": "工程师",
"email": "zhangsan@example.com",
"markName": "张工"
},
"messageList": [
{
"sender": 0,
"textType": 1,
"itemMessageList": [
{"feature": 2, "text": "你好"}
]
}
]
}
```
### 字段说明
| 字段 | 类型 | 说明 |
|------|------|------|
| type | int | 消息类型101=接收的消息列表 |
| roomType | int | 房间类型1=外部群, 2=外部联系人, 3=内部群, 4=内部联系人 |
| titleList | Array | 聊天对象名称(群名或好友名) |
| contact | Object | 联系人信息(仅单聊时有效) |
| messageList | Array | 消息列表 |
### messageList 每条消息
| 字段 | 类型 | 说明 |
|------|------|------|
| sender | int | 发送者0=其他人, 1=自己, 2=系统消息 |
| textType | int | 消息类型1=文本, 2=图片, 3=语音, 5=视频, 8=链接, 9=文件 |
| nameList | Array | 发送者名称列表(群聊时有效) |
| itemMessageList | Array | 消息内容列表 |
### contact 联系人信息
| 字段 | 类型 | 说明 |
|------|------|------|
| name | String | 好友昵称 |
| wechatId | String | 微信号 |
| phone | String | 手机号 |
| corpName | String | 企业名称 |
| department | String | 部门 |
| position | String | 职位 |
| email | String | 邮箱 |
| markName | String | 备注名 |
| gender | int | 性别1=男, 2=女, 0=未知 |

View File

@@ -246,6 +246,9 @@ public class WeworkMessageBean {
//添加好友 //添加好友
public Friend friend; public Friend friend;
//联系人信息(单聊时上传)
public Friend contact;
//网络文件 //网络文件
public String fileBase64; public String fileBase64;
public String fileUrl; public String fileUrl;
@@ -376,18 +379,32 @@ public class WeworkMessageBean {
public Boolean newFriend; public Boolean newFriend;
//留言 //留言
public String leavingMsg; public String leavingMsg;
//微信号
public String wechatId;
//企业名称
public String corpName;
//部门
public String department;
//职位
public String position;
//邮箱
public String email;
//性别: 1男 2女 0未知
public Integer gender;
//头像URL
public String avatarUrl;
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
Friend friend = (Friend) o; Friend friend = (Friend) o;
return Objects.equals(phone, friend.phone) && Objects.equals(name, friend.name) && Objects.equals(markName, friend.markName) && Objects.equals(markCorp, friend.markCorp) && Objects.equals(markExtra, friend.markExtra) && Objects.equals(tagList, friend.tagList) && Objects.equals(newFriend, friend.newFriend) && Objects.equals(leavingMsg, friend.leavingMsg); return Objects.equals(phone, friend.phone) && Objects.equals(name, friend.name) && Objects.equals(markName, friend.markName) && Objects.equals(markCorp, friend.markCorp) && Objects.equals(markExtra, friend.markExtra) && Objects.equals(tagList, friend.tagList) && Objects.equals(newFriend, friend.newFriend) && Objects.equals(leavingMsg, friend.leavingMsg) && Objects.equals(wechatId, friend.wechatId) && Objects.equals(corpName, friend.corpName) && Objects.equals(department, friend.department) && Objects.equals(position, friend.position) && Objects.equals(email, friend.email) && Objects.equals(gender, friend.gender) && Objects.equals(avatarUrl, friend.avatarUrl);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(phone, name, markName, markCorp, markExtra, tagList, newFriend, leavingMsg); return Objects.hash(phone, name, markName, markCorp, markExtra, tagList, newFriend, leavingMsg, wechatId, corpName, department, position, email, gender, avatarUrl);
} }
@Override @Override
@@ -401,6 +418,13 @@ public class WeworkMessageBean {
", tagList=" + tagList + ", tagList=" + tagList +
", newFriend=" + newFriend + ", newFriend=" + newFriend +
", leavingMsg='" + leavingMsg + '\'' + ", leavingMsg='" + leavingMsg + '\'' +
", wechatId='" + wechatId + '\'' +
", corpName='" + corpName + '\'' +
", department='" + department + '\'' +
", position='" + position + '\'' +
", email='" + email + '\'' +
", gender=" + gender +
", avatarUrl='" + avatarUrl + '\'' +
'}'; '}';
} }
} }

View File

@@ -280,8 +280,17 @@ object WeworkLoopImpl {
} }
messageList.removeIf { it.textType == WeworkMessageBean.TEXT_TYPE_IMAGE } messageList.removeIf { it.textType == WeworkMessageBean.TEXT_TYPE_IMAGE }
} }
WeworkController.weworkService.webSocketManager.send( // 获取单聊联系人详细信息
WeworkMessageBean( var contactInfo: WeworkMessageBean.Friend? = null
if (roomType == WeworkMessageBean.ROOM_TYPE_EXTERNAL_CONTACT
|| roomType == WeworkMessageBean.ROOM_TYPE_INTERNAL_CONTACT) {
val friendName = titleList.firstOrNull() ?: ""
if (friendName.isNotEmpty()) {
contactInfo = getChatContactInfo(friendName)
}
}
val messageBean = WeworkMessageBean(
null, null, null, null,
WeworkMessageBean.TYPE_RECEIVE_MESSAGE_LIST, WeworkMessageBean.TYPE_RECEIVE_MESSAGE_LIST,
roomType, roomType,
@@ -289,7 +298,8 @@ object WeworkLoopImpl {
messageList, messageList,
null null
) )
) messageBean.contact = contactInfo
WeworkController.weworkService.webSocketManager.send(messageBean)
//推测是否回复并在房间等待指令 //推测是否回复并在房间等待指令
if (needInfer) { if (needInfer) {
val lastMessage = messageList.lastOrNull() val lastMessage = messageList.lastOrNull()
@@ -415,7 +425,8 @@ object WeworkLoopImpl {
val filter = textViewList.filter { it.text != null && it.text.toString() != "微信" } val filter = textViewList.filter { it.text != null && it.text.toString() != "微信" }
if (filter.isNotEmpty()) { if (filter.isNotEmpty()) {
val tvNick = filter[0] val tvNick = filter[0]
LogUtils.d("好友请求: " + tvNick.text) val friendName = tvNick.text.toString()
LogUtils.d("好友请求: $friendName")
//设置标签 //设置标签
if (AccessibilityUtil.findTextAndClick(getRoot(), "标签")) { if (AccessibilityUtil.findTextAndClick(getRoot(), "标签")) {
WeworkOperationImpl.setFriendTags(arrayListOf("worktool自动通过")) WeworkOperationImpl.setFriendTags(arrayListOf("worktool自动通过"))
@@ -429,14 +440,13 @@ object WeworkLoopImpl {
if (textNode?.text?.toString() == "添加请求已过期,添加失败") { if (textNode?.text?.toString() == "添加请求已过期,添加失败") {
LogUtils.d("添加好友失败") LogUtils.d("添加好友失败")
} else { } else {
// 获取完整的好友信息
val friendInfo = getFriendDetailInfo(friendName)
val weworkMessageBean = WeworkMessageBean() val weworkMessageBean = WeworkMessageBean()
weworkMessageBean.type = WeworkMessageBean.GET_FRIEND_INFO weworkMessageBean.type = WeworkMessageBean.GET_FRIEND_INFO
weworkMessageBean.friend = WeworkMessageBean.Friend().apply { weworkMessageBean.friend = friendInfo
name = tvNick.text.toString()
newFriend = true
}
WeworkController.weworkService.webSocketManager.send(weworkMessageBean) WeworkController.weworkService.webSocketManager.send(weworkMessageBean)
nameList.add(tvNick.text.toString()) nameList.add(friendName)
} }
//回到上一页 //回到上一页
var retry = 5 var retry = 5
@@ -451,6 +461,107 @@ object WeworkLoopImpl {
return nameList return nameList
} }
/**
* 获取好友详细信息
* 通过好友后进入详情页抓取完整信息
*/
private fun getFriendDetailInfo(friendName: String): WeworkMessageBean.Friend {
val friend = WeworkMessageBean.Friend().apply {
name = friendName
newFriend = true
}
try {
// 点击发消息进入聊天页面
val sendMsgNode = AccessibilityUtil.findOneByText(getRoot(), "发消息", exact = true)
if (sendMsgNode != null) {
AccessibilityUtil.performClick(sendMsgNode)
sleep(Constant.CHANGE_PAGE_INTERVAL)
}
// 进入好友详情页
if (WeworkRoomUtil.intoFriendDetail()) {
sleep(Constant.CHANGE_PAGE_INTERVAL)
// 解析详情页信息
val listView = AccessibilityUtil.findOneByClazz(getRoot(), Views.ListView)
if (listView != null) {
// 遍历列表获取各字段信息
for (i in 0 until listView.childCount) {
val item = listView.getChild(i) ?: continue
val textViews = AccessibilityUtil.findAllOnceByClazz(item, Views.TextView)
if (textViews.size >= 2) {
val label = textViews[0].text?.toString() ?: ""
val value = textViews[1].text?.toString() ?: ""
when {
label.contains("微信号") || label.contains("微信ID") -> friend.wechatId = value
label.contains("手机") -> friend.phone = value
label.contains("企业") -> friend.corpName = value
label.contains("部门") -> friend.department = value
label.contains("职位") || label.contains("职务") -> friend.position = value
label.contains("邮箱") -> friend.email = value
label.contains("备注") -> friend.markName = value
}
LogUtils.d("好友详情 - $label: $value")
}
}
}
// 尝试获取头像(如果有)
val avatarView = AccessibilityUtil.findOneByClazz(getRoot(), Views.ImageView)
if (avatarView != null) {
// 头像通常没有直接URL这里留空或可通过其他方式获取
// friend.avatarUrl = ""
}
// 返回聊天页面
backPress()
sleep(Constant.POP_WINDOW_INTERVAL)
}
} catch (e: Exception) {
LogUtils.e("获取好友详情失败: ${e.message}")
}
LogUtils.d("好友信息: $friend")
return friend
}
/**
* 获取单聊联系人详细信息
*/
private fun getChatContactInfo(friendName: String): WeworkMessageBean.Friend? {
val friend = WeworkMessageBean.Friend().apply {
name = friendName
}
try {
// 进入好友详情页
if (WeworkRoomUtil.intoFriendDetail()) {
sleep(Constant.CHANGE_PAGE_INTERVAL)
// 解析详情页信息
val listView = AccessibilityUtil.findOneByClazz(getRoot(), Views.ListView)
if (listView != null) {
for (i in 0 until listView.childCount) {
val item = listView.getChild(i) ?: continue
val textViews = AccessibilityUtil.findAllOnceByClazz(item, Views.TextView)
if (textViews.size >= 2) {
val label = textViews[0].text?.toString() ?: ""
val value = textViews[1].text?.toString() ?: ""
when {
label.contains("微信号") || label.contains("微信ID") -> friend.wechatId = value
label.contains("手机") -> friend.phone = value
label.contains("企业") -> friend.corpName = value
label.contains("部门") -> friend.department = value
label.contains("职位") || label.contains("职务") -> friend.position = value
label.contains("邮箱") -> friend.email = value
label.contains("备注") -> friend.markName = value
}
}
}
}
backPress()
sleep(Constant.POP_WINDOW_INTERVAL)
}
} catch (e: Exception) {
LogUtils.e("获取联系人详情失败: ${e.message}")
}
return friend
}
/** /**
* 读取聊天列表 * 读取聊天列表
*/ */

View File

@@ -73,7 +73,7 @@
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_marginTop="4dp" android:layout_marginTop="4dp"
android:gravity="center" android:gravity="center"
android:text="Awin WorkTool 极致的自动化体验" android:text="AwinWorkTool 智能自动化体验"
android:textColor="#9affffff" android:textColor="#9affffff"
android:textSize="10sp" android:textSize="10sp"
tools:ignore="SmallSp" /> tools:ignore="SmallSp" />

View File

@@ -1,8 +1,47 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<!-- AI 风格青色主题 -->
<!-- Material 主题颜色 -->
<color name="colorPrimary">#00BCD4</color> <color name="colorPrimary">#00BCD4</color>
<color name="colorPrimaryDark">#0097A7</color> <color name="colorPrimaryDark">#0097A7</color>
<color name="colorAccent">#E0F7FA</color> <color name="colorAccent">#00BCD4</color>
<color name="textInputLayout">#00BCD4</color>
<color name="textInputLayout">#96ffffff</color> <!-- 主色调 -->
<color name="ai_primary">#00BCD4</color>
<color name="ai_primary_dark">#0097A7</color>
<color name="ai_primary_light">#26C6DA</color>
<color name="ai_accent">#00E5FF</color>
<!-- 背景色 -->
<color name="background">#FFFFFF</color>
<color name="background_light">#F5F9FA</color>
<color name="background_card">#FFFFFF</color>
<!-- 文字颜色 -->
<color name="color_333333">#212121</color>
<color name="color_666666">#424242</color>
<color name="color_999999">#757575</color>
<color name="white">#FFFFFF</color>
<color name="c8c8c8">#C8C8C8</color>
<!-- 原有颜色 - 保留兼容 -->
<color name="color_dashen">#00BCD4</color>
<color name="color_dashen_passed">#00838F</color>
<color name="float_time_color">#00BCD4</color>
<color name="list_divider_line">#E0E0E0</color>
<!-- 保留原有一些颜色 -->
<color name="color_rec_bg">#FAFAFA</color>
<color name="color_bottom">#F5F5F5</color>
<color name="color_line">#E0E0E0</color>
<color name="transparent">#00000000</color>
<color name="e6e6e6">#E6E6E6</color>
<color name="d9d9d9">#D9D9D9</color>
<color name="black">#000000</color>
<!-- 状态颜色 -->
<color name="status_success">#4CAF50</color>
<color name="status_warning">#FF9800</color>
<color name="status_error">#F44336</color>
</resources> </resources>