|
|
@@ -17,9 +17,12 @@ import android.view.accessibility.AccessibilityNodeInfo;
|
|
|
|
|
|
import com.wiipu.marketingrobot.AutoReplyService;
|
|
|
import com.wiipu.marketingrobot.contract.LoginContract;
|
|
|
+import com.wiipu.marketingrobot.contract.getCommonValueContract;
|
|
|
import com.wiipu.marketingrobot.contract.replyContract;
|
|
|
import com.wiipu.marketingrobot.presenter.LoginPresenter;
|
|
|
+import com.wiipu.marketingrobot.presenter.getCommonValuePresenter;
|
|
|
import com.wiipu.marketingrobot.presenter.replyPresenter;
|
|
|
+import com.wiipu.marketingrobot.response.CommonValueResponse;
|
|
|
import com.wiipu.marketingrobot.response.LoginResponse;
|
|
|
import com.wiipu.marketingrobot.response.replyResponse;
|
|
|
import com.wiipu.marketingrobot.response.uploadFriendResponse;
|
|
|
@@ -38,7 +41,7 @@ import static android.accessibilityservice.AccessibilityService.GLOBAL_ACTION_BA
|
|
|
* Description:聊天处理部分,负责消息回复
|
|
|
* Code: Axion
|
|
|
*/
|
|
|
-public class handleChatFunction implements replyContract.View , LoginContract.View {
|
|
|
+public class handleChatFunction implements replyContract.View , LoginContract.View , getCommonValueContract.View {
|
|
|
private AccessibilityService mService;
|
|
|
private List<String> chatRoomMemberName = new ArrayList<>();//群聊成员名称
|
|
|
private int chatRoomMemberIndex = 0;//聊天室人员列表下标
|
|
|
@@ -53,6 +56,7 @@ public class handleChatFunction implements replyContract.View , LoginContract.Vi
|
|
|
private List<AccessibilityNodeInfo> nodeList = new ArrayList<>();//对于小群人员,把所有的人员node放一起
|
|
|
private replyPresenter mReplyPresenter;
|
|
|
private LoginPresenter mLoginPresenter;
|
|
|
+ private getCommonValuePresenter mGetCommonValuePresenter;
|
|
|
private String groupName = null;
|
|
|
private String reply;
|
|
|
private String senderName;
|
|
|
@@ -68,6 +72,7 @@ public class handleChatFunction implements replyContract.View , LoginContract.Vi
|
|
|
private static final String chatListMem = "com.tencent.mm:id/nj";//聊天列表头像的id
|
|
|
private static final String chatNameInLeftUp = "com.tencent.mm:id/jw";//聊天界面左上角的微信名
|
|
|
private static final String nameUnderIconInChatRoom = "com.tencent.mm:id/dwz";//群聊人员头像下的名称
|
|
|
+ private static final String areaUnderGroupName = "com.tencent.mm:id/b4y"; // 群成员详情页群昵称下的地区
|
|
|
private static final String msgNoDisturb = "com.tencent.mm:id/j0";//消息免打扰开关
|
|
|
private static final String addToContract = "com.tencent.mm:id/cp";//添加到通讯录按钮
|
|
|
private static final String sendFriendRequestBtn = "com.tencent.mm:id/jq";//加好友验证页面右上角发送按钮
|
|
|
@@ -323,7 +328,7 @@ public class handleChatFunction implements replyContract.View , LoginContract.Vi
|
|
|
return;
|
|
|
}*/
|
|
|
|
|
|
- if (!isGroupChatFriend()) {
|
|
|
+ if (!isGroupChatFriend() && isAllowedAreaFriend()) {
|
|
|
addGroupFriend();
|
|
|
Log.e(TAG, "secondChoice: iissssssfriend");
|
|
|
//mService.performGlobalAction(GLOBAL_ACTION_BACK);
|
|
|
@@ -440,6 +445,7 @@ public class handleChatFunction implements replyContract.View , LoginContract.Vi
|
|
|
//群聊的标题栏会带有群聊人员的数目,用)判断
|
|
|
if (judgeGroupChatName(title)) {
|
|
|
groupName = title.substring(0, title.indexOf("("));
|
|
|
+ mGetCommonValuePresenter.getAllowedArea();
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
@@ -754,6 +760,28 @@ public class handleChatFunction implements replyContract.View , LoginContract.Vi
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 判断是否是符合指定地区的群成员
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private boolean isAllowedAreaFriend() {
|
|
|
+ SystemClock.sleep(500);
|
|
|
+ AccessibilityNodeInfo root = mService.getRootInActiveWindow();
|
|
|
+ AccessibilityNodeInfo target = null;
|
|
|
+ if (root == null) {
|
|
|
+ LogUtils.d(TAG + " 无法获取根View ");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ target = AccessibilityHelper.findNodeInfosById(root, areaUnderGroupName); // 获取地区id
|
|
|
+ if (target != null && target.getText() != null && target.getText().equals(AutoReplyService.allowedArea)) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ // 找不到地区id或不符合要求
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 添加群聊成员好友
|
|
|
*/
|
|
|
|
|
|
@@ -874,6 +902,7 @@ public class handleChatFunction implements replyContract.View , LoginContract.Vi
|
|
|
mService = service;
|
|
|
mReplyPresenter = new replyPresenter(this);
|
|
|
mLoginPresenter = new LoginPresenter(this);
|
|
|
+ mGetCommonValuePresenter = new getCommonValuePresenter(this);
|
|
|
pref = mService.getSharedPreferences("robotData", Context.MODE_PRIVATE);
|
|
|
}
|
|
|
|
|
|
@@ -894,4 +923,13 @@ public class handleChatFunction implements replyContract.View , LoginContract.Vi
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
+ public void showCommonValue(CommonValueResponse commonValueResponse, String key) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void showAllowedArea(CommonValueResponse commonValueResponse) {
|
|
|
+ AutoReplyService.allowedArea = commonValueResponse.getMsg();
|
|
|
+ }
|
|
|
}
|