MySetViewController.m 45 KB

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