cloudPhoneViewController.m 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. //
  2. // cloudPhoneViewController.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2024/6/20.
  6. //
  7. #import "cloudPhoneViewController.h"
  8. #import "cloudPhoneSetView.h"
  9. #import "PlayerViewController.h"
  10. #import "audioPlayingView.h"
  11. #import "DFPlayer.h"
  12. #import "audioPlayerViewController.h"
  13. @interface cloudPhoneViewController ()
  14. @property (nonatomic,strong) cloudPhoneSetView *cloudPhoneSetV;
  15. @end
  16. @implementation cloudPhoneViewController
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. // Do any additional setup after loading the view.
  20. [self.view setBackgroundColor:HWF5F7FAColor];
  21. [self.toolBar setHidden:YES];
  22. [self.navigationBar setHidden:YES];
  23. [self.navBarBGView setHidden:YES];
  24. [self drawAnyView];
  25. }
  26. - (void)drawAnyView{
  27. //顶底底部图片
  28. UIImageView *topImageV = [UIImageView new];
  29. topImageV.userInteractionEnabled = YES;
  30. topImageV.image = [UIImage imageNamed:@"cloudPhone_bg"];
  31. [self.view addSubview:topImageV];
  32. [topImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  33. make.top.mas_equalTo(0);
  34. make.left.mas_equalTo(0);
  35. make.right.mas_equalTo(0);
  36. make.bottom.mas_equalTo(0);
  37. }];
  38. CGFloat width = SCREEN_W;
  39. CGFloat height = SCREEN_H;
  40. BOOL isSmallPhoneType = NO;
  41. if(width == 375 && height == 667){
  42. isSmallPhoneType = YES;
  43. }
  44. CGFloat adjustSmallScale = 1.0;
  45. if(isSmallPhoneType){
  46. adjustSmallScale = 0.9;
  47. }
  48. CGFloat imageTopY = 54.0;
  49. if(isSmallPhoneType){
  50. imageTopY = 20.0;
  51. }
  52. //设置按钮
  53. UIButton *setButton = [[UIButton alloc] init];
  54. //[setButton setBackgroundImage:[UIImage imageNamed:@"cloudPhone_set"] forState:UIControlStateNormal];
  55. [setButton setImage:[UIImage imageNamed:@"cloudPhone_set"] forState:UIControlStateNormal];
  56. setButton.tag = 1;
  57. [setButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  58. [self.view addSubview:setButton];
  59. //setButton.backgroundColor = [UIColor greenColor];
  60. [setButton mas_makeConstraints:^(MASConstraintMaker *make) {
  61. make.top.mas_equalTo(imageTopY);
  62. if(isSmallPhoneType){
  63. make.right.mas_equalTo(-5);
  64. }
  65. else{
  66. make.right.mas_equalTo(-16);
  67. }
  68. make.width.mas_equalTo(50);
  69. make.height.mas_equalTo(50);
  70. // make.top.mas_equalTo(imageTopY);
  71. // make.right.mas_equalTo(-16);
  72. // make.width.mas_equalTo(24);
  73. // make.height.mas_equalTo(24);
  74. }];
  75. //中间图片
  76. UIImageView *midImageV = [UIImageView new];
  77. midImageV.userInteractionEnabled = YES;
  78. midImageV.image = [UIImage imageNamed:@"cloudPhone_mid_img"];
  79. [self.view addSubview:midImageV];
  80. [midImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  81. make.width.mas_equalTo(326*WAUTOSCALE*adjustSmallScale);
  82. make.height.mas_equalTo(608*WAUTOSCALE*adjustSmallScale);
  83. make.centerX.mas_equalTo(0);
  84. make.centerY.mas_equalTo(-10);
  85. }];
  86. NSString *midTopTipImageStr = @"cloudPhone_topTip_img_cs";
  87. //欢迎
  88. //en-US 英文 ja-JP 日文
  89. NSArray *arLanguages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"];
  90. NSLog(@"arLanguages:%@",arLanguages);
  91. ///获取设备当前地区的代码和APP语言环境
  92. NSString *languageCode = [NSLocale preferredLanguages][0];
  93. //目前支持 中文(简体 繁体) 英文 日语
  94. if([languageCode rangeOfString:@"zh-Hans"].location != NSNotFound)
  95. {
  96. midTopTipImageStr = @"cloudPhone_topTip_img_cs";
  97. }
  98. else if([languageCode rangeOfString:@"zh-Hant"].location != NSNotFound)
  99. {
  100. midTopTipImageStr = @"cloudPhone_topTip_img_ct";
  101. }
  102. else{
  103. midTopTipImageStr = @"cloudPhone_topTip_img_en";
  104. }
  105. //提示文字图片
  106. UIImageView *midTopTipImageV = [UIImageView new];
  107. midTopTipImageV.image = [UIImage imageNamed:midTopTipImageStr];
  108. [midImageV addSubview:midTopTipImageV];
  109. [midTopTipImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  110. make.width.mas_equalTo(282*WAUTOSCALE*adjustSmallScale);
  111. make.height.mas_equalTo(84*WAUTOSCALE*adjustSmallScale);
  112. make.centerX.mas_equalTo(0);
  113. make.top.equalTo(midImageV.mas_top).offset(64);
  114. }];
  115. //进入云机
  116. UIButton*enterCloudPhoneButton = [[UIButton alloc] init];
  117. CGFloat w_btn = SCREEN_W - 15*2 - 50*2;
  118. // gradient
  119. CAGradientLayer *gl = [CAGradientLayer layer];
  120. gl.frame = CGRectMake(0,0,w_btn,44.f);
  121. gl.startPoint = CGPointMake(0, 0.5);
  122. gl.endPoint = CGPointMake(0.97, 0.5);
  123. gl.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor];
  124. gl.locations = @[@(0), @(1.0f)];
  125. [enterCloudPhoneButton.layer addSublayer:gl];
  126. [enterCloudPhoneButton setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
  127. //[enterCloudPhoneButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:(UIControlEventTouchUpInside)];
  128. [enterCloudPhoneButton setTitle:NSLocalizedString(@"cloudPhone_enter_tip",nil) forState:(UIControlStateNormal)];
  129. [enterCloudPhoneButton.titleLabel setFont:[UIFont systemFontOfSize:16.f]];
  130. [enterCloudPhoneButton.layer setCornerRadius:21.f];
  131. enterCloudPhoneButton.layer.borderWidth = 1.5;
  132. enterCloudPhoneButton.layer.borderColor = [UIColor whiteColor].CGColor;
  133. enterCloudPhoneButton.clipsToBounds = YES;
  134. //enterCloudPhoneButton.tag = 2;
  135. [midImageV addSubview:enterCloudPhoneButton];
  136. [enterCloudPhoneButton mas_makeConstraints:^(MASConstraintMaker *make) {
  137. make.width.mas_equalTo(w_btn);
  138. make.height.mas_equalTo(42);
  139. make.centerX.mas_equalTo(0);
  140. make.bottom.equalTo(midImageV.mas_bottom).offset(-60);
  141. }];
  142. //扩大金融云机范围按钮
  143. UIButton *bigButton = [[UIButton alloc] init];
  144. bigButton.tag = 2;
  145. [bigButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  146. [self.view addSubview:bigButton];
  147. //bigButton.backgroundColor = [UIColor greenColor];
  148. [bigButton mas_makeConstraints:^(MASConstraintMaker *make) {
  149. make.top.equalTo(midImageV.mas_top).offset(0);
  150. make.right.equalTo(midImageV.mas_right).offset(0);
  151. make.left.equalTo(midImageV.mas_left).offset(0);
  152. make.bottom.equalTo(midImageV.mas_bottom).offset(0);
  153. }];
  154. }
  155. #pragma mark 点击按钮
  156. - (void)didClickButtonFun:(UIButton*)but
  157. {
  158. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  159. {
  160. [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
  161. return;
  162. }
  163. if (!ksharedAppDelegate.isWebSockLinkOKAginType) {//未链接
  164. [[iToast makeText:NSLocalizedString(@"box_link_error_show_tip",nil)] show];
  165. return;
  166. }
  167. NSInteger tag = but.tag;
  168. HLog(@"%ld",tag);
  169. switch (tag) {
  170. case 1:
  171. {
  172. //数据埋点
  173. [[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"Cloud_settings"];
  174. _cloudPhoneSetV = [cloudPhoneSetView new];
  175. [ksharedAppDelegate.window addSubview:_cloudPhoneSetV];
  176. [_cloudPhoneSetV mas_makeConstraints:^(MASConstraintMaker *make) {
  177. make.left.mas_equalTo(0);
  178. make.right.mas_equalTo(0);
  179. make.top.mas_equalTo(0);
  180. make.bottom.mas_equalTo(0);
  181. }];
  182. KWeakSelf
  183. _cloudPhoneSetV.didClickButtonFun = ^(NSInteger tag) {
  184. if (tag == 10) {//重启
  185. [weakSelf didClickRestartFun];
  186. }
  187. else if (tag == 11){//恢复出厂
  188. [weakSelf RestoreFactoryAleartFun];
  189. }
  190. };
  191. }
  192. break;
  193. case 2:
  194. {
  195. //[self checkFullScreenWithTVShowStateFun];
  196. PlayerViewController *vc = [PlayerViewController new];
  197. [self pushViewController:vc animated:YES];
  198. if(ksharedAppDelegate.TvStatusMod.isTVShowType){
  199. [[iToast makeText:NSLocalizedString(@"tv_p2p_ing",nil)] show];
  200. }
  201. //数据埋点
  202. [[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"Cloud_enter"];
  203. }
  204. break;
  205. default:
  206. break;
  207. }
  208. }
  209. #pragma mark 点击了重启空间
  210. - (void)didClickRestartFun
  211. {
  212. KWeakSelf
  213. /*弹窗提示重启*/
  214. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_restart_phone_tips",nil)
  215. msg:@""
  216. imageStr:@""
  217. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  218. okTitle:NSLocalizedString(@"my_set_no_restart_phone_btn_ok",nil) isOkBtnHighlight:NO
  219. didClickOk:^{
  220. [weakSelf sureToRestartCloudPhoneFun];
  221. } didClickCancel:^{
  222. }];
  223. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  224. [self presentViewController:nextVC animated:YES completion:^{
  225. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  226. }];
  227. }
  228. #pragma mark 确认重启云机
  229. - (void)sureToRestartCloudPhoneFun{
  230. // /*重启云手机*/
  231. // 通过指令通道发送 {"type":"reboot"}
  232. [[webSocketManager shareInstance] needToRebootFun];
  233. //提示语
  234. [[iToast makeText:NSLocalizedString(@"player_link_rebooting_Tips",nil)] show];
  235. }
  236. #pragma mark 点击恢复出厂
  237. - (void)RestoreFactoryAleartFun
  238. {
  239. KWeakSelf
  240. /*弹窗提示恢复出厂*/
  241. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_Restore_Factory_tips",nil)
  242. msg:NSLocalizedString(@"my_set_no_Restore_Factory_msg",nil)
  243. imageStr:@"icon_Restore_Factory_big"
  244. cancelTitle:NSLocalizedString(@"my_set_TVP2P_Open_sure",nil)
  245. okTitle:NSLocalizedString(@"other_cancel",nil) isOkBtnHighlight:YES
  246. didClickOk:^{
  247. } didClickCancel:^{
  248. //点击确定
  249. [weakSelf gotoResetFun];
  250. }];
  251. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  252. [self presentViewController:nextVC animated:YES completion:^{
  253. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  254. }];
  255. }
  256. #pragma mark 点击了恢复出厂
  257. - (void)gotoResetFun
  258. {
  259. [[webSocketManager shareInstance] needToResetFun];
  260. [self RestoreFactoryingFun];
  261. }
  262. #pragma mark 恢复出厂中
  263. - (void)RestoreFactoryingFun
  264. {
  265. KWeakSelf
  266. /*弹窗提示恢复出厂*/
  267. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_Restore_Factorying_tips",nil)
  268. msg:NSLocalizedString(@"my_set_no_Restore_Factorying_msg",nil)
  269. imageStr:@""
  270. cancelTitle:NSLocalizedString(@"my_set_no_Restore_Factorying",nil)
  271. okTitle:@""
  272. isOkBtnHighlight:NO
  273. didClickOk:^{
  274. [weakSelf RestoreFactoryCompleteFun];
  275. } didClickCancel:^{
  276. }];
  277. [nextVC setButtonCountdownFun:180];//90
  278. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  279. [self presentViewController:nextVC animated:YES completion:^{
  280. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  281. }];
  282. }
  283. #pragma mark 恢复出厂倒计时结束
  284. - (void)RestoreFactoryCompleteFun
  285. {
  286. //KWeakSelf
  287. //瑞云发起重连
  288. //[[connectDeviceManager shareInstance] onConnectFun];
  289. /*弹窗提示恢复出厂*/
  290. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_Restore_Factory_ok_tips",nil)
  291. msg:@""
  292. imageStr:@""
  293. cancelTitle:NSLocalizedString(@"my_set_no_Restore_FactoryOK",nil)
  294. okTitle:@""
  295. isOkBtnHighlight:NO
  296. didClickOk:^{
  297. } didClickCancel:^{
  298. }];
  299. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  300. [self presentViewController:nextVC animated:YES completion:^{
  301. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  302. }];
  303. }
  304. - (void)viewWillAppear:(BOOL)animated{
  305. [super viewWillAppear:animated];
  306. [self handelAudioPlayingViewFun];
  307. }
  308. - (void)viewWillDisappear:(BOOL)animated{
  309. [super viewWillDisappear:animated];
  310. }
  311. - (void)pushViewController:(UIViewController*)vc animated:(BOOL)animated
  312. {
  313. [self.navigationController pushViewController:vc animated:animated];
  314. }
  315. #pragma mark 处理音频播放中的视图状态
  316. - (void)handelAudioPlayingViewFun
  317. {
  318. audioPlayingView * audioPlayingV = [audioPlayingView sharedInstance];
  319. if([DFPlayer sharedPlayer].state == DFPlayerStateBuffering
  320. ||[DFPlayer sharedPlayer].state == DFPlayerStatePlaying
  321. ||[DFPlayer sharedPlayer].state == DFPlayerStatePause){//播放中
  322. [self showAudioPlayingViewFun];
  323. }
  324. else{
  325. [self hideAudioPlayingViewFun];
  326. }
  327. KWeakSelf
  328. audioPlayingV.didClickButtonFun = ^(NSInteger tag) {
  329. if(tag == 1){
  330. [weakSelf hideAudioPlayingViewFun];
  331. }
  332. else if(tag == 5){
  333. [weakSelf AudioPlayingGotoAudioPlayerVCFun];
  334. }
  335. };
  336. }
  337. - (void)AudioPlayingGotoAudioPlayerVCFun{
  338. audioPlayerViewController *vc = [audioPlayerViewController new];
  339. vc.isfirstEnterType = NO;
  340. [self.navigationController pushViewController:vc animated:YES];
  341. }
  342. #pragma mark 显示音频播放中的视图
  343. - (void)showAudioPlayingViewFun
  344. {
  345. audioPlayingView * audioPlayingV = [audioPlayingView sharedInstance];
  346. [self.view addSubview:audioPlayingV];
  347. [audioPlayingV mas_makeConstraints:^(MASConstraintMaker *make) {
  348. make.height.mas_equalTo(49);
  349. make.left.mas_equalTo(0);
  350. make.right.mas_equalTo(0);
  351. make.bottom.mas_equalTo(-TABBARHEIGHT);
  352. }];
  353. }
  354. #pragma mark 隐藏音频播放中的视图
  355. - (void)hideAudioPlayingViewFun
  356. {
  357. // audioPlayingView * audioPlayingV = [audioPlayingView sharedInstance];
  358. // [audioPlayingV removeFromSuperview];
  359. }
  360. @end