cloudPhoneViewController.m 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  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. _cloudPhoneSetV = [cloudPhoneSetView new];
  143. [ksharedAppDelegate.window addSubview:_cloudPhoneSetV];
  144. [_cloudPhoneSetV mas_makeConstraints:^(MASConstraintMaker *make) {
  145. make.left.mas_equalTo(0);
  146. make.right.mas_equalTo(0);
  147. make.top.mas_equalTo(0);
  148. make.bottom.mas_equalTo(0);
  149. }];
  150. KWeakSelf
  151. _cloudPhoneSetV.didClickButtonFun = ^(NSInteger tag) {
  152. if (tag == 10) {//重启
  153. [weakSelf didClickRestartFun];
  154. }
  155. else if (tag == 11){//恢复出厂
  156. [weakSelf RestoreFactoryingFun];
  157. }
  158. };
  159. }
  160. break;
  161. case 2:
  162. {
  163. BOOL isTVShowType = ksharedAppDelegate.TvStatusMod.isTVShowType;
  164. if(isTVShowType){//关闭全屏屏
  165. [HWDataManager setBoolWithKey:Consn_player_full_screen_show value:NO];
  166. }
  167. BOOL fullscreenType = [HWDataManager getBoolWithKey:Consn_player_full_screen_show];
  168. //重新设置分辨率
  169. if(fullscreenType){
  170. NSString *commandStr = [RCCommandHelp commondToSetFullScreenPhoneSize];
  171. [[webSocketManager shareInstance] send_data:commandStr];
  172. }
  173. else{
  174. if ((ksharedAppDelegate.couldPhone_W_PHONE == 720 && ksharedAppDelegate.couldPhone_H_PHONE == 1280)
  175. || (ksharedAppDelegate.couldPhone_W_PHONE == 1080 && ksharedAppDelegate.couldPhone_H_PHONE == 1920)) {//云机可能存在的分辨率
  176. }
  177. else{
  178. NSString *commondStr = @"{\"data\":{\"height\":1920,\"width\":1080},\"type\":\"setPhoneSize\"}";
  179. [[webSocketManager shareInstance] send_data:commondStr];
  180. }
  181. }
  182. PlayerViewController *vc = [PlayerViewController new];
  183. [self pushViewController:vc animated:YES];
  184. if(ksharedAppDelegate.TvStatusMod.isTVShowType){
  185. [[iToast makeText:NSLocalizedString(@"tv_p2p_ing",nil)] show];
  186. }
  187. }
  188. break;
  189. default:
  190. break;
  191. }
  192. }
  193. #pragma mark 点击了重启空间
  194. - (void)didClickRestartFun
  195. {
  196. KWeakSelf
  197. /*弹窗提示重启*/
  198. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_restart_phone_tips",nil)
  199. msg:nil
  200. imageStr:nil
  201. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  202. okTitle:NSLocalizedString(@"my_set_no_restart_phone_btn_ok",nil) isOkBtnHighlight:NO
  203. didClickOk:^{
  204. [weakSelf sureToRestartCloudPhoneFun];
  205. } didClickCancel:^{
  206. }];
  207. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  208. [self presentViewController:nextVC animated:YES completion:^{
  209. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  210. }];
  211. }
  212. #pragma mark 确认重启云机
  213. - (void)sureToRestartCloudPhoneFun{
  214. // /*重启云手机*/
  215. // 通过指令通道发送 {"type":"reboot"}
  216. [[webSocketManager shareInstance] needToRebootFun];
  217. //提示语
  218. [[iToast makeText:NSLocalizedString(@"player_link_rebooting_Tips",nil)] show];
  219. }
  220. #pragma mark 点击恢复出厂
  221. - (void)RestoreFactoryAleartFun
  222. {
  223. KWeakSelf
  224. /*弹窗提示恢复出厂*/
  225. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_Restore_Factory_tips",nil)
  226. msg:NSLocalizedString(@"my_set_no_Restore_Factory_msg",nil)
  227. imageStr:@"icon_Restore_Factory_big"
  228. cancelTitle:NSLocalizedString(@"my_set_TVP2P_Open_sure",nil)
  229. okTitle:NSLocalizedString(@"other_cancel",nil) isOkBtnHighlight:YES
  230. didClickOk:^{
  231. } didClickCancel:^{
  232. //点击确定
  233. [weakSelf gotoResetFun];
  234. }];
  235. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  236. [self presentViewController:nextVC animated:YES completion:^{
  237. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  238. }];
  239. }
  240. #pragma mark 点击了恢复出厂
  241. - (void)gotoResetFun
  242. {
  243. [[webSocketManager shareInstance] needToResetFun];
  244. [self RestoreFactoryingFun];
  245. }
  246. #pragma mark 恢复出厂中
  247. - (void)RestoreFactoryingFun
  248. {
  249. KWeakSelf
  250. /*弹窗提示恢复出厂*/
  251. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_Restore_Factorying_tips",nil)
  252. msg:NSLocalizedString(@"my_set_no_Restore_Factorying_msg",nil)
  253. imageStr:nil
  254. cancelTitle:NSLocalizedString(@"my_set_no_Restore_Factorying",nil)
  255. okTitle:nil
  256. isOkBtnHighlight:NO
  257. didClickOk:^{
  258. [weakSelf RestoreFactoryCompleteFun];
  259. } didClickCancel:^{
  260. }];
  261. [nextVC setButtonCountdownFun:180];//90
  262. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  263. [self presentViewController:nextVC animated:YES completion:^{
  264. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  265. }];
  266. }
  267. #pragma mark 恢复出厂倒计时结束
  268. - (void)RestoreFactoryCompleteFun
  269. {
  270. KWeakSelf
  271. //瑞云发起重连
  272. NSString *snStr = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.changeSn;
  273. if(snStr){
  274. [[connectDeviceManager shareInstance] getThridMsgBySN:snStr needReconnect:YES didNetEnd:^(NSInteger didSuc) {
  275. if(didSuc){
  276. }
  277. else{
  278. [weakSelf RestoreFactoryCompleteFun];
  279. return;
  280. }
  281. }];
  282. }
  283. /*弹窗提示恢复出厂*/
  284. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_Restore_Factory_ok_tips",nil)
  285. msg:@""//NSLocalizedString(@"my_set_no_Restore_Factory_ok_msg",nil)
  286. imageStr:nil
  287. cancelTitle:NSLocalizedString(@"my_set_no_Restore_FactoryOK",nil)
  288. okTitle:nil
  289. isOkBtnHighlight:NO
  290. didClickOk:^{
  291. } didClickCancel:^{
  292. }];
  293. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  294. [self presentViewController:nextVC animated:YES completion:^{
  295. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  296. }];
  297. }
  298. - (void)viewWillAppear:(BOOL)animated{
  299. [super viewWillAppear:animated];
  300. }
  301. - (void)viewWillDisappear:(BOOL)animated{
  302. [super viewWillDisappear:animated];
  303. }
  304. - (void)pushViewController:(UIViewController*)vc animated:(BOOL)animated
  305. {
  306. [self.navigationController pushViewController:vc animated:animated];
  307. }
  308. @end