mySetHeadView.m 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. //
  2. // mySetHeadView.m
  3. // 隐私保护
  4. //
  5. // Created by xd h on 2023/11/9.
  6. //
  7. #import "mySetHeadView.h"
  8. #import "TZImageManager.h"
  9. #import "backupsFileManager.h"
  10. #import "AFNetworkReachabilityManager.h"
  11. @interface mySetHeadView ()
  12. {
  13. UIView *imageBackupsBgView;
  14. UILabel *imageBackupsLabel;
  15. }
  16. @end
  17. @implementation mySetHeadView
  18. - (id)initWithFrame:(CGRect)frame{
  19. self = [super initWithFrame:frame];
  20. [self drawAnyView];
  21. [self setBackupsStateFun];
  22. return self;
  23. }
  24. - (void)drawAnyView{
  25. [self setBackgroundColor:[UIColor hwColor:@"#F5F7FA" alpha:1.0]];
  26. //self.backgroundColor = [UIColor redColor];
  27. //setting_Privacy_bg
  28. UIImageView *PrivacyBg = [[UIImageView alloc] init];
  29. PrivacyBg.image = [UIImage imageNamed:@"setting_Privacy_bg"];
  30. //PrivacyBg.contentMode = UIViewContentModeScaleAspectFit;
  31. PrivacyBg.userInteractionEnabled = YES;
  32. [self addSubview:PrivacyBg];
  33. //PrivacyBg.backgroundColor = [UIColor greenColor];
  34. CGFloat PrivacyBgW = SCREEN_W - 20;
  35. CGFloat PrivacyBgH = 116.0 * PrivacyBgW / (345.0);
  36. [PrivacyBg mas_makeConstraints:^(MASConstraintMaker *make) {
  37. make.left.mas_equalTo(10);
  38. make.top.mas_equalTo(10);
  39. make.width.mas_equalTo(PrivacyBgW);
  40. make.height.mas_equalTo(PrivacyBgH);
  41. }];
  42. UILabel *PrivacyTitleLabel = [[UILabel alloc] init];
  43. PrivacyTitleLabel.text = NSLocalizedString(@"my_set_Privacy_Model",nil) ;
  44. PrivacyTitleLabel.font = [UIFont boldSystemFontOfSize:16.0];
  45. PrivacyTitleLabel.textColor = [UIColor hwColor:@"0A132B" alpha:1.0];
  46. [PrivacyBg addSubview:PrivacyTitleLabel];
  47. [PrivacyTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.left.mas_equalTo(10);
  49. make.top.mas_equalTo(15);
  50. make.width.mas_equalTo(150);
  51. make.height.mas_equalTo(20);
  52. }];
  53. UIButton *setPrivacyBut = [[UIButton alloc] init];
  54. // gradient
  55. CAGradientLayer *gl = [CAGradientLayer layer];
  56. gl.frame = CGRectMake(0,0,80.f,32.f);
  57. gl.startPoint = CGPointMake(0, 0.5);
  58. gl.endPoint = CGPointMake(1, 0.5);
  59. gl.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor];
  60. gl.locations = @[@(0), @(1.0f)];
  61. [setPrivacyBut.layer addSublayer:gl];
  62. setPrivacyBut.tag = 4;
  63. [setPrivacyBut addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  64. setPrivacyBut.layer.cornerRadius = 16.0;
  65. setPrivacyBut.layer.masksToBounds = YES;
  66. [setPrivacyBut setTitle:NSLocalizedString(@"set_Privacy_button_title",nil) forState:UIControlStateNormal];
  67. setPrivacyBut.titleLabel.font = [UIFont systemFontOfSize:12.0];
  68. [PrivacyBg addSubview:setPrivacyBut];
  69. [setPrivacyBut mas_makeConstraints:^(MASConstraintMaker *make) {
  70. make.right.mas_equalTo(-10);
  71. make.top.mas_equalTo(10);
  72. make.width.mas_equalTo(80);
  73. make.height.mas_equalTo(32);
  74. }];
  75. UILabel *PrivacyTipLabel = [[UILabel alloc] init];
  76. PrivacyTipLabel.text = NSLocalizedString(@"set_Privacy_Tip",nil) ;
  77. PrivacyTipLabel.font = [UIFont systemFontOfSize:14.0];
  78. PrivacyTipLabel.textColor = [UIColor hwColor:@"#01B7EA" alpha:1.0];
  79. [PrivacyBg addSubview:PrivacyTipLabel];
  80. [PrivacyTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  81. make.left.mas_equalTo(10);
  82. make.top.mas_equalTo(PrivacyTitleLabel.mas_bottom).offset(10);
  83. make.right.mas_equalTo(0);
  84. make.height.mas_equalTo(20);
  85. }];
  86. UILabel *PrivacyTipLabel2 = [[UILabel alloc] init];
  87. PrivacyTipLabel2.text = NSLocalizedString(@"my_set_Privacy_Mode_tip1",nil) ;
  88. //PrivacyTipLabel2.font = [UIFont systemFontOfSize:12.0];
  89. PrivacyTipLabel2.textColor = [UIColor hwColor:@"#6A6A6A" alpha:1.0];
  90. PrivacyTipLabel2.numberOfLines = 0;
  91. [PrivacyBg addSubview:PrivacyTipLabel2];
  92. PrivacyTipLabel2.adjustsFontSizeToFitWidth = YES;
  93. [PrivacyTipLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
  94. make.left.mas_equalTo(10);
  95. make.top.mas_equalTo(PrivacyTipLabel.mas_bottom).offset(15);
  96. make.right.mas_equalTo(-10);
  97. make.height.mas_equalTo(30);
  98. }];
  99. //文件上传
  100. UIView *fileUploadBgView = [[UIView alloc] init];
  101. fileUploadBgView.backgroundColor = [UIColor whiteColor];
  102. fileUploadBgView.layer.cornerRadius = 8;
  103. [self addSubview:fileUploadBgView];
  104. [fileUploadBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  105. make.left.mas_equalTo(10);
  106. make.top.mas_equalTo(PrivacyBg.mas_bottom).offset(15);
  107. make.right.mas_equalTo(-10);
  108. make.height.mas_equalTo(110);
  109. }];
  110. UILabel *titleLabel = [[UILabel alloc] init];
  111. titleLabel.text = NSLocalizedString(@"my_set_no_File_upload_title",nil) ;
  112. titleLabel.font = [UIFont boldSystemFontOfSize:16.0];
  113. titleLabel.textColor = [UIColor blackColor];
  114. [fileUploadBgView addSubview:titleLabel];
  115. [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  116. make.left.mas_equalTo(10);
  117. make.top.mas_equalTo(10);
  118. make.width.mas_equalTo(140);
  119. make.height.mas_equalTo(20);
  120. }];
  121. //上传记录
  122. UIImageView *arrowImageView = [[UIImageView alloc] init];
  123. arrowImageView.image = [UIImage imageNamed:@"cell_right_access"];
  124. [fileUploadBgView addSubview:arrowImageView];
  125. [arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  126. make.right.mas_equalTo(-10);
  127. make.top.mas_equalTo(10);
  128. make.width.mas_equalTo(20);
  129. make.height.mas_equalTo(20);
  130. }];
  131. UILabel *rightLabel = [[UILabel alloc] init];
  132. rightLabel.text = NSLocalizedString(@"set_upload_download_tip",nil) ;
  133. rightLabel.font = [UIFont systemFontOfSize:14.0];
  134. rightLabel.textColor = [UIColor hwColor:@"#959799" alpha:1.0];
  135. rightLabel.textAlignment = NSTextAlignmentRight;
  136. [fileUploadBgView addSubview:rightLabel];
  137. [rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  138. make.right.mas_equalTo(arrowImageView.mas_left).offset(-2);
  139. make.top.mas_equalTo(10);
  140. make.width.mas_equalTo(200);
  141. make.height.mas_equalTo(20);
  142. }];
  143. UIButton *recordBut = [[UIButton alloc] init];
  144. //recordBut.backgroundColor = [UIColor greenColor];
  145. recordBut.tag = 1;
  146. [recordBut addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  147. [fileUploadBgView addSubview:recordBut];
  148. [recordBut mas_makeConstraints:^(MASConstraintMaker *make) {
  149. make.right.mas_equalTo(0);
  150. make.top.mas_equalTo(0);
  151. make.width.mas_equalTo(150);
  152. make.height.mas_equalTo(40);
  153. }];
  154. // arrowImageView.hidden = YES;
  155. // rightLabel.hidden = YES;
  156. // recordBut.hidden = YES;
  157. //图片上传
  158. NSString* curImgUploadStr = [[NSString alloc] initWithFormat:@"%@ %@",@" ",NSLocalizedString(@"my_set_no_image_upload",nil)];
  159. UIButton *imageUploadBut = [[UIButton alloc] init];
  160. [imageUploadBut setImage:[UIImage imageNamed:@"icon_image_upload"] forState:UIControlStateNormal];
  161. [imageUploadBut setTitle:curImgUploadStr forState:UIControlStateNormal];
  162. imageUploadBut.backgroundColor = [UIColor hwColor:@"#00D1C1" alpha:0.1];
  163. imageUploadBut.layer.cornerRadius = 4;
  164. [imageUploadBut setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  165. imageUploadBut.titleLabel.font = [UIFont systemFontOfSize:13.0];
  166. imageUploadBut.tag = 2;
  167. [imageUploadBut addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  168. [fileUploadBgView addSubview:imageUploadBut];
  169. [imageUploadBut mas_makeConstraints:^(MASConstraintMaker *make) {
  170. make.left.mas_equalTo(10);
  171. make.right.mas_equalTo(self.mas_centerX).offset(-10);
  172. make.bottom.mas_equalTo(-10);
  173. make.height.mas_equalTo(48);
  174. }];
  175. //视频上传
  176. NSString* curVidelUploadStr = [[NSString alloc] initWithFormat:@"%@ %@",@" ",NSLocalizedString(@"my_set_no_video_upload",nil)];
  177. UIButton *videoUploadBut = [[UIButton alloc] init];
  178. [videoUploadBut setImage:[UIImage imageNamed:@"icon_video_upload"] forState:UIControlStateNormal];
  179. [videoUploadBut setTitle:curVidelUploadStr forState:UIControlStateNormal];
  180. videoUploadBut.backgroundColor = [UIColor hwColor:@"#00D8FF" alpha:0.1];
  181. videoUploadBut.layer.cornerRadius = 4;
  182. [videoUploadBut setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  183. videoUploadBut.titleLabel.font = [UIFont systemFontOfSize:13.0];
  184. videoUploadBut.tag = 3;
  185. [videoUploadBut addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  186. [fileUploadBgView addSubview:videoUploadBut];
  187. [videoUploadBut mas_makeConstraints:^(MASConstraintMaker *make) {
  188. make.right.mas_equalTo(-10);
  189. make.left.mas_equalTo(self.mas_centerX).offset(10);
  190. make.bottom.mas_equalTo(-10);
  191. make.height.mas_equalTo(48);
  192. }];
  193. //文件备份
  194. UIView *fileBackupsBgView = [[UIView alloc] init];
  195. fileBackupsBgView.backgroundColor = [UIColor whiteColor];
  196. fileBackupsBgView.layer.cornerRadius = 8;
  197. [self addSubview:fileBackupsBgView];
  198. [fileBackupsBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  199. make.left.mas_equalTo(10);
  200. make.top.mas_equalTo(fileUploadBgView.mas_bottom).offset(15);
  201. make.right.mas_equalTo(-10);
  202. make.height.mas_equalTo(110);
  203. }];
  204. UILabel *BackupsTitleLabel = [[UILabel alloc] init];
  205. BackupsTitleLabel.text = NSLocalizedString(@"set_Privacy_title",nil) ;
  206. BackupsTitleLabel.font = [UIFont boldSystemFontOfSize:16.0];
  207. BackupsTitleLabel.textColor = [UIColor blackColor];
  208. [fileBackupsBgView addSubview:BackupsTitleLabel];
  209. [BackupsTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  210. make.left.mas_equalTo(10);
  211. make.top.mas_equalTo(10);
  212. make.width.mas_equalTo(180);
  213. make.height.mas_equalTo(20);
  214. }];
  215. //
  216. UIImageView *arrowImageView2 = [[UIImageView alloc] init];
  217. arrowImageView2.image = [UIImage imageNamed:@"cell_right_access"];
  218. [fileBackupsBgView addSubview:arrowImageView2];
  219. [arrowImageView2 mas_makeConstraints:^(MASConstraintMaker *make) {
  220. make.right.mas_equalTo(-10);
  221. make.top.mas_equalTo(10);
  222. make.width.mas_equalTo(20);
  223. make.height.mas_equalTo(20);
  224. }];
  225. NSString *BackupsRightTitle = NSLocalizedString(@"set_Privacy_right_tip",nil);
  226. CGFloat BackupsRightW = [BackupsRightTitle boundingRectWithSize:CGSizeMake(200, 20) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14.0]} context:nil].size.width;
  227. BackupsRightW += 5;
  228. UILabel *BackupsRightLabel = [[UILabel alloc] init];
  229. BackupsRightLabel.text = BackupsRightTitle;
  230. BackupsRightLabel.font = [UIFont systemFontOfSize:14.0];
  231. BackupsRightLabel.textColor = [UIColor hwColor:@"#959799" alpha:1.0];
  232. BackupsRightLabel.textAlignment = NSTextAlignmentRight;
  233. [fileBackupsBgView addSubview:BackupsRightLabel];
  234. [BackupsRightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  235. make.right.mas_equalTo(arrowImageView.mas_left).offset(-2);
  236. make.top.mas_equalTo(10);
  237. make.width.mas_equalTo(BackupsRightW);
  238. make.height.mas_equalTo(20);
  239. }];
  240. UIButton *BackupsSetBut = [[UIButton alloc] init];
  241. //BackupsSetBut.backgroundColor = [UIColor greenColor];
  242. BackupsSetBut.tag = 5;
  243. [BackupsSetBut addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  244. [fileBackupsBgView addSubview:BackupsSetBut];
  245. [BackupsSetBut mas_makeConstraints:^(MASConstraintMaker *make) {
  246. make.right.mas_equalTo(0);
  247. make.top.mas_equalTo(0);
  248. make.left.mas_equalTo(BackupsRightLabel.mas_left);
  249. make.height.mas_equalTo(40);
  250. }];
  251. // arrowImageView2.hidden = YES;
  252. // BackupsRightLabel.hidden = YES;
  253. // BackupsSetBut.hidden = YES;
  254. UIButton *BackupsEyeBut = [[UIButton alloc] init];
  255. //BackupsEyeBut.backgroundColor = [UIColor greenColor];
  256. [BackupsEyeBut setImage:[UIImage imageNamed:@"common_eye_open"] forState:UIControlStateNormal];
  257. [BackupsEyeBut setImage:[UIImage imageNamed:@"common_eye_close"] forState:UIControlStateSelected];
  258. BackupsEyeBut.tag = 6;
  259. [BackupsEyeBut addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  260. [fileBackupsBgView addSubview:BackupsEyeBut];
  261. [BackupsEyeBut mas_makeConstraints:^(MASConstraintMaker *make) {
  262. make.right.mas_equalTo(BackupsSetBut.mas_left).offset(0);
  263. make.centerY.mas_equalTo(BackupsRightLabel.mas_centerY);
  264. make.width.mas_equalTo(40);
  265. make.height.mas_equalTo(40);
  266. }];
  267. BackupsEyeBut.hidden = YES;
  268. imageBackupsBgView = [[UIView alloc] init];
  269. imageBackupsBgView.backgroundColor = [UIColor hwColor:@"#F9F9F9" alpha:1.0];
  270. imageBackupsBgView.layer.cornerRadius = 8;
  271. [fileBackupsBgView addSubview:imageBackupsBgView];
  272. [imageBackupsBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  273. make.right.mas_equalTo(-10);
  274. make.left.mas_equalTo(10);
  275. make.bottom.mas_equalTo(-10);
  276. make.height.mas_equalTo(56);
  277. }];
  278. UIImageView *backupsImageV = [[UIImageView alloc] init];
  279. backupsImageV.image = [UIImage imageNamed:@"image_backups_icon"];
  280. [imageBackupsBgView addSubview:backupsImageV];
  281. [backupsImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  282. make.centerY.mas_equalTo(0);
  283. make.left.mas_equalTo(10);
  284. make.width.mas_equalTo(28);
  285. make.height.mas_equalTo(28);
  286. }];
  287. UILabel *imageBackupsTitleLabel = [[UILabel alloc] init];
  288. imageBackupsTitleLabel.text = NSLocalizedString(@"set_Privacy_title_image",nil) ;
  289. imageBackupsTitleLabel.font = [UIFont systemFontOfSize:14.0];
  290. imageBackupsTitleLabel.textColor = [UIColor blackColor];
  291. [imageBackupsBgView addSubview:imageBackupsTitleLabel];
  292. [imageBackupsTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  293. make.centerY.mas_equalTo(-10);
  294. make.left.mas_equalTo(backupsImageV.mas_right).offset(10);
  295. make.right.mas_equalTo(-(10+60+10));
  296. make.height.mas_equalTo(20);
  297. }];
  298. _imageBackupsLabel = [[UILabel alloc] init];
  299. //_imageBackupsLabel.text = NSLocalizedString(@"set_Privacy_title_image_open",nil) ;
  300. _imageBackupsLabel.font = [UIFont systemFontOfSize:12.0];
  301. _imageBackupsLabel.textColor = [UIColor hwColor:@"#6A6A6A" alpha:1.0];
  302. [imageBackupsBgView addSubview:_imageBackupsLabel];
  303. [_imageBackupsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  304. make.centerY.mas_equalTo(10);
  305. make.left.mas_equalTo(backupsImageV.mas_right).offset(10);
  306. make.right.mas_equalTo(-(10+60+10));
  307. make.height.mas_equalTo(20);
  308. }];
  309. _imageBackupsButton = [[UIButton alloc] init];
  310. _imageBackupsButton.backgroundColor = [UIColor hwColor:@"#DCF4FB" alpha:1.0];
  311. _imageBackupsButton.tag = 7;
  312. [_imageBackupsButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  313. _imageBackupsButton.layer.cornerRadius = 12.0;
  314. _imageBackupsButton.layer.masksToBounds = YES;
  315. [_imageBackupsButton setTitle:NSLocalizedString(@"common_open",nil) forState:UIControlStateNormal];
  316. [_imageBackupsButton setTitle:NSLocalizedString(@"common_close",nil) forState:UIControlStateSelected];
  317. [_imageBackupsButton setTitleColor:[UIColor hwColor:@"#01B7EA" alpha:1.0] forState:UIControlStateNormal];
  318. _imageBackupsButton.titleLabel.font = [UIFont systemFontOfSize:12.0];
  319. [imageBackupsBgView addSubview:_imageBackupsButton];
  320. [_imageBackupsButton mas_makeConstraints:^(MASConstraintMaker *make) {
  321. make.right.mas_equalTo(-10);
  322. make.centerY.mas_equalTo(0);
  323. make.width.mas_equalTo(60);
  324. make.height.mas_equalTo(24);
  325. }];
  326. //其他功能
  327. UIView *otherBgView = [[UIView alloc] init];
  328. otherBgView.backgroundColor = [UIColor whiteColor];
  329. otherBgView.layer.cornerRadius = 8;
  330. [self addSubview:otherBgView];
  331. [otherBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  332. make.left.mas_equalTo(10);
  333. make.top.mas_equalTo(fileBackupsBgView.mas_bottom).offset(15);
  334. make.right.mas_equalTo(-10);
  335. make.height.mas_equalTo(135);
  336. }];
  337. UILabel *otherTitleLabel = [[UILabel alloc] init];
  338. otherTitleLabel.text = NSLocalizedString(@"set_other_title",nil) ;
  339. otherTitleLabel.font = [UIFont boldSystemFontOfSize:16.0];
  340. otherTitleLabel.textColor = [UIColor blackColor];
  341. [otherBgView addSubview:otherTitleLabel];
  342. [otherTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  343. make.left.mas_equalTo(10);
  344. make.top.mas_equalTo(10);
  345. make.width.mas_equalTo(150);
  346. make.height.mas_equalTo(20);
  347. }];
  348. NSArray *titleArr = @[NSLocalizedString(@"my_set_no_change_phone",nil),
  349. NSLocalizedString(@"my_set_no_restart_phone",nil),
  350. NSLocalizedString(@"my_set_no_Restore_Factory",nil),
  351. NSLocalizedString(@"my_set_no_common_problem",nil),
  352. NSLocalizedString(@"my_set_no_check_update",nil)];
  353. NSArray *imageArr = @[@"icon_change_ohone",@"icon-gengxin",@"icon_Restore_Factory",@"icon_common_problem",@"app_update"];
  354. CGFloat butWidth = (SCREEN_W -20)/titleArr.count;
  355. CGFloat butHeight = 88.0;
  356. for (int i=0; i<titleArr.count; i++) {
  357. UILabel *curlab = [[UILabel alloc] init];
  358. curlab.text = titleArr[i];
  359. curlab.font = [UIFont systemFontOfSize:12.0];
  360. curlab.textColor = [UIColor hwColor:@"#0A132B" alpha:1.0];
  361. curlab.numberOfLines = 0;
  362. curlab.textAlignment = NSTextAlignmentCenter;
  363. [otherBgView addSubview:curlab];
  364. [curlab mas_makeConstraints:^(MASConstraintMaker *make) {
  365. make.left.mas_equalTo(butWidth*i);
  366. make.bottom.mas_equalTo(-10);
  367. make.width.mas_equalTo(butWidth);
  368. make.height.mas_equalTo(30);
  369. }];
  370. UIButton *curImageV = [[UIButton alloc] init];
  371. curImageV.userInteractionEnabled = NO;
  372. [curImageV setImage:[UIImage imageNamed:imageArr[i]] forState:UIControlStateNormal];;
  373. [otherBgView addSubview:curImageV];
  374. [curImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  375. make.left.mas_equalTo(butWidth*i);
  376. make.bottom.mas_equalTo(curlab.mas_top);
  377. make.width.mas_equalTo(butWidth);
  378. make.height.mas_equalTo(40);
  379. }];
  380. UIButton *curButton = [[UIButton alloc] init];
  381. //curButton.backgroundColor = [UIColor greenColor];
  382. curButton.tag = 10 + i;
  383. [curButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  384. //[curButton setTitle:titleArr[i] forState:UIControlStateNormal];
  385. //[curButton setTitleColor:[UIColor hwColor:@"#0A132B" alpha:1.0] forState:UIControlStateNormal];
  386. //[curButton setImage:[UIImage imageNamed:imageArr[i]] forState:UIControlStateNormal];
  387. //curButton.titleLabel.font = [UIFont systemFontOfSize:12.0];
  388. [otherBgView addSubview:curButton];
  389. [curButton mas_makeConstraints:^(MASConstraintMaker *make) {
  390. make.left.mas_equalTo(butWidth*i);
  391. make.bottom.mas_equalTo(0);
  392. make.width.mas_equalTo(butWidth);
  393. make.height.mas_equalTo(butHeight);
  394. }];
  395. }
  396. }
  397. - (void)closeImageBackupsFun
  398. {
  399. [HWDataManager setBoolWithKey:stringKeyAddSn(Const_photo_backups_state) value:NO];
  400. [self setBackupsStateFun];
  401. //处理相册备份
  402. [[backupsFileManager shareInstance] suspendBackupsFileFun];
  403. }
  404. - (void)openImageBackupsFun
  405. {
  406. BOOL isCanUseCellular = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_backups_canUse_Cellular)];
  407. if(!isCanUseCellular){//不允许流量上传
  408. //
  409. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWWAN){
  410. mainBlock(^{
  411. [[iToast makeText:NSLocalizedString(@"File_Transfer_By_Cellular_tip",nil)] show];
  412. });
  413. return;
  414. }
  415. }
  416. [self showBackupsReadTipFun];
  417. [HWDataManager setBoolWithKey:stringKeyAddSn(Const_photo_backups_state) value:YES];
  418. [self setBackupsStateFun];
  419. [[iToast makeText:NSLocalizedString(@"set_Privacy_title_image_open",nil)] show];
  420. //处理相册备份
  421. [[backupsFileManager shareInstance] handlePhotosBackupsFun];
  422. }
  423. - (void)showBackupsReadTipFun
  424. {
  425. BOOL didReadbackupsTipType = [HWDataManager getBoolWithKey:Const_file_backups_need_read];
  426. if(didReadbackupsTipType){//阅读过
  427. return;
  428. }
  429. //KWeakSelf
  430. /*弹窗提示恢复出厂*/
  431. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:nil
  432. msg:NSLocalizedString(@"backups_need_read_msg",nil)
  433. imageStr:nil
  434. cancelTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil)
  435. okTitle:nil
  436. isOkBtnHighlight:NO
  437. didClickOk:^{
  438. } didClickCancel:^{
  439. [HWDataManager setBoolWithKey:Const_file_backups_need_read value:YES];
  440. }];
  441. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  442. [[iTools appRootViewController] presentViewController:nextVC animated:YES completion:^{
  443. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  444. }];
  445. }
  446. - (void)setBackupsStateFun
  447. {
  448. BOOL haveOpenBackups = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_photo_backups_state)];
  449. _imageBackupsButton.selected = haveOpenBackups;
  450. if(haveOpenBackups){
  451. _imageBackupsLabel.text = NSLocalizedString(@"set_Privacy_title_image_open",nil) ;
  452. }
  453. else
  454. {
  455. _imageBackupsLabel.text = NSLocalizedString(@"set_Privacy_title_image_close",nil) ;
  456. }
  457. }
  458. #pragma mark 按钮点击事件
  459. - (void)didClickButFun:(UIButton*)but
  460. {
  461. NSInteger tag = but.tag;
  462. //HLog(@"xxxx:%ld",tag)
  463. if(tag == 7){
  464. BOOL haveOpenBackups = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_photo_backups_state)];
  465. if(!haveOpenBackups){
  466. if(ksharedAppDelegate.DisabledFileTransferType){
  467. [[iToast makeText:NSLocalizedString(@"File_Transfer_Disable_tip",nil)] show];
  468. return;
  469. }
  470. if(!ksharedAppDelegate.isWebSockLinkOKAginType){
  471. [[iToast makeText:NSLocalizedString(@"check_could_phone_state",nil)] show];
  472. return;
  473. }
  474. //相册权限
  475. if (![[TZImageManager manager] authorizationStatusAuthorized]){
  476. [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
  477. if(status == PHAuthorizationStatusAuthorized){
  478. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  479. [self openImageBackupsFun];
  480. });
  481. }
  482. }];
  483. }
  484. else{
  485. [self openImageBackupsFun];
  486. }
  487. return;
  488. }
  489. }
  490. if(_didClickBut){
  491. _didClickBut(tag);
  492. }
  493. }
  494. @end