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. //1.4.3 新加一个tableview 显示镜像相关信息
  123. //用户协议 隐私协议 app当前版本 系统当前版本 系统待更新版本
  124. _msgTitleArr = @[//NSLocalizedString(@"app_update_use_deal",nil)
  125. //,NSLocalizedString(@"app_update_private",nil),
  126. NSLocalizedString(@"app_version_current",nil)
  127. ,NSLocalizedString(@"system_version_current",nil)
  128. ,NSLocalizedString(@"asystem_version_wait_update",nil)];
  129. [self.view addSubview:self.tableView];
  130. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  131. make.left.mas_equalTo(15.f);
  132. make.right.mas_equalTo(-15.f);
  133. make.top.equalTo(_checUpdatekBtn.mas_bottom).offset(25.f);
  134. //make.height.mas_equalTo(240.f);
  135. make.height.mas_equalTo(160.f);
  136. }];
  137. // UIButton *privateBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  138. // self.privateBtn = privateBtn;
  139. // privateBtn.titleLabel.font = [UIFont systemFontOfSize:13.f];
  140. // [privateBtn setTitle:NSLocalizedString(@"app_update_private",nil) forState:UIControlStateNormal];
  141. // [privateBtn setTitleColor:HW13B2EBColor forState:UIControlStateNormal];
  142. // [privateBtn setBackgroundColor:[UIColor clearColor]];
  143. // [privateBtn addTarget:self action:@selector(privateBtnClick) forControlEvents:UIControlEventTouchUpInside];
  144. // privateBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  145. // [self.view addSubview:privateBtn];
  146. // [privateBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  147. // make.bottom.mas_equalTo(-80-AdaptTabHeight);
  148. // //make.width.mas_equalTo(55);
  149. // make.width.mas_equalTo(130);
  150. // make.height.mas_equalTo(38);
  151. // make.left.equalTo(self.view.mas_centerX).offset(6);
  152. // }];
  153. //
  154. // UIButton *ruleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  155. // self.ruleBtn = ruleBtn;
  156. // ruleBtn.titleLabel.font = [UIFont systemFontOfSize:13.f];
  157. // [ruleBtn setTitle:NSLocalizedString(@"app_update_use_deal",nil) forState:UIControlStateNormal];
  158. // [ruleBtn setTitleColor:HW13B2EBColor forState:UIControlStateNormal];
  159. // [ruleBtn setBackgroundColor:[UIColor clearColor]];
  160. // [ruleBtn addTarget:self action:@selector(ruleBtnClick) forControlEvents:UIControlEventTouchUpInside];
  161. // ruleBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
  162. // [self.view addSubview:ruleBtn];
  163. // [ruleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  164. // make.bottom.mas_equalTo(-80-AdaptTabHeight);
  165. // //make.width.mas_equalTo(55);
  166. // make.width.mas_equalTo(130);
  167. // make.height.mas_equalTo(38);
  168. // make.right.equalTo(self.view.mas_centerX).offset(-6);
  169. // }];
  170. //
  171. // UIView *lineView = [[UIView alloc] init];
  172. // [lineView setBackgroundColor:HW999999Color];
  173. // [self.view addSubview:lineView];
  174. // [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
  175. // make.centerX.equalTo(self.view.mas_centerX);
  176. // make.width.mas_equalTo(1);
  177. // make.height.mas_equalTo(14);
  178. // make.centerY.equalTo(ruleBtn.mas_centerY);
  179. // }];
  180. }
  181. #pragma mark - 懒加载
  182. - (UITableView *)tableView{
  183. if (!_tableView) {
  184. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H - TABBARHEIGHT) style:UITableViewStylePlain];
  185. _tableView.delegate = self;
  186. _tableView.dataSource = self;
  187. _tableView.showsVerticalScrollIndicator = NO;
  188. _tableView.showsHorizontalScrollIndicator = NO;
  189. // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
  190. [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
  191. [_tableView setSeparatorColor:[UIColor clearColor]];
  192. [_tableView setBackgroundColor:[UIColor whiteColor]];
  193. _tableView.layer.cornerRadius = 8;
  194. _tableView.scrollEnabled = NO;
  195. [_tableView setTableFooterView:[UIView new]];
  196. [_tableView setBounces:YES];
  197. if (@available(iOS 15.0, *)) {
  198. _tableView.sectionHeaderTopPadding = 0;
  199. }
  200. }
  201. return _tableView;
  202. }
  203. #pragma mark - 列表委托
  204. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  205. return 1;
  206. }
  207. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  208. return _msgTitleArr.count;
  209. }
  210. - (baseTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  211. __block NSInteger row = indexPath.row;
  212. static NSString *identifier = @"baseTableViewCell";
  213. baseTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  214. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  215. if (!cell){
  216. cell = [[baseTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  217. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  218. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  219. cell.showLeftImageType = NO;
  220. }
  221. //左边标题
  222. cell.showRightImageType = NO;
  223. if (row < _msgTitleArr.count) {
  224. NSString *title = _msgTitleArr[row];
  225. cell.titleLabel.text = title;
  226. // if(row == 0 || row ==1){
  227. // cell.showRightImageType = YES;
  228. // cell.contentLabel.hidden = YES;
  229. // }
  230. // else
  231. if(row == 0){
  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 == 1) {
  238. cell.contentLabel.text = _couldphoneSysInfoMod.data.hostImgVer;
  239. }
  240. else if(row == 2) {
  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. //
  260. // if(row == 0){
  261. // [self ruleBtnClick];
  262. // }
  263. // else if(row ==1){
  264. // [self privateBtnClick];
  265. // }
  266. }
  267. - (UIImage *)getAppIcon{
  268. NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
  269. //获取app中所有icon名字数组
  270. NSArray *iconsArr = infoDict[@"CFBundleIcons"][@"CFBundlePrimaryIcon"][@"CFBundleIconFiles"];
  271. //取最后一个icon的名字
  272. NSString *iconLastName = [iconsArr lastObject];
  273. //打印icon名字
  274. NSLog(@"iconsArr: %@", iconsArr);
  275. NSLog(@"iconLastName: %@", iconLastName);
  276. return [UIImage imageNamed:iconLastName];
  277. }
  278. #pragma mark- 网络请求
  279. - (void)getVersion {
  280. [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"app_update_checking",nil)];
  281. NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
  282. [paraDict setValue:@"ios" forKey:@"type"];
  283. [paraDict setValue:@"stealth" forKey:@"source"];
  284. [[netWorkManager shareInstance] CommonGetWithCallBackCode:upgradeNewVersion Parameters:paraDict success:^(id _Nonnull responseObject) {
  285. HLog(@"%@", responseObject);
  286. [self removeNewIndicatorHaveStr];
  287. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  288. if (model.status == 0) {
  289. HWVersionModel *model = [HWVersionModel mj_objectWithKeyValues:responseObject[@"data"]];
  290. self.versionModel = model;
  291. [self checkVersion];
  292. }
  293. else
  294. {
  295. //[[iToast makeText:model.msg] show];
  296. }
  297. } failure:^(NSError * _Nonnull error) {
  298. HLog(@"%@", error);
  299. [[iToast makeText:NSLocalizedString(@"player_link_fail_tip",nil)] show];
  300. [self removeNewIndicatorHaveStr];
  301. }];
  302. }
  303. - (void)versionCheckBtnClick {
  304. [self getVersion];
  305. }
  306. - (void)checkVersion {
  307. // NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleVersion"];
  308. NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"];
  309. NSString *newVersion = [self.versionModel.versionNumber stringByReplacingOccurrencesOfString:@"v" withString:@""]; //去掉v
  310. newVersion = [newVersion stringByReplacingOccurrencesOfString:@"V" withString:@""]; //去掉v
  311. // HLog(@"%@---%@", newVersion, currentVersion);
  312. if ([currentVersion compare:newVersion options:NSNumericSearch] == NSOrderedSame) { // 本地版本号 == 服务器版本号
  313. // [self showNoNewVersion];
  314. //[self showNewVersion];
  315. [[iToast makeText:NSLocalizedString(@"app_update_last_version",nil)] show];
  316. [HWDataManager setBoolWithKey:Const_haveVersion value:NO];
  317. // _checUpdatekBtn.enabled = NO;
  318. // _checUpdatekBtn.backgroundColor = [UIColor hwColor:@"#959799" alpha:1.0];
  319. // [_gl_checkVersonBut removeFromSuperlayer];
  320. }else if ([currentVersion compare:newVersion options:NSNumericSearch] == NSOrderedDescending) { // 本地版本号 > 服务器版本号 (异常情况)
  321. [self showNoNewVersion];
  322. [HWDataManager setBoolWithKey:Const_haveVersion value:NO];
  323. // _checUpdatekBtn.enabled = NO;
  324. // _checUpdatekBtn.backgroundColor = [UIColor hwColor:@"#959799" alpha:1.0];
  325. // [_gl_checkVersonBut removeFromSuperlayer];
  326. }else { // 本地版本号 < 服务器版本号 (有新版本)
  327. self.versionModel.versionNumber = newVersion;
  328. [self showNewVersion];
  329. [HWDataManager setBoolWithKey:Const_haveVersion value:YES];
  330. };
  331. }
  332. - (void)showNewVersion {
  333. HaveNewVersionView *haveNewVersionView = [HaveNewVersionView shardInstance];
  334. if (haveNewVersionView.isShow) {
  335. return;
  336. }
  337. haveNewVersionView.versionModel = self.versionModel;
  338. haveNewVersionView.isContinueCheckAlert = NO; // 是否继续走下一步弹窗检测流程
  339. [haveNewVersionView setBackgroundColor:RGBACOLOR(0, 0, 0, 0.5)];
  340. [[[UIApplication sharedApplication] keyWindow] addSubview:haveNewVersionView];
  341. haveNewVersionView.isShow = YES;
  342. if(!self.versionModel.necessary){
  343. haveNewVersionView.deleteBtn.hidden = NO;
  344. }
  345. [haveNewVersionView mas_makeConstraints:^(MASConstraintMaker *make) {
  346. make.top.mas_equalTo(0);
  347. make.left.mas_equalTo(0);
  348. make.right.mas_equalTo(0);
  349. make.bottom.mas_equalTo(0);
  350. }];
  351. haveNewVersionView.alpha = 0.0;
  352. [UIView animateWithDuration:0.3 delay:0.0 options:UIViewAnimationOptionCurveEaseIn animations:^ {
  353. haveNewVersionView.alpha = 1.0;
  354. KyoLog(@"in animate start");
  355. } completion:^(BOOL finished) {
  356. KyoLog(@"in animate completion");
  357. }];
  358. }
  359. - (void)showNoNewVersion {
  360. [[iToast makeText:NSLocalizedString(@"app_update_last_version",nil)] show];
  361. }
  362. - (void)ruleBtnClick {
  363. //https://cliys.armclouding.com/h5/protocol/protocol.html?agreementCoding=YSZYHXY2002&type=1
  364. // [self gotoProtocolWKWebVCByPush:YES];
  365. CustomerWebViewController *vc = [[CustomerWebViewController alloc] init];
  366. vc.titleStr = NSLocalizedString(@"app_update_use_deal",nil);
  367. 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];
  368. vc.webUrl = url;
  369. [self.navigationController pushViewController:vc animated:YES];
  370. }
  371. - (void)privateBtnClick {
  372. // [self gotoPrivateProtocolWKWebVCByPush:YES];
  373. CustomerWebViewController *vc = [[CustomerWebViewController alloc] init];
  374. vc.titleStr = NSLocalizedString(@"app_update_private",nil);
  375. 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];
  376. vc.webUrl = url;
  377. [self.navigationController pushViewController:vc animated:YES];
  378. }
  379. - (void)didTap5NumFun
  380. {
  381. allVersionView *view = [[allVersionView alloc] init];
  382. UIWindow *keyWindow = [iTools getKeyWindow];
  383. [keyWindow addSubview:view];
  384. [view mas_makeConstraints:^(MASConstraintMaker *make) {
  385. make.top.mas_equalTo(0);
  386. make.left.mas_equalTo(0);
  387. make.right.mas_equalTo(0);
  388. make.bottom.mas_equalTo(0);
  389. }];
  390. if(_getSysInfo){
  391. _getSysInfo();
  392. }
  393. }
  394. - (void)getCouldPhoneBaseInfoFun:(NSNotification*)not
  395. {
  396. _couldphoneSysInfoMod = [not object];
  397. //HLog(@"%@",baseInfoModel);
  398. if(!_couldphoneSysInfoMod || ![_couldphoneSysInfoMod isKindOfClass:[couldphoneSysInfoModel class]]){
  399. return;
  400. }
  401. KWeakSelf
  402. mainBlock(^{
  403. [weakSelf.tableView reloadData];
  404. });
  405. }
  406. @end