cloudPhoneViewController.m 15 KB

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