cloudPhoneViewController.m 14 KB

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