NASViewController.m 34 KB

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