MySetViewController.m 44 KB

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