MySetViewController.m 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169
  1. //
  2. // MySetViewController.m
  3. // 双子星云手机
  4. //
  5. // Created by APPLE on 2023/8/17.
  6. //
  7. #import "MySetViewController.h"
  8. #import <SDWebImage.h>
  9. #import <Masonry.h>
  10. #import "HelpDownScrollView.h"
  11. #import "MineViewCell.h"
  12. #import "ChangeLogoViewController.h"
  13. #import "HidenMaskSetViewController.h"
  14. #import "CustomerWebViewController.h"
  15. #import "AboutViewController.h"
  16. #import "iPhone.h"
  17. #import "CloudPhoneAPI.h"
  18. #import "ComontAlretViewController.h"
  19. #import "ModifyPWDFirstViewController.h"
  20. #import "TipsQRCodeForChangeDeviceViewController.h"
  21. #import "connectDeviceManager.h"
  22. #import "mySetHeadView.h"
  23. #import "uploadImageOrVideoViewController.h"
  24. #import "TZImagePickerController.h"
  25. #import "uploadFileRecordViewController.h"
  26. #import "privacyModeViewController.h"
  27. #import "TvStatusModel.h"
  28. #import "inputPWDViewController.h"
  29. #import "fileTransferPopView.h"
  30. #import "fileTransfeSetViewController.h"
  31. #import "backupsSetViewController.h"
  32. #import "downLoadPreviewViewController.h"
  33. #import "uploadFileDataModel.h"
  34. #import "uploadFileManager.h"
  35. #import "downloadManager.h"
  36. #import "clearCacheAlretViewController.h"
  37. #import "customShareManageTool.h"
  38. #import "previewImageOrVideoViewController.h"
  39. #import "previewAudioOrDocumentViewController.h"
  40. #import "previewFileAndFolderViewController.h"
  41. #import "shareRecordViewController.h"
  42. #import "backupsOptionViewController.h"
  43. @interface MySetViewController ()<HelpDownScrollViewDelegate,UITableViewDelegate,UITableViewDataSource,ComontAlretViewControllerDelegate>
  44. {
  45. UIButton* rightButton;
  46. UIView* rightRedView;
  47. UILabel *phoneLabel;
  48. UILabel *vipTypeTipsLabel;
  49. UIButton *tvP2PBtn;
  50. BOOL hadUploadTaskType;
  51. BOOL hadDownloadTaskType;
  52. }
  53. @property (nonatomic, strong, nullable) UITableView *tableView;
  54. @property (nonatomic, strong, nullable) mySetHeadView *customTableHeadView;
  55. @end
  56. @implementation MySetViewController
  57. - (void)viewDidLoad {
  58. [super viewDidLoad];
  59. // Do any additional setup after loading the view.
  60. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getCouldPhoneTvStatusFun:) name:getCouldPhoneTvStatusNotification object:nil];
  61. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(uploadFileAllTaskDoneNot:) name:uploadFileAllTaskDoneNotification object:nil];
  62. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadFileAllTaskDoneNot:) name:downloadFileAllTaskDoneNotification object:nil];
  63. [self drawAnyView];
  64. }
  65. - (void)viewWillAppear:(BOOL)animated
  66. {
  67. [super viewWillAppear:animated];
  68. [[UIApplication sharedApplication] setStatusBarHidden:NO];
  69. if(_getTvStatus){
  70. _getTvStatus();
  71. }
  72. }
  73. - (void)viewDidAppear:(BOOL)animated{
  74. [super viewDidAppear:animated];
  75. [self checkFileTransferTask];
  76. }
  77. - (void)drawAnyView{
  78. [self.view setBackgroundColor:HWF5F7FAColor];
  79. [self.toolBar setHidden:YES];
  80. [self.navigationBar setHidden:YES];
  81. [self.navBarBGView setHidden:NO];
  82. [self.titleLabel setText:NSLocalizedString(@"more_set",nil)];
  83. rightButton = [[UIButton alloc] init];
  84. [rightButton setImage:[UIImage imageNamed:@"icon_file_transfer"] forState:UIControlStateNormal];
  85. [rightButton addTarget:self action:@selector(didiClikRightButFun:) forControlEvents:UIControlEventTouchUpInside];
  86. [self.navBarBGView addSubview:rightButton];
  87. [rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
  88. make.width.mas_equalTo(40);
  89. make.height.mas_equalTo(40);
  90. make.right.mas_equalTo(-15);
  91. make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
  92. }];
  93. rightRedView = [[UIView alloc] init];
  94. rightRedView.backgroundColor = [UIColor hwColor:@"#DD4E4E" alpha:1.0];
  95. [rightButton addSubview:rightRedView];
  96. rightRedView.layer.cornerRadius = 7;
  97. rightRedView.hidden = YES;
  98. [rightRedView mas_makeConstraints:^(MASConstraintMaker *make) {
  99. make.width.mas_equalTo(14);
  100. make.height.mas_equalTo(14);
  101. make.right.mas_equalTo(0);
  102. make.top.mas_equalTo(6);
  103. }];
  104. [self.view addSubview:self.tableView];
  105. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  106. make.left.mas_equalTo(0);
  107. make.right.mas_equalTo(0);
  108. make.bottom.mas_equalTo(0);
  109. make.top.equalTo(self.navBarBGView.mas_bottom).offset(5.f);
  110. }];
  111. }
  112. - (mySetHeadView *)customTableHeadView{
  113. if(!_customTableHeadView){
  114. // CGFloat PrivacyBgW = SCREEN_W - 20;
  115. // CGFloat PrivacyBgH = 116.0 * PrivacyBgW / (345.0);
  116. //
  117. // CGFloat totalHeight = 10 + PrivacyBgH + (110+15) + (110+15)+(135+ 88 + 15);
  118. CGFloat totalHeight = 10 + 220 + 25 + 220 +15;
  119. _customTableHeadView = [[mySetHeadView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, totalHeight)];
  120. KWeakSelf
  121. #pragma mark 上传文件相关处理
  122. _customTableHeadView.didClickBut = ^(NSInteger tag) {
  123. [weakSelf didClickUploadFileByTag:tag];
  124. };
  125. }
  126. return _customTableHeadView;
  127. }
  128. - (void)didiClikRightButFun:(UIButton*)but
  129. {
  130. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  131. [self.navigationController pushViewController:vc animated:YES];
  132. }
  133. #pragma mark 点击文件上传相关
  134. - (void)didClickUploadFileByTag:(NSInteger)tag
  135. {
  136. HLog(@"hhh %ld",tag);
  137. KWeakSelf
  138. switch (tag) {
  139. case 100:{
  140. //[[customShareManageTool sharedManager] shareType:1 withShareUrl:@"https://baidu.com" withShareTitle:@"我是标题" withShareContent:@"我是测试内容"];
  141. previewImageOrVideoViewController *vc = [previewImageOrVideoViewController new];
  142. vc.isPhotoType = YES;
  143. [self.navigationController pushViewController:vc animated:YES];
  144. }
  145. break;
  146. case 101:{
  147. //[[customShareManageTool sharedManager] shareType:2 withShareUrl:@"https://baidu.com" withShareTitle:@"我是标题" withShareContent:@"我是测试内容"];
  148. previewImageOrVideoViewController *vc = [previewImageOrVideoViewController new];
  149. vc.isPhotoType = NO;
  150. [self.navigationController pushViewController:vc animated:YES];
  151. }
  152. break;
  153. case 102:{
  154. //[[customShareManageTool sharedManager] shareType:3 withShareUrl:@"https://baidu.com" withShareTitle:@"我是标题" withShareContent:@"我是测试内容"];
  155. previewAudioOrDocumentViewController *vc = [previewAudioOrDocumentViewController new];
  156. vc.isAudioType = YES;
  157. [self.navigationController pushViewController:vc animated:YES];
  158. }
  159. break;
  160. case 103:{
  161. previewFileAndFolderViewController *vc = [previewFileAndFolderViewController new];
  162. [self.navigationController pushViewController:vc animated:YES];
  163. }
  164. break;
  165. case 104:{
  166. shareRecordViewController *vc = [shareRecordViewController new];
  167. [self.navigationController pushViewController:vc animated:YES];
  168. }
  169. break;
  170. case 105:{
  171. backupsOptionViewController *vc = [backupsOptionViewController new];
  172. [self.navigationController pushViewController:vc animated:YES];
  173. }
  174. break;
  175. case 106:
  176. {
  177. if(!ksharedAppDelegate.isWebSockLinkOKAginType){
  178. [[iToast makeText:NSLocalizedString(@"check_could_phone_state",nil)] show];
  179. return;
  180. }
  181. fileTransfeSetViewController *nextVC = [fileTransfeSetViewController new];
  182. [self.navigationController pushViewController:nextVC animated:YES];
  183. }
  184. break;
  185. case 2:
  186. case 3:
  187. {
  188. if(ksharedAppDelegate.DisabledFileTransferType){
  189. if(ksharedAppDelegate.isImageNewFor130){
  190. [[iToast makeText:NSLocalizedString(@"File_Transfer_Disable_tip",nil)] show];
  191. }
  192. else{
  193. [[iToast makeText:NSLocalizedString(@"File_Transfer_Disable_tip2",nil)] show];
  194. }
  195. return;
  196. }
  197. if(!ksharedAppDelegate.isWebSockLinkOKAginType){
  198. [[iToast makeText:NSLocalizedString(@"check_could_phone_state",nil)] show];
  199. return;
  200. }
  201. // fileTransferPopView * fileTransferPopV = [[fileTransferPopView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
  202. // if(tag==2){
  203. // fileTransferPopV.fileTransferType =1;
  204. // }
  205. // else{
  206. // fileTransferPopV.fileTransferType =2;
  207. // }
  208. // [self.view.window addSubview:fileTransferPopV];
  209. //
  210. //
  211. // fileTransferPopV.didClickBut = ^(NSInteger tag) {
  212. // [weakSelf gotoFileTransferFunBy:tag];
  213. // };
  214. }
  215. break;
  216. case 4:
  217. {
  218. inputPWDViewController *nextVC = [inputPWDViewController new];
  219. nextVC.isCheckPwdType = YES;
  220. [self.navigationController pushViewController:nextVC animated:YES];
  221. nextVC.didInputRightPwdFun = ^{
  222. [weakSelf gotoPrivacyModeVCFun];
  223. };
  224. }
  225. break;
  226. case 5:
  227. {
  228. // backupsSetViewController *nextVC = [backupsSetViewController new];
  229. // [self.navigationController pushViewController:nextVC animated:YES];
  230. fileTransfeSetViewController *nextVC = [fileTransfeSetViewController new];
  231. [self.navigationController pushViewController:nextVC animated:YES];
  232. }
  233. break;
  234. case 7:
  235. {
  236. /*弹窗提示关闭备份*/
  237. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_backups_set_close_title",nil)
  238. msg:NSLocalizedString(@"File_backups_set_close_tip",nil)
  239. imageStr:nil
  240. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  241. okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
  242. didClickOk:^{
  243. [weakSelf gotoClosePhotosBackupsFun];
  244. } didClickCancel:^{
  245. }];
  246. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  247. [self presentViewController:nextVC animated:YES completion:^{
  248. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  249. }];
  250. }
  251. break;
  252. case 10:{
  253. inputPWDViewController *nextVC = [inputPWDViewController new];
  254. nextVC.isCheckPwdType = YES;
  255. [self.navigationController pushViewController:nextVC animated:YES];
  256. nextVC.didInputRightPwdFun = ^{
  257. [weakSelf gotoPrivacyModeVCFun];
  258. };
  259. }
  260. break;
  261. case 11:
  262. {
  263. TipsQRCodeForChangeDeviceViewController *vc = [[TipsQRCodeForChangeDeviceViewController alloc] init];
  264. [self.navigationController pushViewController:vc animated:YES];
  265. }
  266. break;
  267. case 12:
  268. {
  269. /*弹窗提示重启*/
  270. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_restart_phone_tips",nil)
  271. msg:nil
  272. imageStr:nil
  273. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  274. okTitle:NSLocalizedString(@"my_set_no_restart_phone_btn_ok",nil) isOkBtnHighlight:NO
  275. didClickOk:^{
  276. } didClickCancel:^{
  277. }];
  278. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  279. nextVC.delegate = self;
  280. [self presentViewController:nextVC animated:YES completion:^{
  281. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  282. }];
  283. }
  284. break;
  285. case 13:
  286. {
  287. [self RestoreFactoryAleartFun];
  288. }
  289. break;
  290. case 14:
  291. {
  292. CustomerWebViewController *vc = [[CustomerWebViewController alloc] init];
  293. vc.titleStr = NSLocalizedString(@"my_set_no_common_problem",nil);
  294. NSString *url = @"https://cliys.armclouding.com/h5/microserviceUserH5/commonProblem/questionIndex.html";
  295. vc.webUrl = url;
  296. [self.navigationController pushViewController:vc animated:YES];
  297. }
  298. break;
  299. case 15:
  300. {
  301. AboutViewController *vc = [[AboutViewController alloc] init];
  302. vc.getSysInfo = ^{
  303. if(self->_getSysInfo){
  304. self->_getSysInfo();
  305. }
  306. };
  307. [self.navigationController pushViewController:vc animated:YES];
  308. }
  309. break;
  310. case 16:
  311. {
  312. [self clickClearCacheButtonFun];
  313. }
  314. break;
  315. default:
  316. break;
  317. }
  318. }
  319. - (void)gotoClosePhotosBackupsFun
  320. {
  321. [[self customTableHeadView] closeImageBackupsFun];
  322. }
  323. - (void)checkDidHadUploadTaskFunWith:(NSInteger)tag
  324. {
  325. KWeakSelf
  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. [weakSelf gotoUploadFileFunWith:tag];
  332. }
  333. else{
  334. [[iToast makeText:NSLocalizedString(@"upload_task_not_done_tip",nil)] show];
  335. }
  336. }
  337. else{
  338. [weakSelf gotoUploadFileFunWith:tag];
  339. };
  340. });
  341. }];
  342. }
  343. - (void)gotoUploadFileFunWith:(NSInteger)tag
  344. {
  345. if(self->_getBaseInfo){
  346. self->_getBaseInfo();
  347. }
  348. uploadImageOrVideoViewController *vc = [uploadImageOrVideoViewController new];
  349. if(tag ==11){
  350. vc.isPhotoType = YES;
  351. }
  352. else{
  353. vc.isPhotoType = NO;
  354. }
  355. [self.navigationController pushViewController:vc animated:YES];
  356. }
  357. //- (void)checkDidHadDownloadTaskFunWith:(NSInteger)tag
  358. //{
  359. // KWeakSelf
  360. // [[downloadManager shareInstance] getDataInDatabaseFun:YES complete:^(NSMutableArray * _Nonnull Arr) {
  361. // mainBlock(^{
  362. // if(Arr && Arr.count== 3){
  363. // NSArray *downloadingArr = Arr.firstObject;
  364. // if(downloadingArr.count == 0){
  365. // [weakSelf gotoDownloadFileFunWith:tag];
  366. // }
  367. // else{
  368. // [[iToast makeText:NSLocalizedString(@"download_task_not_done_tip",nil)] show];
  369. // }
  370. // }
  371. // else{
  372. // [weakSelf gotoDownloadFileFunWith:tag];
  373. // };
  374. // });
  375. //
  376. // }];
  377. //}
  378. //- (void)gotoDownloadFileFunWith:(NSInteger)tag
  379. //{
  380. // downLoadPreviewViewController *vc = [downLoadPreviewViewController new];
  381. // if(tag ==12){
  382. // vc.isPhotoType = YES;
  383. // }
  384. // else{
  385. // vc.isPhotoType = NO;
  386. // }
  387. //
  388. // [self.navigationController pushViewController:vc animated:YES];
  389. //}
  390. //#pragma mark 点击图片或者视频
  391. //- (void)gotoFileTransferFunBy:(NSInteger)tag
  392. //{
  393. // if(tag == 11 ||tag == 21){
  394. // [self checkDidHadUploadTaskFunWith:tag];
  395. // }
  396. // else if(tag == 12 ||tag == 22){
  397. // [self checkDidHadDownloadTaskFunWith:tag];
  398. // }
  399. //}
  400. - (UIView *)tableFoorView{
  401. UIView *bgView = [[UIView alloc] initWithFrame:(CGRectMake(0, 0, SCREEN_W, 48.f + 40))];
  402. [bgView setBackgroundColor:[UIColor clearColor]];
  403. tvP2PBtn = [[UIButton alloc] initWithFrame:(CGRectMake(15, 20, SCREEN_W - 2*15.f, 48.f))];
  404. [tvP2PBtn setBackgroundColor:HWFFFFFFColor];
  405. [tvP2PBtn setTitle:NSLocalizedString(@"my_set_no_TV_p2p",nil) forState:(UIControlStateNormal)];
  406. [tvP2PBtn setTitle:NSLocalizedString(@"my_set_no_close_TV_p2p",nil) forState:(UIControlStateSelected)];
  407. [tvP2PBtn setTitleColor:HW0A132BColor forState:(UIControlStateNormal)];
  408. [tvP2PBtn.titleLabel setFont:[UIFont boldSystemFontOfSize:14.f]];
  409. [tvP2PBtn addTarget:self
  410. action:@selector(tvP2PBtnPressed)
  411. forControlEvents:(UIControlEventTouchUpInside)];
  412. [tvP2PBtn.layer setCornerRadius:8.f];
  413. [bgView addSubview:tvP2PBtn];
  414. return bgView;
  415. }
  416. #pragma mark 点击投屏
  417. - (void)tvP2PBtnPressed{
  418. if(tvP2PBtn.selected)
  419. {
  420. [self showCloseTVP2PFun];
  421. }
  422. else{
  423. [self showTVP2PFun];
  424. }
  425. }
  426. #pragma mark 显示投屏提示语
  427. - (void)showTVP2PFun{
  428. /*弹窗提示TV投屏*/
  429. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_TVP2P_Open_title",nil)
  430. msg:NSLocalizedString(@"my_set_TVP2P_Open_Subtitle",nil)
  431. imageStr:nil
  432. cancelTitle:NSLocalizedString(@"my_set_TVP2P_Open_sure",nil)
  433. okTitle:nil isOkBtnHighlight:NO
  434. didClickOk:^{
  435. HLog(@"111");
  436. } didClickCancel:^{
  437. //HLog(@"2222");
  438. [self gotoSetTVP2PFun];
  439. }];
  440. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  441. [self presentViewController:nextVC animated:YES completion:^{
  442. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  443. }];
  444. }
  445. #pragma mark 确认开始TV投屏
  446. -(void)gotoSetTVP2PFun
  447. {
  448. if(_needToTVP2P){
  449. _needToTVP2P();
  450. }
  451. [self.navigationController popViewControllerAnimated:YES];
  452. }
  453. #pragma mark 显示关闭投屏提示语
  454. - (void)showCloseTVP2PFun{
  455. /*弹窗提示TV投屏*/
  456. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_close_TV_p2p_tip",nil)
  457. msg:nil
  458. imageStr:nil
  459. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  460. okTitle:NSLocalizedString(@"my_set_TVP2P_Open_sure",nil) isOkBtnHighlight:YES
  461. didClickOk:^{
  462. [self gotoCloseTVP2PFun];
  463. } didClickCancel:^{
  464. //HLog(@"2222");
  465. }];
  466. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  467. [self presentViewController:nextVC animated:YES completion:^{
  468. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  469. }];
  470. }
  471. #pragma mark 确认开始TV投屏
  472. -(void)gotoCloseTVP2PFun
  473. {
  474. if(_closeTVP2P){
  475. _closeTVP2P();
  476. tvP2PBtn.selected = NO;
  477. }
  478. tvP2PBtn.userInteractionEnabled = NO;
  479. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  480. self->tvP2PBtn.userInteractionEnabled = YES;
  481. });
  482. }
  483. - (void)helpDownScrollViewBePressed:(nonnull id)sender withIndex:(NSInteger)index {
  484. HLog(@"\n----点击了第个%ld按钮----",index);
  485. if (index == 0){
  486. ChangeLogoViewController *nextVC = [[ChangeLogoViewController alloc] init];
  487. [self.navigationController pushViewController:nextVC animated:YES];
  488. }else if (index == 1){/**/
  489. HidenMaskSetViewController *nextVC = [[HidenMaskSetViewController alloc] init];
  490. [self.navigationController pushViewController:nextVC animated:YES];
  491. }
  492. }
  493. #pragma mark - 懒加载
  494. - (UITableView *)tableView{
  495. if (!_tableView) {
  496. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H - TABBARHEIGHT) style:UITableViewStylePlain];
  497. _tableView.delegate = self;
  498. _tableView.dataSource = self;
  499. _tableView.showsVerticalScrollIndicator = NO;
  500. _tableView.showsHorizontalScrollIndicator = NO;
  501. // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
  502. [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
  503. [_tableView setSeparatorColor:[UIColor clearColor]];
  504. [_tableView setBackgroundColor:[UIColor clearColor]];
  505. [_tableView setTableFooterView:[UIView new]];
  506. [_tableView setBounces:YES];
  507. if (@available(iOS 15.0, *)) {
  508. _tableView.sectionHeaderTopPadding = 0;
  509. }
  510. [_tableView setTableFooterView:[self tableFoorView]];
  511. [_tableView setTableHeaderView:[self customTableHeadView]];
  512. }
  513. return _tableView;
  514. }
  515. #pragma mark - 列表委托
  516. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  517. return 0;
  518. //return 1;
  519. }
  520. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  521. return 0;
  522. //return 6;
  523. //return 5;//去掉更换icon
  524. }
  525. - (MineViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  526. NSInteger row = indexPath.row;
  527. static NSString *identifier = @"MineViewCell";
  528. MineViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  529. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  530. if (!cell){
  531. cell = [[MineViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  532. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  533. [cell setBackgroundColor:[UIColor clearColor]];
  534. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  535. }
  536. [cell.bgViewLayer removeFromSuperlayer];
  537. [cell.titleLabel2 setHidden:YES];
  538. [cell.rightImage setHidden:NO];
  539. [cell.lineView setHidden:NO];
  540. [cell.maskSwitch setHidden:YES];
  541. if (row == 0){
  542. [cell.titleLabel setText:NSLocalizedString(@"my_set_Privacy_Model",nil)];
  543. [cell.mImageView setImage:[UIImage imageNamed:@"icon_Privacy_model"]];
  544. // [cell.titleLabel setText:NSLocalizedString(@"my_set_no_modify_pwd",nil)];
  545. // [cell.mImageView setImage:[UIImage imageNamed:@"mdoify_pwd"]];
  546. /*上圆角*/
  547. //设置部分圆角 贝塞尔曲线
  548. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  549. byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
  550. cornerRadii:CGSizeMake(8, 8)];
  551. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  552. maskLayer.frame = cell.cellBgView.bounds;
  553. maskLayer.path = maskPath.CGPath;
  554. cell.bgViewLayer = maskLayer;
  555. cell.cellBgView.layer.mask = cell.bgViewLayer;
  556. // }else if (row == 1){
  557. // [cell.titleLabel setText:NSLocalizedString(@"my_set_no_change_logo",nil)];
  558. // [cell.mImageView setImage:[UIImage imageNamed:@"icon_change_logo"]];
  559. // // }else if (row == 2){
  560. // // [cell.titleLabel setText:NSLocalizedString(@"mask_view_hiden_set_hiden",nil)];
  561. // // [cell.mImageView setImage:[UIImage imageNamed:@"icon-jincheng"]];
  562. // // }else if (row == 3){
  563. // }else if (row == 1){
  564. // [cell.titleLabel setText:NSLocalizedString(@"my_set_no_fanzhuan_exit",nil)];
  565. // [cell.mImageView setImage:[UIImage imageNamed:@"fanzhuan"]];
  566. // [cell.rightImage setHidden:YES];
  567. // [cell.maskSwitch setHidden:NO];
  568. //}else if (row == 4){/*版本信息*/
  569. }else if (row == 1){/*版本信息*/
  570. [cell.titleLabel setText:NSLocalizedString(@"my_set_no_check_update",nil)];
  571. [cell.mImageView setImage:[UIImage imageNamed:@"app_update"]];
  572. [cell.titleLabel2 setText:[iPhone appVersion]];
  573. [cell.titleLabel2 setHidden:NO];
  574. //}else if (row == 5){/*更换设备*/
  575. }else if (row == 2){/*更换设备*/
  576. [cell.titleLabel setText:NSLocalizedString(@"my_set_no_change_phone",nil)];
  577. [cell.mImageView setImage:[UIImage imageNamed:@"icon_change_ohone"]];
  578. //}else if (row == 6){
  579. }else if (row == 3){/*常见问题*/
  580. [cell.titleLabel setText:NSLocalizedString(@"my_set_no_common_problem",nil)];
  581. [cell.mImageView setImage:[UIImage imageNamed:@"icon_common_problem"]];
  582. }else if (row == 4){/*回复出厂*/
  583. [cell.titleLabel setText:NSLocalizedString(@"my_set_no_Restore_Factory",nil)];
  584. [cell.mImageView setImage:[UIImage imageNamed:@"icon_Restore_Factory"]];
  585. }else if (row == 5){/*重启空间*/
  586. [cell.titleLabel setText:NSLocalizedString(@"my_set_no_restart_phone",nil)];
  587. [cell.mImageView setImage:[UIImage imageNamed:@"icon-gengxin"]];
  588. /*下圆角*/
  589. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  590. byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
  591. cornerRadii:CGSizeMake(8, 8)];
  592. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  593. maskLayer.frame = cell.cellBgView.bounds;
  594. maskLayer.path = maskPath.CGPath;
  595. cell.bgViewLayer = maskLayer;
  596. cell.cellBgView.layer.mask = cell.bgViewLayer;
  597. [cell.lineView setHidden:YES];
  598. }
  599. return cell;
  600. }
  601. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  602. return 60;
  603. }
  604. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  605. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  606. NSInteger row = indexPath.row;
  607. if (0 == row){
  608. inputPWDViewController *nextVC = [inputPWDViewController new];
  609. nextVC.isCheckPwdType = YES;
  610. [self.navigationController pushViewController:nextVC animated:YES];
  611. KWeakSelf
  612. nextVC.didInputRightPwdFun = ^{
  613. [weakSelf gotoPrivacyModeVCFun];
  614. };
  615. /*修改密码*/
  616. // ModifyPWDFirstViewController *nextVC = [[ModifyPWDFirstViewController alloc] init];
  617. // [self.navigationController pushViewController:nextVC animated:YES];
  618. // }else if (1 == row){
  619. // /*更换图标*/
  620. // ChangeLogoViewController *nextVC = [[ChangeLogoViewController alloc] init];
  621. // [self.navigationController pushViewController:nextVC animated:YES];
  622. // }else if (1 == row){/*进城隐藏*/
  623. // HidenMaskSetViewController *nextVC = [[HidenMaskSetViewController alloc] init];
  624. // [self.navigationController pushViewController:nextVC animated:YES];
  625. // }else if (3 == row){/*设备翻转*/
  626. // ;
  627. }
  628. //else if (4 == row){/*版本信息*/
  629. else if (1 == row){/*版本信息*/
  630. AboutViewController *vc = [[AboutViewController alloc] init];
  631. vc.getSysInfo = ^{
  632. if(self->_getSysInfo){
  633. self->_getSysInfo();
  634. }
  635. };
  636. [self.navigationController pushViewController:vc animated:YES];
  637. //}else if (5 == row){/*更换设备*/
  638. }else if (2 == row){/*更换设备*/
  639. TipsQRCodeForChangeDeviceViewController *vc = [[TipsQRCodeForChangeDeviceViewController alloc] init];
  640. [self.navigationController pushViewController:vc animated:YES];
  641. }else if (3 == row){/*常见问题*/
  642. CustomerWebViewController *vc = [[CustomerWebViewController alloc] init];
  643. vc.titleStr = NSLocalizedString(@"my_set_no_common_problem",nil);
  644. NSString *url = @"https://cliys.armclouding.com/h5/microserviceUserH5/commonProblem/questionIndex.html";
  645. vc.webUrl = url;
  646. [self.navigationController pushViewController:vc animated:YES];
  647. }else if (4 == row){/*恢复出厂*/
  648. [self RestoreFactoryAleartFun];
  649. }else if (5 == row){/*重启空间*/
  650. /*弹窗提示重启*/
  651. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_restart_phone_tips",nil)
  652. msg:nil
  653. imageStr:nil
  654. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  655. okTitle:NSLocalizedString(@"my_set_no_restart_phone_btn_ok",nil) isOkBtnHighlight:NO
  656. didClickOk:^{
  657. } didClickCancel:^{
  658. }];
  659. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  660. nextVC.delegate = self;
  661. [self presentViewController:nextVC animated:YES completion:^{
  662. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  663. }];
  664. }
  665. }
  666. #pragma mark 去设置隐私
  667. - (void)gotoPrivacyModeVCFun
  668. {
  669. privacyModeViewController *nextVC = [[privacyModeViewController alloc] init];
  670. [self.navigationController pushViewController:nextVC animated:YES];
  671. }
  672. - (void)CommonAlertokBtnClickPressed{
  673. // /*重启云手机*/
  674. // 通过指令通道发送 {"type":"reboot"}
  675. if(_needToReboot){
  676. _needToReboot();
  677. }
  678. //提示语
  679. [[iToast makeText:NSLocalizedString(@"player_link_rebooting_Tips",nil)] show];
  680. }
  681. #pragma mark 点击恢复出厂
  682. - (void)RestoreFactoryAleartFun
  683. {
  684. KWeakSelf
  685. /*弹窗提示恢复出厂*/
  686. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_Restore_Factory_tips",nil)
  687. msg:NSLocalizedString(@"my_set_no_Restore_Factory_msg",nil)
  688. imageStr:@"icon_Restore_Factory_big"
  689. cancelTitle:NSLocalizedString(@"my_set_TVP2P_Open_sure",nil)
  690. okTitle:NSLocalizedString(@"other_cancel",nil) isOkBtnHighlight:YES
  691. didClickOk:^{
  692. } didClickCancel:^{
  693. //点击确定
  694. [weakSelf gotoResetFun];
  695. }];
  696. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  697. [self presentViewController:nextVC animated:YES completion:^{
  698. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  699. }];
  700. }
  701. #pragma mark 点击了恢复出厂
  702. - (void)gotoResetFun
  703. {
  704. if(_needToReset){
  705. _needToReset();
  706. }
  707. [self RestoreFactoryingFun];
  708. }
  709. #pragma mark 恢复出厂中
  710. - (void)RestoreFactoryingFun
  711. {
  712. KWeakSelf
  713. /*弹窗提示恢复出厂*/
  714. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_Restore_Factorying_tips",nil)
  715. msg:NSLocalizedString(@"my_set_no_Restore_Factorying_msg",nil)
  716. imageStr:nil
  717. cancelTitle:NSLocalizedString(@"my_set_no_Restore_Factorying",nil)
  718. okTitle:nil
  719. isOkBtnHighlight:NO
  720. didClickOk:^{
  721. [weakSelf RestoreFactoryCompleteFun];
  722. } didClickCancel:^{
  723. }];
  724. [nextVC setButtonCountdownFun:180];//90
  725. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  726. [self presentViewController:nextVC animated:YES completion:^{
  727. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  728. }];
  729. }
  730. #pragma mark 恢复出厂倒计时结束
  731. - (void)RestoreFactoryCompleteFun
  732. {
  733. KWeakSelf
  734. //瑞云发起重连
  735. NSString *snStr = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.changeSn;
  736. if(snStr){
  737. [[connectDeviceManager shareInstance] getThridMsgBySN:snStr needReconnect:YES didNetEnd:^(NSInteger didSuc) {
  738. if(didSuc){
  739. if(self->_needToResetAndOk){
  740. self->_needToResetAndOk();
  741. }
  742. }
  743. else{
  744. [weakSelf RestoreFactoryCompleteFun];
  745. return;
  746. }
  747. }];
  748. }
  749. /*弹窗提示恢复出厂*/
  750. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_Restore_Factory_ok_tips",nil)
  751. msg:NSLocalizedString(@"my_set_no_Restore_Factory_ok_msg",nil)
  752. imageStr:nil
  753. cancelTitle:NSLocalizedString(@"my_set_no_Restore_FactoryOK",nil)
  754. okTitle:nil
  755. isOkBtnHighlight:NO
  756. didClickOk:^{
  757. } didClickCancel:^{
  758. [weakSelf.navigationController popViewControllerAnimated:YES];
  759. }];
  760. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  761. [self presentViewController:nextVC animated:YES completion:^{
  762. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  763. }];
  764. }
  765. - (void)getCouldPhoneTvStatusFun:(NSNotification*)not
  766. {
  767. TvStatusModel *model = [not object];
  768. //HLog(@"%@",baseInfoModel);
  769. if(!model || ![model isKindOfClass:[TvStatusModel class]]){
  770. return;
  771. }
  772. if([model.msg containsString:@"PushStreamBActivity"]){
  773. tvP2PBtn.selected = YES;
  774. }
  775. else{
  776. tvP2PBtn.selected = NO;
  777. }
  778. }
  779. - (void)uploadFileAllTaskDoneNot:(NSNotification*)not
  780. {
  781. hadUploadTaskType = NO;
  782. [self setRightButtonRedTypeFun];
  783. }
  784. - (void)downloadFileAllTaskDoneNot:(NSNotification*)not
  785. {
  786. hadDownloadTaskType = NO;
  787. [self setRightButtonRedTypeFun];
  788. }
  789. - (void)checkFileTransferTask
  790. {//有个偶现的闪退在BGFMDB
  791. [[uploadFileManager shareInstance] checkHadUploadTaskWithComplete:^(BOOL isSuccess) {
  792. self->hadUploadTaskType = isSuccess;
  793. [self setRightButtonRedTypeFun];
  794. }];
  795. KWeakSelf
  796. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  797. [[downloadManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
  798. self->hadDownloadTaskType = isSuccess;
  799. [weakSelf setRightButtonRedTypeFun];
  800. }];
  801. });
  802. }
  803. - (void)setRightButtonRedTypeFun
  804. {
  805. mainBlock(^{
  806. if(self->hadUploadTaskType || self->hadDownloadTaskType){
  807. self->rightRedView.hidden = NO;
  808. }
  809. else{
  810. self->rightRedView.hidden = YES;
  811. }
  812. });
  813. }
  814. #pragma mark 清理缓存相关
  815. - (void)clickClearCacheButtonFun
  816. {
  817. KWeakSelf
  818. /*弹窗提示清除缓存*/
  819. clearCacheAlretViewController *nextVC = [[clearCacheAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_clear_cache",nil)
  820. msg:NSLocalizedString(@"clear_cache_tip",nil)
  821. imageStr:nil
  822. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  823. okTitle:NSLocalizedString(@"other_clear",nil) isOkBtnHighlight:YES
  824. didClickOk:^(BOOL isSelect) {
  825. [weakSelf handleClearCacheFunWith:isSelect];
  826. } didClickCancel:^{
  827. }];
  828. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  829. [self presentViewController:nextVC animated:YES completion:^{
  830. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  831. }];
  832. }
  833. - (void)handleClearCacheFunWith:(BOOL)isSelectFileTransfer
  834. {
  835. [self ClearCommonCacheFun:isSelectFileTransfer];
  836. }
  837. - (void)ClearCommonCacheFun:(BOOL)isSelectFileTransfer
  838. {
  839. NSString *ruiyunLogPath = [NSString stringWithFormat:@"%@/logs/debug_0.log",CachesPatch];
  840. long logSize1 = [iTools fileSizeAtPath:ruiyunLogPath];
  841. [[NSFileManager defaultManager] removeItemAtPath:ruiyunLogPath error:nil];
  842. NSString *appLogPath = [NSString stringWithFormat:@"%@/logs/app.log",CachesPatch];
  843. long logSize2 = [iTools fileSizeAtPath:appLogPath];
  844. [[NSFileManager defaultManager] removeItemAtPath:appLogPath error:nil];
  845. //
  846. NSString *downLoadThumbnailPath = [NSString stringWithFormat:@"%@/DownLoadThumbnail",CachesPatch];
  847. long logSize3 = [iTools folderSizeAtPath:downLoadThumbnailPath];
  848. [[NSFileManager defaultManager] removeItemAtPath:downLoadThumbnailPath error:nil];
  849. long clearTotal = logSize1 + logSize2 + logSize3;
  850. if(isSelectFileTransfer){
  851. [self clearCacheByFileTransferFun:clearTotal];
  852. }
  853. else{
  854. [self showClearAllTipBy:clearTotal];
  855. }
  856. }
  857. - (void)showClearAllTipBy:(long)clearTotal
  858. {
  859. long clearTotalK = clearTotal /1024;
  860. NSString *tipStr1 = NSLocalizedString(@"my_set_no_clear_finish",nil);
  861. NSString *tipStr2 = @"";
  862. if(clearTotalK > 1024*1024){
  863. tipStr2 = [[NSString alloc] initWithFormat:@"%.02fGB",clearTotalK/1024.0/1024.0];
  864. }
  865. else if(clearTotalK > 1024){
  866. tipStr2 = [[NSString alloc] initWithFormat:@"%.02fMB",clearTotalK/1024.0];
  867. }
  868. else //if(clearTotalK > 0)
  869. {
  870. tipStr2 = [[NSString alloc] initWithFormat:@"%ldKB",clearTotalK];
  871. }
  872. NSString *tipfullStr = [[NSString alloc] initWithFormat:@"%@%@",tipStr1,tipStr2];
  873. //提示语
  874. [[iToast makeText:tipfullStr] show];
  875. }
  876. - (void)clearCacheByFileTransferFun:(long)clearTotal
  877. {
  878. //清理图片
  879. BOOL needReUploadingType = NO;
  880. NSString *ImagePath = [NSString stringWithFormat:@"%@/Image",CachesPatch];
  881. long imageAllSize = [iTools folderSizeAtPath:ImagePath];
  882. if([uploadFileManager shareInstance].curUploadFileDataModel
  883. && [uploadFileManager shareInstance].curUploadFileDataModel.curUploadFileType == uploadFileTypeImage
  884. && [uploadFileManager shareInstance].curUploadFileDataModel.curUploadStateType == uploadStateUploading){
  885. [uploadFileManager shareInstance].curUploadFileDataModel.curUploadStateType = uploadStateSuspend;
  886. needReUploadingType = YES;
  887. }
  888. [[NSFileManager defaultManager] removeItemAtPath:ImagePath error:nil];
  889. if(needReUploadingType){
  890. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  891. [uploadFileManager shareInstance].curUploadFileDataModel.curUploadStateType = uploadStateUploading;
  892. });
  893. }
  894. //清理视频文件
  895. NSString *videoPath = [NSString stringWithFormat:@"%@/Video",CachesPatch];
  896. long vide0AllSizeBeforeClear = [iTools folderSizeAtPath:videoPath];
  897. NSString *backupsingVideoName = nil;
  898. if([backupsFileManager shareInstance].curPhotosBackupsTaskMod
  899. && [backupsFileManager shareInstance].curPhotosBackupsTaskMod.curUploadFileType == uploadFileTypeVideo){
  900. backupsingVideoName = [backupsFileManager shareInstance].curPhotosBackupsTaskMod.filename;
  901. }
  902. NSString *uploadingVideoName = nil;
  903. if([uploadFileManager shareInstance].curUploadFileDataModel
  904. && [uploadFileManager shareInstance].curUploadFileDataModel.curUploadFileType == uploadFileTypeVideo){
  905. uploadingVideoName = [uploadFileManager shareInstance].curUploadFileDataModel.filename;
  906. }
  907. if(backupsingVideoName || uploadingVideoName){
  908. NSMutableString *fileName = [NSMutableString new];
  909. if(backupsingVideoName){
  910. [fileName appendString:backupsingVideoName];
  911. }
  912. if(uploadingVideoName){
  913. if(fileName.length > 0){
  914. [fileName appendString:@"|"];
  915. }
  916. [fileName appendString:uploadingVideoName];
  917. }
  918. [self deleteFilesInDirectoryAtPath:videoPath withOutFileName:fileName];
  919. }
  920. else{
  921. [[NSFileManager defaultManager] removeItemAtPath:videoPath error:nil];
  922. }
  923. long vide0AllSizeAfterClear = [iTools folderSizeAtPath:videoPath];
  924. //清理下载中
  925. NSString *downLoadingPath = [NSString stringWithFormat:@"%@/DownLoadFlie",CachesPatch];
  926. long downLoadingSizeBeforeClear = [iTools folderSizeAtPath:downLoadingPath];
  927. NSString *downLoadingFileName = nil;
  928. if([downloadManager shareInstance].curDownloadFileModel
  929. && ([downloadManager shareInstance].curDownloadFileModel.curDownloadStateType == downloadStateUploading
  930. ||[downloadManager shareInstance].curDownloadFileModel.curDownloadStateType == downloadStateSuspend)){
  931. downLoadingFileName = [[downloadManager shareInstance].curDownloadFileModel getFileNameFun];
  932. [self deleteFilesInDirectoryAtPath:downLoadingPath withOutFileName:downLoadingFileName];
  933. }
  934. else{
  935. [[NSFileManager defaultManager] removeItemAtPath:downLoadingPath error:nil];
  936. }
  937. long downLoadingSizeAfterClear = [iTools folderSizeAtPath:downLoadingPath];
  938. //清理数据库表 完成的
  939. //下载完成
  940. NSMutableString* where = [[NSMutableString alloc] initWithString:@"where "];
  941. NSString *curStr = [NSString stringWithFormat:@"%@=%@ or %@=%@ ",bg_sqlKey(@"curDownloadStateType"),bg_sqlValue([NSNumber numberWithInt:downloadStateDone]),bg_sqlKey(@"curDownloadStateType"),bg_sqlValue([NSNumber numberWithInt:downloadStateFail])];
  942. [where appendString:curStr];
  943. [couldPhoneFileModel bg_deleteAsync:download_tableName where:where complete:^(BOOL isSuccess) {
  944. }];
  945. //上传完成
  946. NSMutableString* where2 = [[NSMutableString alloc] initWithString:@"where "];
  947. NSString *curStr2 = [NSString stringWithFormat:@"%@=%@ or %@=%@ ",bg_sqlKey(@"curUploadStateType"),bg_sqlValue([NSNumber numberWithInt:uploadStateDone]),
  948. bg_sqlKey(@"curUploadStateType"),bg_sqlValue([NSNumber numberWithInt:uploadStateFail])];
  949. [where2 appendString:curStr2];
  950. [uploadFileDataModel bg_deleteAsync:upLoadFile_image_tableName where:where2 complete:^(BOOL isSuccess) {
  951. }];
  952. long curTotolSize = (downLoadingSizeBeforeClear - downLoadingSizeAfterClear) + (vide0AllSizeBeforeClear - vide0AllSizeAfterClear) + imageAllSize + clearTotal;
  953. [self showClearAllTipBy:curTotolSize];
  954. }
  955. - (BOOL)deleteFilesInDirectoryAtPath:(NSString *)path withOutFileName:(NSString*)fileNames {
  956. NSFileManager *fileManager = [NSFileManager defaultManager];
  957. NSArray *fileNameArr = [fileNames componentsSeparatedByString:@"|"];
  958. // 使用NSDirectoryEnumerator遍历目录
  959. NSDirectoryEnumerator *directoryEnumerator = [fileManager enumeratorAtPath:path];
  960. NSString *fileName;
  961. while ((fileName = [directoryEnumerator nextObject])) {
  962. BOOL canDelType = YES;
  963. for (NSString*noDelfileName in fileNameArr) {
  964. if([noDelfileName isEqualToString:fileName]){
  965. canDelType = NO;
  966. break;
  967. }
  968. }
  969. if(canDelType){
  970. NSString *filePath = [path stringByAppendingPathComponent:fileName];
  971. // 如果是文件,则删除它
  972. if ([fileManager fileExistsAtPath:filePath]) {
  973. BOOL success = [fileManager removeItemAtPath:filePath error:nil];
  974. if (!success) {
  975. // 如果删除失败,返回NO并处理错误
  976. return NO;
  977. }
  978. }
  979. }
  980. }
  981. // 所有文件都成功删除,返回YES
  982. return YES;
  983. }
  984. @end