fileTransfeSetViewController.m 32 KB

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