NASViewController.m 38 KB

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