Explorar el Código

接入三个接口,并根据最新接口调整代码逻辑;

owen hace 6 años
padre
commit
e50830dc52
Se han modificado 19 ficheros con 620 adiciones y 168 borrados
  1. 18 17
      app/src/main/java/com/wiipu/marketingrobot/AutoReplyService.java
  2. 11 0
      app/src/main/java/com/wiipu/marketingrobot/Constants.java
  3. 137 4
      app/src/main/java/com/wiipu/marketingrobot/MainActivity.java
  4. 26 0
      app/src/main/java/com/wiipu/marketingrobot/contract/LoginContract.java
  5. 0 20
      app/src/main/java/com/wiipu/marketingrobot/contract/enableAddFriendContract.java
  6. 25 0
      app/src/main/java/com/wiipu/marketingrobot/contract/getCommonValueContract.java
  7. 3 1
      app/src/main/java/com/wiipu/marketingrobot/contract/replyContract.java
  8. 46 26
      app/src/main/java/com/wiipu/marketingrobot/function/addAutoReplyFunction.java
  9. 51 27
      app/src/main/java/com/wiipu/marketingrobot/function/addFriendFunction.java
  10. 9 5
      app/src/main/java/com/wiipu/marketingrobot/function/addGroupFunction.java
  11. 41 9
      app/src/main/java/com/wiipu/marketingrobot/function/handleChatFunction.java
  12. 48 0
      app/src/main/java/com/wiipu/marketingrobot/presenter/LoginPresenter.java
  13. 0 48
      app/src/main/java/com/wiipu/marketingrobot/presenter/enableAddFriendPresenter.java
  14. 48 0
      app/src/main/java/com/wiipu/marketingrobot/presenter/getCommonValuePresenter.java
  15. 9 5
      app/src/main/java/com/wiipu/marketingrobot/presenter/replyPresenter.java
  16. 28 0
      app/src/main/java/com/wiipu/marketingrobot/response/CommonValueResponse.java
  17. 85 0
      app/src/main/java/com/wiipu/marketingrobot/response/LoginResponse.java
  18. 33 5
      app/src/main/java/com/wiipu/marketingrobot/service/replyService.java
  19. 2 1
      app/src/main/res/layout/activity_main.xml

+ 18 - 17
app/src/main/java/com/wiipu/marketingrobot/AutoReplyService.java

@@ -22,14 +22,15 @@ import android.view.accessibility.AccessibilityEvent;
 import android.view.accessibility.AccessibilityManager;
 import android.view.accessibility.AccessibilityNodeInfo;
 
-import com.wiipu.marketingrobot.contract.enableAddFriendContract;
+import com.wiipu.marketingrobot.contract.getCommonValueContract;
 import com.wiipu.marketingrobot.function.addAutoReplyFunction;
 import com.wiipu.marketingrobot.function.addFriendFunction;
 import com.wiipu.marketingrobot.function.addGroupFunction;
 import com.wiipu.marketingrobot.function.eventClassFunction;
 import com.wiipu.marketingrobot.function.getMoneyFunction;
 import com.wiipu.marketingrobot.function.handleChatFunction;
-import com.wiipu.marketingrobot.presenter.enableAddFriendPresenter;
+import com.wiipu.marketingrobot.presenter.getCommonValuePresenter;
+import com.wiipu.marketingrobot.response.CommonValueResponse;
 import com.wiipu.marketingrobot.response.enableAddFriendResponse;
 import com.wiipu.marketingrobot.widget.AccessibilityHelper;
 import com.wiipu.netlib.rxbus.RxBus;
@@ -48,7 +49,7 @@ import rx.subscriptions.CompositeSubscription;
  * Description: 智能投股机器人主服务
  */
 
