MySetViewController.m 45 KB

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