MySetViewController.m 45 KB

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