mySetHeadView.m 25 KB

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