fileTransfeSetViewController.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  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. [self gotofileTransferPathCheckVCFunWithType:2];
  295. // KWeakSelf
  296. // [photosBackupsTaskModel bg_findAsync:backups_photos_tableName limit:1 orderBy:nil desc:YES complete:^(NSArray * _Nullable array) {
  297. // mainBlock(^{
  298. // if(array && array.count > 0){
  299. // photosBackupsTaskModel *preModel = array.lastObject;
  300. // if(preModel.curBackupsState == backupsStateUploading
  301. // ||preModel.curBackupsState == backupsStateSuspend
  302. // ){
  303. // [[iToast makeText:NSLocalizedString(@"File_backups_set_default_path_tip",nil)] show];
  304. // }
  305. // else{
  306. // [self gotofileTransferPathCheckVCFunWithType:2];
  307. // }
  308. // }
  309. // else{
  310. // [self gotofileTransferPathCheckVCFunWithType:2];
  311. // }
  312. // });
  313. //
  314. // }];
  315. }
  316. else if(model.curBackupsState == backupsStateUploading
  317. //|| model.curBackupsState == backupsStateSuspend
  318. )
  319. {
  320. //判断尺寸路径是否存在
  321. NSString * uploadDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_photo_backups_default_path)];
  322. BOOL isExtraFileType = NO;
  323. BOOL isExtraPathFind = NO;
  324. if(uploadDefaultPath){
  325. if(![uploadDefaultPath containsString:@"sdcard/"]){
  326. isExtraFileType = YES;
  327. }
  328. }
  329. if(uploadDefaultPath && ksharedAppDelegate.cloudPhoneExtraFileListMod){
  330. NSArray*arr = ksharedAppDelegate.cloudPhoneExtraFileListMod.data;
  331. for (cloudPhoneExtraFileModel*model in arr) {
  332. if([uploadDefaultPath containsString:model.extraPath]){
  333. isExtraPathFind = YES;
  334. break;
  335. }
  336. }
  337. }
  338. if(isExtraFileType && !isExtraPathFind){
  339. [self gotofileTransferPathCheckVCFunWithType:2];
  340. }
  341. else{
  342. [[iToast makeText:NSLocalizedString(@"File_backups_set_default_path_tip",nil)] show];
  343. }
  344. }
  345. else{
  346. [self gotofileTransferPathCheckVCFunWithType:2];
  347. }
  348. }
  349. //type 1 上传 2备份
  350. - (void)gotofileTransferPathCheckVCFunWithType:(NSInteger)type
  351. {
  352. fileTransferPathCheckViewController *vc = [fileTransferPathCheckViewController new];
  353. vc.curType = type;
  354. [self.navigationController pushViewController:vc animated:YES];
  355. }
  356. #pragma mark - 列表委托
  357. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  358. return 2;
  359. //return 3;
  360. }
  361. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  362. //return 2;
  363. return 1;
  364. }
  365. - (fileSetTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  366. //__block NSInteger row = indexPath.row;
  367. __block NSInteger section = indexPath.section;
  368. static NSString *identifier = @"fileSetTableViewCell";
  369. fileSetTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  370. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  371. if (!cell){
  372. cell = [[fileSetTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  373. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  374. [cell setBackgroundColor:[UIColor clearColor]];
  375. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  376. [cell.bgViewLayer removeFromSuperlayer];
  377. [cell.titleLabel2 setHidden:YES];
  378. [cell.rightImage setHidden:YES];
  379. [cell.lineView setHidden:NO];
  380. [cell.maskSwitch setHidden:NO];
  381. }
  382. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  383. byRoundingCorners:UIRectCornerAllCorners
  384. cornerRadii:CGSizeMake(8, 8)];
  385. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  386. maskLayer.frame = cell.cellBgView.bounds;
  387. maskLayer.path = maskPath.CGPath;
  388. cell.bgViewLayer = maskLayer;
  389. cell.cellBgView.layer.mask = cell.bgViewLayer;
  390. [cell.lineView setHidden:YES];
  391. if (section == 0){
  392. [cell.titleLabel setText:NSLocalizedString(@"file_Transfer_By_Cellular",nil)];
  393. BOOL haveOpenMask = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_canUse_Cellular_all)];
  394. [cell.maskSwitch setOn:haveOpenMask];
  395. /*上圆角*/
  396. //设置部分圆角 贝塞尔曲线
  397. // UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  398. // byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
  399. // cornerRadii:CGSizeMake(8, 8)];
  400. }
  401. else if (section == 1){
  402. [cell.titleLabel setText:NSLocalizedString(@"File_Transfer_background_working",nil)];
  403. BOOL haveOpenMask = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_working_background)];
  404. [cell.maskSwitch setOn:haveOpenMask];
  405. }
  406. else if (section == 2){
  407. [cell.titleLabel setText:NSLocalizedString(@"File_Transfer_full_speed",nil)];
  408. BOOL haveOpenMask = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_full_speed)];
  409. [cell.maskSwitch setOn:haveOpenMask];
  410. }
  411. // else if (row == 1){
  412. // [cell.titleLabel setText:NSLocalizedString(@"File_Transfer_set_battery_level",nil)];
  413. //
  414. // BOOL haveOpenMask = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_battery_level)];
  415. // [cell.maskSwitch setOn:haveOpenMask];
  416. //
  417. // /*下圆角*/
  418. // UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  419. // byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
  420. // cornerRadii:CGSizeMake(8, 8)];
  421. // CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  422. // maskLayer.frame = cell.cellBgView.bounds;
  423. // maskLayer.path = maskPath.CGPath;
  424. // cell.bgViewLayer = maskLayer;
  425. // cell.cellBgView.layer.mask = cell.bgViewLayer;
  426. //
  427. // [cell.lineView setHidden:YES];
  428. // }
  429. KWeakSelf
  430. cell.didClickSwitch = ^(BOOL SwitchOn) {
  431. [weakSelf didClickSwitchBy:SwitchOn withRow:section];
  432. };
  433. return cell;
  434. }
  435. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  436. return 60;
  437. }
  438. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  439. if(section==2){
  440. return 5+10+30;
  441. }
  442. return 5+10+20;
  443. }
  444. - (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
  445. UIView *tailView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 5+10+20)];
  446. if(section==2){
  447. tailView.frame = CGRectMake(0, 0, SCREEN_W, 5+10+30);
  448. }
  449. UILabel *lab = [[UILabel alloc] init];
  450. lab.font = [UIFont systemFontOfSize:12.0];
  451. lab.textColor = [UIColor hwColor:@"666666" alpha:1.0];
  452. lab.numberOfLines = 0;
  453. //lab.backgroundColor = [UIColor redColor];
  454. [tailView addSubview:lab];
  455. [lab mas_makeConstraints:^(MASConstraintMaker *make) {
  456. make.left.mas_equalTo(15);
  457. make.right.mas_equalTo(-15);
  458. make.bottom.mas_equalTo(-10);
  459. make.top.mas_equalTo(5);
  460. }];
  461. if(section==0){
  462. [lab setText:NSLocalizedString(@"File_Transfer_By_Cellular_tip2",nil)];
  463. }
  464. else if(section==1){
  465. [lab setText:NSLocalizedString(@"File_Transfer_background_working_tip",nil)];
  466. }
  467. else if(section==2){
  468. [lab setText:NSLocalizedString(@"File_Transfer_full_speed_tip",nil)];
  469. }
  470. return tailView;
  471. }
  472. - (void)didClickSwitchBy:(BOOL)SwitchOn withRow:(NSInteger)row
  473. {
  474. if(row == 0){
  475. [HWDataManager setBoolWithKey:stringKeyAddSn(Const_file_Transfe_canUse_Cellular_all) value:SwitchOn];
  476. if(SwitchOn){
  477. [[iToast makeText:NSLocalizedString(@"File_Transfer_WWAN_working_open",nil)] show];
  478. }
  479. else{
  480. [[iToast makeText:NSLocalizedString(@"File_Transfer_WWAN_working_close",nil)] show];
  481. }
  482. }
  483. else if(row == 1){
  484. [HWDataManager setBoolWithKey:stringKeyAddSn(Const_file_Transfe_working_background) value:SwitchOn];
  485. if(SwitchOn){
  486. [[iToast makeText:NSLocalizedString(@"File_Transfer_background_working_open",nil)] show];
  487. }
  488. else{
  489. [[iToast makeText:NSLocalizedString(@"File_Transfer_background_working_close",nil)] show];
  490. }
  491. }
  492. else if(row == 2){
  493. [HWDataManager setBoolWithKey:stringKeyAddSn(Const_file_Transfe_full_speed) value:SwitchOn];
  494. }
  495. // else{
  496. // [HWDataManager setBoolWithKey:stringKeyAddSn(Const_file_Transfe_battery_level) value:SwitchOn];
  497. // }
  498. }
  499. @end