AboutViewController.m 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  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. @interface AboutViewController ()
  19. @property (nonatomic, strong) UIButton *checUpdatekBtn;
  20. // gradient
  21. @property (nonatomic, strong)CAGradientLayer *gl_checkVersonBut;
  22. @property (nonatomic, strong) UIButton *ruleBtn;
  23. @property (nonatomic, strong) UIButton *privateBtn;
  24. @property (nonatomic, strong) HWVersionModel *versionModel;
  25. @end
  26. @implementation AboutViewController
  27. - (void)viewDidLoad {
  28. [super viewDidLoad];
  29. [self drawAnyView];
  30. }
  31. - (void)viewDidAppear:(BOOL)animated {
  32. [super viewDidAppear:animated];
  33. }
  34. - (void)drawAnyView
  35. {
  36. [self.view setBackgroundColor:HWF5F7FAColor];
  37. self.navBarBGView.hidden = NO;
  38. [self.navigationBar setHidden:YES];
  39. [self.toolBar setHidden:YES];
  40. [self.titleLabel setText:NSLocalizedString(@"app_update_title",nil)];
  41. UIImageView *topImage = [[UIImageView alloc] init];
  42. [topImage setImage:[self getAppIcon]];
  43. topImage.userInteractionEnabled = YES;
  44. [self.view addSubview:topImage];
  45. [topImage mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.width.mas_equalTo(72.f);
  47. make.height.mas_equalTo(72.f);
  48. make.centerX.equalTo(self.view.mas_centerX);
  49. make.top.equalTo(self.navBarBGView.mas_bottom).offset(123.f);
  50. }];
  51. [topImage.layer setCornerRadius:15.f];
  52. topImage.clipsToBounds = YES;
  53. UITapGestureRecognizer *tap5 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTap5NumFun)];
  54. tap5.numberOfTapsRequired = 5;
  55. [topImage addGestureRecognizer:tap5];
  56. /*app名*/
  57. UILabel *appName = [[UILabel alloc] init];
  58. [appName setBackgroundColor:[UIColor clearColor]];
  59. [appName setTextColor:HW333333Color];
  60. [appName setFont:[UIFont boldSystemFontOfSize:16.f]];
  61. [appName setTextAlignment:(NSTextAlignmentCenter)];
  62. [appName setText:[NSString stringWithFormat:@"%@",[iPhone appBundleName]]];
  63. //[appName setText:[NSString stringWithFormat:@"%@",@"Private- X"]];
  64. [self.view addSubview:appName];
  65. [appName mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.top.equalTo(topImage.mas_bottom).offset(20.f);
  67. make.right.mas_equalTo(-27.f);
  68. make.left.mas_equalTo(27.f);
  69. make.height.mas_equalTo(22.f);
  70. }];
  71. /*版本号*/
  72. UILabel *versionLabel = [[UILabel alloc] init];
  73. [versionLabel setBackgroundColor:[UIColor clearColor]];
  74. [versionLabel setTextColor:HW333333Color];
  75. [versionLabel setFont:[UIFont systemFontOfSize:13.f]];
  76. [versionLabel setTextAlignment:(NSTextAlignmentCenter)];
  77. NSString *vers = [iPhone appVersion];
  78. [versionLabel setText:[NSString stringWithFormat:@"V%@",vers]];
  79. [self.view addSubview:versionLabel];
  80. [versionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  81. make.top.equalTo(appName.mas_bottom).offset(10.f);
  82. make.right.mas_equalTo(-27.f);
  83. make.left.mas_equalTo(27.f);
  84. make.height.mas_equalTo(20.f);
  85. }];
  86. /*开始体验*/
  87. _checUpdatekBtn = [[UIButton alloc] init];
  88. _checUpdatekBtn.frame = CGRectMake(0, 0, 160.f, 48.f);
  89. // gradient
  90. _gl_checkVersonBut = [CAGradientLayer layer];
  91. _gl_checkVersonBut.frame = CGRectMake(0,0,160.f,48.f);
  92. _gl_checkVersonBut.startPoint = CGPointMake(0, 0.5);
  93. _gl_checkVersonBut.endPoint = CGPointMake(1, 0.5);
  94. _gl_checkVersonBut.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor];
  95. _gl_checkVersonBut.locations = @[@(0), @(1.0f)];
  96. [_checUpdatekBtn.layer addSublayer:_gl_checkVersonBut];
  97. [_checUpdatekBtn addTarget:self action:@selector(versionCheckBtnClick) forControlEvents:(UIControlEventTouchUpInside)];
  98. [_checUpdatekBtn setTitle:NSLocalizedString(@"app_update_check",nil) forState:(UIControlStateNormal)];
  99. [_checUpdatekBtn setTitle:NSLocalizedString(@"app_update_last_version",nil) forState:(UIControlStateDisabled)];
  100. [_checUpdatekBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
  101. [_checUpdatekBtn.titleLabel setFont:[UIFont systemFontOfSize:16.f]];
  102. [_checUpdatekBtn.layer setCornerRadius:8.f];
  103. _checUpdatekBtn.clipsToBounds = YES;
  104. [self.view addSubview:_checUpdatekBtn];
  105. [_checUpdatekBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  106. make.centerX.equalTo(self.view.mas_centerX);
  107. make.width.mas_equalTo(160.f);
  108. make.top.equalTo(versionLabel.mas_bottom).offset(25.f);
  109. make.height.mas_equalTo(48.f);
  110. }];
  111. UIButton *privateBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  112. self.privateBtn = privateBtn;
  113. privateBtn.titleLabel.font = [UIFont systemFontOfSize:13.f];
  114. [privateBtn setTitle:NSLocalizedString(@"app_update_private",nil) forState:UIControlStateNormal];
  115. [privateBtn setTitleColor:HW13B2EBColor forState:UIControlStateNormal];
  116. [privateBtn setBackgroundColor:[UIColor clearColor]];
  117. [privateBtn addTarget:self action:@selector(privateBtnClick) forControlEvents:UIControlEventTouchUpInside];
  118. privateBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  119. [self.view addSubview:privateBtn];
  120. [privateBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  121. make.bottom.mas_equalTo(-80-AdaptTabHeight);
  122. //make.width.mas_equalTo(55);
  123. make.width.mas_equalTo(130);
  124. make.height.mas_equalTo(38);
  125. make.left.equalTo(self.view.mas_centerX).offset(6);
  126. }];
  127. UIButton *ruleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  128. self.ruleBtn = ruleBtn;
  129. ruleBtn.titleLabel.font = [UIFont systemFontOfSize:13.f];
  130. [ruleBtn setTitle:NSLocalizedString(@"app_update_use_deal",nil) forState:UIControlStateNormal];
  131. [ruleBtn setTitleColor:HW13B2EBColor forState:UIControlStateNormal];
  132. [ruleBtn setBackgroundColor:[UIColor clearColor]];
  133. [ruleBtn addTarget:self action:@selector(ruleBtnClick) forControlEvents:UIControlEventTouchUpInside];
  134. ruleBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
  135. [self.view addSubview:ruleBtn];
  136. [ruleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  137. make.bottom.mas_equalTo(-80-AdaptTabHeight);
  138. //make.width.mas_equalTo(55);
  139. make.width.mas_equalTo(130);
  140. make.height.mas_equalTo(38);
  141. make.right.equalTo(self.view.mas_centerX).offset(-6);
  142. }];
  143. UIView *lineView = [[UIView alloc] init];
  144. [lineView setBackgroundColor:HW999999Color];
  145. [self.view addSubview:lineView];
  146. [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
  147. make.centerX.equalTo(self.view.mas_centerX);
  148. make.width.mas_equalTo(1);
  149. make.height.mas_equalTo(14);
  150. make.centerY.equalTo(ruleBtn.mas_centerY);
  151. }];
  152. }
  153. - (UIImage *)getAppIcon{
  154. NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
  155. //获取app中所有icon名字数组
  156. NSArray *iconsArr = infoDict[@"CFBundleIcons"][@"CFBundlePrimaryIcon"][@"CFBundleIconFiles"];
  157. //取最后一个icon的名字
  158. NSString *iconLastName = [iconsArr lastObject];
  159. //打印icon名字
  160. NSLog(@"iconsArr: %@", iconsArr);
  161. NSLog(@"iconLastName: %@", iconLastName);
  162. return [UIImage imageNamed:iconLastName];
  163. }
  164. #pragma mark- 网络请求
  165. - (void)getVersion {
  166. [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"app_update_checking",nil)];
  167. NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
  168. [paraDict setValue:@"ios" forKey:@"type"];
  169. [paraDict setValue:@"skyworth" forKey:@"source"];
  170. [[netWorkManager shareInstance] CommonGetWithCallBackCode:upgradeNewVersion Parameters:paraDict success:^(id _Nonnull responseObject) {
  171. HLog(@"%@", responseObject);
  172. [self removeNewIndicatorHaveStr];
  173. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  174. if (model.status == 0) {
  175. HWVersionModel *model = [HWVersionModel mj_objectWithKeyValues:responseObject[@"data"]];
  176. self.versionModel = model;
  177. [self checkVersion];
  178. }
  179. else
  180. {
  181. //[[iToast makeText:model.msg] show];
  182. }
  183. } failure:^(NSError * _Nonnull error) {
  184. HLog(@"%@", error);
  185. [[iToast makeText:NSLocalizedString(@"player_link_fail_tip",nil)] show];
  186. [self removeNewIndicatorHaveStr];
  187. }];
  188. }
  189. - (void)versionCheckBtnClick {
  190. [self getVersion];
  191. }
  192. - (void)checkVersion {
  193. // NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleVersion"];
  194. NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"];
  195. NSString *newVersion = [self.versionModel.versionNumber stringByReplacingOccurrencesOfString:@"v" withString:@""]; //去掉v
  196. // HLog(@"%@---%@", newVersion, currentVersion);
  197. if ([currentVersion compare:newVersion options:NSNumericSearch] == NSOrderedSame) { // 本地版本号 == 服务器版本号
  198. // [self showNoNewVersion];
  199. //[self showNewVersion];
  200. [[iToast makeText:NSLocalizedString(@"app_update_last_version",nil)] show];
  201. [HWDataManager setBoolWithKey:Const_haveVersion value:NO];
  202. // _checUpdatekBtn.enabled = NO;
  203. // _checUpdatekBtn.backgroundColor = [UIColor hwColor:@"#959799" alpha:1.0];
  204. // [_gl_checkVersonBut removeFromSuperlayer];
  205. }else if ([currentVersion compare:newVersion options:NSNumericSearch] == NSOrderedDescending) { // 本地版本号 > 服务器版本号 (异常情况)
  206. [self showNoNewVersion];
  207. [HWDataManager setBoolWithKey:Const_haveVersion value:NO];
  208. // _checUpdatekBtn.enabled = NO;
  209. // _checUpdatekBtn.backgroundColor = [UIColor hwColor:@"#959799" alpha:1.0];
  210. // [_gl_checkVersonBut removeFromSuperlayer];
  211. }else { // 本地版本号 < 服务器版本号 (有新版本)
  212. self.versionModel.versionNumber = newVersion;
  213. [self showNewVersion];
  214. [HWDataManager setBoolWithKey:Const_haveVersion value:YES];
  215. };
  216. }
  217. - (void)showNewVersion {
  218. HaveNewVersionView *haveNewVersionView = [HaveNewVersionView shardInstance];
  219. if (haveNewVersionView.isShow) {
  220. return;
  221. }
  222. haveNewVersionView.versionModel = self.versionModel;
  223. haveNewVersionView.isContinueCheckAlert = NO; // 是否继续走下一步弹窗检测流程
  224. [haveNewVersionView setBackgroundColor:RGBACOLOR(0, 0, 0, 0.5)];
  225. [[[UIApplication sharedApplication] keyWindow] addSubview:haveNewVersionView];
  226. haveNewVersionView.isShow = YES;
  227. if(!self.versionModel.necessary){
  228. haveNewVersionView.deleteBtn.hidden = NO;
  229. }
  230. [haveNewVersionView mas_makeConstraints:^(MASConstraintMaker *make) {
  231. make.top.mas_equalTo(0);
  232. make.left.mas_equalTo(0);
  233. make.right.mas_equalTo(0);
  234. make.bottom.mas_equalTo(0);
  235. }];
  236. haveNewVersionView.alpha = 0.0;
  237. [UIView animateWithDuration:0.3 delay:0.0 options:UIViewAnimationOptionCurveEaseIn animations:^ {
  238. haveNewVersionView.alpha = 1.0;
  239. KyoLog(@"in animate start");
  240. } completion:^(BOOL finished) {
  241. KyoLog(@"in animate completion");
  242. }];
  243. }
  244. - (void)showNoNewVersion {
  245. [[iToast makeText:NSLocalizedString(@"app_update_last_version",nil)] show];
  246. }
  247. - (void)ruleBtnClick {
  248. //https://cliys.armclouding.com/h5/protocol/protocol.html?agreementCoding=YSZYHXY2002&type=1
  249. // [self gotoProtocolWKWebVCByPush:YES];
  250. CustomerWebViewController *vc = [[CustomerWebViewController alloc] init];
  251. vc.titleStr = NSLocalizedString(@"app_update_use_deal",nil);
  252. 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];
  253. vc.webUrl = url;
  254. [self.navigationController pushViewController:vc animated:YES];
  255. }
  256. - (void)privateBtnClick {
  257. // [self gotoPrivateProtocolWKWebVCByPush:YES];
  258. CustomerWebViewController *vc = [[CustomerWebViewController alloc] init];
  259. vc.titleStr = NSLocalizedString(@"app_update_private",nil);
  260. 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];
  261. vc.webUrl = url;
  262. [self.navigationController pushViewController:vc animated:YES];
  263. }
  264. - (void)didTap5NumFun
  265. {
  266. allVersionView *view = [[allVersionView alloc] init];
  267. UIWindow *keyWindow = [iTools getKeyWindow];
  268. [keyWindow addSubview:view];
  269. [view mas_makeConstraints:^(MASConstraintMaker *make) {
  270. make.top.mas_equalTo(0);
  271. make.left.mas_equalTo(0);
  272. make.right.mas_equalTo(0);
  273. make.bottom.mas_equalTo(0);
  274. }];
  275. if(_getSysInfo){
  276. _getSysInfo();
  277. }
  278. }
  279. @end