-public class AutoReplyService extends AccessibilityService implements enableAddFriendContract.View {
+public class AutoReplyService extends AccessibilityService implements getCommonValueContract.View {
     private final static String MM_PNAME = "com.tencent.mm";
     private static final String TAG = "maptrix";
     public static boolean hasAction = false;
@@ -65,11 +66,12 @@ public class AutoReplyService extends AccessibilityService implements enableAddF
     public static AutoReplyService mAutoReplyService;
     private addAutoReplyFunction mAddAutoReplyFunction;
     private CompositeSubscription mSubscription = new CompositeSubscription();
-    private enableAddFriendPresenter mEnableAddFriendPresenter;
+    private getCommonValuePresenter mGetCommonValuePresenter;
     public volatile static int enableFriendsCounts = 1;//为了防止程序初次运行时候出现bug,先置1
     private SharedPreferences pref;
     private boolean breakOutLoop = false;
     private static final String savedRobotNum = "robotNum";
+    private static final String savedRobotId = "robotId";
     private boolean inMineView = false; //标志页面在主页面“我的”模块
     private boolean msgView = false;//标志收到消息
     private AccessibilityEvent changeStateEvent = AccessibilityEvent.obtain();
@@ -95,9 +97,11 @@ public class AutoReplyService extends AccessibilityService implements enableAddF
     public static windowAction mWindowAction;
 
     @Override
-    public void showEnableAddFriendReply(enableAddFriendResponse enableAddFriendResponse) {
-        enableFriendsCounts = enableAddFriendResponse.getMsg();
-        LogUtils.e(TAG + " showEnableAddFriendReply: 允许人数为 " + enableFriendsCounts);
+    public void showCommonValue(CommonValueResponse commonValueResponse, String key) {
+        if (key.equals(Constants.KEY_MAX_FRIEND_NUM)) {
+            enableFriendsCounts = Integer.parseInt(commonValueResponse.getMsg());
+            LogUtils.e(TAG + " 当前可添加最大好友数为 : " + enableFriendsCounts);
+        }
     }
 
     @Override
@@ -109,9 +113,6 @@ public class AutoReplyService extends AccessibilityService implements enableAddF
     public void showError(String message) {
     }
 
-    @Override
-    public void showEnableError(String msg) {
-    }
 
     @Override
     protected void onServiceConnected() {
@@ -122,11 +123,11 @@ public class AutoReplyService extends AccessibilityService implements enableAddF
         mAddFriendFunction = new addFriendFunction(this);
         mAddGroupFunction = new addGroupFunction(this);
         mAddAutoReplyFunction = new addAutoReplyFunction(this);
-        mEnableAddFriendPresenter = new enableAddFriendPresenter(this);
+        mGetCommonValuePresenter = new getCommonValuePresenter(this);
         pref = getSharedPreferences("robotData", Context.MODE_PRIVATE);
         mAutoReplyService = this;
-        if (pref.getString(savedRobotNum, null) != null) {
-            mEnableAddFriendPresenter.getEnableAddFriend(pref.getString(savedRobotNum, null));
+        if (pref.getString(savedRobotId, null) != null) {
+            mGetCommonValuePresenter.getValueByKey(pref.getString(savedRobotId, null), Constants.KEY_MAX_FRIEND_NUM);
         }
         Subscription subscription = RxBus.toObservable(eventClassFunction.class)
                 .subscribe(new Action1<eventClassFunction>() {
@@ -161,8 +162,8 @@ public class AutoReplyService extends AccessibilityService implements enableAddF
         switch (eventType) {
             case AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED:// 通知栏事件,仅有在锁屏状态下, 或者亮屏后台状态下才会发送通知
                 LogUtils.d("maptrix : get notification event");
-                if (pref.getString(savedRobotNum, null) != null) {
-                    mEnableAddFriendPresenter.getEnableAddFriend(pref.getString(savedRobotNum, null));
+                if (pref.getString(savedRobotId, null) != null) {
+                    mGetCommonValuePresenter.getValueByKey(pref.getString(savedRobotId, null), Constants.KEY_MAX_FRIEND_NUM);
                 }
                 List<CharSequence> texts = event.getText();
                 if (!texts.isEmpty()) {
@@ -634,7 +635,7 @@ public class AutoReplyService extends AccessibilityService implements enableAddF
         //获取电源管理器对象
         PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
         //获取PowerManager.WakeLock对象,后面的参数|表示同时传入两个值,最后的是调试用的Tag
-        PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "bright");
+        PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "MarketingRobot");
 
         //点亮屏幕
         wl.acquire();
@@ -656,7 +657,7 @@ public class AutoReplyService extends AccessibilityService implements enableAddF
         PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
 
         //获取PowerManager.WakeLock对象,后面的参数|表示同时传入两个值,最后的是调试用的Tag
-        PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "bright");
+        PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "MarketingRobot");
 
         //点亮屏幕
         wl.acquire();

+ 11 - 0
app/src/main/java/com/wiipu/marketingrobot/Constants.java

@@ -1,5 +1,16 @@
 package com.wiipu.marketingrobot;
 
 public class Constants {
+
     public static final String TAG_PREFIX = "AUTO_ROBOT";
+
+    /**
+     *  * key = max_friend_num,返回能添加最大好友数
+     *  * key = add_friend_content,返回添加好友时候的备注
+     *  * key = first_answer,返回添加好友成功后给予的回复内容
+     */
+    public static final String KEY_MAX_FRIEND_NUM = "max_friend_num";
+    public static final String KEY_ADD_FRIEND_CONTENT = "add_friend_content";
+    public static final String KEY_FIRST_ANSWER = "first_answer";
+
 }

+ 137 - 4
app/src/main/java/com/wiipu/marketingrobot/MainActivity.java

@@ -1,13 +1,146 @@
 package com.wiipu.marketingrobot;
 
+import android.app.ActivityManager;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.provider.Settings;
 import android.support.v7.app.AppCompatActivity;
 import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+import android.widget.Toast;
 
-public class MainActivity extends AppCompatActivity {
+import com.wiipu.netlib.base.BaseMvpActivity;
+
+import java.util.List;
+
+public class MainActivity extends BaseMvpActivity implements View.OnClickListener {
+
+    private TextView textView;
+    private Button button;
+    private PackageInfo mWechatPackageInfo = null;
+    private final static String MM_PNAME = "com.tencent.mm";
+
+    @Override
+    protected void attach() {
+        // App.getRefWatcher(this).watch(getApplicationContext());
+
+    }
+
+    @Override
+    protected void detach() {
+
+    }
+
+
+
+    @Override
+    protected int getLayoutId() {
+        return R.layout.activity_main;
+    }
+
+    @Override
+    protected void initViews() {
+        textView = findViewById(R.id.textViewService);
+        button = findViewById(R.id.buttonStartService);
+    }
+
+    @Override
+    protected void initListeners() {
+        button.setOnClickListener(this);
+    }
 
     @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.activity_main);
+    protected void initData() {
+        updatePackageInfo();
+    }
+
+    @Override
+    public void onClick(View view) {
+
+        switch (view.getId()) {
+            case R.id.buttonStartService:
+                openAccessibilityServiceSettings();
+                //bring2Front();
+                break;
+            default:
+                break;
+
+        }
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        if (getWechatVersion() != 1380) {
+            textView.setText("请使用微信7.0版本");
+            button.setVisibility(View.GONE);
+        }else {
+            if (!AutoReplyService.isRunning()) {
+                textView.setText("服务未运行");
+                button.setVisibility(View.VISIBLE);
+
+            } else {
+                textView.setText("服务正在运行");
+                button.setVisibility(View.GONE);
+            }
+
+        }
+
+
+
+    }
+    private void bring2Front() {
+
+        ActivityManager activtyManager = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
+        List<ActivityManager.RunningTaskInfo> runningTaskInfos = activtyManager.getRunningTasks(10);
+        Log.d(TAG, "bring2Front: "+runningTaskInfos.size());
+        for (ActivityManager.RunningTaskInfo runningTaskInfo : runningTaskInfos) {
+            Log.d(TAG, "bring2Front: " + runningTaskInfo.baseActivity.getPackageName() + runningTaskInfo.topActivity.getPackageName());
+            if ("com.tencent.mm".equals(runningTaskInfo.topActivity.getPackageName())) {
+                activtyManager.moveTaskToFront(runningTaskInfo.id, ActivityManager.MOVE_TASK_WITH_HOME);
+                return;
+            }
+        }
+
+        // PackageManager manager = mService.getPackageManager();
+        //  Intent intent = manager.getLaunchIntentForPackage("com.tencent.mm");
+        // intent.addCategory(Intent.CATEGORY_LAUNCHER);
+        // intent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
+        //  intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        // intent.setAction("android.intent.action.MAIN");
+        //  intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
+        // mService.startActivity(intent);
+    }
+
+    /** 打开辅助服务的设置*/
+    private void openAccessibilityServiceSettings() {
+        try {
+            Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
+            startActivity(intent);
+            Toast.makeText(this, "开启AutoWX服务", Toast.LENGTH_LONG).show();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /** 获取微信的版本*/
+    private  int getWechatVersion() {
+        if(mWechatPackageInfo == null) {
+            return 0;
+        }
+        return mWechatPackageInfo.versionCode;
+    }
+    /** 更新微信包信息*/
+    private void updatePackageInfo() {
+        try {
+            mWechatPackageInfo = getPackageManager().getPackageInfo(MM_PNAME, 0);
+        } catch (PackageManager.NameNotFoundException e) {
+            e.printStackTrace();
+        }
     }
 }

+ 26 - 0
app/src/main/java/com/wiipu/marketingrobot/contract/LoginContract.java

@@ -0,0 +1,26 @@
+package com.wiipu.marketingrobot.contract;
+
+
+import com.wiipu.marketingrobot.response.LoginResponse;
+import com.wiipu.marketingrobot.response.replyResponse;
+import com.wiipu.marketingrobot.response.uploadFriendResponse;
+import com.wiipu.netlib.base.BaseView;
+
+/**
+ * Description:
+ */
+public interface LoginContract {
+    interface View extends BaseView {
+
+        void showResult(LoginResponse loginResponse);
+
+    }
+
+    interface Presenter {
+
+        void login(String robotWechatNum);
+
+
+    }
+
+}

+ 0 - 20
app/src/main/java/com/wiipu/marketingrobot/contract/enableAddFriendContract.java

@@ -1,20 +0,0 @@
-package com.wiipu.marketingrobot.contract;
-
-
-import com.wiipu.marketingrobot.response.enableAddFriendResponse;
-import com.wiipu.netlib.base.BaseView;
-
-/**
- * Description:
- */
-public interface enableAddFriendContract {
-    interface View extends BaseView {
-        void showEnableAddFriendReply(enableAddFriendResponse enableAddFriendResponse);
-
-        void showEnableError(String msg);
-    }
-
-    interface Presenter{
-        void getEnableAddFriend(String robotNum);
-    }
-}

+ 25 - 0
app/src/main/java/com/wiipu/marketingrobot/contract/getCommonValueContract.java

@@ -0,0 +1,25 @@
+package com.wiipu.marketingrobot.contract;
+
+
+import com.wiipu.marketingrobot.response.CommonValueResponse;
+import com.wiipu.marketingrobot.response.enableAddFriendResponse;
+import com.wiipu.netlib.base.BaseView;
+
+/**
+ * Description: 获取通用数值
+ * key = max_friend_num,返回能添加最大好友数
+ * key = add_friend_content,返回添加好友时候的备注
+ * key = first_answer,返回添加好友成功后给予的回复内容
+ */
+public interface getCommonValueContract {
+    interface View extends BaseView {
+
+        void showCommonValue(CommonValueResponse commonValueResponse, String key);
+
+    }
+
+    interface Presenter{
+
+        void getValueByKey(String robotNum , String key);
+    }
+}

+ 3 - 1
app/src/main/java/com/wiipu/marketingrobot/contract/replyContract.java

@@ -10,6 +10,7 @@ import com.wiipu.netlib.base.BaseView;
  */
 public interface replyContract {
     interface View extends BaseView {
+
         void showReply(replyResponse replyResponse);
 
         void showUploadFriendReply(uploadFriendResponse uploadFriendResponse);
@@ -17,9 +18,10 @@ public interface replyContract {
     }
 
     interface Presenter {
+
         void loadReply(String content, String mmNum, String robotNum);
 
-        void upLoadFriends(String mmName, String mmNum, String robotName, String robotNum);
+        void upLoadFriends(String mmName, String mmNum, String robotName, String robotId);
 
 
     }

+ 46 - 26
app/src/main/java/com/wiipu/marketingrobot/function/addAutoReplyFunction.java

@@ -15,10 +15,12 @@ import android.view.accessibility.AccessibilityNodeInfo;
 
 
 import com.wiipu.marketingrobot.AutoReplyService;
-import com.wiipu.marketingrobot.contract.enableAddFriendContract;
+import com.wiipu.marketingrobot.Constants;
+import com.wiipu.marketingrobot.contract.getCommonValueContract;
 import com.wiipu.marketingrobot.contract.replyContract;
-import com.wiipu.marketingrobot.presenter.enableAddFriendPresenter;
+import com.wiipu.marketingrobot.presenter.getCommonValuePresenter;
 import com.wiipu.marketingrobot.presenter.replyPresenter;
+import com.wiipu.marketingrobot.response.CommonValueResponse;
 import com.wiipu.marketingrobot.response.enableAddFriendResponse;
 import com.wiipu.marketingrobot.response.replyResponse;
 import com.wiipu.marketingrobot.response.uploadFriendResponse;
@@ -34,27 +36,29 @@ import static android.accessibilityservice.AccessibilityService.GLOBAL_ACTION_BA
  * Description:主动加好友对方确认调用
  * Code: Axion
  */
-public class addAutoReplyFunction implements replyContract.View , enableAddFriendContract.View{
+public class addAutoReplyFunction implements replyContract.View , getCommonValueContract.View{
     private AccessibilityService mService;
     private static final String TAG = addAutoReplyFunction.class.getSimpleName();
     private boolean hasGetmmId = false;
     private replyPresenter mReplyPresenter;
-    private enableAddFriendPresenter mEnableAddFriendPresenter;
+    private getCommonValuePresenter mGetCommonValuePresenter;
     private String mmNum;
     private String mmName;
     private String reply = "reply";
     private SharedPreferences pref;
-    private static final String savedRobotName="robotName";
-    private static final String savedRobotNum="robotNum";
-    private static final String threePointInLanucher="com.tencent.mm:id/jr";
-    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 chatRoomNewCi7List="com.tencent.mm:id/d4l";//新的ci7list
+    private static final String savedRobotName = "robotName";
+    private static final String savedRobotNum = "robotNum";
+    private static final String savedRobotId = "robotId";
+    private static final String threePointInLauncher = "com.tencent.mm:id/jr";
+    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 chatRoomNewCi7List = "com.tencent.mm:id/d4l";//新的ci7list
     public addAutoReplyFunction(AccessibilityService service) {
         mService = service;
         mReplyPresenter = new replyPresenter(this);
-        mEnableAddFriendPresenter = new enableAddFriendPresenter(this);
-        pref= mService.getSharedPreferences("robotData", Context.MODE_PRIVATE);
+      //  mEnableAddFriendPresenter = new enableAddFriendPresenter(this);
+        mGetCommonValuePresenter = new getCommonValuePresenter(this);
+        pref = mService.getSharedPreferences("robotData", Context.MODE_PRIVATE);
 
     }
 
@@ -80,16 +84,6 @@ public class addAutoReplyFunction implements replyContract.View , enableAddFrien
         finalAction(message);
     }
 
-    @Override
-    public void showEnableAddFriendReply(enableAddFriendResponse enableAddFriendResponse) {
-        AutoReplyService.enableFriendsCounts = enableAddFriendResponse.getMsg();
-        LogUtils.d(TAG + " addAutoReplyService showEnableAddFriendReply,now the enableFriendCounts is :"+AutoReplyService.enableFriendsCounts);
-    }
-
-    @Override
-    public void showEnableError(String msg) {
-
-    }
 
     /**
      * 最终操作
@@ -105,7 +99,7 @@ public class addAutoReplyFunction implements replyContract.View , enableAddFrien
         AutoReplyService.isInAction = false;
         mService.performGlobalAction(GLOBAL_ACTION_BACK);
         mReplyPresenter.clearSub();
-        mEnableAddFriendPresenter.clearSub();
+        mGetCommonValuePresenter.clearSub();
         RxBus.post(new eventClassFunction(true));
         /*
         if (AutoReplyService.msgList.size() != 0) {
@@ -135,8 +129,9 @@ public class addAutoReplyFunction implements replyContract.View , enableAddFrien
             }
 
             LogUtils.d(TAG + " addAutoReply: 2.5");
-            mReplyPresenter.upLoadFriends(mmName, mmNum, pref.getString(savedRobotName, null), pref.getString(savedRobotNum, null));
-            mEnableAddFriendPresenter.getEnableAddFriend(pref.getString(savedRobotNum, null));
+         //   mReplyPresenter.upLoadFriends(mmName, mmNum, pref.getString(savedRobotName, null), pref.getString(savedRobotNum, null));
+         //   mEnableAddFriendPresenter.getEnableAddFriend(pref.getString(savedRobotNum, null));
+            mGetCommonValuePresenter.getValueByKey(pref.getString(savedRobotId, null), Constants.KEY_FIRST_ANSWER);
 
 
         }
@@ -174,12 +169,36 @@ public class addAutoReplyFunction implements replyContract.View , enableAddFrien
 
     }
 
+    @Override
+    public void showCommonValue(CommonValueResponse commonValueResponse, String key) {
+        if (null != commonValueResponse && commonValueResponse.getCode().equals("1")) {
+            switch (key){
+                case Constants.KEY_ADD_FRIEND_CONTENT:
+                    // 加好友时发送给待添加好友的备注
+
+                    break;
+                case Constants.KEY_FIRST_ANSWER:
+                    // 陌生人同意添加好友后自动回复的消息
+                    finalAction(commonValueResponse.getMsg());
+                    break;
+                case Constants.KEY_MAX_FRIEND_NUM:
+                    // 当前机器人能够添加的剩余好友数
+                    AutoReplyService.enableFriendsCounts = Integer.parseInt(commonValueResponse.getMsg());
+                    LogUtils.d(TAG + " 当前机器人能够添加的剩余好友数 :" + AutoReplyService.enableFriendsCounts);
+                    break;
+                default:
+                    break;
+            }
+
+        }
+    }
+
     /**
      * 打开右上角
      */
     private void openMemberList() {
         AccessibilityNodeInfo nodeInfo = mService.getRootInActiveWindow();
-        AccessibilityNodeInfo target = AccessibilityHelper.findNodeInfosById(nodeInfo, threePointInLanucher);
+        AccessibilityNodeInfo target = AccessibilityHelper.findNodeInfosById(nodeInfo, threePointInLauncher);
         AccessibilityNodeInfo name = AccessibilityHelper.findNodeInfosById(nodeInfo, chatNameInLeftUp);//名称
 
         if (name != null) {
@@ -364,4 +383,5 @@ public class addAutoReplyFunction implements replyContract.View , enableAddFrien
     public void setMmName(String mmName) {
         this.mmName = mmName;
     }
+
 }

+ 51 - 27
app/src/main/java/com/wiipu/marketingrobot/function/addFriendFunction.java

@@ -13,11 +13,15 @@ import android.view.accessibility.AccessibilityEvent;
 import android.view.accessibility.AccessibilityNodeInfo;
 
 import com.wiipu.marketingrobot.AutoReplyService;
-import com.wiipu.marketingrobot.contract.enableAddFriendContract;
+import com.wiipu.marketingrobot.Constants;
+import com.wiipu.marketingrobot.contract.LoginContract;
+import com.wiipu.marketingrobot.contract.getCommonValueContract;
 import com.wiipu.marketingrobot.contract.replyContract;
-import com.wiipu.marketingrobot.presenter.enableAddFriendPresenter;
+import com.wiipu.marketingrobot.presenter.LoginPresenter;
+import com.wiipu.marketingrobot.presenter.getCommonValuePresenter;
 import com.wiipu.marketingrobot.presenter.replyPresenter;
-import com.wiipu.marketingrobot.response.enableAddFriendResponse;
+import com.wiipu.marketingrobot.response.CommonValueResponse;
+import com.wiipu.marketingrobot.response.LoginResponse;
 import com.wiipu.marketingrobot.response.replyResponse;
 import com.wiipu.marketingrobot.response.uploadFriendResponse;
 import com.wiipu.marketingrobot.widget.AccessibilityHelper;
@@ -32,14 +36,15 @@ import static android.accessibilityservice.AccessibilityService.GLOBAL_ACTION_BA
  * Description:被动加好友
  * Code: Axion
  */
-public class addFriendFunction implements replyContract.View , enableAddFriendContract.View{
+public class addFriendFunction implements replyContract.View , getCommonValueContract.View , LoginContract.View{
     AccessibilityService mService;
     private boolean hasGetmmId = false;
     private static final String TAG = addFriendFunction.class.getSimpleName();
     private String mmNum = null;
     private String mmName = null;
     private replyPresenter mReplyPresenter;
-    private enableAddFriendPresenter mEnableAddFriendPresenter;
+    private getCommonValuePresenter mGetCommonValuePresenter;
+    private LoginPresenter mLoginPresenter;
     private String reply;
     private boolean needGetSelfInfo;
     private static final String threePointInLanucher="com.tencent.mm:id/jr";//聊天界面右上角三个点
@@ -49,11 +54,13 @@ public class addFriendFunction implements replyContract.View , enableAddFriendCo
     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";
     private SharedPreferences pref;
     public addFriendFunction(AccessibilityService service) {
         mService = service;
         mReplyPresenter = new replyPresenter(this);
-        mEnableAddFriendPresenter = new enableAddFriendPresenter(this);
+        mGetCommonValuePresenter = new getCommonValuePresenter(this);
+        mLoginPresenter = new LoginPresenter(this);
         pref= mService.getSharedPreferences("robotData", Context.MODE_PRIVATE);
     }
 
@@ -80,17 +87,6 @@ public class addFriendFunction implements replyContract.View , enableAddFriendCo
     }
 
 
-    @Override
-    public void showEnableAddFriendReply(enableAddFriendResponse enableAddFriendResponse) {
-        AutoReplyService.enableFriendsCounts = enableAddFriendResponse.getMsg();
-        LogUtils.d(TAG + " showEnableAddFriendReply,now the enableFriendCounts is :"+AutoReplyService.enableFriendsCounts);
-    }
-
-    @Override
-    public void showEnableError(String msg) {
-
-    }
-
     /**
      * 最终操作
      */
@@ -103,7 +99,7 @@ public class addFriendFunction implements replyContract.View , enableAddFriendCo
         mmNum = null;
         mmName = null;
         AutoReplyService.isInAction = false;
-        mEnableAddFriendPresenter.clearSub();
+        mGetCommonValuePresenter.clearSub();
         mService.performGlobalAction(GLOBAL_ACTION_BACK);
         RxBus.post(new eventClassFunction(true));
         /*
@@ -163,11 +159,17 @@ public class addFriendFunction implements replyContract.View , enableAddFriendCo
             if(needGetSelfInfo){
                 AccessibilityNodeInfo addTocContract = AccessibilityHelper.findNodeInfosByText(root, "添加到通讯录");//有时候会出现这个界面,很奇特
                 if (mmId != null) {
-                    String id = mmId.getText().toString();
-                    id = id.substring(id.indexOf(":") + 2, id.length()).trim();
-                    SharedPreferences.Editor editor=pref.edit();
-                    editor.putString(savedRobotNum, id);
+                    // 获取机器人微信号
+                    // 保存到SharedPreferences文件中
+                    String robotWechatNum = mmId.getText().toString();
+                    robotWechatNum = robotWechatNum.substring(robotWechatNum.indexOf(":") + 2, robotWechatNum.length()).trim();
+                    SharedPreferences.Editor editor = pref.edit();
+                    editor.putString(savedRobotNum, robotWechatNum);
                     editor.apply();
+
+                    // 登陆当前机器人,获取机器人id
+                    mLoginPresenter.login(robotWechatNum);
+
                 } else if (addTocContract != null) {
                     AccessibilityHelper.performClick(addTocContract);
                     return;
@@ -219,8 +221,8 @@ public class addFriendFunction implements replyContract.View , enableAddFriendCo
                 return;
             }
             LogUtils.e(TAG + " addFriend: 3");
-            mReplyPresenter.upLoadFriends(mmName, mmNum, pref.getString(savedRobotName, null), pref.getString(savedRobotNum, null));
-            mEnableAddFriendPresenter.getEnableAddFriend(pref.getString(savedRobotNum, null));
+            mReplyPresenter.upLoadFriends(mmName, mmNum, pref.getString(savedRobotName, null), pref.getString(savedRobotId, null));
+            mGetCommonValuePresenter.getValueByKey(pref.getString(savedRobotId, null),Constants.KEY_MAX_FRIEND_NUM);
 
         }
 
@@ -246,14 +248,31 @@ public class addFriendFunction implements replyContract.View , enableAddFriendCo
     }
 
     /**
+     * 登陆反馈
+     * @param loginResponse
+     */
+
+    @Override
+    public void showResult(LoginResponse loginResponse) {
+        // 保存机器人id到本地
+        if (loginResponse.getCode() == 1){
+            if (loginResponse.getMsg() != null){
+                SharedPreferences.Editor editor = pref.edit();
+                editor.putString(savedRobotId, loginResponse.getMsg().getId());
+                editor.apply();
+            }
+        }
+    }
+
+    /**
      * 获得机器人信息
      */
 
     private void getTheRobotInfo(AccessibilityEvent event) {
-        LogUtils.d(TAG + " getTheRobotInfo: ");
+        LogUtils.d(TAG + " 获取机器人信息: ");
         String senderName = AutoReplyService.msgSenderName;
         if (senderName == null) {
-            LogUtils.e(TAG + " getTheRobotInfo: wtf!!!!");
+            LogUtils.e(TAG + "发消息人昵称为null");
             return;
         }
 
@@ -375,5 +394,10 @@ public class addFriendFunction implements replyContract.View , enableAddFriendCo
     }
 
 
-
+    @Override
+    public void showCommonValue(CommonValueResponse commonValueResponse, String key) {
+        if (key.equals(Constants.KEY_MAX_FRIEND_NUM))
+        AutoReplyService.enableFriendsCounts = Integer.parseInt(commonValueResponse.getMsg());
+        LogUtils.d(TAG + " 当前剩余可添加好友数 : "+ AutoReplyService.enableFriendsCounts);
+    }
 }

+ 9 - 5
app/src/main/java/com/wiipu/marketingrobot/function/addGroupFunction.java

@@ -10,6 +10,7 @@ import android.graphics.Rect;
 import android.os.Bundle;
 import android.os.SystemClock;
 import android.support.annotation.Nullable;
+import android.util.Log;
 import android.view.accessibility.AccessibilityEvent;
 import android.view.accessibility.AccessibilityNodeInfo;
 
@@ -196,15 +197,16 @@ public class addGroupFunction implements moneyContract.View {
             findallchild(root);
             isNumLegal(root);
             if (!isGroupNumLegal) {
-                LogUtils.e(TAG + " addGroup: 人数不合法");
+                LogUtils.e(TAG + " addGroup: 当前群人数不足100");
                 mService.performGlobalAction(GLOBAL_ACTION_BACK);
                 return;
             } else {
-                LogUtils.e(TAG + " addGroup: num is legal");
+                LogUtils.e(TAG + " 当前群人数超过100");
             }
             LogUtils.e(TAG + " addGroup: 1");
 
-            if (needToReplyInvite) {//第一次检查符合人数后,回消息页面进行回复
+            if (needToReplyInvite) {
+                // 第一次检查符合人数后,回消息页面进行回复
                 mMoneyPresenter.addGroupReply(mmNum, pref.getString(savedRobotNum, null),
                         null);
 //                mMoneyPresenter.loadMoneyReply(mmNum, "10.00", pref.getString(savedRobotNum, null));//拉一次群等于10块
@@ -222,11 +224,12 @@ public class addGroupFunction implements moneyContract.View {
                 return;
             }
 
-            LogUtils.e(TAG + " addGroup: click 加入");
+            LogUtils.e(TAG + " addGroup: 点击加入群聊字段");
 
             AccessibilityHelper.performClick(node);
 
 
+
         }
         if (event.getClassName().equals("com.tencent.mm.chatroom.ui.ChatroomInfoUI")) {//聊天室页面
             SystemClock.sleep(2000);
@@ -688,7 +691,8 @@ public class addGroupFunction implements moneyContract.View {
 
         AccessibilityNodeInfo exit = AccessibilityHelper.findNodeInfosById(root, msgNoDisturb);//消息免打扰右侧开关ID
         if (exit != null) {
-            forceClick(exit);
+            // forceClick(exit);
+            LogUtils.e(TAG +  " 启用 消息免打扰 当前已注释");
         }
 
         /**

+ 41 - 9
app/src/main/java/com/wiipu/marketingrobot/function/handleChatFunction.java

@@ -16,8 +16,11 @@ import android.view.accessibility.AccessibilityEvent;
 import android.view.accessibility.AccessibilityNodeInfo;
 
 import com.wiipu.marketingrobot.AutoReplyService;
+import com.wiipu.marketingrobot.contract.LoginContract;
 import com.wiipu.marketingrobot.contract.replyContract;
+import com.wiipu.marketingrobot.presenter.LoginPresenter;
 import com.wiipu.marketingrobot.presenter.replyPresenter;
+import com.wiipu.marketingrobot.response.LoginResponse;
 import com.wiipu.marketingrobot.response.replyResponse;
 import com.wiipu.marketingrobot.response.uploadFriendResponse;
 import com.wiipu.marketingrobot.widget.AccessibilityHelper;
@@ -35,7 +38,7 @@ import static android.accessibilityservice.AccessibilityService.GLOBAL_ACTION_BA
  * Description:聊天处理部分,负责消息回复
  * Code: Axion
  */
-public class handleChatFunction implements replyContract.View {
+public class handleChatFunction implements replyContract.View , LoginContract.View {
     private AccessibilityService mService;
     private List<String> chatRoomMemberName = new ArrayList<>();//群聊成员名称
     private int chatRoomMemberIndex = 0;//聊天室人员列表下标
@@ -49,6 +52,7 @@ public class handleChatFunction implements replyContract.View {
     private boolean isInGroupChatAction = false;//用于区分小群聊和单聊
     private List<AccessibilityNodeInfo> nodeList = new ArrayList<>();//对于小群人员,把所有的人员node放一起
     private replyPresenter mReplyPresenter;
+    private LoginPresenter mLoginPresenter;
     private String groupName = null;
     private String reply;
     private String senderName;
@@ -69,6 +73,7 @@ public class handleChatFunction implements replyContract.View {
     private static final String sendFriendRequestBtn = "com.tencent.mm:id/jq";//加好友验证页面右上角发送按钮
     private static final String savedRobotName = "robotName";
     private static final String savedRobotNum = "robotNum";
+    private static final String savedRobotId = "robotId";
     // private String mmRobotNum;
     // private String mmRobotName;
 
@@ -88,7 +93,7 @@ public class handleChatFunction implements replyContract.View {
         if (replyResponse.getCode().equals("104")
                 && replyResponse.getMsg().equals("\u67e5\u8be2\u9519\u8bef\uff0c\u8be5\u7528\u6237\u4e0d\u5b58\u5728")) {
             LogUtils.d(TAG + " showReply: " + senderName + " " + mmNum + " " + pref.getString(savedRobotName, null) + " " + pref.getString(savedRobotNum, null));
-            mReplyPresenter.upLoadFriends(senderName, mmNum, pref.getString(savedRobotName, null), pref.getString(savedRobotNum, null));
+            mReplyPresenter.upLoadFriends(senderName, mmNum, pref.getString(savedRobotName, null), pref.getString(savedRobotId, null));
             return;
         }
 
@@ -154,7 +159,9 @@ public class handleChatFunction implements replyContract.View {
         senderContent = content;
         AutoReplyService.isInAction = true;
         LogUtils.d(TAG + " handleChat: " + pref.getString(savedRobotName, null) + pref.getString(savedRobotNum, null));
-        if (pref.getString(savedRobotName, null) == null || pref.getString(savedRobotNum, null) == null) {
+        if (pref.getString(savedRobotName, null) == null
+                || pref.getString(savedRobotNum, null) == null
+                || pref.getString(savedRobotId, null) == null ) {
             getTheRobotInfo(event);
             return;
         }
@@ -176,7 +183,7 @@ public class handleChatFunction implements replyContract.View {
                 return;
             }
 
-            LogUtils.e(TAG + " handleChat: 1" + mmNum);
+            LogUtils.e(TAG + " handleChat: 1 " + mmNum);
             if (mmNum == null) {
                 getTheMMnum(event);
                 return;
@@ -367,11 +374,17 @@ public class handleChatFunction implements replyContract.View {
             AccessibilityNodeInfo mmId = AccessibilityHelper.findNodeInfosByText(root, "微信号");
             AccessibilityNodeInfo addTocContract = AccessibilityHelper.findNodeInfosByText(root, "添加到通讯录");//有时候会出现这个界面,很奇特
             if (mmId != null) {
-                String id = mmId.getText().toString();
-                id = id.substring(id.indexOf(":") + 2, id.length()).trim();
+                // 获取机器人微信号
+                // 保存到SharedPreferences文件中
+                String robotWechatNum = mmId.getText().toString();
+                robotWechatNum = robotWechatNum.substring(robotWechatNum.indexOf(":") + 2, robotWechatNum.length()).trim();
                 SharedPreferences.Editor editor = pref.edit();
-                editor.putString(savedRobotNum, id);
+                editor.putString(savedRobotNum, robotWechatNum);
                 editor.apply();
+
+                // 登陆当前机器人,获取机器人id
+                mLoginPresenter.login(robotWechatNum);
+
             } else if (addTocContract != null) {
                 AccessibilityHelper.performClick(addTocContract);
                 return;
@@ -685,8 +698,8 @@ public class handleChatFunction implements replyContract.View {
 
         AccessibilityNodeInfo exit = AccessibilityHelper.findNodeInfosById(root, msgNoDisturb);//消息免打扰右侧开关ID
         if (exit != null) {
-            Log.e(TAG, "finalAction: force click");
-            forceClick(exit);
+            LogUtils.e(TAG +  " 启用 消息免打扰 当前已注释");
+            // forceClick(exit);
         }
 
         addCount = 0;
@@ -784,6 +797,22 @@ public class handleChatFunction implements replyContract.View {
 
     }
 
+    /**
+     * 登陆反馈
+     * @param loginResponse
+     */
+
+    @Override
+    public void showResult(LoginResponse loginResponse) {
+        // 保存机器人id到本地
+        if (loginResponse.getCode() == 1){
+            if (loginResponse.getMsg() != null){
+                SharedPreferences.Editor editor = pref.edit();
+                editor.putString(savedRobotId, loginResponse.getMsg().getId());
+                editor.apply();
+            }
+        }
+    }
 
     public String getMmNum() {
         return mmNum;
@@ -844,6 +873,7 @@ public class handleChatFunction implements replyContract.View {
     public handleChatFunction(AccessibilityService service) {
         mService = service;
         mReplyPresenter = new replyPresenter(this);
+        mLoginPresenter = new LoginPresenter(this);
         pref = mService.getSharedPreferences("robotData", Context.MODE_PRIVATE);
     }
 
@@ -862,4 +892,6 @@ public class handleChatFunction implements replyContract.View {
     public void setFriendSendError(boolean friendSendError) {
         isFriendSendError = friendSendError;
     }
+
+
 }

+ 48 - 0
app/src/main/java/com/wiipu/marketingrobot/presenter/LoginPresenter.java

@@ -0,0 +1,48 @@
+package com.wiipu.marketingrobot.presenter;
+
+import com.wiipu.marketingrobot.contract.LoginContract;
+import com.wiipu.marketingrobot.response.LoginResponse;
+import com.wiipu.marketingrobot.service.replyService;
+import com.wiipu.netlib.base.BasePresenter;
+import com.wiipu.netlib.net.HttpClient;
+import com.wiipu.netlib.net.RxTransformer;
+
+import rx.Subscription;
+import rx.functions.Action1;
+
+/**
+ * Description:获取通用数值
+ * Code: ozqowen
+ */
+public class LoginPresenter extends BasePresenter<LoginContract.View> implements LoginContract.Presenter {
+
+    public LoginPresenter(LoginContract.View view) {
+        super(view);
+    }
+
+    @Override
+    public void login(String robotWechatNum) {
+        String method = "login";
+        Subscription subscription = HttpClient.getInstance()
+                .create(replyService.class)
+                .login(method, robotWechatNum)
+                .compose(RxTransformer.<LoginResponse>apply())
+                .subscribe(new Action1<LoginResponse>() {
+                    @Override
+                    public void call(LoginResponse loginResponse) {
+                        mView.showResult(loginResponse);
+                    }
+                }, new Action1<Throwable>() {
+                    @Override
+                    public void call(Throwable throwable) {
+                        mView.showError(throwable.getMessage());
+                    }
+                });
+        mSubscriptions.add(subscription);
+    }
+
+    public void clearSub() {
+        mSubscriptions.clear();
+    }
+
+}

+ 0 - 48
app/src/main/java/com/wiipu/marketingrobot/presenter/enableAddFriendPresenter.java

@@ -1,48 +0,0 @@
-package com.wiipu.marketingrobot.presenter;
-
-import com.wiipu.marketingrobot.contract.enableAddFriendContract;
-import com.wiipu.marketingrobot.response.enableAddFriendResponse;
-import com.wiipu.marketingrobot.service.replyService;
-import com.wiipu.netlib.base.BasePresenter;
-import com.wiipu.netlib.net.HttpClient;
-import com.wiipu.netlib.net.RxTransformer;
-
-import rx.Subscription;
-import rx.functions.Action1;
-
-/**
- * Description:查询可加人数的presenter
- * Code: Axion
- */
-public class enableAddFriendPresenter extends BasePresenter<enableAddFriendContract.View> implements enableAddFriendContract.Presenter {
-
-    public enableAddFriendPresenter(enableAddFriendContract.View view) {
-        super(view);
-    }
-
-    @Override
-    public void getEnableAddFriend(String robotNum) {
-        String method = "user_status";
-        Subscription subscription = HttpClient.getInstance()
-                .create(replyService.class)
-                .getEnableAddFriendResponse(method, robotNum)
-                .compose(RxTransformer.<enableAddFriendResponse>apply())
-                .subscribe(new Action1<enableAddFriendResponse>() {
-                    @Override
-                    public void call(enableAddFriendResponse enableAddFriendResponse) {
-                        mView.showEnableAddFriendReply(enableAddFriendResponse);
-                    }
-                }, new Action1<Throwable>() {
-                    @Override
-                    public void call(Throwable throwable) {
-                        mView.showEnableError(throwable.getMessage());
-                    }
-                });
-        mSubscriptions.add(subscription);
-    }
-
-    public void clearSub() {
-        mSubscriptions.clear();
-    }
-
-}

+ 48 - 0
app/src/main/java/com/wiipu/marketingrobot/presenter/getCommonValuePresenter.java

@@ -0,0 +1,48 @@
+package com.wiipu.marketingrobot.presenter;
+
+import com.wiipu.marketingrobot.contract.getCommonValueContract;
+import com.wiipu.marketingrobot.response.CommonValueResponse;
+import com.wiipu.marketingrobot.service.replyService;
+import com.wiipu.netlib.base.BasePresenter;
+import com.wiipu.netlib.net.HttpClient;
+import com.wiipu.netlib.net.RxTransformer;
+
+import rx.Subscription;
+import rx.functions.Action1;
+
+/**
+ * Description:获取通用数值
+ * Code: ozqowen
+ */
+public class getCommonValuePresenter extends BasePresenter<getCommonValueContract.View> implements getCommonValueContract.Presenter {
+
+    public getCommonValuePresenter(getCommonValueContract.View view) {
+        super(view);
+    }
+
+    @Override
+    public void getValueByKey(String robotId , final String key) {
+        String method = "get_val_by_key";
+        Subscription subscription = HttpClient.getInstance()
+                .create(replyService.class)
+                .getCommonValueResponse(method, robotId, key)
+                .compose(RxTransformer.<CommonValueResponse>apply())
+                .subscribe(new Action1<CommonValueResponse>() {
+                    @Override
+                    public void call(CommonValueResponse commonValueResponse) {
+                        mView.showCommonValue(commonValueResponse ,key);
+                    }
+                }, new Action1<Throwable>() {
+                    @Override
+                    public void call(Throwable throwable) {
+                        mView.showError(throwable.getMessage());
+                    }
+                });
+        mSubscriptions.add(subscription);
+    }
+
+    public void clearSub() {
+        mSubscriptions.clear();
+    }
+
+}

+ 9 - 5
app/src/main/java/com/wiipu/marketingrobot/presenter/replyPresenter.java

@@ -53,17 +53,21 @@ public class replyPresenter extends BasePresenter<replyContract.View> implements
     }
 
     @Override
-    public void upLoadFriends(String mmName, String mmNum, String robotName, String robotNum) {
-        Log.d("presenter", "upLoadFriends: ");
-        String method = "user_add";
+    public void upLoadFriends(String mmName, String mmNum, String robotName, String robotId) {
+
+        LogUtils.d("执行添加好友接口");
+      //  String method = "user_add";
+        String method = "add_friend";
+
         Subscription subscription = HttpClient.getInstance()
                 .create(replyService.class)
-                .getUploadFriendResponse(method, robotName, robotNum, mmName, mmNum)
+               // .getUploadFriendResponse(method, robotName, robotNum, mmName, mmNum)
+                .getUploadFriendResponse(method, robotId, mmName, mmNum)
                 .compose(RxTransformer.<uploadFriendResponse>apply())
                 .subscribe(new Action1<uploadFriendResponse>() {
                     @Override
                     public void call(uploadFriendResponse uploadFriendResponse) {
-                        LogUtils.d("success");
+                        LogUtils.d("添加好友成功");
                         mView.showUploadFriendReply(uploadFriendResponse);
 
                     }

+ 28 - 0
app/src/main/java/com/wiipu/marketingrobot/response/CommonValueResponse.java

@@ -0,0 +1,28 @@
+package com.wiipu.marketingrobot.response;
+
+/**
+ * Description: 通用数值
+ *  * key = max_friend_num, msg = 能添加最大好友数
+ *  * key = add_friend_content, msg = 添加好友时候的备注
+ *  * key = first_answer, msg = 添加好友成功后给予的回复内容
+ */
+public class CommonValueResponse {
+    private String code;
+    private String msg;
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
+
+    public void setMsg(String msg) {
+        this.msg = msg;
+    }
+}

+ 85 - 0
app/src/main/java/com/wiipu/marketingrobot/response/LoginResponse.java

@@ -0,0 +1,85 @@
+package com.wiipu.marketingrobot.response;
+
+public class LoginResponse {
+
+
+    /**
+     * code : 1
+     * msg : {"id":"2","key":"ozqowen","name":null,"pay":null,"addtime":"1558194844"}
+     */
+
+    private int code;
+    private MsgBean msg;
+
+    public int getCode() {
+        return code;
+    }
+
+    public void setCode(int code) {
+        this.code = code;
+    }
+
+    public MsgBean getMsg() {
+        return msg;
+    }
+
+    public void setMsg(MsgBean msg) {
+        this.msg = msg;
+    }
+
+    public static class MsgBean {
+        /**
+         * id : 2
+         * key : ozqowen
+         * name : null
+         * pay : null
+         * addtime : 1558194844
+         */
+
+        private String id;
+        private String key;
+        private String name;
+        private String pay;
+        private String addtime;
+
+        public String getId() {
+            return id;
+        }
+
+        public void setId(String id) {
+            this.id = id;
+        }
+
+        public String getKey() {
+            return key;
+        }
+
+        public void setKey(String key) {
+            this.key = key;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public void setName(String name) {
+            this.name = name;
+        }
+
+        public String getPay() {
+            return pay;
+        }
+
+        public void setPay(String pay) {
+            this.pay = pay;
+        }
+
+        public String getAddtime() {
+            return addtime;
+        }
+
+        public void setAddtime(String addtime) {
+            this.addtime = addtime;
+        }
+    }
+}

+ 33 - 5
app/src/main/java/com/wiipu/marketingrobot/service/replyService.java

@@ -2,6 +2,8 @@ package com.wiipu.marketingrobot.service;
 
 
 import com.wiipu.marketingrobot.response.AddGroupReplyResponse;
+import com.wiipu.marketingrobot.response.CommonValueResponse;
+import com.wiipu.marketingrobot.response.LoginResponse;
 import com.wiipu.marketingrobot.response.enableAddFriendResponse;
 import com.wiipu.marketingrobot.response.moneyResponse;
 import com.wiipu.marketingrobot.response.replyResponse;
@@ -18,6 +20,23 @@ import rx.Observable;
 public interface replyService {
 
     /**
+     * 通过机器人微信号获取机器人id
+     */
+    @POST("api.php")
+    @FormUrlEncoded
+    Observable<LoginResponse> login(@Field("method") String method,
+                                    @Field("rabot_no") String rabot_no);
+
+    /**
+     * 获得通用数值
+     */
+    @POST("api.php")
+    @FormUrlEncoded
+    Observable<CommonValueResponse> getCommonValueResponse(@Field("method") String method,
+                                                           @Field("uid") String uid,
+                                                           @Field("key") String key);
+
+    /**
      * 获取回复
      */
 
@@ -29,17 +48,26 @@ public interface replyService {
                                           @Field("rabot_no") String rabotNum
     );
 
+//    /**
+//     * 获取上传好友结果
+//     */
+//    @POST("api.php")
+//    @FormUrlEncoded
+//    Observable<uploadFriendResponse> getUploadFriendResponse(@Field("method") String add,
+//                                                             @Field("rabot_name") String rabotName,
+//                                                             @Field("rabot_no") String rabotNum,
+//                                                             @Field("user_name") String mmName,
+//                                                             @Field("user_no") String mmNum);
+
     /**
      * 获取上传好友结果
      */
     @POST("api.php")
     @FormUrlEncoded
     Observable<uploadFriendResponse> getUploadFriendResponse(@Field("method") String add,
-                                                             @Field("rabot_name") String rabotName,
-                                                             @Field("rabot_no") String rabotNum,
-                                                             @Field("user_name") String mmName,
-                                                             @Field("user_no") String mmNum);
-
+                                                             @Field("uid") String robotId,
+                                                             @Field("user_name") String user_name,
+                                                             @Field("user_key") String user_key);
 
     /**
      * 上传金钱结果

+ 2 - 1
app/src/main/res/layout/activity_main.xml

@@ -9,7 +9,8 @@
         android:id="@+id/textViewService"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_gravity="center"/>
+        android:layout_gravity="center"
+        android:text="TextView"/>
 
     <Button
         android:id="@+id/buttonStartService"