fileTransfeSetViewController.m 28 KB

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