Exemple #1
0
        /// <summary>
        /// 单个发送朋友圈
        /// </summary>
        /// <param name="device"></param>-
        public void SendFriendCircle(UploadFilesToPhoneViewModel viewModel)
        {
            ///检测设备是否处于连接状态
            if (_baseAction.CheckEquipmentIsConnecting(viewModel.Device))
            {
                return;
            }

            var isSuccess = false;

            _baseAction.UnlockSingleScreen(viewModel.Device);

            OpenWX(viewModel.Device);

            ///获取屏幕分辨率
            WMPoint wmPoint = _baseAction.GetWMSize(viewModel.Device);

            ////我
            _baseAction.actionDirectStr(viewModel.Device, 700, 1180, wmPoint);

            //////相册
            _baseAction.actionDirectStr(viewModel.Device, 450, 650, wmPoint);

            //检测是否进入我的相册
            isSuccess = _baseAction.CircleDetection("SnsUserUI", viewModel.Device);

            if (!isSuccess)
            {
                return;
            }

            /////今天
            _baseAction.actionDirectStr(viewModel.Device, 200, 910, wmPoint);

            /////从相册中选择
            _baseAction.actionDirectStr(viewModel.Device, 360, 700, wmPoint);

            ///是否进入相册列表
            isSuccess = _baseAction.CircleDetection("AlbumPreviewUI", viewModel.Device);


            if (!isSuccess)
            {
                //滑动一下 去除通知
                _baseAction.InitProcessWithTaskState(viewModel.Device, " shell input swipe 100 100 600  100");

                ///去除意外弹框
                _baseAction.actionDirectStr(viewModel.Device, 200, 100, wmPoint);

                /////今天
                _baseAction.actionDirectStr(viewModel.Device, 200, 900, wmPoint);

                /////从相册中选择
                _baseAction.actionDirectStr(viewModel.Device, 360, 700, wmPoint);

                isSuccess = _baseAction.CircleDetection("AlbumPreviewUI", viewModel.Device);

                if (!isSuccess)
                {
                    return;
                }
            }

            ///选择照片
            _baseAction.SelectImage(viewModel.Files, wmPoint, viewModel.Device, 120, 200, 120, 180);

            ///发送的是视频
            if (viewModel.PublishContentType == EnumPublishContentType.VedioAndWord)
            {
                //检测是否进入视频预览界面
                isSuccess = _baseAction.CircleDetection("ImagePreviewUI", viewModel.Device);

                if (!isSuccess)
                {
                    return;
                }
            }

            ///向上滑动 防止出现通知
            _baseAction.InitProcessWithTaskState(viewModel.Device, " shell input swipe 100 100 600  100");

            ////完成
            _baseAction.actionDirectStr(viewModel.Device, 700, 100, wmPoint);

            Thread.Sleep(1000);

            var list = _baseAction.InitProcessWithTaskState(viewModel.Device, " shell dumpsys window | grep mCurrentFocus", true);

            var stateStr = list.FirstOrDefault();

            //检测是否进入确定发送朋友圈页面
            while (stateStr.Contains("AlbumPreviewUI") || stateStr.Contains("ImagePreviewUI") || stateStr.Contains("VideoCompressUI"))
            {
                list = _baseAction.InitProcessWithTaskState(viewModel.Device, " shell dumpsys window | grep mCurrentFocus", true);

                stateStr = list.FirstOrDefault();
            }

            ///点击text 获取焦点
            _baseAction.actionDirectStr(viewModel.Device, 100, 200, wmPoint);

            ///输入文字
            _baseAction.InitProcessWithTaskState(viewModel.Device, "shell am broadcast -a ADB_INPUT_TEXT --es msg '" + viewModel.Content + "'");


            ///向上滑动 防止出现通知
            _baseAction.InitProcessWithTaskState(viewModel.Device, " shell input swipe 100 100 600  100");

            // 点击确定发送朋友圈按钮
            _baseAction.actionDirectStr(viewModel.Device, 700, 100, wmPoint);

            //Thread.Sleep(1000);

            //list = _baseAction.InitProcessWithTaskState(viewModel.Device, " shell dumpsys window | grep mCurrentFocus", true);

            //stateStr = list.FirstOrDefault();

            /////是否进入朋友圈界面

            //while (stateStr.Contains("SnsUploadUI"))
            //{
            //    ///向上滑动 防止出现通知
            //    _baseAction.InitProcessWithTaskState(viewModel.Device, " shell input swipe 100 100 600  100");

            //    ///点击确定发送朋友圈按钮
            //    _baseAction.InitProcessWithTaskState(viewModel.Device, "shell input tap 700 100");

            //    list = _baseAction.InitProcessWithTaskState(viewModel.Device, " shell dumpsys window | grep mCurrentFocus", true);

            //    stateStr = list.FirstOrDefault();

            //    Thread.Sleep(500);

            //}
        }