NASViewController.m 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063
  1. //
  2. // NASViewController.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2024/6/19.
  6. //
  7. #import "NASViewController.h"
  8. #import "NASMySpaceView.h"
  9. #import "NASCommonUsedView.h"
  10. #import "shareSecretTableViewCell.h"
  11. #import "NASLastFileView.h"
  12. #import "previewImageOrVideoViewController.h"
  13. #import "previewAudioOrDocumentViewController.h"
  14. #import "previewFileAndFolderViewController.h"
  15. #import "shareRecordViewController.h"
  16. #import "backupsOptionViewController.h"
  17. #import "fileTransfeSetViewController.h"
  18. #import "uploadFileRecordViewController.h"
  19. #import "previewToUploadFileView.h"
  20. #import "NASMySpaceViewController.h"
  21. #import "NasPreviewVideoViewController.h"
  22. #import "lastFileManager.h"
  23. #import "lastFileTableViewCell.h"
  24. #import "nasLastFileViewController.h"
  25. #import "audioPlayerViewController.h"
  26. #import "videoPlayByAVPlayerViewController.h"
  27. #import "imageDetailsScrollViewController.h"
  28. #import "queryShareModel.h"
  29. #import "imageVersionRenewTipView.h"
  30. #import "HWVersionModel.h"
  31. #import "HaveNewVersionView.h"
  32. #import "newerGuideView.h"
  33. #import "CustomerWebViewController.h"
  34. #import "noticeModel.h"
  35. #import "HaveNoticeView.h"
  36. #import "audioPlayingView.h"
  37. #import "DFPlayer.h"
  38. #import "queryShareReportMarkModel.h"
  39. #import "UpgradeInfoModel.h"
  40. #import "imageVersionUpdateDoneView.h"
  41. #import "imageVersionUpdateFailView.h"
  42. #import "queryHeartbeatModel.h"
  43. #import "BoxHeartbeatAlertTool.h"
  44. @interface NASViewController ()<UITableViewDelegate,UITableViewDataSource>
  45. {
  46. BOOL canShareType;
  47. UIImageView *welcomeImageV;//弃用
  48. UIView* rightRedView;//
  49. BOOL hadUploadTaskType;
  50. BOOL hadDownloadTaskType;
  51. NSInteger tryLinkNum;
  52. NSInteger tryLinkFrpNum;//frp接口连接次数
  53. imageVersionRenewTipView * RenewTipView;
  54. imageVersionUpdateDoneView* imageVersionUpdateDoneV;
  55. imageVersionUpdateFailView* imageVersionUpdateFailV;
  56. }
  57. @property (nonatomic,strong)UITableView*tableView;
  58. @property (nonatomic, strong) UIView*tableHeadView;
  59. @property (nonatomic, strong) NASMySpaceView* NASMySpaceV;
  60. @property (nonatomic, strong) NASCommonUsedView* NASCommonUsedV;
  61. @property (nonatomic,strong)NASLastFileView*NASLastFileV;
  62. @property (nonatomic,strong) NSMutableArray *lastFileDataArr;
  63. @property (nonatomic,strong)UpgradeInfoModel*otaUpgradeInfoModel;
  64. @end
  65. @implementation NASViewController
  66. - (void)viewDidLoad {
  67. [super viewDidLoad];
  68. // Do any additional setup after loading the view.
  69. [self.view setBackgroundColor:HWF5F7FAColor];
  70. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getExtraFilesDoneFun:) name:getExtraFilesDoneNotification object:nil];
  71. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil];
  72. [self.toolBar setHidden:YES];
  73. [self.navigationBar setHidden:YES];
  74. [self.navBarBGView setHidden:YES];
  75. [self drawAnyView];
  76. // CGFloat second = 0.1;
  77. // BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_cloudPhone_Model_Open];
  78. // if(haveOpenMask){
  79. // second = 5;
  80. // }
  81. // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(second * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  82. // [self beginShowAlertFun];
  83. // });
  84. //[self beginShowAlertFun];
  85. }
  86. - (void)drawAnyView{
  87. //顶底底部图片
  88. UIImageView *topImageV = [UIImageView new];
  89. topImageV.image = [UIImage imageNamed:@"Nas_top_img"];
  90. [self.view addSubview:topImageV];
  91. [topImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  92. make.top.mas_equalTo(0);
  93. make.left.mas_equalTo(0);
  94. make.right.mas_equalTo(0);
  95. make.height.mas_equalTo(280.0*AUTOSCALE);
  96. }];
  97. // NSString *welcomeImageStr = @"nas_welcome_cs";
  98. // //欢迎
  99. // //en-US 英文 ja-JP 日文
  100. // NSArray *arLanguages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"];
  101. // NSLog(@"arLanguages:%@",arLanguages);
  102. // ///获取设备当前地区的代码和APP语言环境
  103. // NSString *languageCode = [NSLocale preferredLanguages][0];
  104. //
  105. // //目前支持 中文(简体 繁体) 英文 日语
  106. // if([languageCode rangeOfString:@"zh-Hans"].location != NSNotFound)
  107. // {
  108. // welcomeImageStr = @"nas_welcome_cs";
  109. // }
  110. // else if([languageCode rangeOfString:@"zh-Hant"].location != NSNotFound)
  111. // {
  112. // welcomeImageStr = @"nas_welcome_ct";
  113. // }
  114. // else{
  115. // welcomeImageStr = @"nas_welcome_en";
  116. // }
  117. CGFloat imageTopY = 54.0;
  118. welcomeImageV = [UIImageView new];
  119. welcomeImageV.hidden = YES;
  120. //welcomeImageV.image = [UIImage imageNamed:welcomeImageStr];
  121. [self.view addSubview:welcomeImageV];
  122. [welcomeImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  123. make.top.mas_equalTo(imageTopY);
  124. make.left.mas_equalTo(16);
  125. make.width.mas_equalTo(210);
  126. make.height.mas_equalTo(24);
  127. }];
  128. UILabel *welcomelabel = [[UILabel alloc] init];
  129. welcomelabel.text = NSLocalizedString(@"NAS_top_welcome_title",nil);
  130. welcomelabel.textColor = [UIColor hwColor:@"#0A132B"];
  131. welcomelabel.font = [UIFont boldSystemFontOfSize:18.0];
  132. [self.view addSubview:welcomelabel];
  133. [welcomelabel mas_makeConstraints:^(MASConstraintMaker *make) {
  134. make.top.mas_equalTo(imageTopY);
  135. make.left.mas_equalTo(16);
  136. make.width.mas_equalTo(240);
  137. make.height.mas_equalTo(24);
  138. }];
  139. //添加按钮
  140. UIButton *addButton = [[UIButton alloc] init];
  141. [addButton setImage:[UIImage imageNamed:@"nas_add_icon"] forState:UIControlStateNormal];
  142. addButton.tag = 1;
  143. [addButton addTarget:self action:@selector(didClickHeadButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  144. [self.view addSubview:addButton];
  145. [addButton mas_makeConstraints:^(MASConstraintMaker *make) {
  146. make.centerY.equalTo(welcomeImageV.mas_centerY).offset(0);
  147. make.right.mas_equalTo(-10);
  148. make.width.mas_equalTo(40);
  149. make.height.mas_equalTo(40);
  150. }];
  151. UIButton *rightTransferListButton = [[UIButton alloc] init];
  152. //[rightTransferListButton setImage:[UIImage imageNamed:@"icon_file_transfer"] forState:UIControlStateNormal];
  153. [rightTransferListButton setImage:[UIImage imageNamed:@"icon_file_transfer"] forState:UIControlStateNormal];
  154. rightTransferListButton.tag = 2;
  155. [rightTransferListButton addTarget:self action:@selector(didClickHeadButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  156. [self.view addSubview:rightTransferListButton];
  157. [rightTransferListButton mas_makeConstraints:^(MASConstraintMaker *make) {
  158. //make.top.mas_equalTo(imageTopY);
  159. make.centerY.equalTo(welcomeImageV.mas_centerY).offset(0);
  160. make.right.equalTo(addButton.mas_left).offset(0);
  161. make.width.mas_equalTo(40);
  162. make.height.mas_equalTo(40);
  163. }];
  164. rightRedView = [[UIView alloc] init];
  165. rightRedView.backgroundColor = [UIColor hwColor:@"#DD4E4E" alpha:1.0];
  166. [rightTransferListButton addSubview:rightRedView];
  167. rightRedView.layer.cornerRadius = 7;
  168. rightRedView.hidden = YES;
  169. [rightRedView mas_makeConstraints:^(MASConstraintMaker *make) {
  170. make.width.mas_equalTo(14);
  171. make.height.mas_equalTo(14);
  172. make.right.mas_equalTo(0);
  173. make.top.mas_equalTo(6);
  174. }];
  175. [self.view addSubview:self.tableView];
  176. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  177. make.left.mas_equalTo(0);
  178. make.right.mas_equalTo(0);
  179. make.top.equalTo(welcomeImageV.mas_bottom).offset(20);
  180. make.bottom.mas_equalTo(-TABBARHEIGHT);
  181. }];
  182. _tableHeadView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 165+ 15 +120 +54 + 15)];
  183. //_tableHeadView.backgroundColor = [UIColor hwColor:@"#F6F8FA"];
  184. _tableHeadView.backgroundColor = [UIColor clearColor];
  185. self.tableView.tableHeaderView = _tableHeadView;
  186. //我的空间
  187. _NASMySpaceV = [[NASMySpaceView alloc] init];
  188. [_tableHeadView addSubview:_NASMySpaceV];
  189. [_NASMySpaceV mas_makeConstraints:^(MASConstraintMaker *make) {
  190. //make.top.equalTo(welcomeImageV.mas_bottom).offset(20);
  191. make.top.mas_equalTo(0);
  192. make.left.mas_equalTo(0);
  193. make.right.mas_equalTo(0);
  194. make.height.mas_equalTo(165);
  195. }];
  196. //常用功能
  197. _NASCommonUsedV = [[NASCommonUsedView alloc] init];
  198. [_tableHeadView addSubview:_NASCommonUsedV];
  199. [_NASCommonUsedV mas_makeConstraints:^(MASConstraintMaker *make) {
  200. make.top.equalTo(_NASMySpaceV.mas_bottom).offset(15);
  201. make.left.mas_equalTo(0);
  202. make.right.mas_equalTo(0);
  203. make.height.mas_equalTo(120);
  204. }];
  205. //最近文件
  206. [_tableHeadView addSubview:self.NASLastFileV];
  207. [self.NASLastFileV mas_makeConstraints:^(MASConstraintMaker *make) {
  208. make.top.equalTo(_NASCommonUsedV.mas_bottom).offset(15);
  209. make.left.mas_equalTo(0);
  210. make.right.mas_equalTo(0);
  211. make.height.mas_equalTo(54);
  212. }];
  213. BOOL isShowLastFileType = [HWDataManager getBoolWithKey:Const_last_file_show];
  214. self.NASLastFileV.eyeButton.selected = !isShowLastFileType;
  215. //tableFooterView
  216. NSString *text = NSLocalizedString(@"NAS_bottom_tip",nil);
  217. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 50)];
  218. label.text = [[NSString alloc] initWithFormat:@"- %@ -",text];
  219. label.textColor = [UIColor hwColor:@"#959799"];
  220. label.font = [UIFont systemFontOfSize:12];
  221. label.textAlignment = NSTextAlignmentCenter;
  222. self.tableView.tableFooterView = label;
  223. KWeakSelf
  224. _NASMySpaceV.didClickButtonFun = ^(NSInteger tag) {
  225. [weakSelf didClickMySpaceFunBy:tag];
  226. };
  227. _NASCommonUsedV.didClickButtonFun = ^(NSInteger tag) {
  228. [weakSelf didClickCommonUsedFunBy:tag];
  229. };
  230. self.NASLastFileV.didClickButtonFun = ^(NSInteger tag) {
  231. [weakSelf didClickLastFileFunBy:tag];
  232. };
  233. [self setMySpaceDataFun];
  234. }
  235. #pragma mark - 懒加载
  236. - (UITableView *)tableView{
  237. if (!_tableView) {
  238. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 0, 0) style:UITableViewStylePlain];
  239. _tableView.delegate = self;
  240. _tableView.dataSource = self;
  241. _tableView.showsVerticalScrollIndicator = NO;
  242. _tableView.showsHorizontalScrollIndicator = NO;
  243. // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
  244. [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
  245. [_tableView setSeparatorColor:[UIColor clearColor]];
  246. //[_tableView setBackgroundColor:[UIColor hwColor:@"#FFFFFF"]];
  247. [_tableView setBackgroundColor:[UIColor clearColor]];
  248. //[_tableView setTableFooterView:[UIView new]];
  249. [_tableView setBounces:YES];
  250. if (@available(iOS 15.0, *)) {
  251. _tableView.sectionHeaderTopPadding = 0;
  252. }
  253. _tableView.layer.cornerRadius = 8;
  254. _tableView.layer.masksToBounds = YES;
  255. }
  256. return _tableView;
  257. }
  258. - (NASLastFileView*)NASLastFileV
  259. {
  260. if(!_NASLastFileV){
  261. _NASLastFileV = [NASLastFileView new];
  262. }
  263. return _NASLastFileV;
  264. }
  265. #pragma mark - 列表委托
  266. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  267. return 1;
  268. }
  269. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  270. if(!_lastFileDataArr){
  271. return 0;
  272. }
  273. return _lastFileDataArr.count;
  274. }
  275. - (lastFileTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  276. __block NSInteger row = indexPath.row;
  277. static NSString *identifier = @"lastFileTableViewCell";
  278. lastFileTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  279. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  280. if (!cell){
  281. cell = [[lastFileTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  282. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  283. [cell setBackgroundColor:[UIColor clearColor]];
  284. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  285. [cell hideCheckButtonBy:YES];
  286. }
  287. if(row < _lastFileDataArr.count){
  288. lastFileModel* dataModel = _lastFileDataArr[row];
  289. cell.curLastFileModel = dataModel;
  290. // KWeakSelf
  291. // cell.didClickSwitch = ^(BOOL SwitchOn) {
  292. // //[weakSelf userCheckFilePreviewByRow:row];
  293. // };
  294. cell.cellBgView.layer.mask = nil;
  295. if(row == _lastFileDataArr.count -1){
  296. /*下圆角*/
  297. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-32 , 84)
  298. byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
  299. cornerRadii:CGSizeMake(12, 12)];
  300. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  301. maskLayer.frame = cell.cellBgView.bounds;
  302. maskLayer.path = maskPath.CGPath;
  303. cell.cellBgView.layer.mask = maskLayer;
  304. }
  305. }
  306. return cell;
  307. }
  308. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  309. return 84;
  310. }
  311. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  312. {
  313. NSInteger row = indexPath.row;
  314. if(row < _lastFileDataArr.count){
  315. lastFileModel* dataModel = _lastFileDataArr[row];
  316. if([dataModel.type isEqualToString:@"video"]){
  317. videoPlayByAVPlayerViewController *vc = [videoPlayByAVPlayerViewController new];
  318. vc.VideoDataMode = (NASFileAndFolderDataModel*)dataModel;
  319. [self.navigationController pushViewController:vc animated:YES];
  320. }
  321. else if([dataModel.type isEqualToString:@"audio"]){
  322. // NSMutableArray *audioDataArr = [NSMutableArray new];
  323. // NSInteger index = 0;
  324. //
  325. // for (int i=0; i<_lastFileDataArr.count; i++) {
  326. // lastFileModel* audioDataModel = _lastFileDataArr[i];
  327. // if([audioDataModel.type isEqualToString:@"audio"]){
  328. //
  329. // if(i == row){
  330. // index = audioDataArr.count;
  331. // }
  332. //
  333. // [audioDataArr addObject:audioDataModel];
  334. // }
  335. // }
  336. audioPlayerViewController *vc = [audioPlayerViewController new];
  337. vc.isfirstEnterType = YES;
  338. vc.outSideDataModel = (NASFileAudioDataModel *)dataModel;
  339. [self.navigationController pushViewController:vc animated:YES];
  340. KWeakSelf
  341. vc.didNeedDeleteFile = ^(NSString * _Nonnull filePath) {
  342. [weakSelf getLastFileDataFun];
  343. };
  344. }
  345. else if([dataModel.type containsString:@"jpg"]){
  346. NSMutableArray *jpgDataArr = [NSMutableArray new];
  347. NSInteger index = 0;
  348. for (int i=0; i<_lastFileDataArr.count; i++) {
  349. lastFileModel* jpgDataModel = _lastFileDataArr[i];
  350. if([jpgDataModel.type containsString:@"jpg"]){
  351. if(i == row){
  352. index = jpgDataArr.count;
  353. }
  354. [jpgDataArr addObject:jpgDataModel];
  355. }
  356. }
  357. imageDetailsScrollViewController *vc = [imageDetailsScrollViewController new];
  358. vc.index = index;
  359. vc.totalDataArr = jpgDataArr;
  360. [self.navigationController pushViewController:vc animated:YES];
  361. vc.canShareType = canShareType;
  362. }
  363. }
  364. }
  365. #pragma mark 点击头部
  366. - (void)didClickHeadButtonFun:(UIButton*)but
  367. {
  368. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  369. {
  370. [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
  371. return;
  372. }
  373. NSInteger tag = but.tag;
  374. switch (tag) {
  375. case 1:
  376. {
  377. if(ksharedAppDelegate.DisabledFileTransferType){
  378. if(ksharedAppDelegate.isImageNewFor130){
  379. [[iToast makeText:NSLocalizedString(@"File_Transfer_Disable_tip",nil)] show];
  380. }
  381. else{
  382. [[iToast makeText:NSLocalizedString(@"File_Transfer_Disable_tip2",nil)] show];
  383. }
  384. return;
  385. }
  386. [self userDidClickUploadViewFun];
  387. }
  388. break;
  389. case 2:
  390. {
  391. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  392. [self pushViewController:vc animated:YES];
  393. }
  394. break;
  395. default:
  396. break;
  397. }
  398. }
  399. #pragma mark 点击我的空间模块
  400. - (void)didClickMySpaceFunBy:(NSInteger)tag
  401. {
  402. // if(tag ==1 ){
  403. // if(!ksharedAppDelegate.cloudPhoneExtraFileListMod){
  404. // //链接了
  405. // tryLinkNum ++;
  406. // [[webSocketManager shareInstance] getExtraFilesListFun];
  407. //
  408. // if(tryLinkNum >= 3){
  409. // tryLinkNum = 0;
  410. // [[iToast makeText:NSLocalizedString(@"box_link_error_show_tip",nil)] show];
  411. // return;
  412. // }
  413. //
  414. // KWeakSelf
  415. // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  416. // [weakSelf didClickMySpaceFunBy:tag];
  417. // });
  418. // return;
  419. // }
  420. // }
  421. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  422. {
  423. [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
  424. return;
  425. }
  426. // if (!ksharedAppDelegate.isWebSockLinkOKAginType) {//未链接
  427. // [[iToast makeText:NSLocalizedString(@"box_link_error_show_tip",nil)] show];
  428. // return;
  429. // }
  430. if(ksharedAppDelegate.DisabledFileTransferType){
  431. if(ksharedAppDelegate.isImageNewFor130){
  432. [[iToast makeText:NSLocalizedString(@"File_Transfer_Disable_tip",nil)] show];
  433. }
  434. else{
  435. [[iToast makeText:NSLocalizedString(@"File_Transfer_Disable_tip2",nil)] show];
  436. }
  437. return;
  438. }
  439. tryLinkNum = 0;
  440. switch (tag)
  441. {
  442. case 1:
  443. {
  444. NASMySpaceViewController *vc = [NASMySpaceViewController new];
  445. [self pushViewController:vc animated:YES];
  446. }
  447. break;
  448. case 10:{
  449. previewImageOrVideoViewController *vc = [previewImageOrVideoViewController new];
  450. vc.isPhotoType = YES;
  451. [self pushViewController:vc animated:YES];
  452. }
  453. break;
  454. case 11:{
  455. // previewImageOrVideoViewController *vc = [previewImageOrVideoViewController new];
  456. // vc.isPhotoType = NO;
  457. // [self pushViewController:vc animated:YES];
  458. NasPreviewVideoViewController *vc = [NasPreviewVideoViewController new];
  459. [self pushViewController:vc animated:YES];
  460. }
  461. break;
  462. case 12:{
  463. previewAudioOrDocumentViewController *vc = [previewAudioOrDocumentViewController new];
  464. vc.isAudioType = YES;
  465. [self pushViewController:vc animated:YES];
  466. }
  467. break;
  468. case 13:{
  469. previewFileAndFolderViewController *vc = [previewFileAndFolderViewController new];
  470. [self pushViewController:vc animated:YES];
  471. }
  472. break;
  473. default:
  474. break;
  475. }
  476. }
  477. #pragma mark 点击常用模块模块
  478. - (void)didClickCommonUsedFunBy:(NSInteger)tag
  479. {
  480. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  481. {
  482. [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
  483. return;
  484. }
  485. // if (!ksharedAppDelegate.isWebSockLinkOKAginType) {//未链接
  486. // [[iToast makeText:NSLocalizedString(@"box_link_error_show_tip",nil)] show];
  487. // return;
  488. // }
  489. switch (tag)
  490. {
  491. case 10:{
  492. backupsOptionViewController *vc = [backupsOptionViewController new];
  493. [self pushViewController:vc animated:YES];
  494. }
  495. break;
  496. case 11:
  497. {
  498. // if(!ksharedAppDelegate.isWebSockLinkOKAginType){
  499. // [[iToast makeText:NSLocalizedString(@"check_could_phone_state",nil)] show];
  500. // return;
  501. // }
  502. fileTransfeSetViewController *nextVC = [fileTransfeSetViewController new];
  503. [self pushViewController:nextVC animated:YES];
  504. }
  505. break;
  506. case 12:{
  507. shareRecordViewController *vc = [shareRecordViewController new];
  508. [self pushViewController:vc animated:YES];
  509. [self.NASCommonUsedV setRedPointShow:NO];
  510. [self updateShareBeMarkFun];
  511. }
  512. break;
  513. default:
  514. break;
  515. }
  516. }
  517. #pragma mark 点击最近文件模块
  518. - (void)didClickLastFileFunBy:(NSInteger)tag
  519. {
  520. if(tag == 2){
  521. [self getLastFileDataFun];
  522. }
  523. else if (tag ==1){
  524. nasLastFileViewController *vc = [nasLastFileViewController new];
  525. [self pushViewController:vc animated:YES];
  526. }
  527. }
  528. #pragma mark 用户点击上传文件
  529. - (void)userDidClickUploadViewFun
  530. {
  531. [self hideTabbarFun];
  532. previewToUploadFileView *previewToUploadFileV = [[previewToUploadFileView alloc] init];
  533. [self.view addSubview:previewToUploadFileV];
  534. [previewToUploadFileV mas_makeConstraints:^(MASConstraintMaker *make) {
  535. make.left.mas_equalTo(0);
  536. make.right.mas_equalTo(0);
  537. make.bottom.mas_equalTo(10);
  538. make.top.mas_equalTo(0);
  539. }];
  540. KWeakSelf
  541. previewToUploadFileV.didClickButtonFun = ^(NSInteger tag) {
  542. [weakSelf gotoUploadFileFunWith:tag];
  543. };
  544. previewToUploadFileV.didClickCloseFun = ^{
  545. [weakSelf showTabbarFun];
  546. };
  547. }
  548. #pragma mark 调整文件上传
  549. - (void)gotoUploadFileFunWith:(NSInteger)tag
  550. {
  551. uploadImageOrVideoViewController *vc = [uploadImageOrVideoViewController new];
  552. if(tag ==10){
  553. vc.isPhotoType = YES;
  554. }
  555. else{
  556. vc.isPhotoType = NO;
  557. }
  558. [self pushViewController:vc animated:YES];
  559. }
  560. #pragma mark 获取到云机磁盘相关信息
  561. - (void)getExtraFilesDoneFun:(NSNotification*)not
  562. {
  563. // mainBlock(^{
  564. // [self setMySpaceDataFun];
  565. // });
  566. [self getExtraFilesByFrpHttpFun];
  567. }
  568. #pragma mark 走frp方案 获取云机磁盘信息
  569. - (void)getExtraFilesByFrpHttpFun
  570. {
  571. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  572. KWeakSelf
  573. [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"getExtra" Parameters:paraDict success:^(id _Nonnull responseObject) {
  574. cloudPhoneExtraFileListModel *model = [[cloudPhoneExtraFileListModel alloc] initWithDictionary:responseObject error:nil];
  575. if(model && model.status == 0){
  576. ksharedAppDelegate.cloudPhoneExtraFileListMod = model;
  577. [weakSelf setMySpaceDataFun];
  578. }
  579. } failure:^(NSError * _Nonnull error) {
  580. [weakSelf setMySpaceDataFun];
  581. }];
  582. }
  583. #pragma mark 设置我的空间信息
  584. - (void)setMySpaceDataFun
  585. {
  586. if(ksharedAppDelegate.cloudPhoneExtraFileListMod){
  587. tryLinkFrpNum = 0;
  588. [_NASMySpaceV setProgressFun];
  589. }
  590. else{
  591. tryLinkFrpNum ++;
  592. if(tryLinkFrpNum == 3){
  593. tryLinkFrpNum = 0;
  594. [self checkBoxHeartbeatFun];
  595. }
  596. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  597. //[self setMySpaceDataFun];
  598. [self getExtraFilesByFrpHttpFun];
  599. });
  600. }
  601. }
  602. - (void)viewWillAppear:(BOOL)animated{
  603. [super viewWillAppear:animated];
  604. [self getLastFileDataFun];
  605. [self queryShareSwitchFunFun];
  606. [self queryShareBeMarkFun];
  607. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  608. [self checkFileTransferTask];
  609. });
  610. //[self beginShowAlertFun];
  611. [self handelAudioPlayingViewFun];
  612. [self showTabbarFun];
  613. //尝试修复偶现获取不到磁盘空间问题
  614. [self getExtraFilesByFrpHttpFun];
  615. }
  616. - (void)viewWillDisappear:(BOOL)animated{
  617. [super viewWillDisappear:animated];
  618. }
  619. - (void)pushViewController:(UIViewController*)vc animated:(BOOL)animated
  620. {
  621. [self.navigationController pushViewController:vc animated:animated];
  622. //[self hideTabbarFun];
  623. }
  624. - (void)showTabbarFun
  625. {
  626. // 显示 tab bar
  627. self.tabBarController.tabBar.hidden = NO;
  628. }
  629. - (void)hideTabbarFun
  630. {
  631. // 隐藏 tab bar
  632. self.tabBarController.tabBar.hidden = YES;
  633. }
  634. #pragma mark 获取最近文件数据
  635. - (void)getLastFileDataFun
  636. {
  637. _lastFileDataArr = [lastFileManager shareManager].lastFileListArr;
  638. //HLog(@"%@",_lastFileDataArr);
  639. BOOL isShowLastFileType = [HWDataManager getBoolWithKey:Const_last_file_show];
  640. if(!isShowLastFileType){
  641. _tableHeadView.frame = CGRectMake(0, 0, SCREEN_W, 165+ 15 +120 +54 + 15);
  642. [self.NASLastFileV mas_remakeConstraints:^(MASConstraintMaker *make) {
  643. make.top.equalTo(_NASCommonUsedV.mas_bottom).offset(15);
  644. make.left.mas_equalTo(0);
  645. make.right.mas_equalTo(0);
  646. make.height.mas_equalTo(54);
  647. }];
  648. self.NASLastFileV.notDataImageV.hidden = YES;
  649. self.NASLastFileV.notDataLabel.hidden = YES;
  650. //全圆角
  651. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-32 , 54)
  652. byRoundingCorners:UIRectCornerAllCorners
  653. cornerRadii:CGSizeMake(12, 12)];
  654. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  655. maskLayer.frame = self.NASLastFileV.bounds;
  656. maskLayer.path = maskPath.CGPath;
  657. self.NASLastFileV.whiteBgView.layer.mask = nil;
  658. self.NASLastFileV.whiteBgView.layer.mask = maskLayer;
  659. _lastFileDataArr = [NSMutableArray new];
  660. }
  661. else if(_lastFileDataArr.count > 0){
  662. _tableHeadView.frame = CGRectMake(0, 0, SCREEN_W, 165+ 15 +120 +54 + 15);
  663. [self.NASLastFileV mas_remakeConstraints:^(MASConstraintMaker *make) {
  664. make.top.equalTo(_NASCommonUsedV.mas_bottom).offset(15);
  665. make.left.mas_equalTo(0);
  666. make.right.mas_equalTo(0);
  667. make.height.mas_equalTo(54);
  668. }];
  669. self.NASLastFileV.notDataImageV.hidden = YES;
  670. self.NASLastFileV.notDataLabel.hidden = YES;
  671. /*上圆角*/
  672. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W- 32 , 54)
  673. byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight
  674. cornerRadii:CGSizeMake(12, 12)];
  675. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  676. maskLayer.frame = CGRectMake(0, 0, SCREEN_W -32, 54);
  677. maskLayer.path = maskPath.CGPath;
  678. self.NASLastFileV.whiteBgView.layer.mask = nil;
  679. self.NASLastFileV.whiteBgView.layer.mask = maskLayer;
  680. }
  681. else{
  682. _tableHeadView.frame = CGRectMake(0, 0, SCREEN_W, 165+ 15 +120 +254 + 15);
  683. [self.NASLastFileV mas_remakeConstraints:^(MASConstraintMaker *make) {
  684. make.top.equalTo(_NASCommonUsedV.mas_bottom).offset(15);
  685. make.left.mas_equalTo(0);
  686. make.right.mas_equalTo(0);
  687. make.height.mas_equalTo(254);
  688. }];
  689. self.NASLastFileV.notDataImageV.hidden = NO;
  690. self.NASLastFileV.notDataLabel.hidden = NO;
  691. //全圆角
  692. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-32 , 254)
  693. byRoundingCorners:UIRectCornerAllCorners
  694. cornerRadii:CGSizeMake(12, 12)];
  695. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  696. maskLayer.frame = self.NASLastFileV.bounds;
  697. maskLayer.path = maskPath.CGPath;
  698. self.NASLastFileV.whiteBgView.layer.mask = nil;
  699. self.NASLastFileV.whiteBgView.layer.mask = maskLayer;
  700. }
  701. KWeakSelf
  702. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  703. [weakSelf.tableView reloadData];
  704. });
  705. }
  706. #pragma mark 获取分享开关
  707. -(void)queryShareSwitchFunFun
  708. {
  709. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  710. [paraDict setValue:@7 forKey:@"type"];
  711. //KWeakSelf
  712. [[netWorkManager shareInstance] CommonGetWithCallBackCode:queryShareSwitchFun Parameters:paraDict success:^(id _Nonnull responseObject){
  713. queryShareModel *queryShareMod = [[queryShareModel alloc] initWithDictionary:responseObject error:nil];
  714. if(queryShareMod){
  715. self->canShareType = queryShareMod.data.configValue;
  716. //[weakSelf.curEditTypeBottomView setCanShaewFunBy:queryShareMod.data.configValue];
  717. }
  718. } failure:^(NSError * _Nonnull error) {
  719. }];
  720. }
  721. - (void)checkFileTransferTask
  722. {//有个偶现的闪退在BGFMDB
  723. [[nasUploadFileManager shareInstance] checkHadUploadTaskWithComplete:^(BOOL isSuccess) {
  724. self->hadUploadTaskType = isSuccess;
  725. [self setRightButtonRedTypeFun];
  726. }];
  727. KWeakSelf
  728. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  729. [[nasDownloadFileManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
  730. self->hadDownloadTaskType = isSuccess;
  731. [weakSelf setRightButtonRedTypeFun];
  732. }];
  733. });
  734. }
  735. - (void)setRightButtonRedTypeFun
  736. {
  737. mainBlock(^{
  738. if(self->hadUploadTaskType || self->hadDownloadTaskType){
  739. self->rightRedView.hidden = NO;
  740. }
  741. else{
  742. self->rightRedView.hidden = YES;
  743. }
  744. });
  745. }
  746. #pragma mark 是否有新的分享被封禁
  747. -(void)queryShareBeMarkFun
  748. {
  749. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  750. KWeakSelf
  751. [[netWorkManager shareInstance] CommonGetWithCallBackCode:queryShareReportMarkFun Parameters:paraDict success:^(id _Nonnull responseObject){
  752. queryShareReportMarkModel *ShareMarkMod = [[queryShareReportMarkModel alloc] initWithDictionary:responseObject error:nil];
  753. if(ShareMarkMod){
  754. [weakSelf.NASCommonUsedV setRedPointShow:ShareMarkMod.data.reportMark];
  755. }
  756. } failure:^(NSError * _Nonnull error) {
  757. }];
  758. }
  759. #pragma mark 修改分享被封禁的mark状态()
  760. -(void)updateShareBeMarkFun
  761. {
  762. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  763. //KWeakSelf
  764. [[netWorkManager shareInstance] CommonPostCallBackCode:updateShareReportMarkFun Parameters:paraDict success:^(id _Nonnull responseObject){
  765. // SuperModel *ShareMarkMod = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  766. // if(ShareMarkMod){
  767. //
  768. // }
  769. } failure:^(NSError * _Nonnull error) {
  770. }];
  771. }
  772. #pragma mark 处理音频播放中的视图状态
  773. - (void)handelAudioPlayingViewFun
  774. {
  775. audioPlayingView * audioPlayingV = [audioPlayingView sharedInstance];
  776. if([DFPlayer sharedPlayer].state == DFPlayerStateBuffering
  777. ||[DFPlayer sharedPlayer].state == DFPlayerStatePlaying
  778. ||[DFPlayer sharedPlayer].state == DFPlayerStatePause){//播放中
  779. [self showAudioPlayingViewFun];
  780. }
  781. else{
  782. [self hideAudioPlayingViewFun];
  783. }
  784. KWeakSelf
  785. audioPlayingV.didClickButtonFun = ^(NSInteger tag) {
  786. if(tag == 1){
  787. [weakSelf hideAudioPlayingViewFun];
  788. }
  789. else if(tag == 5){
  790. [weakSelf AudioPlayingGotoAudioPlayerVCFun];
  791. }
  792. };
  793. }
  794. - (void)AudioPlayingGotoAudioPlayerVCFun{
  795. audioPlayerViewController *vc = [audioPlayerViewController new];
  796. vc.isfirstEnterType = NO;
  797. [self.navigationController pushViewController:vc animated:YES];
  798. }
  799. #pragma mark 显示音频播放中的视图
  800. - (void)showAudioPlayingViewFun
  801. {
  802. audioPlayingView * audioPlayingV = [audioPlayingView sharedInstance];
  803. [self.view addSubview:audioPlayingV];
  804. if([DFPlayer sharedPlayer].state == DFPlayerStatePlaying){
  805. [audioPlayingV startRotatingImage];
  806. }
  807. else if ([DFPlayer sharedPlayer].state == DFPlayerStatePause){
  808. [audioPlayingV stopRotatingImage];
  809. }
  810. [audioPlayingV mas_makeConstraints:^(MASConstraintMaker *make) {
  811. make.height.mas_equalTo(49);
  812. make.left.mas_equalTo(0);
  813. make.right.mas_equalTo(0);
  814. make.bottom.mas_equalTo(-TABBARHEIGHT);
  815. }];
  816. [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  817. make.left.mas_equalTo(0);
  818. make.right.mas_equalTo(0);
  819. make.top.equalTo(welcomeImageV.mas_bottom).offset(20);
  820. make.bottom.mas_equalTo(-TABBARHEIGHT -49);
  821. }];
  822. }
  823. #pragma mark 隐藏音频播放中的视图
  824. - (void)hideAudioPlayingViewFun
  825. {
  826. // audioPlayingView * audioPlayingV = [audioPlayingView sharedInstance];
  827. // [audioPlayingV removeFromSuperview];
  828. [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  829. make.left.mas_equalTo(0);
  830. make.right.mas_equalTo(0);
  831. make.top.equalTo(welcomeImageV.mas_bottom).offset(20);
  832. make.bottom.mas_equalTo(-TABBARHEIGHT);
  833. }];
  834. }
  835. - (void)applicationDidBecomeActive:(NSNotification *)notification
  836. {
  837. //[self beginShowAlertFun];
  838. [self checkBoxHeartbeatFun];
  839. }
  840. #pragma mark 检测盒子的心跳情况
  841. - (void)checkBoxHeartbeatFun
  842. {
  843. //1.隐私模式密码界面 3秒检测一次是否输入完成密码了
  844. if(ksharedAppDelegate.isDidShowPwdType){
  845. KWeakSelf
  846. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  847. [weakSelf checkBoxHeartbeatFun];
  848. });
  849. return;
  850. }
  851. // [[BoxHeartbeatAlertTool shareInstance] showBoxHeartbeatAlertFun:1 didClickBut:^(NSInteger tag) {
  852. //
  853. // }];
  854. if(ksharedAppDelegate.isWebSockLinkOKAginType && ksharedAppDelegate.cloudPhoneExtraFileListMod){
  855. return;
  856. }
  857. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  858. KWeakSelf
  859. [[netWorkManager shareInstance] CommonGetWithCallBackCode:queryHeartbeat Parameters:paraDict success:^(id _Nonnull responseObject){
  860. queryHeartbeatModel *heartbeatMod = [[queryHeartbeatModel alloc] initWithDictionary:responseObject error:nil];
  861. if(heartbeatMod && heartbeatMod.data){
  862. [weakSelf checkBoxHeartbeatToShowPopViewFunBy:heartbeatMod];
  863. }
  864. } failure:^(NSError * _Nonnull error) {
  865. }];
  866. }
  867. #pragma mark 根据盒子的心跳情况 显示异常谈了
  868. - (void)checkBoxHeartbeatToShowPopViewFunBy:(queryHeartbeatModel*)heartbeatMod
  869. {
  870. if(!heartbeatMod || !heartbeatMod.data){
  871. return;
  872. }
  873. if (!heartbeatMod.data.frpStatus
  874. &&!heartbeatMod.data.hostAgentStatus
  875. &&!heartbeatMod.data.containerAgentStatus) {//全部异常
  876. [[BoxHeartbeatAlertTool shareInstance] showBoxHeartbeatAlertFun:1 didClickBut:^(NSInteger tag) {
  877. }];
  878. }
  879. else if (heartbeatMod.data.hostAgentStatus
  880. && !heartbeatMod.data.frpStatus
  881. && heartbeatMod.data.containerAgentStatus) {//frp异常
  882. [[BoxHeartbeatAlertTool shareInstance] showBoxHeartbeatAlertFun:2 didClickBut:^(NSInteger tag) {
  883. }];
  884. }
  885. }
  886. @end