NASViewController.m 38 KB

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