fileTransfeSetViewController.m 28 KB

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