123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536 |
- //
- // cloudPhoneViewController.m
- // Private-X
- //
- // Created by xd h on 2024/6/20.
- //
- #import "cloudPhoneViewController.h"
- #import "cloudPhoneSetView.h"
- #import "audioPlayingView.h"
- #import "DFPlayer.h"
- #import "audioPlayerViewController.h"
- #import "webRtcMsgModel.h"
- #import "webRtcPlayerViewController.h"
- @interface cloudPhoneViewController ()
- @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];
-
- [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 = 1.0;
- if(isSmallPhoneType){
- adjustSmallScale = 0.9;
- }
-
- CGFloat imageTopY = 54.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 *midTopTipImageStr = @"cloudPhone_topTip_img_cs";
- //欢迎
- //en-US 英文 ja-JP 日文
- NSArray *arLanguages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"];
- NSLog(@"arLanguages:%@",arLanguages);
- ///获取设备当前地区的代码和APP语言环境
- NSString *languageCode = [NSLocale preferredLanguages][0];
-
- //目前支持 中文(简体 繁体) 英文 日语
- if([languageCode rangeOfString:@"zh-Hans"].location != NSNotFound)
- {
- midTopTipImageStr = @"cloudPhone_topTip_img_cs";
- }
- else if([languageCode rangeOfString:@"zh-Hant"].location != NSNotFound)
- {
- midTopTipImageStr = @"cloudPhone_topTip_img_ct";
- }
- else{
- midTopTipImageStr = @"cloudPhone_topTip_img_en";
- }
-
- //提示文字图片
- UIImageView *midTopTipImageV = [UIImageView new];
- midTopTipImageV.image = [UIImage imageNamed:midTopTipImageStr];
- [midImageV addSubview:midTopTipImageV];
-
- [midTopTipImageV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(282*WAUTOSCALE*adjustSmallScale);
- make.height.mas_equalTo(84*WAUTOSCALE*adjustSmallScale);
- make.centerX.mas_equalTo(0);
- make.top.equalTo(midImageV.mas_top).offset(64);
- }];
-
- //进入云机
- 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)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor];
- gl.locations = @[@(0), @(1.0f)];
-
- [enterCloudPhoneButton.layer addSublayer:gl];
- [enterCloudPhoneButton setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
- //[enterCloudPhoneButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:(UIControlEventTouchUpInside)];
- [enterCloudPhoneButton setTitle:NSLocalizedString(@"cloudPhone_enter_tip",nil) forState:(UIControlStateNormal)];
- [enterCloudPhoneButton.titleLabel setFont:[UIFont systemFontOfSize:16.f]];
- [enterCloudPhoneButton.layer setCornerRadius:21.f];
- enterCloudPhoneButton.layer.borderWidth = 1.5;
- enterCloudPhoneButton.layer.borderColor = [UIColor whiteColor].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(-60);
- }];
-
- //扩大金融云机范围按钮
- 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"];
-
- }
- 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
- //瑞云发起重连
- //[[connectDeviceManager shareInstance] onConnectFun];
-
- /*弹窗提示恢复出厂*/
- 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 handelAudioPlayingViewFun];
- }
- - (void)viewWillDisappear:(BOOL)animated{
- [super viewWillDisappear:animated];
-
- }
- - (void)pushViewController:(UIViewController*)vc animated:(BOOL)animated
- {
- [self.navigationController pushViewController:vc animated:animated];
- }
- #pragma mark 处理音频播放中的视图状态
- - (void)handelAudioPlayingViewFun
- {
- audioPlayingView * audioPlayingV = [audioPlayingView sharedInstance];
-
- if([DFPlayer sharedPlayer].state == DFPlayerStateBuffering
- ||[DFPlayer sharedPlayer].state == DFPlayerStatePlaying
- ||[DFPlayer sharedPlayer].state == DFPlayerStatePause){//播放中
-
- [self showAudioPlayingViewFun];
- }
- else{
- [self hideAudioPlayingViewFun];
- }
-
- KWeakSelf
- audioPlayingV.didClickButtonFun = ^(NSInteger tag) {
- if(tag == 1){
- [weakSelf hideAudioPlayingViewFun];
- }
- else if(tag == 5){
- [weakSelf AudioPlayingGotoAudioPlayerVCFun];
- }
- };
- }
- - (void)AudioPlayingGotoAudioPlayerVCFun{
- audioPlayerViewController *vc = [audioPlayerViewController new];
- vc.isfirstEnterType = NO;
- [self.navigationController pushViewController:vc animated:YES];
- }
-
- #pragma mark 显示音频播放中的视图
- - (void)showAudioPlayingViewFun
- {
- audioPlayingView * audioPlayingV = [audioPlayingView sharedInstance];
- [self.view addSubview:audioPlayingV];
-
- if([DFPlayer sharedPlayer].state == DFPlayerStatePlaying){
- [audioPlayingV startRotatingImage];
- }
- else if ([DFPlayer sharedPlayer].state == DFPlayerStatePause){
- [audioPlayingV stopRotatingImage];
- }
-
- [audioPlayingV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(49);
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(-TABBARHEIGHT);
- }];
-
- }
- #pragma mark 隐藏音频播放中的视图
- - (void)hideAudioPlayingViewFun
- {
- // audioPlayingView * audioPlayingV = [audioPlayingView sharedInstance];
- // [audioPlayingV removeFromSuperview];
- }
- #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;
- }
- [cachesFileManager writeLogsWithMsg:@"webRtcPlayer push webRtcPlayerVC"];
-
- 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;
- ksharedAppDelegate.needToPushWebRtcVCType = NO;
- });
- }
- #pragma mark 输入密码完成
- - (void)didInpuPwdOkFun
- {
- KWeakSelf
- mainBlock(^{
- if(ksharedAppDelegate.isCloudPhoneModeAndPrivacyModeOpenType
- || ksharedAppDelegate.needToPushWebRtcVCType){
- [weakSelf queryWebRtcMsgFun:YES];
- }
- });
- }
- @end
|