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

@@ -246,6 +246,9 @@ public class WeworkMessageBean {
//添加好友
public Friend friend;
//联系人信息(单聊时上传)
public Friend contact;
//网络文件
public String fileBase64;
public String fileUrl;
@@ -376,18 +379,32 @@ public class WeworkMessageBean {
public Boolean newFriend;
//留言
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
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
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
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
@@ -401,6 +418,13 @@ public class WeworkMessageBean {
", tagList=" + tagList +
", newFriend=" + newFriend +
", leavingMsg='" + leavingMsg + '\'' +
", wechatId='" + wechatId + '\'' +
", corpName='" + corpName + '\'' +
", department='" + department + '\'' +
", position='" + position + '\'' +
", email='" + email + '\'' +
", gender=" + gender +
", avatarUrl='" + avatarUrl + '\'' +
'}';
}
}

View File

@@ -280,16 +280,26 @@ object WeworkLoopImpl {
}
messageList.removeIf { it.textType == WeworkMessageBean.TEXT_TYPE_IMAGE }
}
WeworkController.weworkService.webSocketManager.send(
WeworkMessageBean(
null, null,
WeworkMessageBean.TYPE_RECEIVE_MESSAGE_LIST,
roomType,
titleList,
messageList,
null
)
// 获取单聊联系人详细信息
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,
WeworkMessageBean.TYPE_RECEIVE_MESSAGE_LIST,
roomType,
titleList,
messageList,
null
)
messageBean.contact = contactInfo
WeworkController.weworkService.webSocketManager.send(messageBean)
//推测是否回复并在房间等待指令
if (needInfer) {
val lastMessage = messageList.lastOrNull()
@@ -415,7 +425,8 @@ object WeworkLoopImpl {
val filter = textViewList.filter { it.text != null && it.text.toString() != "微信" }
if (filter.isNotEmpty()) {
val tvNick = filter[0]
LogUtils.d("好友请求: " + tvNick.text)
val friendName = tvNick.text.toString()
LogUtils.d("好友请求: $friendName")
//设置标签
if (AccessibilityUtil.findTextAndClick(getRoot(), "标签")) {
WeworkOperationImpl.setFriendTags(arrayListOf("worktool自动通过"))
@@ -429,14 +440,13 @@ object WeworkLoopImpl {
if (textNode?.text?.toString() == "添加请求已过期,添加失败") {
LogUtils.d("添加好友失败")
} else {
// 获取完整的好友信息
val friendInfo = getFriendDetailInfo(friendName)
val weworkMessageBean = WeworkMessageBean()
weworkMessageBean.type = WeworkMessageBean.GET_FRIEND_INFO
weworkMessageBean.friend = WeworkMessageBean.Friend().apply {
name = tvNick.text.toString()
newFriend = true
}
weworkMessageBean.friend = friendInfo
WeworkController.weworkService.webSocketManager.send(weworkMessageBean)
nameList.add(tvNick.text.toString())
nameList.add(friendName)
}
//回到上一页
var retry = 5
@@ -451,6 +461,107 @@ object WeworkLoopImpl {
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

@@ -23,7 +23,7 @@
android:layout_marginTop="18dp"
android:layout_marginStart="18dp"
android:layout_marginEnd="18dp"
android:text="请开启无障碍服务以使用Awin WorkTool主功能"
android:text="请开启无障碍服务以使用AwinWorkTool主功能"
android:textColor="@color/color_333333"
android:textSize="14sp" />
@@ -150,7 +150,7 @@
android:layout_gravity="center_vertical"
android:textSize="17sp"
android:textColor="@color/qmui_config_color_black"
android:text="使用Awin WorkTool"
android:text="使用AwinWorkTool"
/>
<ImageView

View File

@@ -91,7 +91,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/setting_vertical_padding"
android:text="2.开启主功能在无障碍栏目里找到Awin WorkTool并开启"
android:text="2.开启主功能在无障碍栏目里找到AwinWorkTool并开启"
android:textColor="@color/color_333333"
android:textSize="@dimen/setting_start_font_size" />

View File

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

View File

@@ -1,8 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- AI 风格青色主题 -->
<!-- Material 主题颜色 -->
<color name="colorPrimary">#00BCD4</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>

View File

@@ -1,7 +1,7 @@
<resources>
<string name="app_name">Awin WorkTool</string>
<string name="app_name">AwinWorkTool</string>
<string name="accessibility_desc">Awin WorkTool</string>
<string name="accessibility_desc">AwinWorkTool</string>
<string name="tips">如果需要使用或停止该应用,应用需打开 无障碍服务 进行权限设置</string>
<!-- 升级对话框 -->