fileTransfeSetViewController.m 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813
  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,UITextViewDelegate>
  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. [self setSaveFileToBoxPathLabelTitleFun];
  40. }
  41. - (void)drawAnyView{
  42. [self.view addSubview:self.tableView];
  43. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.left.mas_equalTo(0);
  45. make.right.mas_equalTo(0);
  46. make.bottom.mas_equalTo(0);
  47. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  48. }];
  49. self.tableView.tableFooterView = [self tailView];
  50. }
  51. #pragma mark - 懒加载
  52. - (UITableView *)tableView{
  53. if (!_tableView) {
  54. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H - TABBARHEIGHT) style:UITableViewStylePlain];
  55. _tableView.delegate = self;
  56. _tableView.dataSource = self;
  57. _tableView.showsVerticalScrollIndicator = NO;
  58. _tableView.showsHorizontalScrollIndicator = NO;
  59. // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
  60. [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
  61. [_tableView setSeparatorColor:[UIColor clearColor]];
  62. [_tableView setBackgroundColor:[UIColor clearColor]];
  63. [_tableView setTableFooterView:[UIView new]];
  64. [_tableView setBounces:YES];
  65. //_tableView.scrollEnabled = NO;
  66. if (@available(iOS 15.0, *)) {
  67. _tableView.sectionHeaderTopPadding = 0;
  68. }
  69. }
  70. return _tableView;
  71. }
  72. #pragma mark - 懒加载
  73. - (UIView *)tailView{
  74. if (!_tailView) {
  75. _tailView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 90 + 15 + 90 + 15 + 90 + 15)];
  76. UIView *tailBgView = [[UIView alloc] init];
  77. tailBgView.backgroundColor = [UIColor whiteColor];
  78. tailBgView.layer.cornerRadius = 8;
  79. tailBgView.tag = 1;
  80. [_tailView addSubview:tailBgView];
  81. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didClickTailViewFun:)];
  82. [tailBgView addGestureRecognizer:tap];
  83. [tailBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  84. make.left.mas_equalTo(15);
  85. make.right.mas_equalTo(-15);
  86. make.height.mas_equalTo(90);
  87. make.top.mas_equalTo(15);
  88. }];
  89. UILabel *titleLab = [[UILabel alloc] init];
  90. titleLab.text = NSLocalizedString(@"File_upload_path_set",nil);
  91. titleLab.font = [UIFont boldSystemFontOfSize:14.0];
  92. titleLab.textColor = [UIColor hwColor:@"#0A132B" alpha:1.0];
  93. [tailBgView addSubview:titleLab];
  94. [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
  95. make.left.mas_equalTo(10);
  96. make.right.mas_equalTo(-50);
  97. make.height.mas_equalTo(20);
  98. make.top.mas_equalTo(20);
  99. }];
  100. /*右侧箭头*/
  101. UIImageView *rightImage = [[UIImageView alloc] init];
  102. [rightImage setBackgroundColor:[UIColor clearColor]];
  103. [rightImage setImage:[UIImage imageNamed:@"cell_right_access"]];
  104. [tailBgView addSubview:rightImage];
  105. [rightImage mas_makeConstraints:^(MASConstraintMaker *make) {
  106. make.width.mas_equalTo(28);
  107. make.right.mas_equalTo(-15.f);
  108. make.height.mas_equalTo(28);
  109. make.centerY.equalTo(titleLab.mas_centerY);
  110. }];
  111. _uploadFilePathLabel=[[UILabel alloc] init];
  112. //titleLab.text = NSLocalizedString(@"File_upload_path_set",nil);
  113. _uploadFilePathLabel.font = [UIFont systemFontOfSize:12.0];
  114. _uploadFilePathLabel.textColor = [UIColor hwColor:@"#6A6A6A" alpha:1.0];
  115. _uploadFilePathLabel.numberOfLines = 0;
  116. [tailBgView addSubview:_uploadFilePathLabel];
  117. [_uploadFilePathLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  118. make.left.mas_equalTo(10);
  119. make.right.mas_equalTo(-15);
  120. make.bottom.mas_equalTo(-20);
  121. make.top.mas_equalTo(titleLab.mas_bottom).offset(10.0);
  122. }];
  123. [self setUploadFilePathLabelTitleFun];
  124. //相册备份设置
  125. UIView *tailBgView2 = [[UIView alloc] init];
  126. tailBgView2.backgroundColor = [UIColor whiteColor];
  127. tailBgView2.layer.cornerRadius = 8;
  128. tailBgView2.tag = 2;
  129. [_tailView addSubview:tailBgView2];
  130. UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didClickTailViewFun:)];
  131. [tailBgView2 addGestureRecognizer:tap2];
  132. [tailBgView2 mas_makeConstraints:^(MASConstraintMaker *make) {
  133. make.left.mas_equalTo(15);
  134. make.right.mas_equalTo(-15);
  135. make.height.mas_equalTo(90);
  136. make.top.mas_equalTo(tailBgView.mas_bottom).offset(15.0);
  137. }];
  138. UILabel *titleLab2 = [[UILabel alloc] init];
  139. titleLab2.text = NSLocalizedString(@"File_backups_path_set",nil);
  140. titleLab2.font = [UIFont boldSystemFontOfSize:14.0];
  141. titleLab2.textColor = [UIColor hwColor:@"#0A132B" alpha:1.0];
  142. [tailBgView2 addSubview:titleLab2];
  143. [titleLab2 mas_makeConstraints:^(MASConstraintMaker *make) {
  144. make.left.mas_equalTo(10);
  145. make.right.mas_equalTo(-50);
  146. make.height.mas_equalTo(20);
  147. make.top.mas_equalTo(20);
  148. }];
  149. /*右侧箭头*/
  150. UIImageView *rightImage2 = [[UIImageView alloc] init];
  151. [rightImage2 setBackgroundColor:[UIColor clearColor]];
  152. [rightImage2 setImage:[UIImage imageNamed:@"cell_right_access"]];
  153. [tailBgView2 addSubview:rightImage2];
  154. [rightImage2 mas_makeConstraints:^(MASConstraintMaker *make) {
  155. make.width.mas_equalTo(28);
  156. make.right.mas_equalTo(-15.f);
  157. make.height.mas_equalTo(28);
  158. make.centerY.equalTo(titleLab2.mas_centerY);
  159. }];
  160. _backupsFilePathLabel=[[UILabel alloc] init];
  161. //titleLab.text = NSLocalizedString(@"File_upload_path_set",nil);
  162. _backupsFilePathLabel.font = [UIFont systemFontOfSize:12.0];
  163. _backupsFilePathLabel.textColor = [UIColor hwColor:@"#6A6A6A" alpha:1.0];
  164. _backupsFilePathLabel.numberOfLines = 0;
  165. [tailBgView2 addSubview:_backupsFilePathLabel];
  166. [_backupsFilePathLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  167. make.left.mas_equalTo(15);
  168. make.right.mas_equalTo(-15);
  169. make.bottom.mas_equalTo(-10);
  170. make.top.mas_equalTo(titleLab2.mas_bottom).offset(10.0);
  171. }];
  172. [self setBackupsFilePathLabelTitleFun];
  173. ////相册备份设置
  174. UIView *tailBgView3 = [[UIView alloc] init];
  175. tailBgView3.backgroundColor = [UIColor whiteColor];
  176. tailBgView3.layer.cornerRadius = 8;
  177. tailBgView3.tag = 3;
  178. [_tailView addSubview:tailBgView3];
  179. UITapGestureRecognizer *tap3 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didClickTailViewFun:)];
  180. [tailBgView3 addGestureRecognizer:tap3];
  181. [tailBgView3 mas_makeConstraints:^(MASConstraintMaker *make) {
  182. make.left.mas_equalTo(15);
  183. make.right.mas_equalTo(-15);
  184. make.height.mas_equalTo(90);
  185. make.top.mas_equalTo(tailBgView2.mas_bottom).offset(15.0);
  186. }];
  187. UILabel *titleLab3 = [[UILabel alloc] init];
  188. titleLab3.text = NSLocalizedString(@"File_save_to_box_path_set",nil);
  189. titleLab3.font = [UIFont boldSystemFontOfSize:14.0];
  190. titleLab3.textColor = [UIColor hwColor:@"#0A132B" alpha:1.0];
  191. [tailBgView3 addSubview:titleLab3];
  192. [titleLab3 mas_makeConstraints:^(MASConstraintMaker *make) {
  193. make.left.mas_equalTo(10);
  194. make.right.mas_equalTo(-50);
  195. make.height.mas_equalTo(20);
  196. make.top.mas_equalTo(20);
  197. }];
  198. /*右侧箭头*/
  199. UIImageView *rightImage3 = [[UIImageView alloc] init];
  200. [rightImage3 setBackgroundColor:[UIColor clearColor]];
  201. [rightImage3 setImage:[UIImage imageNamed:@"cell_right_access"]];
  202. [tailBgView3 addSubview:rightImage3];
  203. [rightImage3 mas_makeConstraints:^(MASConstraintMaker *make) {
  204. make.width.mas_equalTo(28);
  205. make.right.mas_equalTo(-15.f);
  206. make.height.mas_equalTo(28);
  207. make.centerY.equalTo(titleLab3.mas_centerY);
  208. }];
  209. _saveBoxFilePathLabel=[[UILabel alloc] init];
  210. //titleLab.text = NSLocalizedString(@"File_upload_path_set",nil);
  211. _saveBoxFilePathLabel.font = [UIFont systemFontOfSize:12.0];
  212. _saveBoxFilePathLabel.textColor = [UIColor hwColor:@"#6A6A6A" alpha:1.0];
  213. _saveBoxFilePathLabel.numberOfLines = 0;
  214. [tailBgView3 addSubview:_saveBoxFilePathLabel];
  215. [_saveBoxFilePathLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  216. make.left.mas_equalTo(15);
  217. make.right.mas_equalTo(-15);
  218. make.bottom.mas_equalTo(-10);
  219. make.top.mas_equalTo(titleLab3.mas_bottom).offset(10.0);
  220. }];
  221. [self setSaveFileToBoxPathLabelTitleFun];
  222. }
  223. return _tailView;
  224. }
  225. - (void)setUploadFilePathLabelTitleFun
  226. {
  227. NSString * leftStr = NSLocalizedString(@"File_upload_path_way",nil);
  228. NSString * uploadDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_photo_upload_default_path)];
  229. if(!uploadDefaultPath || uploadDefaultPath.length == 0){
  230. [HWDataManager setStringWithKey:stringKeyAddSn(Const_photo_upload_default_path) value:Const_default_upload_path];
  231. uploadDefaultPath = Const_default_upload_path;
  232. }
  233. uploadDefaultPath = [iTools changePathToShowPathBy:uploadDefaultPath];
  234. NSString * rightStr = uploadDefaultPath;
  235. NSString *totalStr = [[NSString alloc] initWithFormat:@"%@%@",leftStr,rightStr];
  236. NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:totalStr];
  237. NSRange redRange = NSMakeRange([totalStr rangeOfString:rightStr].location, [totalStr rangeOfString:rightStr].length);
  238. [noteStr addAttribute:NSForegroundColorAttributeName value:[UIColor hwColor:@"#01B7EA" alpha:0.8] range:redRange];
  239. [noteStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12.0] range:redRange];
  240. // 设置行间距
  241. NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
  242. [paragraphStyle setLineSpacing:5]; //设置行间距
  243. [noteStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [totalStr length])];
  244. _uploadFilePathLabel.attributedText = noteStr;
  245. }
  246. - (void)setBackupsFilePathLabelTitleFun
  247. {
  248. NSString * leftStr = NSLocalizedString(@"File_backups_path_way_tip2",nil);
  249. NSString * backupsDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_photo_backups_default_path)];
  250. if(!backupsDefaultPath || backupsDefaultPath.length == 0){
  251. backupsDefaultPath = Const_default_backups_path;
  252. [HWDataManager setStringWithKey:stringKeyAddSn(Const_photo_backups_default_path) value:backupsDefaultPath];
  253. }
  254. backupsDefaultPath = [iTools changePathToShowPathBy:backupsDefaultPath];
  255. NSString * rightStr = backupsDefaultPath;
  256. NSString *totalStr = [[NSString alloc] initWithFormat:@"%@%@",leftStr,rightStr];
  257. NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:totalStr];
  258. NSRange redRange = NSMakeRange([totalStr rangeOfString:rightStr].location, [totalStr rangeOfString:rightStr].length);
  259. [noteStr addAttribute:NSForegroundColorAttributeName value:[UIColor hwColor:@"#01B7EA" alpha:0.8] range:redRange];
  260. [noteStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12.0] range:redRange];
  261. // 设置行间距
  262. NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
  263. [paragraphStyle setLineSpacing:5]; //设置行间距
  264. [noteStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [totalStr length])];
  265. _backupsFilePathLabel.attributedText = noteStr;
  266. }
  267. #pragma mark 设置 盒子的接收路径
  268. - (void)setSaveFileToBoxPathLabelTitleFun
  269. {
  270. NSString * leftStr = NSLocalizedString(@"File_upload_path_way",nil);
  271. NSString * boxSaveDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_box_save_default_path)];
  272. if(!boxSaveDefaultPath || boxSaveDefaultPath.length == 0){
  273. boxSaveDefaultPath = Const_default_save_path;
  274. [HWDataManager setStringWithKey:stringKeyAddSn(Const_box_save_default_path) value:boxSaveDefaultPath];
  275. }
  276. boxSaveDefaultPath = [iTools changePathToShowPathBy:boxSaveDefaultPath];
  277. NSString * rightStr = boxSaveDefaultPath;
  278. NSString *totalStr = [[NSString alloc] initWithFormat:@"%@%@",leftStr,rightStr];
  279. NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:totalStr];
  280. NSRange redRange = NSMakeRange([totalStr rangeOfString:rightStr].location, [totalStr rangeOfString:rightStr].length);
  281. [noteStr addAttribute:NSForegroundColorAttributeName value:[UIColor hwColor:@"#01B7EA" alpha:0.8] range:redRange];
  282. [noteStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12.0] range:redRange];
  283. // 设置行间距
  284. NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
  285. [paragraphStyle setLineSpacing:5]; //设置行间距
  286. [noteStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [totalStr length])];
  287. _saveBoxFilePathLabel.attributedText = noteStr;
  288. }
  289. #pragma mark 尾部事件
  290. - (void)didClickTailViewFun:(UITapGestureRecognizer*)tap
  291. {
  292. UIView *curView = tap.view;
  293. if(curView.tag == 1){
  294. [self gotoSetUploadPathFun];
  295. }
  296. else if (curView.tag == 2){
  297. [self gotoSetBackupsPathFun];
  298. }
  299. else if (curView.tag == 3){
  300. [self gotofileTransferPathCheckVCFunWithType:3];
  301. }
  302. }
  303. -(void)gotoSetUploadPathFun
  304. {
  305. [self gotofileTransferPathCheckVCFunWithType:1];
  306. // uploadFileDataModel* model = [uploadFileManager shareInstance].curUploadFileDataModel;
  307. //
  308. // if(!model){
  309. // [[uploadFileManager shareInstance] getDataInDatabaseFun:YES complete:^(NSMutableArray * _Nonnull Arr) {
  310. // mainBlock(^{
  311. // if(Arr && Arr.count== 3){
  312. // NSArray *uploadingArr = Arr.firstObject;
  313. // if(uploadingArr.count == 0){
  314. // [self gotofileTransferPathCheckVCFunWithType:1];
  315. // }
  316. // else{
  317. // [[iToast makeText:NSLocalizedString(@"File_upload_set_default_path_tip",nil)] show];
  318. // }
  319. // }
  320. // });
  321. //
  322. // }];
  323. // }
  324. // else if(model.curUploadStateType == uploadStateUploading
  325. // ||model.curUploadStateType == uploadStateSuspend
  326. // ){
  327. //
  328. // //判断尺寸路径是否存在
  329. //
  330. // NSString * uploadDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_photo_upload_default_path)];
  331. //
  332. // BOOL isExtraFileType = NO;
  333. // BOOL isExtraPathFind = NO;
  334. // if(uploadDefaultPath){
  335. // if(![uploadDefaultPath containsString:@"sdcard/"]){
  336. // isExtraFileType = YES;
  337. // }
  338. // }
  339. //
  340. // if(uploadDefaultPath && ksharedAppDelegate.cloudPhoneExtraFileListMod){
  341. // NSArray*arr = ksharedAppDelegate.cloudPhoneExtraFileListMod.data;
  342. //
  343. // for (cloudPhoneExtraFileModel*model in arr) {
  344. // if([uploadDefaultPath containsString:model.extraPath]){
  345. // isExtraPathFind = YES;
  346. // break;
  347. // }
  348. // }
  349. //
  350. //
  351. // }
  352. //
  353. // if(isExtraFileType && !isExtraPathFind){
  354. // [self gotofileTransferPathCheckVCFunWithType:1];
  355. // }
  356. // else{
  357. // [[iToast makeText:NSLocalizedString(@"File_upload_set_default_path_tip",nil)] show];
  358. // }
  359. //
  360. // }
  361. // else{
  362. // [self gotofileTransferPathCheckVCFunWithType:1];
  363. // }
  364. }
  365. #pragma mark 设置备份路径相关
  366. - (void)gotoSetBackupsPathFun
  367. {
  368. //photosBackupsTaskModel* model = [backupsFileManager shareInstance].curPhotosBackupsTaskMod;
  369. photosBackupsTaskModel* model = [nasBackupsManager shareInstance].curPhotosBackupsTaskMod;
  370. if(!model){
  371. [self gotofileTransferPathCheckVCFunWithType:2];
  372. // KWeakSelf
  373. // [photosBackupsTaskModel bg_findAsync:backups_photos_tableName limit:1 orderBy:nil desc:YES complete:^(NSArray * _Nullable array) {
  374. // mainBlock(^{
  375. // if(array && array.count > 0){
  376. // photosBackupsTaskModel *preModel = array.lastObject;
  377. // if(preModel.curBackupsState == backupsStateUploading
  378. // ||preModel.curBackupsState == backupsStateSuspend
  379. // ){
  380. // [[iToast makeText:NSLocalizedString(@"File_backups_set_default_path_tip",nil)] show];
  381. // }
  382. // else{
  383. // [self gotofileTransferPathCheckVCFunWithType:2];
  384. // }
  385. // }
  386. // else{
  387. // [self gotofileTransferPathCheckVCFunWithType:2];
  388. // }
  389. // });
  390. //
  391. // }];
  392. }
  393. else if(model.curBackupsState == backupsStateUploading
  394. //|| model.curBackupsState == backupsStateSuspend
  395. )
  396. {
  397. //判断尺寸路径是否存在
  398. NSString * uploadDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_photo_backups_default_path)];
  399. BOOL isExtraFileType = NO;
  400. BOOL isExtraPathFind = NO;
  401. if(uploadDefaultPath){
  402. if(![uploadDefaultPath containsString:@"sdcard/"]){
  403. isExtraFileType = YES;
  404. }
  405. }
  406. if(uploadDefaultPath && ksharedAppDelegate.cloudPhoneExtraFileListMod){
  407. NSArray*arr = ksharedAppDelegate.cloudPhoneExtraFileListMod.data;
  408. for (cloudPhoneExtraFileModel*model in arr) {
  409. if([uploadDefaultPath containsString:model.extraPath]){
  410. isExtraPathFind = YES;
  411. break;
  412. }
  413. }
  414. }
  415. if(isExtraFileType && !isExtraPathFind){
  416. [self gotofileTransferPathCheckVCFunWithType:2];
  417. }
  418. else{
  419. [[iToast makeText:NSLocalizedString(@"File_backups_set_default_path_tip",nil)] show];
  420. }
  421. }
  422. else{
  423. [self gotofileTransferPathCheckVCFunWithType:2];
  424. }
  425. }
  426. //type 1 上传 2备份
  427. - (void)gotofileTransferPathCheckVCFunWithType:(NSInteger)type
  428. {
  429. fileTransferPathCheckViewController *vc = [fileTransferPathCheckViewController new];
  430. vc.curType = type;
  431. [self.navigationController pushViewController:vc animated:YES];
  432. }
  433. #pragma mark - 列表委托
  434. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  435. return 2;
  436. //return 3;
  437. }
  438. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  439. //return 2;
  440. return 1;
  441. }
  442. - (fileSetTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  443. //__block NSInteger row = indexPath.row;
  444. __block NSInteger section = indexPath.section;
  445. static NSString *identifier = @"fileSetTableViewCell";
  446. fileSetTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  447. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  448. if (!cell){
  449. cell = [[fileSetTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  450. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  451. [cell setBackgroundColor:[UIColor clearColor]];
  452. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  453. [cell.bgViewLayer removeFromSuperlayer];
  454. [cell.titleLabel2 setHidden:YES];
  455. [cell.rightImage setHidden:YES];
  456. [cell.lineView setHidden:NO];
  457. [cell.maskSwitch setHidden:NO];
  458. }
  459. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  460. byRoundingCorners:UIRectCornerAllCorners
  461. cornerRadii:CGSizeMake(8, 8)];
  462. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  463. maskLayer.frame = cell.cellBgView.bounds;
  464. maskLayer.path = maskPath.CGPath;
  465. cell.bgViewLayer = maskLayer;
  466. cell.cellBgView.layer.mask = cell.bgViewLayer;
  467. [cell.lineView setHidden:YES];
  468. if (section == 0){
  469. [cell.titleLabel setText:NSLocalizedString(@"file_Transfer_By_Cellular",nil)];
  470. BOOL haveOpenMask = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_canUse_Cellular_all)];
  471. [cell.maskSwitch setOn:haveOpenMask];
  472. /*上圆角*/
  473. //设置部分圆角 贝塞尔曲线
  474. // UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  475. // byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
  476. // cornerRadii:CGSizeMake(8, 8)];
  477. }
  478. else if (section == 1){
  479. [cell.titleLabel setText:NSLocalizedString(@"File_Transfer_background_working",nil)];
  480. BOOL haveOpenMask = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_working_background)];
  481. [cell.maskSwitch setOn:haveOpenMask];
  482. }
  483. else if (section == 2){
  484. [cell.titleLabel setText:NSLocalizedString(@"File_Transfer_full_speed",nil)];
  485. BOOL haveOpenMask = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_full_speed)];
  486. [cell.maskSwitch setOn:haveOpenMask];
  487. }
  488. // else if (row == 1){
  489. // [cell.titleLabel setText:NSLocalizedString(@"File_Transfer_set_battery_level",nil)];
  490. //
  491. // BOOL haveOpenMask = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_battery_level)];
  492. // [cell.maskSwitch setOn:haveOpenMask];
  493. //
  494. // /*下圆角*/
  495. // UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  496. // byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
  497. // cornerRadii:CGSizeMake(8, 8)];
  498. // CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  499. // maskLayer.frame = cell.cellBgView.bounds;
  500. // maskLayer.path = maskPath.CGPath;
  501. // cell.bgViewLayer = maskLayer;
  502. // cell.cellBgView.layer.mask = cell.bgViewLayer;
  503. //
  504. // [cell.lineView setHidden:YES];
  505. // }
  506. KWeakSelf
  507. cell.didClickSwitch = ^(BOOL SwitchOn) {
  508. [weakSelf didClickSwitchBy:SwitchOn withRow:section];
  509. };
  510. return cell;
  511. }
  512. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  513. return 60;
  514. }
  515. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  516. if(section==2){
  517. return 5+10+30;
  518. }
  519. else if (section==1){
  520. return 5+10+40;
  521. }
  522. return 5+10+20;
  523. }
  524. - (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
  525. UIView *tailView = [[UIView alloc] init];
  526. // if(section==2){
  527. // tailView.frame = CGRectMake(0, 0, SCREEN_W, 5+10+30);
  528. // }
  529. if(section==0){
  530. tailView.frame = CGRectMake(0, 0, SCREEN_W, 5+10+20);
  531. UILabel *lab = [[UILabel alloc] init];
  532. lab.font = [UIFont systemFontOfSize:12.0];
  533. lab.textColor = [UIColor hwColor:@"666666" alpha:1.0];
  534. lab.numberOfLines = 0;
  535. //lab.backgroundColor = [UIColor redColor];
  536. [tailView addSubview:lab];
  537. CGFloat height = 20.0;
  538. [lab setText:NSLocalizedString(@"File_Transfer_By_Cellular_tip2",nil)];
  539. [lab mas_makeConstraints:^(MASConstraintMaker *make) {
  540. make.left.mas_equalTo(15);
  541. make.right.mas_equalTo(-15);
  542. //make.bottom.mas_equalTo(-10);
  543. make.height.mas_equalTo(height);
  544. make.top.mas_equalTo(5);
  545. }];
  546. }
  547. else if(section==1){
  548. tailView.frame = CGRectMake(0, 0, SCREEN_W, 5+10+40.0);
  549. UITextView *contentTV = [[UITextView alloc] init];
  550. contentTV.backgroundColor = [UIColor clearColor];
  551. // contentTV.textColor = [UIColor hwColor:@"#666666"];
  552. contentTV.font = [UIFont systemFontOfSize:12.0];
  553. // contentTV.textAlignment = NSTextAlignmentCenter;
  554. contentTV.delegate = self;
  555. contentTV.editable = NO; //必须禁止输入,否则点击将弹出输入键盘
  556. contentTV.scrollEnabled = NO;
  557. [tailView addSubview:contentTV];
  558. [contentTV mas_makeConstraints:^(MASConstraintMaker *make) {
  559. make.left.mas_equalTo(15);
  560. make.right.mas_equalTo(-15);
  561. make.bottom.mas_equalTo(0);
  562. make.top.mas_equalTo(5);
  563. }];
  564. // 创建长按手势识别器
  565. UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress)];
  566. // 设置长按手势的最小按压时间
  567. longPress.minimumPressDuration = 0.5; // 2
  568. // 将手势识别器添加到视图上
  569. [contentTV addGestureRecognizer:longPress];
  570. NSString *title1 = NSLocalizedString(@"File_Transfer_background_working_tip_2",nil);
  571. NSString *title2 = @"";//NSLocalizedString(@"go_setting_title",nil);
  572. NSString *fullTitle = [[NSString alloc] initWithFormat:@"%@ %@",title1,title2];
  573. NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:fullTitle];
  574. UIColor *noteColor = [UIColor hwColor:@"#6A6A6A" alpha:1.0];
  575. NSRange leftRange = NSMakeRange([fullTitle rangeOfString:title1].location, [fullTitle rangeOfString:title1].length);
  576. [attrStr addAttribute:NSForegroundColorAttributeName value:noteColor range:leftRange];
  577. // UIColor *rightColor = [UIColor hwColor:@"#01B7EA" alpha:0.8];
  578. // NSRange rightRange = NSMakeRange([fullTitle rangeOfString:title2].location, [fullTitle rangeOfString:title2].length);
  579. // [attrStr addAttribute:NSLinkAttributeName
  580. // value:@"didclick1://"
  581. // range:rightRange];
  582. // [attrStr addAttribute:NSForegroundColorAttributeName value:rightColor range:rightRange];
  583. // 设置段落样式以实现水平中间对齐
  584. // NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
  585. // paragraphStyle.alignment = NSTextAlignmentLeft; // 水平中间对齐
  586. // [attrStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, attrStr.length)];
  587. contentTV.attributedText = attrStr;
  588. }
  589. return tailView;
  590. }
  591. - (void)didClickSwitchBy:(BOOL)SwitchOn withRow:(NSInteger)row
  592. {
  593. if(row == 0){
  594. [HWDataManager setBoolWithKey:stringKeyAddSn(Const_file_Transfe_canUse_Cellular_all) value:SwitchOn];
  595. if(SwitchOn){
  596. [[iToast makeText:NSLocalizedString(@"File_Transfer_WWAN_working_open",nil)] show];
  597. //检测下备份任务
  598. if([nasBackupsManager shareInstance].isWifiNeedReBackupsType
  599. ||[nasBackupsManager shareInstance].isWWANNeedReBackupsType){
  600. [[nasBackupsManager shareInstance] reBackupsFileFun];
  601. }
  602. [[nasUploadFileManager shareInstance] reUploadFileFunByNetWork];
  603. [[nasDownloadFileManager shareInstance] reDownloadloadFileFunByNetWork];
  604. }
  605. else{
  606. [[iToast makeText:NSLocalizedString(@"File_Transfer_WWAN_working_close",nil)] show];
  607. //检测当前有没有任务传输 有就暂停
  608. [[nasUploadFileManager shareInstance] saveUploadingTaskByNetWorkErrorFun];
  609. [[nasDownloadFileManager shareInstance] saveDownloadloadingTaskByNetWorkErrorFun];
  610. if([[nasBackupsManager shareInstance] checkBackupsingFun]){
  611. [[nasBackupsManager shareInstance] suspendBackupsFileFun];
  612. [nasBackupsManager shareInstance].isWWANNeedReBackupsType = YES;
  613. }
  614. }
  615. }
  616. else if(row == 1){
  617. [HWDataManager setBoolWithKey:stringKeyAddSn(Const_file_Transfe_working_background) value:SwitchOn];
  618. if(SwitchOn){
  619. [[iToast makeText:NSLocalizedString(@"File_Transfer_background_working_open",nil)] show];
  620. }
  621. else{
  622. [[iToast makeText:NSLocalizedString(@"File_Transfer_background_working_close",nil)] show];
  623. }
  624. }
  625. else if(row == 2){
  626. [HWDataManager setBoolWithKey:stringKeyAddSn(Const_file_Transfe_full_speed) value:SwitchOn];
  627. }
  628. // else{
  629. // [HWDataManager setBoolWithKey:stringKeyAddSn(Const_file_Transfe_battery_level) value:SwitchOn];
  630. // }
  631. }
  632. #pragma mark ---- textView Delegate ----
  633. - (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange interaction:(UITextItemInteraction)interaction
  634. {
  635. if([[URL scheme] isEqualToString:@"didclick1"]){
  636. [self gotoSettingFun];
  637. return NO;
  638. }
  639. return YES;
  640. }
  641. #pragma mark 拦截长按事件
  642. - (void)longPress{
  643. HLog(@"拦截长按事件")
  644. }
  645. #pragma mark 跳转设置界面
  646. - (void)gotoSettingFun
  647. {
  648. // 打开应用的设置页面(不适用于全局设置如低电量模式)
  649. NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
  650. //NSURL *url = [NSURL URLWithString:@"Prefs:root=BATTERY_USAGE"];
  651. // NSURL *url = [NSURL URLWithString:@"Prefs:root=General"];
  652. // [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
  653. if ([[UIApplication sharedApplication] canOpenURL:url]) {
  654. [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
  655. } else {
  656. HLog(@"无法打开系统设置");
  657. }
  658. }
  659. @end