fileTransfeSetViewController.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. //
  2. // fileTransfeSetViewController.m
  3. // 隐私保护
  4. //
  5. // Created by xd h on 2023/12/28.
  6. //
  7. #import "fileTransfeSetViewController.h"
  8. #import "fileSetTableViewCell.h"
  9. #import "fileTransferPathCheckViewController.h"
  10. #import "uploadFileManager.h"
  11. #import "backupsFileManager.h"
  12. @interface fileTransfeSetViewController ()<UITableViewDelegate,UITableViewDataSource>
  13. @property (nonatomic, strong) UITableView *tableView;
  14. @property (nonatomic, strong) UIView *tailView;
  15. @property (nonatomic, strong) UILabel *uploadFilePathLabel;
  16. @property (nonatomic, strong) UILabel *backupsFilePathLabel;
  17. @end
  18. @implementation fileTransfeSetViewController
  19. - (void)viewDidLoad {
  20. [super viewDidLoad];
  21. // Do any additional setup after loading the view.
  22. [self.toolBar setHidden:YES];
  23. [self.navigationBar setHidden:YES];
  24. [self.navBarBGView setHidden:NO];
  25. [self.titleLabel setText:NSLocalizedString(@"set_file_Transfer_WWAN_title",nil)];
  26. [self.view setBackgroundColor:HWF5F7FAColor];
  27. [self drawAnyView];
  28. }
  29. - (void)viewWillAppear:(BOOL)animated
  30. {
  31. [super viewWillAppear:animated];
  32. [self setUploadFilePathLabelTitleFun];
  33. [self setBackupsFilePathLabelTitleFun];
  34. }
  35. - (void)drawAnyView{
  36. [self.view addSubview:self.tableView];
  37. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  38. make.left.mas_equalTo(0);
  39. make.right.mas_equalTo(0);
  40. make.bottom.mas_equalTo(0);
  41. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  42. }];
  43. self.tableView.tableFooterView = [self tailView];
  44. }
  45. #pragma mark - 懒加载
  46. - (UITableView *)tableView{
  47. if (!_tableView) {
  48. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H - TABBARHEIGHT) style:UITableViewStylePlain];
  49. _tableView.delegate = self;
  50. _tableView.dataSource = self;
  51. _tableView.showsVerticalScrollIndicator = NO;
  52. _tableView.showsHorizontalScrollIndicator = NO;
  53. // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
  54. [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
  55. [_tableView setSeparatorColor:[UIColor clearColor]];
  56. [_tableView setBackgroundColor:[UIColor clearColor]];
  57. [_tableView setTableFooterView:[UIView new]];
  58. [_tableView setBounces:YES];
  59. _tableView.scrollEnabled = NO;
  60. if (@available(iOS 15.0, *)) {
  61. _tableView.sectionHeaderTopPadding = 0;
  62. }
  63. }
  64. return _tableView;
  65. }
  66. #pragma mark - 懒加载
  67. - (UIView *)tailView{
  68. if (!_tailView) {
  69. _tailView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 110 +15 + 110)];
  70. UIView *tailBgView = [[UIView alloc] init];
  71. tailBgView.backgroundColor = [UIColor whiteColor];
  72. tailBgView.layer.cornerRadius = 8;
  73. tailBgView.tag = 1;
  74. [_tailView addSubview:tailBgView];
  75. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didClickTailViewFun:)];
  76. [tailBgView addGestureRecognizer:tap];
  77. [tailBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  78. make.left.mas_equalTo(15);
  79. make.right.mas_equalTo(-15);
  80. make.height.mas_equalTo(90);
  81. make.top.mas_equalTo(15);
  82. }];
  83. UILabel *titleLab = [[UILabel alloc] init];
  84. titleLab.text = NSLocalizedString(@"File_upload_path_set",nil);
  85. titleLab.font = [UIFont boldSystemFontOfSize:14.0];
  86. titleLab.textColor = [UIColor hwColor:@"#0A132B" alpha:1.0];
  87. [tailBgView addSubview:titleLab];
  88. [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
  89. make.left.mas_equalTo(10);
  90. make.right.mas_equalTo(-50);
  91. make.height.mas_equalTo(20);
  92. make.top.mas_equalTo(20);
  93. }];
  94. /*右侧箭头*/
  95. UIImageView *rightImage = [[UIImageView alloc] init];
  96. [rightImage setBackgroundColor:[UIColor clearColor]];
  97. [rightImage setImage:[UIImage imageNamed:@"cell_right_access"]];
  98. [tailBgView addSubview:rightImage];
  99. [rightImage mas_makeConstraints:^(MASConstraintMaker *make) {
  100. make.width.mas_equalTo(28);
  101. make.right.mas_equalTo(-15.f);
  102. make.height.mas_equalTo(28);
  103. make.centerY.equalTo(titleLab.mas_centerY);
  104. }];
  105. _uploadFilePathLabel=[[UILabel alloc] init];
  106. //titleLab.text = NSLocalizedString(@"File_upload_path_set",nil);
  107. _uploadFilePathLabel.font = [UIFont systemFontOfSize:12.0];
  108. _uploadFilePathLabel.textColor = [UIColor hwColor:@"#6A6A6A" alpha:1.0];
  109. _uploadFilePathLabel.numberOfLines = 0;
  110. [tailBgView addSubview:_uploadFilePathLabel];
  111. [_uploadFilePathLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  112. make.left.mas_equalTo(10);
  113. make.right.mas_equalTo(-15);
  114. make.bottom.mas_equalTo(-20);
  115. make.top.mas_equalTo(titleLab.mas_bottom).offset(10.0);
  116. }];
  117. [self setUploadFilePathLabelTitleFun];
  118. //相册备份设置
  119. UIView *tailBgView2 = [[UIView alloc] init];
  120. tailBgView2.backgroundColor = [UIColor whiteColor];
  121. tailBgView2.layer.cornerRadius = 8;
  122. tailBgView2.tag = 2;
  123. [_tailView addSubview:tailBgView2];
  124. UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didClickTailViewFun:)];
  125. [tailBgView2 addGestureRecognizer:tap2];
  126. [tailBgView2 mas_makeConstraints:^(MASConstraintMaker *make) {
  127. make.left.mas_equalTo(15);
  128. make.right.mas_equalTo(-15);
  129. make.height.mas_equalTo(90);
  130. make.top.mas_equalTo(tailBgView.mas_bottom).offset(15.0);
  131. }];
  132. UILabel *titleLab2 = [[UILabel alloc] init];
  133. titleLab2.text = NSLocalizedString(@"File_backups_path_set",nil);
  134. titleLab2.font = [UIFont boldSystemFontOfSize:14.0];
  135. titleLab2.textColor = [UIColor hwColor:@"#0A132B" alpha:1.0];
  136. [tailBgView2 addSubview:titleLab2];
  137. [titleLab2 mas_makeConstraints:^(MASConstraintMaker *make) {
  138. make.left.mas_equalTo(10);
  139. make.right.mas_equalTo(-50);
  140. make.height.mas_equalTo(20);
  141. make.top.mas_equalTo(20);
  142. }];
  143. /*右侧箭头*/
  144. UIImageView *rightImage2 = [[UIImageView alloc] init];
  145. [rightImage2 setBackgroundColor:[UIColor clearColor]];
  146. [rightImage2 setImage:[UIImage imageNamed:@"cell_right_access"]];
  147. [tailBgView2 addSubview:rightImage2];
  148. [rightImage2 mas_makeConstraints:^(MASConstraintMaker *make) {
  149. make.width.mas_equalTo(28);
  150. make.right.mas_equalTo(-15.f);
  151. make.height.mas_equalTo(28);
  152. make.centerY.equalTo(titleLab2.mas_centerY);
  153. }];
  154. _backupsFilePathLabel=[[UILabel alloc] init];
  155. //titleLab.text = NSLocalizedString(@"File_upload_path_set",nil);
  156. _backupsFilePathLabel.font = [UIFont systemFontOfSize:12.0];
  157. _backupsFilePathLabel.textColor = [UIColor hwColor:@"#6A6A6A" alpha:1.0];
  158. _backupsFilePathLabel.numberOfLines = 0;
  159. [tailBgView2 addSubview:_backupsFilePathLabel];
  160. [_backupsFilePathLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  161. make.left.mas_equalTo(15);
  162. make.right.mas_equalTo(-15);
  163. make.bottom.mas_equalTo(-10);
  164. make.top.mas_equalTo(titleLab2.mas_bottom).offset(10.0);
  165. }];
  166. [self setBackupsFilePathLabelTitleFun];
  167. }
  168. return _tailView;
  169. }
  170. - (void)setUploadFilePathLabelTitleFun
  171. {
  172. NSString * leftStr = NSLocalizedString(@"File_upload_path_way",nil);
  173. NSString * uploadDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_photo_upload_default_path)];
  174. if(!uploadDefaultPath || uploadDefaultPath.length == 0){
  175. [HWDataManager setStringWithKey:stringKeyAddSn(Const_photo_upload_default_path) value:Const_default_upload_path];
  176. uploadDefaultPath = Const_default_upload_path;
  177. }
  178. if([uploadDefaultPath containsString:@"mnt/media_rw"]){
  179. uploadDefaultPath = [uploadDefaultPath stringByReplacingOccurrencesOfString:@"mnt/media_rw" withString:NSLocalizedString(@"disk_Extra_default_tip",nil)];
  180. }
  181. else if([uploadDefaultPath containsString:@"storage/emulated/0"]){
  182. uploadDefaultPath = [uploadDefaultPath stringByReplacingOccurrencesOfString:@"storage/emulated/0" withString:NSLocalizedString(@"disk_phone_default_tip",nil)];
  183. }
  184. else if([uploadDefaultPath containsString:@"sdcard"]){
  185. uploadDefaultPath = [uploadDefaultPath stringByReplacingOccurrencesOfString:@"sdcard" withString:NSLocalizedString(@"disk_phone_default_tip",nil)];
  186. }
  187. NSString * rightStr = uploadDefaultPath;
  188. NSString *totalStr = [[NSString alloc] initWithFormat:@"%@%@",leftStr,rightStr];
  189. NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:totalStr];
  190. NSRange redRange = NSMakeRange([totalStr rangeOfString:rightStr].location, [totalStr rangeOfString:rightStr].length);
  191. [noteStr addAttribute:NSForegroundColorAttributeName value:[UIColor hwColor:@"#01B7EA" alpha:0.8] range:redRange];
  192. [noteStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12.0] range:redRange];
  193. // 设置行间距
  194. NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
  195. [paragraphStyle setLineSpacing:5]; //设置行间距
  196. [noteStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [totalStr length])];
  197. _uploadFilePathLabel.attributedText = noteStr;
  198. }
  199. - (void)setBackupsFilePathLabelTitleFun
  200. {
  201. NSString * leftStr = NSLocalizedString(@"File_backups_path_way_tip2",nil);
  202. NSString * backupsDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_photo_backups_default_path)];
  203. if(!backupsDefaultPath || backupsDefaultPath.length == 0){
  204. backupsDefaultPath = Const_default_backups_path;
  205. [HWDataManager setStringWithKey:stringKeyAddSn(Const_photo_backups_default_path) value:backupsDefaultPath];
  206. }
  207. if([backupsDefaultPath containsString:@"mnt/media_rw"]){
  208. backupsDefaultPath = [backupsDefaultPath stringByReplacingOccurrencesOfString:@"mnt/media_rw" withString:NSLocalizedString(@"disk_Extra_default_tip",nil)];
  209. }
  210. else if([backupsDefaultPath containsString:@"storage/emulated/0"]){
  211. backupsDefaultPath = [backupsDefaultPath stringByReplacingOccurrencesOfString:@"storage/emulated/0" withString:NSLocalizedString(@"disk_phone_default_tip",nil)];
  212. }
  213. else if([backupsDefaultPath containsString:@"sdcard"]){
  214. backupsDefaultPath = [backupsDefaultPath stringByReplacingOccurrencesOfString:@"sdcard" withString:NSLocalizedString(@"disk_phone_default_tip",nil)];
  215. }
  216. NSString * rightStr = backupsDefaultPath;
  217. NSString *totalStr = [[NSString alloc] initWithFormat:@"%@%@",leftStr,rightStr];
  218. NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:totalStr];
  219. NSRange redRange = NSMakeRange([totalStr rangeOfString:rightStr].location, [totalStr rangeOfString:rightStr].length);
  220. [noteStr addAttribute:NSForegroundColorAttributeName value:[UIColor hwColor:@"#01B7EA" alpha:0.8] range:redRange];
  221. [noteStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12.0] range:redRange];
  222. // 设置行间距
  223. NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
  224. [paragraphStyle setLineSpacing:5]; //设置行间距
  225. [noteStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [totalStr length])];
  226. _backupsFilePathLabel.attributedText = noteStr;
  227. }
  228. #pragma mark 尾部事件
  229. - (void)didClickTailViewFun:(UITapGestureRecognizer*)tap
  230. {
  231. UIView *curView = tap.view;
  232. if(curView.tag == 1){
  233. [self gotoSetUploadPathFun];
  234. }
  235. else if (curView.tag == 2){
  236. [self gotoSetBackupsPathFun];
  237. }
  238. }
  239. -(void)gotoSetUploadPathFun
  240. {
  241. uploadFileDataModel* model = [uploadFileManager shareInstance].curUploadFileDataModel;
  242. if(!model){
  243. [[uploadFileManager shareInstance] getDataInDatabaseFun:YES complete:^(NSMutableArray * _Nonnull Arr) {
  244. mainBlock(^{
  245. if(Arr && Arr.count== 3){
  246. NSArray *uploadingArr = Arr.firstObject;
  247. if(uploadingArr.count == 0){
  248. [self gotofileTransferPathCheckVCFunWithType:1];
  249. }
  250. else{
  251. [[iToast makeText:NSLocalizedString(@"File_upload_set_default_path_tip",nil)] show];
  252. }
  253. }
  254. });
  255. }];
  256. }
  257. else if(model.curUploadStateType == uploadStateUploading
  258. ||model.curUploadStateType == uploadStateSuspend
  259. ){
  260. //判断尺寸路径是否存在
  261. NSString * uploadDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_photo_upload_default_path)];
  262. BOOL isExtraFileType = NO;
  263. BOOL isExtraPathFind = NO;
  264. if(uploadDefaultPath){
  265. if(![uploadDefaultPath containsString:@"sdcard/"]){
  266. isExtraFileType = YES;
  267. }
  268. }
  269. if(uploadDefaultPath && ksharedAppDelegate.cloudPhoneExtraFileListMod){
  270. NSArray*arr = ksharedAppDelegate.cloudPhoneExtraFileListMod.data;
  271. for (cloudPhoneExtraFileModel*model in arr) {
  272. if([uploadDefaultPath containsString:model.extraPath]){
  273. isExtraPathFind = YES;
  274. break;
  275. }
  276. }
  277. }
  278. if(isExtraFileType && !isExtraPathFind){
  279. [self gotofileTransferPathCheckVCFunWithType:1];
  280. }
  281. else{
  282. [[iToast makeText:NSLocalizedString(@"File_upload_set_default_path_tip",nil)] show];
  283. }
  284. }
  285. else{
  286. [self gotofileTransferPathCheckVCFunWithType:1];
  287. }
  288. }
  289. #pragma mark 设置备份路径相关
  290. - (void)gotoSetBackupsPathFun
  291. {
  292. photosBackupsTaskModel* model = [backupsFileManager shareInstance].curPhotosBackupsTaskMod;
  293. if(!model){
  294. KWeakSelf
  295. [photosBackupsTaskModel bg_findAsync:backups_photos_tableName limit:1 orderBy:nil desc:YES complete:^(NSArray * _Nullable array) {
  296. mainBlock(^{
  297. if(array && array.count > 0){
  298. photosBackupsTaskModel *preModel = array.lastObject;
  299. if(preModel.curBackupsState == backupsStateUploading
  300. ||preModel.curBackupsState == backupsStateSuspend
  301. ){
  302. [[iToast makeText:NSLocalizedString(@"File_backups_set_default_path_tip",nil)] show];
  303. }
  304. else{
  305. [self gotofileTransferPathCheckVCFunWithType:2];
  306. }
  307. }
  308. else{
  309. [self gotofileTransferPathCheckVCFunWithType:2];
  310. }
  311. });
  312. }];
  313. }
  314. else if(model.curBackupsState == backupsStateUploading
  315. //|| model.curBackupsState == backupsStateSuspend
  316. )
  317. {
  318. //判断尺寸路径是否存在
  319. NSString * uploadDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_photo_backups_default_path)];
  320. BOOL isExtraFileType = NO;
  321. BOOL isExtraPathFind = NO;
  322. if(uploadDefaultPath){
  323. if(![uploadDefaultPath containsString:@"sdcard/"]){
  324. isExtraFileType = YES;
  325. }
  326. }
  327. if(uploadDefaultPath && ksharedAppDelegate.cloudPhoneExtraFileListMod){
  328. NSArray*arr = ksharedAppDelegate.cloudPhoneExtraFileListMod.data;
  329. for (cloudPhoneExtraFileModel*model in arr) {
  330. if([uploadDefaultPath containsString:model.extraPath]){
  331. isExtraPathFind = YES;
  332. break;
  333. }
  334. }
  335. }
  336. if(isExtraFileType && !isExtraPathFind){
  337. [self gotofileTransferPathCheckVCFunWithType:2];
  338. }
  339. else{
  340. [[iToast makeText:NSLocalizedString(@"File_backups_set_default_path_tip",nil)] show];
  341. }
  342. }
  343. else{
  344. [self gotofileTransferPathCheckVCFunWithType:2];
  345. }
  346. }
  347. //type 1 上传 2备份
  348. - (void)gotofileTransferPathCheckVCFunWithType:(NSInteger)type
  349. {
  350. fileTransferPathCheckViewController *vc = [fileTransferPathCheckViewController new];
  351. vc.curType = type;
  352. [self.navigationController pushViewController:vc animated:YES];
  353. }
  354. #pragma mark - 列表委托
  355. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  356. return 3;
  357. }
  358. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  359. //return 2;
  360. return 1;
  361. }
  362. - (fileSetTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  363. //__block NSInteger row = indexPath.row;
  364. __block NSInteger section = indexPath.section;
  365. static NSString *identifier = @"fileSetTableViewCell";
  366. fileSetTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  367. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  368. if (!cell){
  369. cell = [[fileSetTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  370. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  371. [cell setBackgroundColor:[UIColor clearColor]];
  372. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  373. [cell.bgViewLayer removeFromSuperlayer];
  374. [cell.titleLabel2 setHidden:YES];
  375. [cell.rightImage setHidden:YES];
  376. [cell.lineView setHidden:NO];
  377. [cell.maskSwitch setHidden:NO];
  378. }
  379. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  380. byRoundingCorners:UIRectCornerAllCorners
  381. cornerRadii:CGSizeMake(8, 8)];
  382. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  383. maskLayer.frame = cell.cellBgView.bounds;
  384. maskLayer.path = maskPath.CGPath;
  385. cell.bgViewLayer = maskLayer;
  386. cell.cellBgView.layer.mask = cell.bgViewLayer;
  387. [cell.lineView setHidden:YES];
  388. if (section == 0){
  389. [cell.titleLabel setText:NSLocalizedString(@"file_Transfer_By_Cellular",nil)];
  390. BOOL haveOpenMask = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_canUse_Cellular_all)];
  391. [cell.maskSwitch setOn:haveOpenMask];
  392. /*上圆角*/
  393. //设置部分圆角 贝塞尔曲线
  394. // UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  395. // byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
  396. // cornerRadii:CGSizeMake(8, 8)];
  397. }
  398. else if (section == 1){
  399. [cell.titleLabel setText:NSLocalizedString(@"File_Transfer_background_working",nil)];
  400. BOOL haveOpenMask = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_working_background)];
  401. [cell.maskSwitch setOn:haveOpenMask];
  402. }
  403. else if (section == 2){
  404. [cell.titleLabel setText:NSLocalizedString(@"File_Transfer_full_speed",nil)];
  405. BOOL haveOpenMask = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_full_speed)];
  406. [cell.maskSwitch setOn:haveOpenMask];
  407. }
  408. // else if (row == 1){
  409. // [cell.titleLabel setText:NSLocalizedString(@"File_Transfer_set_battery_level",nil)];
  410. //
  411. // BOOL haveOpenMask = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_battery_level)];
  412. // [cell.maskSwitch setOn:haveOpenMask];
  413. //
  414. // /*下圆角*/
  415. // UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  416. // byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
  417. // cornerRadii:CGSizeMake(8, 8)];
  418. // CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  419. // maskLayer.frame = cell.cellBgView.bounds;
  420. // maskLayer.path = maskPath.CGPath;
  421. // cell.bgViewLayer = maskLayer;
  422. // cell.cellBgView.layer.mask = cell.bgViewLayer;
  423. //
  424. // [cell.lineView setHidden:YES];
  425. // }
  426. KWeakSelf
  427. cell.didClickSwitch = ^(BOOL SwitchOn) {
  428. [weakSelf didClickSwitchBy:SwitchOn withRow:section];
  429. };
  430. return cell;
  431. }
  432. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  433. return 60;
  434. }
  435. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  436. if(section==2){
  437. return 5+10+30;
  438. }
  439. return 5+10+20;
  440. }
  441. - (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
  442. UIView *tailView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 5+10+20)];
  443. if(section==2){
  444. tailView.frame = CGRectMake(0, 0, SCREEN_W, 5+10+30);
  445. }
  446. UILabel *lab = [[UILabel alloc] init];
  447. lab.font = [UIFont systemFontOfSize:12.0];
  448. lab.textColor = [UIColor hwColor:@"666666" alpha:1.0];
  449. lab.numberOfLines = 0;
  450. //lab.backgroundColor = [UIColor redColor];
  451. [tailView addSubview:lab];
  452. [lab mas_makeConstraints:^(MASConstraintMaker *make) {
  453. make.left.mas_equalTo(15);
  454. make.right.mas_equalTo(-15);
  455. make.bottom.mas_equalTo(-10);
  456. make.top.mas_equalTo(5);
  457. }];
  458. if(section==0){
  459. [lab setText:NSLocalizedString(@"File_Transfer_By_Cellular_tip2",nil)];
  460. }
  461. else if(section==1){
  462. [lab setText:NSLocalizedString(@"File_Transfer_background_working_tip",nil)];
  463. }
  464. else if(section==2){
  465. [lab setText:NSLocalizedString(@"File_Transfer_full_speed_tip",nil)];
  466. }
  467. return tailView;
  468. }
  469. - (void)didClickSwitchBy:(BOOL)SwitchOn withRow:(NSInteger)row
  470. {
  471. if(row == 0){
  472. [HWDataManager setBoolWithKey:stringKeyAddSn(Const_file_Transfe_canUse_Cellular_all) value:SwitchOn];
  473. }
  474. else if(row == 1){
  475. [HWDataManager setBoolWithKey:stringKeyAddSn(Const_file_Transfe_working_background) value:SwitchOn];
  476. }
  477. else if(row == 2){
  478. [HWDataManager setBoolWithKey:stringKeyAddSn(Const_file_Transfe_full_speed) value:SwitchOn];
  479. }
  480. // else{
  481. // [HWDataManager setBoolWithKey:stringKeyAddSn(Const_file_Transfe_battery_level) value:SwitchOn];
  482. // }
  483. }
  484. @end