|
@@ -0,0 +1,275 @@
|
|
|
+//
|
|
|
+// AboutViewController.m
|
|
|
+// VclustersGemini
|
|
|
+//
|
|
|
+// Created by APPLE on 2020/2/24.
|
|
|
+// Copyright © 2020 APPLE. All rights reserved.
|
|
|
+//
|
|
|
+
|
|
|
+#import "AboutViewController.h"
|
|
|
+#import "HaveNewVersionView.h"
|
|
|
+#import "HWVersionModel.h"
|
|
|
+#import "iPhone.h"
|
|
|
+#import "UseAccountManage.h"
|
|
|
+#import "CloudPhoneAPI.h"
|
|
|
+#import <MJExtension.h>
|
|
|
+
|
|
|
+@interface AboutViewController ()
|
|
|
+
|
|
|
+@property (nonatomic, strong) UIButton *ruleBtn;
|
|
|
+@property (nonatomic, strong) UIButton *privateBtn;
|
|
|
+@property (nonatomic, strong) HWVersionModel *versionModel;
|
|
|
+
|
|
|
+@end
|
|
|
+
|
|
|
+@implementation AboutViewController
|
|
|
+
|
|
|
+- (void)viewDidLoad {
|
|
|
+ [super viewDidLoad];
|
|
|
+
|
|
|
+ [self drawAnyView];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)viewDidAppear:(BOOL)animated {
|
|
|
+ [super viewDidAppear:animated];
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+- (void)drawAnyView
|
|
|
+{
|
|
|
+ [self.view setBackgroundColor:HWF5F7FAColor];
|
|
|
+ self.navBarBGView.hidden = NO;
|
|
|
+ [self.navigationBar setHidden:YES];
|
|
|
+ [self.toolBar setHidden:YES];
|
|
|
+ [self.titleLabel setText:@"检测更新"];
|
|
|
+
|
|
|
+// // 背景图片
|
|
|
+// CGFloat margin = 35; // 起始高度
|
|
|
+// UIImageView *bgImageView = [[UIImageView alloc] init];
|
|
|
+// [bgImageView setImage:[UIImage imageNamed:@"mine_136"]];
|
|
|
+// bgImageView.contentMode = UIViewContentModeScaleAspectFill;
|
|
|
+// [self.view addSubview:bgImageView];
|
|
|
+// [bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+// make.top.mas_equalTo(margin);
|
|
|
+// make.left.mas_equalTo(0);
|
|
|
+// make.width.mas_equalTo(SCREEN_W);
|
|
|
+// make.height.mas_equalTo(SCREEN_W);
|
|
|
+// }];
|
|
|
+
|
|
|
+ UIImageView *topImage = [[UIImageView alloc] init];
|
|
|
+ [topImage setImage:[self getAppIcon]];
|
|
|
+ [self.view addSubview:topImage];
|
|
|
+ [topImage mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.width.mas_equalTo(90.f);
|
|
|
+ make.height.mas_equalTo(90.f);
|
|
|
+ make.centerX.equalTo(self.view.mas_centerX);
|
|
|
+ make.top.equalTo(self.navBarBGView.mas_bottom).offset(123.f);
|
|
|
+ }];
|
|
|
+
|
|
|
+ /*app名*/
|
|
|
+ UILabel *appName = [[UILabel alloc] init];
|
|
|
+ [appName setBackgroundColor:[UIColor clearColor]];
|
|
|
+ [appName setTextColor:HWFFFFFFColor];
|
|
|
+ [appName setFont:[UIFont boldSystemFontOfSize:18.f]];
|
|
|
+ [appName setTextAlignment:(NSTextAlignmentCenter)];
|
|
|
+ [appName setText:[iPhone appBundleName]];
|
|
|
+ [self.view addSubview:appName];
|
|
|
+ [appName mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(topImage.mas_bottom).offset(11.f);
|
|
|
+ make.right.mas_equalTo(-27.f);
|
|
|
+ make.left.mas_equalTo(27.f);
|
|
|
+ make.height.mas_equalTo(22.f);
|
|
|
+ }];
|
|
|
+
|
|
|
+ /*app名*/
|
|
|
+ UILabel *versionLabel = [[UILabel alloc] init];
|
|
|
+ [versionLabel setBackgroundColor:[UIColor clearColor]];
|
|
|
+ [versionLabel setTextColor:HWFFFFFFColor60];
|
|
|
+ [versionLabel setFont:[UIFont systemFontOfSize:14.f]];
|
|
|
+ [versionLabel setTextAlignment:(NSTextAlignmentCenter)];
|
|
|
+ NSString *vers = [iPhone appVersion];
|
|
|
+ [versionLabel setText:[NSString stringWithFormat:@"版本号%@",vers]];
|
|
|
+ [self.view addSubview:versionLabel];
|
|
|
+ [versionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(appName.mas_bottom).offset(10.f);
|
|
|
+ make.right.mas_equalTo(-27.f);
|
|
|
+ make.left.mas_equalTo(27.f);
|
|
|
+ make.height.mas_equalTo(20.f);
|
|
|
+ }];
|
|
|
+
|
|
|
+ UIButton *privateBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
+ self.privateBtn = privateBtn;
|
|
|
+ privateBtn.titleLabel.font = [UIFont boldSystemFontOfSize:16.f];
|
|
|
+ [privateBtn setTitle:@"隐私协议" forState:UIControlStateNormal];
|
|
|
+ [privateBtn setTitleColor:HWCFD1D4Color forState:UIControlStateNormal];
|
|
|
+ [privateBtn setBackgroundColor:[UIColor clearColor]];
|
|
|
+ [privateBtn addTarget:self action:@selector(privateBtnClick) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ privateBtn.layer.cornerRadius = 8;
|
|
|
+ privateBtn.layer.masksToBounds = YES;
|
|
|
+ privateBtn.layer.borderColor = HWCFD1D4Color.CGColor;
|
|
|
+ privateBtn.layer.borderWidth = 1;
|
|
|
+ [self.view addSubview:privateBtn];
|
|
|
+ [privateBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.bottom.mas_equalTo(-120-AdaptTabHeight);
|
|
|
+ make.width.mas_equalTo(SCREEN_W-38*2);
|
|
|
+ make.height.mas_equalTo(48);
|
|
|
+ make.left.mas_equalTo(38);
|
|
|
+ }];
|
|
|
+
|
|
|
+ UIButton *ruleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
+ self.ruleBtn = ruleBtn;
|
|
|
+ ruleBtn.titleLabel.font = [UIFont boldSystemFontOfSize:16.f];
|
|
|
+ [ruleBtn setTitle:@"用户使用协议" forState:UIControlStateNormal];
|
|
|
+ [ruleBtn setTitleColor:HWCFD1D4Color forState:UIControlStateNormal];
|
|
|
+ [ruleBtn setBackgroundColor:[UIColor clearColor]];
|
|
|
+ [ruleBtn addTarget:self action:@selector(ruleBtnClick) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ ruleBtn.layer.cornerRadius = 8;
|
|
|
+ ruleBtn.layer.masksToBounds = YES;
|
|
|
+ ruleBtn.layer.borderWidth = 1;
|
|
|
+ ruleBtn.layer.borderColor = HWCFD1D4Color.CGColor;
|
|
|
+ [self.view addSubview:ruleBtn];
|
|
|
+ [ruleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.bottom.mas_equalTo(privateBtn.mas_top).mas_offset(-15);
|
|
|
+ make.width.mas_equalTo(SCREEN_W-38*2);
|
|
|
+ make.height.mas_equalTo(48);
|
|
|
+ make.left.mas_equalTo(38);
|
|
|
+ }];
|
|
|
+
|
|
|
+ UIButton *versionCheckBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
+ [versionCheckBtn setTitle:@"版本检测" forState:UIControlStateNormal];
|
|
|
+ versionCheckBtn.titleLabel.font = [UIFont boldSystemFontOfSize:16.f];
|
|
|
+ [versionCheckBtn setTitleColor:HWCFD1D4Color forState:UIControlStateNormal];
|
|
|
+ [versionCheckBtn setBackgroundColor:[UIColor clearColor]];
|
|
|
+ [versionCheckBtn addTarget:self action:@selector(versionCheckBtnClick) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ versionCheckBtn.layer.cornerRadius = 8;
|
|
|
+ versionCheckBtn.layer.masksToBounds = YES;
|
|
|
+ versionCheckBtn.layer.borderWidth = 1;
|
|
|
+ versionCheckBtn.layer.borderColor = HWCFD1D4Color.CGColor;
|
|
|
+ [self.view addSubview:versionCheckBtn];
|
|
|
+ [versionCheckBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.bottom.mas_equalTo(ruleBtn.mas_top).mas_offset(-15);
|
|
|
+ make.left.mas_equalTo(38);
|
|
|
+ make.width.mas_equalTo(SCREEN_W-38*2);
|
|
|
+ make.height.mas_equalTo(48);
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+- (UIImage *)getAppIcon{
|
|
|
+
|
|
|
+ NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
|
|
|
+
|
|
|
+ //获取app中所有icon名字数组
|
|
|
+
|
|
|
+ NSArray *iconsArr = infoDict[@"CFBundleIcons"][@"CFBundlePrimaryIcon"][@"CFBundleIconFiles"];
|
|
|
+
|
|
|
+ //取最后一个icon的名字
|
|
|
+
|
|
|
+ NSString *iconLastName = [iconsArr lastObject];
|
|
|
+
|
|
|
+ //打印icon名字
|
|
|
+
|
|
|
+ NSLog(@"iconsArr: %@", iconsArr);
|
|
|
+
|
|
|
+ NSLog(@"iconLastName: %@", iconLastName);
|
|
|
+
|
|
|
+ return [UIImage imageNamed:iconLastName];
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark- 网络请求
|
|
|
+- (void)getVersion {
|
|
|
+
|
|
|
+ [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:@"检测新版本中…"];
|
|
|
+
|
|
|
+ NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
|
|
|
+ [paraDict setValue:@"ios" forKey:@"os"];
|
|
|
+ NSString *appID = [[NSBundle mainBundle] bundleIdentifier];
|
|
|
+ [paraDict setValue:appID forKey:@"packageName"];
|
|
|
+ [[UseAccountManage shareInstance] CommonGetWithCallBackCode:AppVersionCheckAPI Parameters:paraDict success:^(id _Nonnull responseObject) {
|
|
|
+ HLog(@"%@", responseObject);
|
|
|
+ [self removeNewIndicatorHaveStr];
|
|
|
+
|
|
|
+ SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
|
|
|
+
|
|
|
+ if (model.status && model.status.integerValue == 0) {
|
|
|
+
|
|
|
+ HWVersionModel *model = [HWVersionModel mj_objectWithKeyValues:responseObject[@"data"]];
|
|
|
+ self.versionModel = model;
|
|
|
+ [self checkVersion];
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ [[iToast makeText:model.msg] show];
|
|
|
+ }
|
|
|
+
|
|
|
+ } failure:^(NSError * _Nonnull error) {
|
|
|
+ HLog(@"%@", error);
|
|
|
+ [[iToast makeText:@"网络异常,请稍后重试!"] show];
|
|
|
+ [self removeNewIndicatorHaveStr];
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)versionCheckBtnClick {
|
|
|
+ [self getVersion];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)checkVersion {
|
|
|
+// NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleVersion"];
|
|
|
+ NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"];
|
|
|
+ NSString *newVersion = [self.versionModel.versionNumber stringByReplacingOccurrencesOfString:@"v" withString:@""]; //去掉v
|
|
|
+// HLog(@"%@---%@", newVersion, currentVersion);
|
|
|
+ if ([currentVersion compare:newVersion options:NSNumericSearch] == NSOrderedSame) { // 本地版本号 == 服务器版本号
|
|
|
+ [self showNoNewVersion];
|
|
|
+ [HWDataManager setBoolWithKey:Const_haveVersion value:NO];
|
|
|
+ }else if ([currentVersion compare:newVersion options:NSNumericSearch] == NSOrderedDescending) { // 本地版本号 > 服务器版本号 (异常情况)
|
|
|
+ [self showNoNewVersion];
|
|
|
+ [HWDataManager setBoolWithKey:Const_haveVersion value:NO];
|
|
|
+ }else { // 本地版本号 < 服务器版本号 (有新版本)
|
|
|
+ self.versionModel.versionNumber = newVersion;
|
|
|
+ [self showNewVersion];
|
|
|
+ [HWDataManager setBoolWithKey:Const_haveVersion value:YES];
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
+- (void)showNewVersion {
|
|
|
+
|
|
|
+ HaveNewVersionView *haveNewVersionView = [HaveNewVersionView shardInstance];
|
|
|
+ if (haveNewVersionView.isShow) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ haveNewVersionView.versionModel = self.versionModel;
|
|
|
+ haveNewVersionView.isContinueCheckAlert = NO; // 是否继续走下一步弹窗检测流程
|
|
|
+ [haveNewVersionView setBackgroundColor:RGBACOLOR(0, 0, 0, 0.5)];
|
|
|
+ [[[UIApplication sharedApplication] keyWindow] addSubview:haveNewVersionView];
|
|
|
+ haveNewVersionView.isShow = YES;
|
|
|
+ [haveNewVersionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.mas_equalTo(0);
|
|
|
+ make.left.mas_equalTo(0);
|
|
|
+ make.right.mas_equalTo(0);
|
|
|
+ make.bottom.mas_equalTo(0);
|
|
|
+ }];
|
|
|
+ haveNewVersionView.alpha = 0.0;
|
|
|
+
|
|
|
+ [UIView animateWithDuration:0.3 delay:0.0 options:UIViewAnimationOptionCurveEaseIn animations:^ {
|
|
|
+ haveNewVersionView.alpha = 1.0;
|
|
|
+ KyoLog(@"in animate start");
|
|
|
+ } completion:^(BOOL finished) {
|
|
|
+ KyoLog(@"in animate completion");
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)showNoNewVersion {
|
|
|
+ [[iToast makeText:@"已是最新版本"] show];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)ruleBtnClick {
|
|
|
+
|
|
|
+// [self gotoProtocolWKWebVCByPush:YES];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)privateBtnClick {
|
|
|
+
|
|
|
+// [self gotoPrivateProtocolWKWebVCByPush:YES];
|
|
|
+}
|
|
|
+
|
|
|
+@end
|