AboutViewController.m 18 KB

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