MySetViewController.m 43 KB

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