|
|
@@ -28,6 +28,7 @@ import com.wiipu.marketingrobot.widget.AccessibilityHelper;
|
|
|
import com.wiipu.netlib.rxbus.RxBus;
|
|
|
import com.wiipu.netlib.utils.LogUtils;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
import static android.accessibilityservice.AccessibilityService.GLOBAL_ACTION_BACK;
|
|
|
@@ -45,16 +46,36 @@ public class addFriendFunction implements replyContract.View , getCommonValueCon
|
|
|
private replyPresenter mReplyPresenter;
|
|
|
private getCommonValuePresenter mGetCommonValuePresenter;
|
|
|
private LoginPresenter mLoginPresenter;
|
|
|
- private String reply;
|
|
|
+
|
|
|
+ private String mCurrentSenderName = ""; // 当前已发送接受好友申请的用户
|
|
|
+ private List<String> mCurrentSenderNameList = new ArrayList<>(); // 当前已发送接受好友申请用户集合
|
|
|
private boolean needGetSelfInfo;
|
|
|
- private static final String threePointInLanucher="com.tencent.mm:id/jr";//聊天界面右上角三个点
|
|
|
- private static final String chatFriendInfoName="com.tencent.mm:id/b2x";//点开详细信息的聊天对象微信名
|
|
|
- private static final String chatNameInLeftUp="com.tencent.mm:id/jw";//聊天界面左上角的微信名
|
|
|
- private static final String chatRoomNewCi7List="com.tencent.mm:id/d4l";//新的ci7list
|
|
|
+
|
|
|
+ public String getmCurrentSenderName() {
|
|
|
+ return mCurrentSenderName;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setmCurrentSenderName(String mCurrentSenderName) {
|
|
|
+ this.mCurrentSenderName = mCurrentSenderName;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 微信版本 1380
|
|
|
+// private static final String threePointInLauncher ="com.tencent.mm:id/jr";//聊天界面右上角三个点
|
|
|
+// private static final String chatFriendInfoName="com.tencent.mm:id/b2x";//点开详细信息的聊天对象微信名
|
|
|
+// private static final String chatNameInLeftUp="com.tencent.mm:id/jw";//聊天界面左上角的微信名
|
|
|
+// private static final String chatRoomNewCi7List="com.tencent.mm:id/d4l";//新的ci7list
|
|
|
private static final String chatListMem="com.tencent.mm:id/nj";//聊天列表头像的id
|
|
|
- private static final String savedRobotName="robotName";
|
|
|
- private static final String savedRobotNum="robotNum";
|
|
|
- private static final String savedRobotId="robotId";
|
|
|
+
|
|
|
+ // 微信版本 1400
|
|
|
+ private static final String threePointInLauncher = "com.tencent.mm:id/jy";
|
|
|
+ private static final String chatMyMem = "com.tencent.mm:id/ns";// 聊天列表头像的id
|
|
|
+ private static final String chatRoomNewCi7List = "com.tencent.mm:id/d84";//新的ci7list
|
|
|
+ private static final String chatNameInLeftUp = "com.tencent.mm:id/k3";//聊天界面左上角的微信名
|
|
|
+
|
|
|
+
|
|
|
+ private static final String savedRobotName = "robotName";
|
|
|
+ private static final String savedRobotNum = "robotNum";
|
|
|
+ private static final String savedRobotId = "robotId";
|
|
|
private SharedPreferences pref;
|
|
|
public addFriendFunction(AccessibilityService service) {
|
|
|
mService = service;
|
|
|
@@ -121,11 +142,36 @@ public class addFriendFunction implements replyContract.View , getCommonValueCon
|
|
|
if (event.getClassName().equals("com.tencent.mm.plugin.subapp.ui.friend.FMessageConversationUI")) {
|
|
|
AccessibilityNodeInfo nodeInfo = mService.getRootInActiveWindow();
|
|
|
if (nodeInfo != null) {
|
|
|
- List<AccessibilityNodeInfo> list = nodeInfo.findAccessibilityNodeInfosByText("接受");
|
|
|
- if (list != null && list.size() > 0) {
|
|
|
- for (AccessibilityNodeInfo n : list) {
|
|
|
- //n.performAction(AccessibilityNodeInfo.ACTION_CLICK);
|
|
|
- AccessibilityHelper.performClick(n);
|
|
|
+ if (null != mCurrentSenderName) {
|
|
|
+ if (!mCurrentSenderName.isEmpty()) {
|
|
|
+ mCurrentSenderNameList.add(mCurrentSenderName);
|
|
|
+ }
|
|
|
+ List<AccessibilityNodeInfo> list = nodeInfo.findAccessibilityNodeInfosByText("接受");
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
+ for (AccessibilityNodeInfo acceptBtn : list) {
|
|
|
+ // 找到申请好友的用户微信昵称
|
|
|
+ AccessibilityNodeInfo userName = AccessibilityHelper.findNodeInfosById(nodeInfo,"com.tencent.mm:id/btl");
|
|
|
+ if (null != userName) {
|
|
|
+ boolean isSend = false;
|
|
|
+ for (String uName : mCurrentSenderNameList){
|
|
|
+ if (uName.equals(userName.getText().toString())){
|
|
|
+ isSend = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!isSend) {
|
|
|
+
|
|
|
+ LogUtils.d("点击 接受 添加好友");
|
|
|
+
|
|
|
+ AccessibilityHelper.performClick(acceptBtn);
|
|
|
+ }else {
|
|
|
+
|
|
|
+ LogUtils.e("已经处理过该微信用户 : "
|
|
|
+ + userName.getText().toString() + " 的好友申请了");
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
mService.performGlobalAction(GLOBAL_ACTION_BACK);
|
|
|
@@ -133,9 +179,8 @@ public class addFriendFunction implements replyContract.View , getCommonValueCon
|
|
|
}
|
|
|
|
|
|
if (event.getClassName().equals("com.tencent.mm.ui.LauncherUI")) {
|
|
|
- //这个页面不会调用,很奇妙。
|
|
|
- //event.setClassName("com.tencent.mm.plugin.subapp.ui.friend.FMessageConversationUI");
|
|
|
- // addFriend(event);
|
|
|
+ event.setClassName("com.tencent.mm.plugin.subapp.ui.friend.FMessageConversationUI");
|
|
|
+ addFriend(event);
|
|
|
}
|
|
|
|
|
|
if (event.getClassName().equals("com.tencent.mm.plugin.profile.ui.SayHiWithSnsPermissionUI")) {
|
|
|
@@ -144,7 +189,7 @@ public class addFriendFunction implements replyContract.View , getCommonValueCon
|
|
|
List<AccessibilityNodeInfo> list = nodeInfo.findAccessibilityNodeInfosByText("完成");
|
|
|
if (list != null && list.size() > 0) {
|
|
|
for (AccessibilityNodeInfo n : list) {
|
|
|
- //n.performAction(AccessibilityNodeInfo.ACTION_CLICK);
|
|
|
+ LogUtils.d("点击 完成 验证按钮 ");
|
|
|
AccessibilityHelper.performClick(n);
|
|
|
}
|
|
|
}
|
|
|
@@ -182,47 +227,47 @@ public class addFriendFunction implements replyContract.View , getCommonValueCon
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if(mmId==null){
|
|
|
- LogUtils.e(TAG + " addFriend: mm id is null" );
|
|
|
+ if(mmId == null){
|
|
|
+ LogUtils.e(TAG + " 接受好友申请: 用户微信号为空" );
|
|
|
return;
|
|
|
}
|
|
|
String id = mmId.getText().toString();
|
|
|
id = id.substring(id.indexOf(":")+2, id.length()).trim();
|
|
|
- LogUtils.d(TAG + " addFriend: the mmid is " + id);
|
|
|
+ LogUtils.d(TAG + " 接受好友申请: 用户微信号为 " + id);
|
|
|
mmNum = id;
|
|
|
hasGetmmId = true;
|
|
|
|
|
|
// AccessibilityNodeInfo sendMsg = AccessibilityHelper.findNodeInfosByText(root,"发消息");
|
|
|
- // TODO 发消息 TextView 的resId 微信版本 1400
|
|
|
+ // 发消息 TextView 的resId 微信版本 1400
|
|
|
AccessibilityNodeInfo sendMsg = AccessibilityHelper.findNodeInfosById(root,"com.tencent.mm:id/cs");
|
|
|
if (sendMsg != null) {
|
|
|
- AccessibilityHelper.performClick(sendMsg);
|
|
|
+ AccessibilityHelper.performClick(sendMsg.getParent().getParent());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (event.getClassName().equals("com.tencent.mm.ui.chatting.ChattingUI")) {//聊天页面
|
|
|
- LogUtils.d(TAG + " addFriend: in the chatt ui");
|
|
|
+ LogUtils.d(TAG + " 接受好友申请: 当前为聊天页面 ");
|
|
|
AccessibilityNodeInfo root = mService.getRootInActiveWindow();
|
|
|
- AccessibilityNodeInfo more = AccessibilityHelper.findNodeInfosById(root, threePointInLanucher);//右上角三个点
|
|
|
+ AccessibilityNodeInfo more = AccessibilityHelper.findNodeInfosById(root, threePointInLauncher);//右上角三个点
|
|
|
AccessibilityNodeInfo name = AccessibilityHelper.findNodeInfosById(root, chatNameInLeftUp);//名称
|
|
|
if (more == null || name == null) {
|
|
|
LogUtils.e(TAG + " addFriend: more or name is null");
|
|
|
return;
|
|
|
}
|
|
|
mmName = name.getText().toString();
|
|
|
- LogUtils.e(TAG + " addFriend: 1");
|
|
|
+ LogUtils.e(TAG + " 接受好友申请: 1");
|
|
|
if (!hasGetmmId) {
|
|
|
//增加一个延迟,防止点击不到右上角的三个点。
|
|
|
SystemClock.sleep(1000);
|
|
|
AccessibilityHelper.performClick(more);
|
|
|
return;
|
|
|
}
|
|
|
- LogUtils.e(TAG + " addFriend: 2" );
|
|
|
+ LogUtils.e(TAG + " 接受好友申请: 2" );
|
|
|
if (pref.getString(savedRobotName, null) == null || pref.getString(savedRobotNum, null) == null) {
|
|
|
getTheRobotInfo(event);
|
|
|
return;
|
|
|
}
|
|
|
- LogUtils.e(TAG + " addFriend: 3");
|
|
|
+ LogUtils.e(TAG + " 接受好友申请: 3");
|
|
|
mReplyPresenter.upLoadFriends(mmName, mmNum, pref.getString(savedRobotName, null), pref.getString(savedRobotId, null));
|
|
|
mGetCommonValuePresenter.getValueByKey(pref.getString(savedRobotId, null),Constants.KEY_MAX_FRIEND_NUM);
|
|
|
|
|
|
@@ -314,7 +359,7 @@ public class addFriendFunction implements replyContract.View , getCommonValueCon
|
|
|
if (text != null) {
|
|
|
return findEditText(rootNode, text);
|
|
|
} else {
|
|
|
- return findEditText(rootNode, reply);
|
|
|
+ return findEditText(rootNode, "你好");
|
|
|
}
|
|
|
}
|
|
|
return false;
|