MySetViewController.m 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167
  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. [[nasUploadFileManager 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. [[webSocketManager shareInstance] getBaseInfoFun];
  346. uploadImageOrVideoViewController *vc = [uploadImageOrVideoViewController new];
  347. if(tag ==11){
  348. vc.isPhotoType = YES;
  349. }
  350. else{
  351. vc.isPhotoType = NO;
  352. }
  353. [self.navigationController pushViewController:vc animated:YES];
  354. }
  355. //- (void)checkDidHadDownloadTaskFunWith:(NSInteger)tag
  356. //{
  357. // KWeakSelf
  358. // [[downloadManager shareInstance] getDataInDatabaseFun:YES complete:^(NSMutableArray * _Nonnull Arr) {
  359. // mainBlock(^{
  360. // if(Arr && Arr.count== 3){
  361. // NSArray *downloadingArr = Arr.firstObject;
  362. // if(downloadingArr.count == 0){
  363. // [weakSelf gotoDownloadFileFunWith:tag];
  364. // }
  365. // else{
  366. // [[iToast makeText:NSLocalizedString(@"download_task_not_done_tip",nil)] show];
  367. // }
  368. // }
  369. // else{
  370. // [weakSelf gotoDownloadFileFunWith:tag];
  371. // };
  372. // });
  373. //
  374. // }];
  375. //}
  376. //- (void)gotoDownloadFileFunWith:(NSInteger)tag
  377. //{
  378. // downLoadPreviewViewController *vc = [downLoadPreviewViewController new];
  379. // if(tag ==12){
  380. // vc.isPhotoType = YES;
  381. // }
  382. // else{
  383. // vc.isPhotoType = NO;
  384. // }
  385. //
  386. // [self.navigationController pushViewController:vc animated:YES];
  387. //}
  388. //#pragma mark 点击图片或者视频
  389. //- (void)gotoFileTransferFunBy:(NSInteger)tag
  390. //{
  391. // if(tag == 11 ||tag == 21){
  392. // [self checkDidHadUploadTaskFunWith:tag];
  393. // }
  394. // else if(tag == 12 ||tag == 22){
  395. // [self checkDidHadDownloadTaskFunWith:tag];
  396. // }
  397. //}
  398. - (UIView *)tableFoorView{
  399. UIView *bgView = [[UIView alloc] initWithFrame:(CGRectMake(0, 0, SCREEN_W, 48.f + 40))];
  400. [bgView setBackgroundColor:[UIColor clearColor]];
  401. tvP2PBtn = [[UIButton alloc] initWithFrame:(CGRectMake(15, 20, SCREEN_W - 2*15.f, 48.f))];
  402. [tvP2PBtn setBackgroundColor:HWFFFFFFColor];
  403. [tvP2PBtn setTitle:NSLocalizedString(@"my_set_no_TV_p2p",nil) forState:(UIControlStateNormal)];
  404. [tvP2PBtn setTitle:NSLocalizedString(@"my_set_no_close_TV_p2p",nil) forState:(UIControlStateSelected)];
  405. [tvP2PBtn setTitleColor:HW0A132BColor forState:(UIControlStateNormal)];
  406. [tvP2PBtn.titleLabel setFont:[UIFont boldSystemFontOfSize:14.f]];
  407. [tvP2PBtn addTarget:self
  408. action:@selector(tvP2PBtnPressed)
  409. forControlEvents:(UIControlEventTouchUpInside)];
  410. [tvP2PBtn.layer setCornerRadius:8.f];
  411. [bgView addSubview:tvP2PBtn];
  412. return bgView;
  413. }
  414. #pragma mark 点击投屏
  415. - (void)tvP2PBtnPressed{
  416. if(tvP2PBtn.selected)
  417. {
  418. [self showCloseTVP2PFun];
  419. }
  420. else{
  421. [self showTVP2PFun];
  422. }
  423. }
  424. #pragma mark 显示投屏提示语
  425. - (void)showTVP2PFun{
  426. /*弹窗提示TV投屏*/
  427. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_TVP2P_Open_title",nil)
  428. msg:NSLocalizedString(@"my_set_TVP2P_Open_Subtitle",nil)
  429. imageStr:nil
  430. cancelTitle:NSLocalizedString(@"my_set_TVP2P_Open_sure",nil)
  431. okTitle:nil isOkBtnHighlight:NO
  432. didClickOk:^{
  433. HLog(@"111");
  434. } didClickCancel:^{
  435. //HLog(@"2222");
  436. [self gotoSetTVP2PFun];
  437. }];
  438. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  439. [self presentViewController:nextVC animated:YES completion:^{
  440. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  441. }];
  442. }
  443. #pragma mark 确认开始TV投屏
  444. -(void)gotoSetTVP2PFun
  445. {
  446. if(_needToTVP2P){
  447. _needToTVP2P();
  448. }
  449. [self.navigationController popViewControllerAnimated:YES];
  450. }
  451. #pragma mark 显示关闭投屏提示语
  452. - (void)showCloseTVP2PFun{
  453. /*弹窗提示TV投屏*/
  454. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_close_TV_p2p_tip",nil)
  455. msg:nil
  456. imageStr:nil
  457. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  458. okTitle:NSLocalizedString(@"my_set_TVP2P_Open_sure",nil) isOkBtnHighlight:YES
  459. didClickOk:^{
  460. [self gotoCloseTVP2PFun];
  461. } didClickCancel:^{
  462. //HLog(@"2222");
  463. }];
  464. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  465. [self presentViewController:nextVC animated:YES completion:^{
  466. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  467. }];
  468. }
  469. #pragma mark 确认开始TV投屏
  470. -(void)gotoCloseTVP2PFun
  471. {
  472. if(_closeTVP2P){
  473. _closeTVP2P();
  474. tvP2PBtn.selected = NO;
  475. }
  476. tvP2PBtn.userInteractionEnabled = NO;
  477. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  478. self->tvP2PBtn.userInteractionEnabled = YES;
  479. });
  480. }
  481. - (void)helpDownScrollViewBePressed:(nonnull id)sender withIndex:(NSInteger)index {
  482. HLog(@"\n----点击了第个%ld按钮----",index);
  483. if (index == 0){
  484. ChangeLogoViewController *nextVC = [[ChangeLogoViewController alloc] init];
  485. [self.navigationController pushViewController:nextVC animated:YES];
  486. }else if (index == 1){/**/
  487. HidenMaskSetViewController *nextVC = [[HidenMaskSetViewController alloc] init];
  488. [self.navigationController pushViewController:nextVC animated:YES];
  489. }
  490. }
  491. #pragma mark - 懒加载
  492. - (UITableView *)tableView{
  493. if (!_tableView) {
  494. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H - TABBARHEIGHT) style:UITableViewStylePlain];
  495. _tableView.delegate = self;
  496. _tableView.dataSource = self;
  497. _tableView.showsVerticalScrollIndicator = NO;
  498. _tableView.showsHorizontalScrollIndicator = NO;
  499. // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
  500. [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
  501. [_tableView setSeparatorColor:[UIColor clearColor]];
  502. [_tableView setBackgroundColor:[UIColor clearColor]];
  503. [_tableView setTableFooterView:[UIView new]];
  504. [_tableView setBounces:YES];
  505. if (@available(iOS 15.0, *)) {
  506. _tableView.sectionHeaderTopPadding = 0;
  507. }
  508. [_tableView setTableFooterView:[self tableFoorView]];
  509. [_tableView setTableHeaderView:[self customTableHeadView]];
  510. }
  511. return _tableView;
  512. }
  513. #pragma mark - 列表委托
  514. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  515. return 0;
  516. //return 1;
  517. }
  518. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  519. return 0;
  520. //return 6;
  521. //return 5;//去掉更换icon
  522. }
  523. - (MineViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  524. NSInteger row = indexPath.row;
  525. static NSString *identifier = @"MineViewCell";
  526. MineViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  527. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  528. if (!cell){
  529. cell = [[MineViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  530. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  531. [cell setBackgroundColor:[UIColor clearColor]];
  532. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  533. }
  534. [cell.bgViewLayer removeFromSuperlayer];
  535. [cell.titleLabel2 setHidden:YES];
  536. [cell.rightImage setHidden:NO];
  537. [cell.lineView setHidden:NO];
  538. [cell.maskSwitch setHidden:YES];
  539. if (row == 0){
  540. [cell.titleLabel setText:NSLocalizedString(@"my_set_Privacy_Model",nil)];
  541. [cell.mImageView setImage:[UIImage imageNamed:@"icon_Privacy_model"]];
  542. // [cell.titleLabel setText:NSLocalizedString(@"my_set_no_modify_pwd",nil)];
  543. // [cell.mImageView setImage:[UIImage imageNamed:@"mdoify_pwd"]];
  544. /*上圆角*/
  545. //设置部分圆角 贝塞尔曲线
  546. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  547. byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
  548. cornerRadii:CGSizeMake(8, 8)];
  549. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  550. maskLayer.frame = cell.cellBgView.bounds;
  551. maskLayer.path = maskPath.CGPath;
  552. cell.bgViewLayer = maskLayer;
  553. cell.cellBgView.layer.mask = cell.bgViewLayer;
  554. // }else if (row == 1){
  555. // [cell.titleLabel setText:NSLocalizedString(@"my_set_no_change_logo",nil)];
  556. // [cell.mImageView setImage:[UIImage imageNamed:@"icon_change_logo"]];
  557. // // }else if (row == 2){
  558. // // [cell.titleLabel setText:NSLocalizedString(@"mask_view_hiden_set_hiden",nil)];
  559. // // [cell.mImageView setImage:[UIImage imageNamed:@"icon-jincheng"]];
  560. // // }else if (row == 3){
  561. // }else if (row == 1){
  562. // [cell.titleLabel setText:NSLocalizedString(@"my_set_no_fanzhuan_exit",nil)];
  563. // [cell.mImageView setImage:[UIImage imageNamed:@"fanzhuan"]];
  564. // [cell.rightImage setHidden:YES];
  565. // [cell.maskSwitch setHidden:NO];
  566. //}else if (row == 4){/*版本信息*/
  567. }else if (row == 1){/*版本信息*/
  568. [cell.titleLabel setText:NSLocalizedString(@"my_set_no_check_update",nil)];
  569. [cell.mImageView setImage:[UIImage imageNamed:@"app_update"]];
  570. [cell.titleLabel2 setText:[iPhone appVersion]];
  571. [cell.titleLabel2 setHidden:NO];
  572. //}else if (row == 5){/*更换设备*/
  573. }else if (row == 2){/*更换设备*/
  574. [cell.titleLabel setText:NSLocalizedString(@"my_set_no_change_phone",nil)];
  575. [cell.mImageView setImage:[UIImage imageNamed:@"icon_change_ohone"]];
  576. //}else if (row == 6){
  577. }else if (row == 3){/*常见问题*/
  578. [cell.titleLabel setText:NSLocalizedString(@"my_set_no_common_problem",nil)];
  579. [cell.mImageView setImage:[UIImage imageNamed:@"icon_common_problem"]];
  580. }else if (row == 4){/*回复出厂*/
  581. [cell.titleLabel setText:NSLocalizedString(@"my_set_no_Restore_Factory",nil)];
  582. [cell.mImageView setImage:[UIImage imageNamed:@"icon_Restore_Factory"]];
  583. }else if (row == 5){/*重启空间*/
  584. [cell.titleLabel setText:NSLocalizedString(@"my_set_no_restart_phone",nil)];
  585. [cell.mImageView setImage:[UIImage imageNamed:@"icon-gengxin"]];
  586. /*下圆角*/
  587. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  588. byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
  589. cornerRadii:CGSizeMake(8, 8)];
  590. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  591. maskLayer.frame = cell.cellBgView.bounds;
  592. maskLayer.path = maskPath.CGPath;
  593. cell.bgViewLayer = maskLayer;
  594. cell.cellBgView.layer.mask = cell.bgViewLayer;
  595. [cell.lineView setHidden:YES];
  596. }
  597. return cell;
  598. }
  599. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  600. return 60;
  601. }
  602. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  603. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  604. NSInteger row = indexPath.row;
  605. if (0 == row){
  606. inputPWDViewController *nextVC = [inputPWDViewController new];
  607. nextVC.isCheckPwdType = YES;
  608. [self.navigationController pushViewController:nextVC animated:YES];
  609. KWeakSelf
  610. nextVC.didInputRightPwdFun = ^{
  611. [weakSelf gotoPrivacyModeVCFun];
  612. };
  613. /*修改密码*/
  614. // ModifyPWDFirstViewController *nextVC = [[ModifyPWDFirstViewController alloc] init];
  615. // [self.navigationController pushViewController:nextVC animated:YES];
  616. // }else if (1 == row){
  617. // /*更换图标*/
  618. // ChangeLogoViewController *nextVC = [[ChangeLogoViewController alloc] init];
  619. // [self.navigationController pushViewController:nextVC animated:YES];
  620. // }else if (1 == row){/*进城隐藏*/
  621. // HidenMaskSetViewController *nextVC = [[HidenMaskSetViewController alloc] init];
  622. // [self.navigationController pushViewController:nextVC animated:YES];
  623. // }else if (3 == row){/*设备翻转*/
  624. // ;
  625. }
  626. //else if (4 == row){/*版本信息*/
  627. else if (1 == row){/*版本信息*/
  628. AboutViewController *vc = [[AboutViewController alloc] init];
  629. vc.getSysInfo = ^{
  630. if(self->_getSysInfo){
  631. self->_getSysInfo();
  632. }
  633. };
  634. [self.navigationController pushViewController:vc animated:YES];
  635. //}else if (5 == row){/*更换设备*/
  636. }else if (2 == row){/*更换设备*/
  637. TipsQRCodeForChangeDeviceViewController *vc = [[TipsQRCodeForChangeDeviceViewController alloc] init];
  638. [self.navigationController pushViewController:vc animated:YES];
  639. }else if (3 == row){/*常见问题*/
  640. CustomerWebViewController *vc = [[CustomerWebViewController alloc] init];
  641. vc.titleStr = NSLocalizedString(@"my_set_no_common_problem",nil);
  642. NSString *url = @"https://cliys.armclouding.com/h5/microserviceUserH5/commonProblem/questionIndex.html";
  643. vc.webUrl = url;
  644. [self.navigationController pushViewController:vc animated:YES];
  645. }else if (4 == row){/*恢复出厂*/
  646. [self RestoreFactoryAleartFun];
  647. }else if (5 == row){/*重启空间*/
  648. /*弹窗提示重启*/
  649. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_restart_phone_tips",nil)
  650. msg:nil
  651. imageStr:nil
  652. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  653. okTitle:NSLocalizedString(@"my_set_no_restart_phone_btn_ok",nil) isOkBtnHighlight:NO
  654. didClickOk:^{
  655. } didClickCancel:^{
  656. }];
  657. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  658. nextVC.delegate = self;
  659. [self presentViewController:nextVC animated:YES completion:^{
  660. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  661. }];
  662. }
  663. }
  664. #pragma mark 去设置隐私
  665. - (void)gotoPrivacyModeVCFun
  666. {
  667. privacyModeViewController *nextVC = [[privacyModeViewController alloc] init];
  668. [self.navigationController pushViewController:nextVC animated:YES];
  669. }
  670. - (void)CommonAlertokBtnClickPressed{
  671. // /*重启云手机*/
  672. // 通过指令通道发送 {"type":"reboot"}
  673. if(_needToReboot){
  674. _needToReboot();
  675. }
  676. //提示语
  677. [[iToast makeText:NSLocalizedString(@"player_link_rebooting_Tips",nil)] show];
  678. }
  679. #pragma mark 点击恢复出厂
  680. - (void)RestoreFactoryAleartFun
  681. {
  682. KWeakSelf
  683. /*弹窗提示恢复出厂*/
  684. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_Restore_Factory_tips",nil)
  685. msg:NSLocalizedString(@"my_set_no_Restore_Factory_msg",nil)
  686. imageStr:@"icon_Restore_Factory_big"
  687. cancelTitle:NSLocalizedString(@"my_set_TVP2P_Open_sure",nil)
  688. okTitle:NSLocalizedString(@"other_cancel",nil) isOkBtnHighlight:YES
  689. didClickOk:^{
  690. } didClickCancel:^{
  691. //点击确定
  692. [weakSelf gotoResetFun];
  693. }];
  694. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  695. [self presentViewController:nextVC animated:YES completion:^{
  696. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  697. }];
  698. }
  699. #pragma mark 点击了恢复出厂
  700. - (void)gotoResetFun
  701. {
  702. if(_needToReset){
  703. _needToReset();
  704. }
  705. [self RestoreFactoryingFun];
  706. }
  707. #pragma mark 恢复出厂中
  708. - (void)RestoreFactoryingFun
  709. {
  710. KWeakSelf
  711. /*弹窗提示恢复出厂*/
  712. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_Restore_Factorying_tips",nil)
  713. msg:NSLocalizedString(@"my_set_no_Restore_Factorying_msg",nil)
  714. imageStr:nil
  715. cancelTitle:NSLocalizedString(@"my_set_no_Restore_Factorying",nil)
  716. okTitle:nil
  717. isOkBtnHighlight:NO
  718. didClickOk:^{
  719. [weakSelf RestoreFactoryCompleteFun];
  720. } didClickCancel:^{
  721. }];
  722. [nextVC setButtonCountdownFun:180];//90
  723. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  724. [self presentViewController:nextVC animated:YES completion:^{
  725. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  726. }];
  727. }
  728. #pragma mark 恢复出厂倒计时结束
  729. - (void)RestoreFactoryCompleteFun
  730. {
  731. KWeakSelf
  732. //瑞云发起重连
  733. NSString *snStr = ksharedAppDelegate.DeviceThirdIdMod.data.changeSn;
  734. if(snStr){
  735. [[connectDeviceManager shareInstance] getThridMsgBySN:snStr needReconnect:YES didNetEnd:^(NSInteger didSuc) {
  736. if(didSuc){
  737. if(self->_needToResetAndOk){
  738. self->_needToResetAndOk();
  739. }
  740. }
  741. else{
  742. [weakSelf RestoreFactoryCompleteFun];
  743. return;
  744. }
  745. }];
  746. }
  747. /*弹窗提示恢复出厂*/
  748. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_Restore_Factory_ok_tips",nil)
  749. msg:NSLocalizedString(@"my_set_no_Restore_Factory_ok_msg",nil)
  750. imageStr:nil
  751. cancelTitle:NSLocalizedString(@"my_set_no_Restore_FactoryOK",nil)
  752. okTitle:nil
  753. isOkBtnHighlight:NO
  754. didClickOk:^{
  755. } didClickCancel:^{
  756. [weakSelf.navigationController popViewControllerAnimated:YES];
  757. }];
  758. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  759. [self presentViewController:nextVC animated:YES completion:^{
  760. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  761. }];
  762. }
  763. - (void)getCouldPhoneTvStatusFun:(NSNotification*)not
  764. {
  765. TvStatusModel *model = [not object];
  766. //HLog(@"%@",baseInfoModel);
  767. if(!model || ![model isKindOfClass:[TvStatusModel class]]){
  768. return;
  769. }
  770. if([model.msg containsString:@"PushStreamBActivity"]){
  771. tvP2PBtn.selected = YES;
  772. }
  773. else{
  774. tvP2PBtn.selected = NO;
  775. }
  776. }
  777. - (void)uploadFileAllTaskDoneNot:(NSNotification*)not
  778. {
  779. hadUploadTaskType = NO;
  780. [self setRightButtonRedTypeFun];
  781. }
  782. - (void)downloadFileAllTaskDoneNot:(NSNotification*)not
  783. {
  784. hadDownloadTaskType = NO;
  785. [self setRightButtonRedTypeFun];
  786. }
  787. - (void)checkFileTransferTask
  788. {//有个偶现的闪退在BGFMDB
  789. [[nasUploadFileManager shareInstance] checkHadUploadTaskWithComplete:^(BOOL isSuccess) {
  790. self->hadUploadTaskType = isSuccess;
  791. [self setRightButtonRedTypeFun];
  792. }];
  793. KWeakSelf
  794. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  795. [[nasDownloadFileManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
  796. self->hadDownloadTaskType = isSuccess;
  797. [weakSelf setRightButtonRedTypeFun];
  798. }];
  799. });
  800. }
  801. - (void)setRightButtonRedTypeFun
  802. {
  803. mainBlock(^{
  804. if(self->hadUploadTaskType || self->hadDownloadTaskType){
  805. self->rightRedView.hidden = NO;
  806. }
  807. else{
  808. self->rightRedView.hidden = YES;
  809. }
  810. });
  811. }
  812. #pragma mark 清理缓存相关
  813. - (void)clickClearCacheButtonFun
  814. {
  815. KWeakSelf
  816. /*弹窗提示清除缓存*/
  817. clearCacheAlretViewController *nextVC = [[clearCacheAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_clear_cache",nil)
  818. msg:NSLocalizedString(@"clear_cache_tip",nil)
  819. imageStr:nil
  820. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  821. okTitle:NSLocalizedString(@"other_clear",nil) isOkBtnHighlight:YES
  822. didClickOk:^(BOOL isSelect) {
  823. [weakSelf handleClearCacheFunWith:isSelect];
  824. } didClickCancel:^{
  825. }];
  826. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  827. [self presentViewController:nextVC animated:YES completion:^{
  828. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  829. }];
  830. }
  831. - (void)handleClearCacheFunWith:(BOOL)isSelectFileTransfer
  832. {
  833. [self ClearCommonCacheFun:isSelectFileTransfer];
  834. }
  835. - (void)ClearCommonCacheFun:(BOOL)isSelectFileTransfer
  836. {
  837. NSString *ruiyunLogPath = [NSString stringWithFormat:@"%@/logs/debug_0.log",CachesPatch];
  838. long logSize1 = [iTools fileSizeAtPath:ruiyunLogPath];
  839. [[NSFileManager defaultManager] removeItemAtPath:ruiyunLogPath error:nil];
  840. NSString *appLogPath = [NSString stringWithFormat:@"%@/logs/app.log",CachesPatch];
  841. long logSize2 = [iTools fileSizeAtPath:appLogPath];
  842. [[NSFileManager defaultManager] removeItemAtPath:appLogPath error:nil];
  843. //
  844. NSString *downLoadThumbnailPath = [NSString stringWithFormat:@"%@/DownLoadThumbnail",CachesPatch];
  845. long logSize3 = [iTools folderSizeAtPath:downLoadThumbnailPath];
  846. [[NSFileManager defaultManager] removeItemAtPath:downLoadThumbnailPath error:nil];
  847. long clearTotal = logSize1 + logSize2 + logSize3;
  848. if(isSelectFileTransfer){
  849. [self clearCacheByFileTransferFun:clearTotal];
  850. }
  851. else{
  852. [self showClearAllTipBy:clearTotal];
  853. }
  854. }
  855. - (void)showClearAllTipBy:(long)clearTotal
  856. {
  857. long clearTotalK = clearTotal /1024;
  858. NSString *tipStr1 = NSLocalizedString(@"my_set_no_clear_finish",nil);
  859. NSString *tipStr2 = @"";
  860. if(clearTotalK > 1024*1024){
  861. tipStr2 = [[NSString alloc] initWithFormat:@"%.02fGB",clearTotalK/1024.0/1024.0];
  862. }
  863. else if(clearTotalK > 1024){
  864. tipStr2 = [[NSString alloc] initWithFormat:@"%.02fMB",clearTotalK/1024.0];
  865. }
  866. else //if(clearTotalK > 0)
  867. {
  868. tipStr2 = [[NSString alloc] initWithFormat:@"%ldKB",clearTotalK];
  869. }
  870. NSString *tipfullStr = [[NSString alloc] initWithFormat:@"%@%@",tipStr1,tipStr2];
  871. //提示语
  872. [[iToast makeText:tipfullStr] show];
  873. }
  874. - (void)clearCacheByFileTransferFun:(long)clearTotal
  875. {
  876. //清理图片
  877. BOOL needReUploadingType = NO;
  878. NSString *ImagePath = [NSString stringWithFormat:@"%@/Image",CachesPatch];
  879. long imageAllSize = [iTools folderSizeAtPath:ImagePath];
  880. if([uploadFileManager shareInstance].curUploadFileDataModel
  881. && [uploadFileManager shareInstance].curUploadFileDataModel.curUploadFileType == uploadFileTypeImage
  882. && [uploadFileManager shareInstance].curUploadFileDataModel.curUploadStateType == uploadStateUploading){
  883. [uploadFileManager shareInstance].curUploadFileDataModel.curUploadStateType = uploadStateSuspend;
  884. needReUploadingType = YES;
  885. }
  886. [[NSFileManager defaultManager] removeItemAtPath:ImagePath error:nil];
  887. if(needReUploadingType){
  888. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  889. [uploadFileManager shareInstance].curUploadFileDataModel.curUploadStateType = uploadStateUploading;
  890. });
  891. }
  892. //清理视频文件
  893. NSString *videoPath = [NSString stringWithFormat:@"%@/Video",CachesPatch];
  894. long vide0AllSizeBeforeClear = [iTools folderSizeAtPath:videoPath];
  895. NSString *backupsingVideoName = nil;
  896. if([backupsFileManager shareInstance].curPhotosBackupsTaskMod
  897. && [backupsFileManager shareInstance].curPhotosBackupsTaskMod.curUploadFileType == uploadFileTypeVideo){
  898. backupsingVideoName = [backupsFileManager shareInstance].curPhotosBackupsTaskMod.filename;
  899. }
  900. NSString *uploadingVideoName = nil;
  901. if([uploadFileManager shareInstance].curUploadFileDataModel
  902. && [uploadFileManager shareInstance].curUploadFileDataModel.curUploadFileType == uploadFileTypeVideo){
  903. uploadingVideoName = [uploadFileManager shareInstance].curUploadFileDataModel.filename;
  904. }
  905. if(backupsingVideoName || uploadingVideoName){
  906. NSMutableString *fileName = [NSMutableString new];
  907. if(backupsingVideoName){
  908. [fileName appendString:backupsingVideoName];
  909. }
  910. if(uploadingVideoName){
  911. if(fileName.length > 0){
  912. [fileName appendString:@"|"];
  913. }
  914. [fileName appendString:uploadingVideoName];
  915. }
  916. [self deleteFilesInDirectoryAtPath:videoPath withOutFileName:fileName];
  917. }
  918. else{
  919. [[NSFileManager defaultManager] removeItemAtPath:videoPath error:nil];
  920. }
  921. long vide0AllSizeAfterClear = [iTools folderSizeAtPath:videoPath];
  922. //清理下载中
  923. NSString *downLoadingPath = [NSString stringWithFormat:@"%@/DownLoadFlie",CachesPatch];
  924. long downLoadingSizeBeforeClear = [iTools folderSizeAtPath:downLoadingPath];
  925. NSString *downLoadingFileName = nil;
  926. if([downloadManager shareInstance].curDownloadFileModel
  927. && ([downloadManager shareInstance].curDownloadFileModel.curDownloadStateType == downloadStateUploading
  928. ||[downloadManager shareInstance].curDownloadFileModel.curDownloadStateType == downloadStateSuspend)){
  929. downLoadingFileName = [[downloadManager shareInstance].curDownloadFileModel getFileNameFun];
  930. [self deleteFilesInDirectoryAtPath:downLoadingPath withOutFileName:downLoadingFileName];
  931. }
  932. else{
  933. [[NSFileManager defaultManager] removeItemAtPath:downLoadingPath error:nil];
  934. }
  935. long downLoadingSizeAfterClear = [iTools folderSizeAtPath:downLoadingPath];
  936. //清理数据库表 完成的
  937. //下载完成
  938. NSMutableString* where = [[NSMutableString alloc] initWithString:@"where "];
  939. NSString *curStr = [NSString stringWithFormat:@"%@=%@ or %@=%@ ",bg_sqlKey(@"curDownloadStateType"),bg_sqlValue([NSNumber numberWithInt:downloadStateDone]),bg_sqlKey(@"curDownloadStateType"),bg_sqlValue([NSNumber numberWithInt:downloadStateFail])];
  940. [where appendString:curStr];
  941. [couldPhoneFileModel bg_deleteAsync:download_tableName where:where complete:^(BOOL isSuccess) {
  942. }];
  943. //上传完成
  944. NSMutableString* where2 = [[NSMutableString alloc] initWithString:@"where "];
  945. NSString *curStr2 = [NSString stringWithFormat:@"%@=%@ or %@=%@ ",bg_sqlKey(@"curUploadStateType"),bg_sqlValue([NSNumber numberWithInt:uploadStateDone]),
  946. bg_sqlKey(@"curUploadStateType"),bg_sqlValue([NSNumber numberWithInt:uploadStateFail])];
  947. [where2 appendString:curStr2];
  948. [uploadFileDataModel bg_deleteAsync:upLoadFile_image_tableName where:where2 complete:^(BOOL isSuccess) {
  949. }];
  950. long curTotolSize = (downLoadingSizeBeforeClear - downLoadingSizeAfterClear) + (vide0AllSizeBeforeClear - vide0AllSizeAfterClear) + imageAllSize + clearTotal;
  951. [self showClearAllTipBy:curTotolSize];
  952. }
  953. - (BOOL)deleteFilesInDirectoryAtPath:(NSString *)path withOutFileName:(NSString*)fileNames {
  954. NSFileManager *fileManager = [NSFileManager defaultManager];
  955. NSArray *fileNameArr = [fileNames componentsSeparatedByString:@"|"];
  956. // 使用NSDirectoryEnumerator遍历目录
  957. NSDirectoryEnumerator *directoryEnumerator = [fileManager enumeratorAtPath:path];
  958. NSString *fileName;
  959. while ((fileName = [directoryEnumerator nextObject])) {
  960. BOOL canDelType = YES;
  961. for (NSString*noDelfileName in fileNameArr) {
  962. if([noDelfileName isEqualToString:fileName]){
  963. canDelType = NO;
  964. break;
  965. }
  966. }
  967. if(canDelType){
  968. NSString *filePath = [path stringByAppendingPathComponent:fileName];
  969. // 如果是文件,则删除它
  970. if ([fileManager fileExistsAtPath:filePath]) {
  971. BOOL success = [fileManager removeItemAtPath:filePath error:nil];
  972. if (!success) {
  973. // 如果删除失败,返回NO并处理错误
  974. return NO;
  975. }
  976. }
  977. }
  978. }
  979. // 所有文件都成功删除,返回YES
  980. return YES;
  981. }
  982. @end