AboutViewController.m 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. //
  2. // AboutViewController.m
  3. // VclustersGemini
  4. //
  5. // Created by APPLE on 2020/2/24.
  6. // Copyright © 2020 APPLE. All rights reserved.
  7. //
  8. #import "AboutViewController.h"
  9. #import "HaveNewVersionView.h"
  10. #import "HWVersionModel.h"
  11. #import "iPhone.h"
  12. #import "CloudPhoneAPI.h"
  13. #import <MJExtension.h>
  14. #import "CustomerWebViewController.h"
  15. #import "netWorkManager.h"
  16. #import "SuperModel.h"
  17. #import "allVersionView.h"
  18. #import "baseTableViewCell.h"
  19. @interface AboutViewController ()<UITableViewDelegate,UITableViewDataSource>
  20. @property (nonatomic, strong) UIButton *checUpdatekBtn;
  21. // gradient
  22. @property (nonatomic, strong)CAGradientLayer *gl_checkVersonBut;
  23. @property (nonatomic, strong) UIButton *ruleBtn;
  24. @property (nonatomic, strong) UIButton *privateBtn;
  25. @property (nonatomic, strong) HWVersionModel *versionModel;
  26. @property (nonatomic, strong) UITableView* tableView;
  27. @property (nonatomic, strong) NSArray* msgTitleArr;
  28. @property(nonatomic,strong)couldphoneSysInfoModel *couldphoneSysInfoMod;
  29. @end
  30. @implementation AboutViewController
  31. - (void)viewDidLoad {
  32. [super viewDidLoad];
  33. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getCouldPhoneBaseInfoFun:) name:getCouldPhoneSysInfoNotification object:nil];
  34. [self drawAnyView];
  35. //数据埋点
  36. [[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"Version_information"];
  37. if(_getSysInfo){
  38. _getSysInfo();
  39. }
  40. }
  41. - (void)viewDidAppear:(BOOL)animated {
  42. [super viewDidAppear:animated];
  43. }
  44. - (void)drawAnyView
  45. {
  46. [self.view setBackgroundColor:HWF5F7FAColor];
  47. self.navBarBGView.hidden = NO;
  48. [self.navigationBar setHidden:YES];
  49. [self.toolBar setHidden:YES];
  50. [self.titleLabel setText:NSLocalizedString(@"app_update_title",nil)];
  51. UIImageView *topImage = [[UIImageView alloc] init];
  52. [topImage setImage:[self getAppIcon]];
  53. topImage.userInteractionEnabled = YES;
  54. [self.view addSubview:topImage];
  55. [topImage mas_makeConstraints:^(MASConstraintMaker *make) {
  56. make.width.mas_equalTo(72.f);
  57. make.height.mas_equalTo(72.f);
  58. make.centerX.equalTo(self.view.mas_centerX);
  59. make.top.equalTo(self.navBarBGView.mas_bottom).offset(60.f);
  60. }];
  61. [topImage.layer setCornerRadius:15.f];
  62. topImage.clipsToBounds = YES;
  63. UITapGestureRecognizer *tap5 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTap5NumFun)];
  64. tap5.numberOfTapsRequired = 5;
  65. [topImage addGestureRecognizer:tap5];
  66. /*app名*/
  67. UILabel *appName = [[UILabel alloc] init];
  68. [appName setBackgroundColor:[UIColor clearColor]];
  69. [appName setTextColor:HW333333Color];
  70. [appName setFont:[UIFont boldSystemFontOfSize:16.f]];
  71. [appName setTextAlignment:(NSTextAlignmentCenter)];
  72. [appName setText:[NSString stringWithFormat:@"%@",[iPhone appBundleName]]];
  73. //[appName setText:[NSString stringWithFormat:@"%@",@"Private- X"]];
  74. [self.view addSubview:appName];
  75. [appName mas_makeConstraints:^(MASConstraintMaker *make) {
  76. make.top.equalTo(topImage.mas_bottom).offset(20.f);
  77. make.right.mas_equalTo(-27.f);
  78. make.left.mas_equalTo(27.f);
  79. make.height.mas_equalTo(22.f);
  80. }];
  81. /*版本号*/
  82. // UILabel *versionLabel = [[UILabel alloc] init];
  83. // [versionLabel setBackgroundColor:[UIColor clearColor]];
  84. // [versionLabel setTextColor:HW333333Color];
  85. // [versionLabel setFont:[UIFont systemFontOfSize:13.f]];
  86. // [versionLabel setTextAlignment:(NSTextAlignmentCenter)];
  87. // NSString *vers = [iPhone appVersion];
  88. // [versionLabel setText:[NSString stringWithFormat:@"V%@",vers]];
  89. // [self.view addSubview:versionLabel];
  90. // [versionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  91. // make.top.equalTo(appName.mas_bottom).offset(10.f);
  92. // make.right.mas_equalTo(-27.f);
  93. // make.left.mas_equalTo(27.f);
  94. // make.height.mas_equalTo(20.f);
  95. // }];
  96. /*开始体验*/
  97. _checUpdatekBtn = [[UIButton alloc] init];
  98. _checUpdatekBtn.frame = CGRectMake(0, 0, 160.f, 48.f);
  99. // gradient
  100. _gl_checkVersonBut = [CAGradientLayer layer];
  101. _gl_checkVersonBut.frame = CGRectMake(0,0,160.f,48.f);
  102. _gl_checkVersonBut.startPoint = CGPointMake(0, 0.5);
  103. _gl_checkVersonBut.endPoint = CGPointMake(1, 0.5);
  104. _gl_checkVersonBut.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor];
  105. _gl_checkVersonBut.locations = @[@(0), @(1.0f)];
  106. [_checUpdatekBtn.layer addSublayer:_gl_checkVersonBut];
  107. [_checUpdatekBtn addTarget:self action:@selector(versionCheckBtnClick) forControlEvents:(UIControlEventTouchUpInside)];
  108. [_checUpdatekBtn setTitle:NSLocalizedString(@"app_update_check",nil) forState:(UIControlStateNormal)];
  109. [_checUpdatekBtn setTitle:NSLocalizedString(@"app_update_last_version",nil) forState:(UIControlStateDisabled)];
  110. [_checUpdatekBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
  111. [_checUpdatekBtn.titleLabel setFont:[UIFont systemFontOfSize:16.f]];
  112. [_checUpdatekBtn.layer setCornerRadius:8.f];
  113. _checUpdatekBtn.clipsToBounds = YES;
  114. [self.view addSubview:_checUpdatekBtn];
  115. [_checUpdatekBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  116. make.centerX.equalTo(self.view.mas_centerX);
  117. make.width.mas_equalTo(160.f);
  118. //make.top.equalTo(versionLabel.mas_bottom).offset(25.f);
  119. make.top.equalTo(appName.mas_bottom).offset(25.f);
  120. make.height.mas_equalTo(48.f);
  121. }];
  122. _checUpdatekBtn.hidden = YES;
  123. //1.4.3 新加一个tableview 显示镜像相关信息
  124. //用户协议 隐私协议 app当前版本 系统当前版本 系统待更新版本
  125. _msgTitleArr = @[NSLocalizedString(@"app_update_use_deal",nil)
  126. ,NSLocalizedString(@"app_update_private",nil)
  127. ,NSLocalizedString(@"app_version_current",nil)
  128. ,NSLocalizedString(@"system_version_current",nil)
  129. ,NSLocalizedString(@"asystem_version_wait_update",nil)];
  130. [self.view addSubview:self.tableView];
  131. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  132. make.left.mas_equalTo(15.f);
  133. make.right.mas_equalTo(-15.f);
  134. //make.top.equalTo(_checUpdatekBtn.mas_bottom).offset(25.f);
  135. make.top.equalTo(_checUpdatekBtn.mas_top).offset(15.f);
  136. make.height.mas_equalTo(240.f);
  137. }];
  138. // UIButton *privateBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  139. // self.privateBtn = privateBtn;
  140. // privateBtn.titleLabel.font = [UIFont systemFontOfSize:13.f];
  141. // [privateBtn setTitle:NSLocalizedString(@"app_update_private",nil) forState:UIControlStateNormal];
  142. // [privateBtn setTitleColor:HW13B2EBColor forState:UIControlStateNormal];
  143. // [privateBtn setBackgroundColor:[UIColor clearColor]];
  144. // [privateBtn addTarget:self action:@selector(privateBtnClick) forControlEvents:UIControlEventTouchUpInside];
  145. // privateBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  146. // [self.view addSubview:privateBtn];
  147. // [privateBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  148. // make.bottom.mas_equalTo(-80-AdaptTabHeight);
  149. // //make.width.mas_equalTo(55);
  150. // make.width.mas_equalTo(130);
  151. // make.height.mas_equalTo(38);
  152. // make.left.equalTo(self.view.mas_centerX).offset(6);
  153. // }];
  154. //
  155. // UIButton *ruleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  156. // self.ruleBtn = ruleBtn;
  157. // ruleBtn.titleLabel.font = [UIFont systemFontOfSize:13.f];
  158. // [ruleBtn setTitle:NSLocalizedString(@"app_update_use_deal",nil) forState:UIControlStateNormal];
  159. // [ruleBtn setTitleColor:HW13B2EBColor forState:UIControlStateNormal];
  160. // [ruleBtn setBackgroundColor:[UIColor clearColor]];
  161. // [ruleBtn addTarget:self action:@selector(ruleBtnClick) forControlEvents:UIControlEventTouchUpInside];
  162. // ruleBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
  163. // [self.view addSubview:ruleBtn];
  164. // [ruleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  165. // make.bottom.mas_equalTo(-80-AdaptTabHeight);
  166. // //make.width.mas_equalTo(55);
  167. // make.width.mas_equalTo(130);
  168. // make.height.mas_equalTo(38);
  169. // make.right.equalTo(self.view.mas_centerX).offset(-6);
  170. // }];
  171. //
  172. // UIView *lineView = [[UIView alloc] init];
  173. // [lineView setBackgroundColor:HW999999Color];
  174. // [self.view addSubview:lineView];
  175. // [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
  176. // make.centerX.equalTo(self.view.mas_centerX);
  177. // make.width.mas_equalTo(1);
  178. // make.height.mas_equalTo(14);
  179. // make.centerY.equalTo(ruleBtn.mas_centerY);
  180. // }];
  181. }
  182. #pragma mark - 懒加载
  183. - (UITableView *)tableView{
  184. if (!_tableView) {
  185. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H - TABBARHEIGHT) style:UITableViewStylePlain];
  186. _tableView.delegate = self;
  187. _tableView.dataSource = self;
  188. _tableView.showsVerticalScrollIndicator = NO;
  189. _tableView.showsHorizontalScrollIndicator = NO;
  190. // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
  191. [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
  192. [_tableView setSeparatorColor:[UIColor clearColor]];
  193. [_tableView setBackgroundColor:[UIColor whiteColor]];
  194. _tableView.layer.cornerRadius = 8;
  195. _tableView.scrollEnabled = NO;
  196. [_tableView setTableFooterView:[UIView new]];
  197. [_tableView setBounces:YES];
  198. if (@available(iOS 15.0, *)) {
  199. _tableView.sectionHeaderTopPadding = 0;
  200. }
  201. }
  202. return _tableView;
  203. }
  204. #pragma mark - 列表委托
  205. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  206. return 1;
  207. }
  208. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  209. return _msgTitleArr.count;
  210. }
  211. - (baseTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  212. __block NSInteger row = indexPath.row;
  213. static NSString *identifier = @"baseTableViewCell";
  214. baseTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  215. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  216. if (!cell){
  217. cell = [[baseTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  218. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  219. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  220. cell.showLeftImageType = NO;
  221. }
  222. //左边标题
  223. cell.showRightImageType = NO;
  224. if (row < _msgTitleArr.count) {
  225. NSString *title = _msgTitleArr[row];
  226. cell.titleLabel.text = title;
  227. if(row == 0 || row ==1){
  228. cell.showRightImageType = YES;
  229. cell.contentLabel.hidden = YES;
  230. }
  231. else if(row == 2){
  232. NSString *vers = [iPhone appVersion];
  233. [cell.contentLabel setText:[NSString stringWithFormat:@"V%@",vers]];
  234. }
  235. else if(_couldphoneSysInfoMod){
  236. cell.contentLabel.hidden = NO;
  237. if (row == 3) {
  238. cell.contentLabel.text = _couldphoneSysInfoMod.data.hostImgVer;
  239. }
  240. else if(row == 4) {
  241. cell.contentLabel.text = _couldphoneSysInfoMod.data.MyNewVersion;
  242. }
  243. }
  244. }
  245. return cell;
  246. }
  247. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  248. return 40;
  249. }
  250. - (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
  251. return [UIView new];
  252. }
  253. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  254. return 20;
  255. }
  256. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  257. {
  258. NSInteger row = indexPath.row;
  259. if(row == 0){
  260. [self ruleBtnClick];
  261. }
  262. else if(row ==1){
  263. [self privateBtnClick];
  264. }
  265. }
  266. - (UIImage *)getAppIcon{
  267. NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
  268. //获取app中所有icon名字数组
  269. NSArray *iconsArr = infoDict[@"CFBundleIcons"][@"CFBundlePrimaryIcon"][@"CFBundleIconFiles"];
  270. //取最后一个icon的名字
  271. NSString *iconLastName = [iconsArr lastObject];
  272. //打印icon名字
  273. NSLog(@"iconsArr: %@", iconsArr);
  274. NSLog(@"iconLastName: %@", iconLastName);
  275. return [UIImage imageNamed:iconLastName];
  276. }
  277. #pragma mark- 网络请求
  278. - (void)getVersion {
  279. [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"app_update_checking",nil)];
  280. NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
  281. [paraDict setValue:@"ios" forKey:@"type"];
  282. [paraDict setValue:@"skyworth" forKey:@"source"];
  283. [[netWorkManager shareInstance] CommonGetWithCallBackCode:upgradeNewVersion Parameters:paraDict success:^(id _Nonnull responseObject) {
  284. HLog(@"%@", responseObject);
  285. [self removeNewIndicatorHaveStr];
  286. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  287. if (model.status == 0) {
  288. HWVersionModel *model = [HWVersionModel mj_objectWithKeyValues:responseObject[@"data"]];
  289. self.versionModel = model;
  290. [self checkVersion];
  291. }
  292. else
  293. {
  294. //[[iToast makeText:model.msg] show];
  295. }
  296. } failure:^(NSError * _Nonnull error) {
  297. HLog(@"%@", error);
  298. [[iToast makeText:NSLocalizedString(@"player_link_fail_tip",nil)] show];
  299. [self removeNewIndicatorHaveStr];
  300. }];
  301. }
  302. - (void)versionCheckBtnClick {
  303. [self getVersion];
  304. }
  305. - (void)checkVersion {
  306. // NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleVersion"];
  307. NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"];
  308. NSString *newVersion = [self.versionModel.versionNumber stringByReplacingOccurrencesOfString:@"v" withString:@""]; //去掉v
  309. newVersion = [newVersion stringByReplacingOccurrencesOfString:@"V" withString:@""]; //去掉v
  310. // HLog(@"%@---%@", newVersion, currentVersion);
  311. if ([currentVersion compare:newVersion options:NSNumericSearch] == NSOrderedSame) { // 本地版本号 == 服务器版本号
  312. // [self showNoNewVersion];
  313. //[self showNewVersion];
  314. [[iToast makeText:NSLocalizedString(@"app_update_last_version",nil)] show];
  315. [HWDataManager setBoolWithKey:Const_haveVersion value:NO];
  316. // _checUpdatekBtn.enabled = NO;
  317. // _checUpdatekBtn.backgroundColor = [UIColor hwColor:@"#959799" alpha:1.0];
  318. // [_gl_checkVersonBut removeFromSuperlayer];
  319. }else if ([currentVersion compare:newVersion options:NSNumericSearch] == NSOrderedDescending) { // 本地版本号 > 服务器版本号 (异常情况)
  320. [self showNoNewVersion];
  321. [HWDataManager setBoolWithKey:Const_haveVersion value:NO];
  322. // _checUpdatekBtn.enabled = NO;
  323. // _checUpdatekBtn.backgroundColor = [UIColor hwColor:@"#959799" alpha:1.0];
  324. // [_gl_checkVersonBut removeFromSuperlayer];
  325. }else { // 本地版本号 < 服务器版本号 (有新版本)
  326. self.versionModel.versionNumber = newVersion;
  327. [self showNewVersion];
  328. [HWDataManager setBoolWithKey:Const_haveVersion value:YES];
  329. };
  330. }
  331. - (void)showNewVersion {
  332. HaveNewVersionView *haveNewVersionView = [HaveNewVersionView shardInstance];
  333. if (haveNewVersionView.isShow) {
  334. return;
  335. }
  336. haveNewVersionView.versionModel = self.versionModel;
  337. haveNewVersionView.isContinueCheckAlert = NO; // 是否继续走下一步弹窗检测流程
  338. [haveNewVersionView setBackgroundColor:RGBACOLOR(0, 0, 0, 0.5)];
  339. [[[UIApplication sharedApplication] keyWindow] addSubview:haveNewVersionView];
  340. haveNewVersionView.isShow = YES;
  341. if(!self.versionModel.necessary){
  342. haveNewVersionView.deleteBtn.hidden = NO;
  343. }
  344. [haveNewVersionView mas_makeConstraints:^(MASConstraintMaker *make) {
  345. make.top.mas_equalTo(0);
  346. make.left.mas_equalTo(0);
  347. make.right.mas_equalTo(0);
  348. make.bottom.mas_equalTo(0);
  349. }];
  350. haveNewVersionView.alpha = 0.0;
  351. [UIView animateWithDuration:0.3 delay:0.0 options:UIViewAnimationOptionCurveEaseIn animations:^ {
  352. haveNewVersionView.alpha = 1.0;
  353. KyoLog(@"in animate start");
  354. } completion:^(BOOL finished) {
  355. KyoLog(@"in animate completion");
  356. }];
  357. }
  358. - (void)showNoNewVersion {
  359. [[iToast makeText:NSLocalizedString(@"app_update_last_version",nil)] show];
  360. }
  361. - (void)ruleBtnClick {
  362. //https://cliys.armclouding.com/h5/protocol/protocol.html?agreementCoding=YSZYHXY2002&type=1
  363. // [self gotoProtocolWKWebVCByPush:YES];
  364. CustomerWebViewController *vc = [[CustomerWebViewController alloc] init];
  365. vc.titleStr = NSLocalizedString(@"app_update_use_deal",nil);
  366. NSString *url = @"https://cliys.armclouding.com/h5/protocol/protocol.html?agreementCoding=YSZYHXY2003&type=1";//[NSString stringWithFormat:@"%@/h5/protocol/protocol.html?agreementCoding=YSZYHXY2002&type=1", CloudService];
  367. vc.webUrl = url;
  368. [self.navigationController pushViewController:vc animated:YES];
  369. }
  370. - (void)privateBtnClick {
  371. // [self gotoPrivateProtocolWKWebVCByPush:YES];
  372. CustomerWebViewController *vc = [[CustomerWebViewController alloc] init];
  373. vc.titleStr = NSLocalizedString(@"app_update_private",nil);
  374. NSString *url = @"https://cliys.armclouding.com/h5/protocol/protocol.html?agreementCoding=YSZYSXY2002&type=1";//[NSString stringWithFormat:@"%@/h5/protocol/protocol.html?agreementCoding=YSZYSXY2001&type=1", CloudService];
  375. vc.webUrl = url;
  376. [self.navigationController pushViewController:vc animated:YES];
  377. }
  378. - (void)didTap5NumFun
  379. {
  380. allVersionView *view = [[allVersionView alloc] init];
  381. UIWindow *keyWindow = [iTools getKeyWindow];
  382. [keyWindow addSubview:view];
  383. [view mas_makeConstraints:^(MASConstraintMaker *make) {
  384. make.top.mas_equalTo(0);
  385. make.left.mas_equalTo(0);
  386. make.right.mas_equalTo(0);
  387. make.bottom.mas_equalTo(0);
  388. }];
  389. if(_getSysInfo){
  390. _getSysInfo();
  391. }
  392. }
  393. - (void)getCouldPhoneBaseInfoFun:(NSNotification*)not
  394. {
  395. _couldphoneSysInfoMod = [not object];
  396. //HLog(@"%@",baseInfoModel);
  397. if(!_couldphoneSysInfoMod || ![_couldphoneSysInfoMod isKindOfClass:[couldphoneSysInfoModel class]]){
  398. return;
  399. }
  400. KWeakSelf
  401. mainBlock(^{
  402. [weakSelf.tableView reloadData];
  403. });
  404. }
  405. @end