// // cloudPhoneViewController.m // // // Created David on 2024/6/20. // #import "cloudPhoneViewController.h" #import "cloudPhoneSetView.h" #import "webRtcMsgModel.h" #import "webRtcPlayerViewController.h" #import "HaveNewVersionView.h" #import "noticeModel.h" #import "HaveNoticeView.h" //#import "boxCheckStatusModel.h" #import "imageVersionRenewTipView.h" @interface cloudPhoneViewController () { BOOL didGetSysInfoType;//是否收到过系统信息用在---用来判断是否要走弹框流程 } @property (nonatomic,strong) cloudPhoneSetView *cloudPhoneSetV; @property (nonatomic,strong) webRtcMsgModel *webRtcMsgMod; @end @implementation cloudPhoneViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. //输入密码完成 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didInpuPwdOkFun) name:didInputPWDNotification object:nil]; //[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getCouldPhoneSysInfoFun:) name:getCouldPhoneSysInfoNotification object:nil]; [self.view setBackgroundColor:HWF5F7FAColor]; [self.toolBar setHidden:YES]; [self.navigationBar setHidden:YES]; [self.navBarBGView setHidden:YES]; [self drawAnyView]; } - (void)drawAnyView{ //顶底底部图片 UIImageView *topImageV = [UIImageView new]; topImageV.userInteractionEnabled = YES; topImageV.image = [UIImage imageNamed:@"cloudPhone_bg"]; [self.view addSubview:topImageV]; [topImageV mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(0); make.left.mas_equalTo(0); make.right.mas_equalTo(0); make.bottom.mas_equalTo(0); }]; CGFloat width = SCREEN_W; CGFloat height = SCREEN_H; BOOL isSmallPhoneType = NO; if(width == 375 && height == 667){ isSmallPhoneType = YES; } CGFloat adjustSmallScale = 0.9; // if(isSmallPhoneType){ // adjustSmallScale = 0.85; // } CGFloat imageTopY = 40.0; // if(isSmallPhoneType){ // imageTopY = 20.0; // } //设置按钮 UIButton *setButton = [[UIButton alloc] init]; //[setButton setBackgroundImage:[UIImage imageNamed:@"cloudPhone_set"] forState:UIControlStateNormal]; [setButton setImage:[UIImage imageNamed:@"cloudPhone_set"] forState:UIControlStateNormal]; setButton.tag = 1; [setButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:setButton]; //setButton.backgroundColor = [UIColor greenColor]; [setButton mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(imageTopY); if(isSmallPhoneType){ make.right.mas_equalTo(-5); } else{ make.right.mas_equalTo(-16); } make.width.mas_equalTo(50); make.height.mas_equalTo(50); // make.top.mas_equalTo(imageTopY); // make.right.mas_equalTo(-16); // make.width.mas_equalTo(24); // make.height.mas_equalTo(24); }]; //中间图片 UIImageView *midImageV = [UIImageView new]; midImageV.userInteractionEnabled = YES; midImageV.image = [UIImage imageNamed:@"cloudPhone_mid_img"]; [self.view addSubview:midImageV]; [midImageV mas_makeConstraints:^(MASConstraintMaker *make) { make.width.mas_equalTo(326*WAUTOSCALE*adjustSmallScale); make.height.mas_equalTo(608*WAUTOSCALE*adjustSmallScale); make.centerX.mas_equalTo(0); make.centerY.mas_equalTo(-10); }]; // NSString *midTopTip1Str = NSLocalizedString(@"cloudPhone_top_tip1",nil); // NSString *midTopTip2Str = NSLocalizedString(@"cloudPhone_top_tip2",nil); // // //提示文字 // UILabel *midTopTipLab1 = [[UILabel alloc] init]; // midTopTipLab1.text = midTopTip1Str; // midTopTipLab1.font = [UIFont systemFontOfSize:20.0]; // midTopTipLab1.textColor = [UIColor hwColor:@"#0A132B"]; // midTopTipLab1.textAlignment = NSTextAlignmentCenter; // [midImageV addSubview:midTopTipLab1]; // // [midTopTipLab1 mas_makeConstraints:^(MASConstraintMaker *make) { // make.top.equalTo(midImageV.mas_top).offset(64); // make.right.equalTo(midImageV.mas_right).offset(0); // make.left.equalTo(midImageV.mas_left).offset(0); // make.height.mas_equalTo(24); // }]; // // UILabel *midTopTipLab2 = [[UILabel alloc] init]; // midTopTipLab2.text = midTopTip2Str; // midTopTipLab2.font = [UIFont systemFontOfSize:16.0]; // midTopTipLab2.textColor = [UIColor hwColor:@"#535657"]; // midTopTipLab2.textAlignment = NSTextAlignmentCenter; // [midImageV addSubview:midTopTipLab2]; // // [midTopTipLab2 mas_makeConstraints:^(MASConstraintMaker *make) { // make.top.equalTo(midTopTipLab1.mas_bottom).offset(15); // make.right.equalTo(midImageV.mas_right).offset(0); // make.left.equalTo(midImageV.mas_left).offset(0); // make.height.mas_equalTo(20); // }]; // //进入云机 // UIButton*enterCloudPhoneButton = [[UIButton alloc] init]; // CGFloat w_btn = SCREEN_W - 15*2 - 50*2; // // // gradient // CAGradientLayer *gl = [CAGradientLayer layer]; // gl.frame = CGRectMake(0,0,w_btn,44.f); // gl.startPoint = CGPointMake(0, 0.5); // gl.endPoint = CGPointMake(0.97, 0.5); // gl.colors = @[(__bridge id)HWFFE10FColor.CGColor, (__bridge id)HWFFE411Color.CGColor]; // gl.locations = @[@(0), @(1.0f)]; // // [enterCloudPhoneButton.layer addSublayer:gl]; // [enterCloudPhoneButton setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)]; // //[enterCloudPhoneButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:(UIControlEventTouchUpInside)]; // [enterCloudPhoneButton setTitle:NSLocalizedString(@"cloudPhone_enter_tip",nil) forState:(UIControlStateNormal)]; // [enterCloudPhoneButton.titleLabel setFont:[UIFont boldSystemFontOfSize:16.f]]; // [enterCloudPhoneButton.layer setCornerRadius:21.f]; // enterCloudPhoneButton.layer.borderWidth = 0.5; // enterCloudPhoneButton.layer.borderColor = [UIColor clearColor].CGColor; // enterCloudPhoneButton.clipsToBounds = YES; // //enterCloudPhoneButton.tag = 2; // [midImageV addSubview:enterCloudPhoneButton]; // // [enterCloudPhoneButton mas_makeConstraints:^(MASConstraintMaker *make) { // make.width.mas_equalTo(w_btn); // make.height.mas_equalTo(42); // make.centerX.mas_equalTo(0); // make.bottom.equalTo(midImageV.mas_bottom).offset(-30); // }]; //扩大进入云机范围按钮 UIButton *bigButton = [[UIButton alloc] init]; bigButton.tag = 2; [bigButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:bigButton]; //bigButton.backgroundColor = [UIColor greenColor]; [bigButton mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(midImageV.mas_top).offset(0); make.right.equalTo(midImageV.mas_right).offset(0); make.left.equalTo(midImageV.mas_left).offset(0); make.bottom.equalTo(midImageV.mas_bottom).offset(0); }]; } #pragma mark 点击按钮 - (void)didClickButtonFun:(UIButton*)but { if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable) { [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show]; return; } // if (!ksharedAppDelegate.isWebSockLinkOKAginType) {//未链接 // [[iToast makeText:NSLocalizedString(@"box_link_error_show_tip",nil)] show]; // return; // } NSInteger tag = but.tag; HLog(@"%ld",tag); switch (tag) { case 1: { //数据埋点 [[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"Cloud_settings"]; _cloudPhoneSetV = [cloudPhoneSetView new]; [ksharedAppDelegate.window addSubview:_cloudPhoneSetV]; [_cloudPhoneSetV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.right.mas_equalTo(0); make.top.mas_equalTo(0); make.bottom.mas_equalTo(0); }]; KWeakSelf _cloudPhoneSetV.didClickButtonFun = ^(NSInteger tag) { if (tag == 10) {//重启 [weakSelf didClickRestartFun]; } else if (tag == 11){//恢复出厂 [weakSelf RestoreFactoryAleartFun]; } }; } break; case 2: { //[self checkFullScreenWithTVShowStateFun]; // PlayerViewController *vc = [PlayerViewController new]; // [self pushViewController:vc animated:YES]; // // if(ksharedAppDelegate.TvStatusMod.isTVShowType){ // [[iToast makeText:NSLocalizedString(@"tv_p2p_ing",nil)] show]; // } [self queryWebRtcMsgFun:YES]; //数据埋点 [[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"Cloud_enter"]; //[self checkBoxStatusFun]; } break; default: break; } } #pragma mark 点击了重启空间 - (void)didClickRestartFun { KWeakSelf /*弹窗提示重启*/ ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_restart_phone_tips",nil) msg:@"" imageStr:@"" cancelTitle:NSLocalizedString(@"other_cancel",nil) okTitle:NSLocalizedString(@"my_set_no_restart_phone_btn_ok",nil) isOkBtnHighlight:NO didClickOk:^{ [weakSelf sureToRestartCloudPhoneFun]; } didClickCancel:^{ }]; nextVC.modalPresentationStyle = UIModalPresentationCustom; [self presentViewController:nextVC animated:YES completion:^{ nextVC.view.superview.backgroundColor = [UIColor clearColor]; }]; } #pragma mark 确认重启云机 - (void)sureToRestartCloudPhoneFun{ // /*重启云手机*/ // 通过指令通道发送 {"type":"reboot"} [[webRtcManager shareManager] needToRebootFun]; //提示语 [[iToast makeText:NSLocalizedString(@"player_link_rebooting_Tips",nil)] show]; } #pragma mark 点击恢复出厂 - (void)RestoreFactoryAleartFun { KWeakSelf /*弹窗提示恢复出厂*/ ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_Restore_Factory_tips",nil) msg:NSLocalizedString(@"my_set_no_Restore_Factory_msg",nil) imageStr:@"icon_Restore_Factory_big" cancelTitle:NSLocalizedString(@"my_set_TVP2P_Open_sure",nil) okTitle:NSLocalizedString(@"other_cancel",nil) isOkBtnHighlight:YES didClickOk:^{ } didClickCancel:^{ //点击确定 [weakSelf gotoResetFun]; }]; nextVC.modalPresentationStyle = UIModalPresentationCustom; [self presentViewController:nextVC animated:YES completion:^{ nextVC.view.superview.backgroundColor = [UIColor clearColor]; }]; } #pragma mark 点击了恢复出厂 - (void)gotoResetFun { [[webRtcManager shareManager] needToResetFun]; [self RestoreFactoryingFun]; } #pragma mark 恢复出厂中 - (void)RestoreFactoryingFun { KWeakSelf /*弹窗提示恢复出厂*/ ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_Restore_Factorying_tips",nil) msg:NSLocalizedString(@"my_set_no_Restore_Factorying_msg",nil) imageStr:@"" cancelTitle:NSLocalizedString(@"my_set_no_Restore_Factorying",nil) okTitle:@"" isOkBtnHighlight:NO didClickOk:^{ [weakSelf RestoreFactoryCompleteFun]; } didClickCancel:^{ }]; [nextVC setButtonCountdownFun:180];//90 nextVC.modalPresentationStyle = UIModalPresentationCustom; [self presentViewController:nextVC animated:YES completion:^{ nextVC.view.superview.backgroundColor = [UIColor clearColor]; }]; } #pragma mark 恢复出厂倒计时结束 - (void)RestoreFactoryCompleteFun { //KWeakSelf /*弹窗提示恢复出厂*/ ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_Restore_Factory_ok_tips",nil) msg:@"" imageStr:@"" cancelTitle:NSLocalizedString(@"my_set_no_Restore_FactoryOK",nil) okTitle:@"" isOkBtnHighlight:NO didClickOk:^{ } didClickCancel:^{ }]; nextVC.modalPresentationStyle = UIModalPresentationCustom; [self presentViewController:nextVC animated:YES completion:^{ nextVC.view.superview.backgroundColor = [UIColor clearColor]; }]; } - (void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; // [self beginShowAlertFun]; // // BOOL isNeedShowSecret = [HWDataManager getBoolWithKey:Const_need_show_Secret_key]; // if(isNeedShowSecret){ // [self showSecretkeyFun]; // } } - (void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:animated]; } - (void)pushViewController:(UIViewController*)vc animated:(BOOL)animated { [self.navigationController pushViewController:vc animated:animated]; } #pragma mark 获取webrct 的链接信息 -(void)queryWebRtcMsgFun:(BOOL)isPlayerType { if(isPlayerType){ if(ksharedAppDelegate.DeviceWebRtcMsgMod && ksharedAppDelegate.DeviceWebRtcMsgMod.data.sn){ [self gotoWebRtcVcBy:ksharedAppDelegate.DeviceWebRtcMsgMod]; return; } [self showNewIndicatorWithCanBack:YES canTouch:NO]; } NSMutableDictionary *paraDict = [NSMutableDictionary new]; KWeakSelf [[netWorkManager shareInstance] CommonPostCallBackCode:webrctQueryByClient Parameters:paraDict success:^(id _Nonnull responseObject){ if(isPlayerType){ [weakSelf removeNewIndicator]; } webRtcMsgModel *curModel = [[webRtcMsgModel alloc] initWithDictionary:responseObject error:nil]; if(curModel && curModel.status == 0){ ksharedAppDelegate.DeviceWebRtcMsgMod = curModel; if(isPlayerType){ [weakSelf gotoWebRtcVcBy:curModel]; } } else { if(isPlayerType && curModel.msg){ [[iToast makeText:curModel.msg] show]; } } } failure:^(NSError * _Nonnull error) { if(isPlayerType){ [weakSelf removeNewIndicator]; [[iToast makeText:NSLocalizedString(@"get_webrtcMsg_fail_tip",nil)] show]; } }]; } #pragma mark 跳转webrtc 页面 - (void)gotoWebRtcVcBy:(webRtcMsgModel*)webRtcMsgMod { NSArray * vcArrs = self.navigationController.viewControllers; if(vcArrs.count != 1){ return; } webRtcPlayerViewController *vc = [webRtcPlayerViewController new]; vc.webRtcMsgMod = webRtcMsgMod; [self.navigationController pushViewController:vc animated:YES]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ ksharedAppDelegate.isCloudPhoneModeNotPrivacyModeOpenType = NO; ksharedAppDelegate.isCloudPhoneModeAndPrivacyModeOpenType = NO; }); } #pragma mark 输入密码完成 - (void)didInpuPwdOkFun { KWeakSelf mainBlock(^{ if(ksharedAppDelegate.isCloudPhoneModeAndPrivacyModeOpenType){ [weakSelf queryWebRtcMsgFun:YES]; } //查询掌机是否在线 //[weakSelf checkBoxStatusFun]; }); } #pragma mark 获取到云机系统相关基本信息 //- (void)getCouldPhoneSysInfoFun:(NSNotification*)not //{//弹框流程 优先级:强制盒子更新弹窗 > APP版本更新弹窗 > 通知公告弹窗 // // if(didGetSysInfoType){//弹框流程已经走过 // return; // } // // didGetSysInfoType = YES; // // if(ksharedAppDelegate.isNeedShowImageNewType){//强制盒子更新弹窗 // mainBlock(^{ // [self showImageViewRenewTipViewFun]; // }); // // } //} #pragma mark - 查询掌机情况 //1、掌机Gbox助手干掉 - 客户端去掉容器开关机检测功能 20231119 //- (void)checkBoxStatusFun //{ // NSMutableDictionary *paraDict = [NSMutableDictionary dictionary]; // [paraDict setValue:@2 forKey:@"type"]; // // KWeakSelf // [[netWorkManager shareInstance] CommonPostCallBackCode:queryBoxStatus Parameters:paraDict success:^(id _Nonnull responseObject) { // // boxCheckStatusModel *model = [[boxCheckStatusModel alloc] initWithDictionary:responseObject error:nil]; // // if (model && model.data && model.status == 0) { // if(model.data.containerAgentStatus == 0){ // [weakSelf showAlertByBoxCloseStateFun]; // } // } // else // { // // } // // } failure:^(NSError * _Nonnull error) { // HLog(@"%@", error); // }]; //} #pragma mark 显示云机系统已经关闭 - (void)showAlertByBoxCloseStateFun { KWeakSelf /*弹窗提示*/ ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"cloudPhone_system_state_close_title",nil) msg:NSLocalizedString(@"cloudPhone_system_state_close_tip",nil) imageStr:@"" cancelTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil) okTitle:@"" isOkBtnHighlight:NO didClickOk:^{ } didClickCancel:^{ }]; nextVC.modalPresentationStyle = UIModalPresentationCustom; [self presentViewController:nextVC animated:YES completion:^{ nextVC.view.superview.backgroundColor = [UIColor clearColor]; }]; } @end