fileTransfeSetViewController.m 27 KB

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