fileTransfeSetViewController.m 27 KB

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