123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125 |
- //
- // NASViewController.m
- // Private-X
- //
- // Created by xd h on 2024/6/19.
- //
- #import "NASViewController.h"
- #import "NASMySpaceView.h"
- #import "NASCommonUsedView.h"
- #import "shareSecretTableViewCell.h"
- #import "NASLastFileView.h"
- #import "previewImageOrVideoViewController.h"
- #import "previewAudioOrDocumentViewController.h"
- #import "previewFileAndFolderViewController.h"
- #import "shareRecordViewController.h"
- #import "backupsOptionViewController.h"
- #import "fileTransfeSetViewController.h"
- #import "uploadFileRecordViewController.h"
- #import "previewToUploadFileView.h"
- #import "NASMySpaceViewController.h"
- #import "NasPreviewVideoViewController.h"
- #import "lastFileManager.h"
- #import "lastFileTableViewCell.h"
- #import "nasLastFileViewController.h"
- #import "audioPlayerViewController.h"
- #import "videoPlayByAVPlayerViewController.h"
- #import "imageDetailsScrollViewController.h"
- #import "queryShareModel.h"
- #import "imageVersionRenewTipView.h"
- #import "HWVersionModel.h"
- #import "HaveNewVersionView.h"
- #import "newerGuideView.h"
- #import "CustomerWebViewController.h"
- #import "noticeModel.h"
- #import "HaveNoticeView.h"
- #import "audioPlayingView.h"
- #import "DFPlayer.h"
- #import "queryShareReportMarkModel.h"
- #import "UpgradeInfoModel.h"
- #import "imageVersionUpdateDoneView.h"
- #import "imageVersionUpdateFailView.h"
- #import "queryHeartbeatModel.h"
- #import "BoxHeartbeatAlertTool.h"
- #import "DocumentPickerManager.h"
- @interface NASViewController ()<UITableViewDelegate,UITableViewDataSource>
- {
- BOOL canShareType;
-
- UIImageView *welcomeImageV;//弃用
- UIView* rightRedView;//
- BOOL hadUploadTaskType;
- BOOL hadDownloadTaskType;
-
- NSInteger tryLinkNum;
- NSInteger tryLinkFrpNum;//frp接口连接次数
-
- imageVersionRenewTipView * RenewTipView;
- imageVersionUpdateDoneView* imageVersionUpdateDoneV;
- imageVersionUpdateFailView* imageVersionUpdateFailV;
- }
- @property (nonatomic,strong)UITableView*tableView;
- @property (nonatomic, strong) UIView*tableHeadView;
- @property (nonatomic, strong) NASMySpaceView* NASMySpaceV;
- @property (nonatomic, strong) NASCommonUsedView* NASCommonUsedV;
- @property (nonatomic,strong)NASLastFileView*NASLastFileV;
- @property (nonatomic,strong) NSMutableArray *lastFileDataArr;
- @property (nonatomic,strong)UpgradeInfoModel*otaUpgradeInfoModel;
- @end
- @implementation NASViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
-
- [self.view setBackgroundColor:HWF5F7FAColor];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getExtraFilesDoneFun:) name:getExtraFilesDoneNotification object:nil];
-
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil];
-
- //输入密码完成
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didInpuPwdOkFun) name:didInputPWDNotification object:nil];
-
- [self.toolBar setHidden:YES];
- [self.navigationBar setHidden:YES];
- [self.navBarBGView setHidden:YES];
-
- [self drawAnyView];
-
-
- // CGFloat second = 0.1;
- // BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_cloudPhone_Model_Open];
- // if(haveOpenMask){
- // second = 5;
- // }
- // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(second * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- // [self beginShowAlertFun];
- // });
-
- //[self beginShowAlertFun];
- }
- - (void)drawAnyView{
- //顶底底部图片
- UIImageView *topImageV = [UIImageView new];
- topImageV.image = [UIImage imageNamed:@"Nas_top_img"];
- [self.view addSubview:topImageV];
-
- [topImageV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(0);
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.height.mas_equalTo(280.0*AUTOSCALE);
- }];
-
- // NSString *welcomeImageStr = @"nas_welcome_cs";
- // //欢迎
- // //en-US 英文 ja-JP 日文
- // NSArray *arLanguages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"];
- // NSLog(@"arLanguages:%@",arLanguages);
- // ///获取设备当前地区的代码和APP语言环境
- // NSString *languageCode = [NSLocale preferredLanguages][0];
- //
- // //目前支持 中文(简体 繁体) 英文 日语
- // if([languageCode rangeOfString:@"zh-Hans"].location != NSNotFound)
- // {
- // welcomeImageStr = @"nas_welcome_cs";
- // }
- // else if([languageCode rangeOfString:@"zh-Hant"].location != NSNotFound)
- // {
- // welcomeImageStr = @"nas_welcome_ct";
- // }
- // else{
- // welcomeImageStr = @"nas_welcome_en";
- // }
-
- CGFloat imageTopY = 54.0;
- welcomeImageV = [UIImageView new];
- welcomeImageV.hidden = YES;
- //welcomeImageV.image = [UIImage imageNamed:welcomeImageStr];
- [self.view addSubview:welcomeImageV];
-
- [welcomeImageV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(imageTopY);
- make.left.mas_equalTo(16);
- make.width.mas_equalTo(210);
- make.height.mas_equalTo(24);
- }];
-
- UILabel *welcomelabel = [[UILabel alloc] init];
- welcomelabel.text = NSLocalizedString(@"NAS_top_welcome_title",nil);
- welcomelabel.textColor = [UIColor hwColor:@"#0A132B"];
- welcomelabel.font = [UIFont boldSystemFontOfSize:18.0];
- [self.view addSubview:welcomelabel];
-
- [welcomelabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(imageTopY);
- make.left.mas_equalTo(16);
- make.width.mas_equalTo(240);
- make.height.mas_equalTo(24);
- }];
-
- //添加按钮
- UIButton *addButton = [[UIButton alloc] init];
- [addButton setImage:[UIImage imageNamed:@"nas_add_icon"] forState:UIControlStateNormal];
- addButton.tag = 1;
- [addButton addTarget:self action:@selector(didClickHeadButtonFun:) forControlEvents:UIControlEventTouchUpInside];
- [self.view addSubview:addButton];
-
- [addButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(welcomeImageV.mas_centerY).offset(0);
- make.right.mas_equalTo(-10);
- make.width.mas_equalTo(40);
- make.height.mas_equalTo(40);
- }];
-
- UIButton *rightTransferListButton = [[UIButton alloc] init];
- //[rightTransferListButton setImage:[UIImage imageNamed:@"icon_file_transfer"] forState:UIControlStateNormal];
- [rightTransferListButton setImage:[UIImage imageNamed:@"icon_file_transfer"] forState:UIControlStateNormal];
- rightTransferListButton.tag = 2;
- [rightTransferListButton addTarget:self action:@selector(didClickHeadButtonFun:) forControlEvents:UIControlEventTouchUpInside];
- [self.view addSubview:rightTransferListButton];
-
- [rightTransferListButton mas_makeConstraints:^(MASConstraintMaker *make) {
- //make.top.mas_equalTo(imageTopY);
- make.centerY.equalTo(welcomeImageV.mas_centerY).offset(0);
- make.right.equalTo(addButton.mas_left).offset(0);
- make.width.mas_equalTo(40);
- make.height.mas_equalTo(40);
- }];
-
- rightRedView = [[UIView alloc] init];
- rightRedView.backgroundColor = [UIColor hwColor:@"#DD4E4E" alpha:1.0];
- [rightTransferListButton addSubview:rightRedView];
- rightRedView.layer.cornerRadius = 7;
- rightRedView.hidden = YES;
-
- [rightRedView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(14);
- make.height.mas_equalTo(14);
- make.right.mas_equalTo(0);
- make.top.mas_equalTo(6);
- }];
-
- [self.view addSubview:self.tableView];
- [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.top.equalTo(welcomeImageV.mas_bottom).offset(20);
- make.bottom.mas_equalTo(-TABBARHEIGHT);
- }];
-
- //self.tableView.userInteractionEnabled = NO;
-
- _tableHeadView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 165+ 15 +120 +54 + 15)];
- //_tableHeadView.backgroundColor = [UIColor hwColor:@"#F6F8FA"];
- _tableHeadView.backgroundColor = [UIColor clearColor];
- self.tableView.tableHeaderView = _tableHeadView;
-
-
- //我的空间
- _NASMySpaceV = [[NASMySpaceView alloc] init];
- [_tableHeadView addSubview:_NASMySpaceV];
-
- [_NASMySpaceV mas_makeConstraints:^(MASConstraintMaker *make) {
- //make.top.equalTo(welcomeImageV.mas_bottom).offset(20);
- make.top.mas_equalTo(0);
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.height.mas_equalTo(165);
- }];
-
- //常用功能
- _NASCommonUsedV = [[NASCommonUsedView alloc] init];
- [_tableHeadView addSubview:_NASCommonUsedV];
-
- [_NASCommonUsedV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(_NASMySpaceV.mas_bottom).offset(15);
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.height.mas_equalTo(120);
- }];
-
- //最近文件
- [_tableHeadView addSubview:self.NASLastFileV];
- [self.NASLastFileV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(_NASCommonUsedV.mas_bottom).offset(15);
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.height.mas_equalTo(54);
- }];
-
- BOOL isShowLastFileType = [HWDataManager getBoolWithKey:Const_last_file_show];
- self.NASLastFileV.eyeButton.selected = !isShowLastFileType;
-
- //tableFooterView
- NSString *text = NSLocalizedString(@"NAS_bottom_tip",nil);
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 50)];
- label.text = [[NSString alloc] initWithFormat:@"- %@ -",text];
- label.textColor = [UIColor hwColor:@"#959799"];
- label.font = [UIFont systemFontOfSize:12];
- label.textAlignment = NSTextAlignmentCenter;
- self.tableView.tableFooterView = label;
-
- KWeakSelf
- _NASMySpaceV.didClickButtonFun = ^(NSInteger tag) {
- [weakSelf didClickMySpaceFunBy:tag];
- };
-
- _NASCommonUsedV.didClickButtonFun = ^(NSInteger tag) {
- [weakSelf didClickCommonUsedFunBy:tag];
- };
-
- self.NASLastFileV.didClickButtonFun = ^(NSInteger tag) {
- [weakSelf didClickLastFileFunBy:tag];
- };
-
- [self setMySpaceDataFun];
- }
- #pragma mark - 懒加载
- - (UITableView *)tableView{
- if (!_tableView) {
- _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 0, 0) style:UITableViewStylePlain];
- _tableView.delegate = self;
- _tableView.dataSource = self;
- _tableView.showsVerticalScrollIndicator = NO;
- _tableView.showsHorizontalScrollIndicator = NO;
- // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
- [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
- [_tableView setSeparatorColor:[UIColor clearColor]];
- //[_tableView setBackgroundColor:[UIColor hwColor:@"#FFFFFF"]];
- [_tableView setBackgroundColor:[UIColor clearColor]];
- //[_tableView setTableFooterView:[UIView new]];
- [_tableView setBounces:YES];
-
- if (@available(iOS 15.0, *)) {
- _tableView.sectionHeaderTopPadding = 0;
- }
-
- _tableView.layer.cornerRadius = 8;
- _tableView.layer.masksToBounds = YES;
- }
-
- return _tableView;
- }
- - (NASLastFileView*)NASLastFileV
- {
- if(!_NASLastFileV){
- _NASLastFileV = [NASLastFileView new];
- }
- return _NASLastFileV;
- }
- #pragma mark - 列表委托
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- if(!_lastFileDataArr){
- return 0;
- }
- return _lastFileDataArr.count;
- }
- - (lastFileTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- __block NSInteger row = indexPath.row;
- static NSString *identifier = @"lastFileTableViewCell";
-
- lastFileTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- if (!cell){
- cell = [[lastFileTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
- [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
- [cell setBackgroundColor:[UIColor clearColor]];
- [cell setAccessoryType:(UITableViewCellAccessoryNone)];
- [cell hideCheckButtonBy:YES];
- }
-
- if(row < _lastFileDataArr.count){
- lastFileModel* dataModel = _lastFileDataArr[row];
- cell.curLastFileModel = dataModel;
-
- // KWeakSelf
- // cell.didClickSwitch = ^(BOOL SwitchOn) {
- // //[weakSelf userCheckFilePreviewByRow:row];
- // };
-
- cell.cellBgView.layer.mask = nil;
- if(row == _lastFileDataArr.count -1){
- /*下圆角*/
- UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-32 , 84)
- byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
- cornerRadii:CGSizeMake(12, 12)];
- CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
- maskLayer.frame = cell.cellBgView.bounds;
- maskLayer.path = maskPath.CGPath;
- cell.cellBgView.layer.mask = maskLayer;
- }
- }
-
- return cell;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return 84;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- NSInteger row = indexPath.row;
-
- if(row < _lastFileDataArr.count){
- lastFileModel* dataModel = _lastFileDataArr[row];
-
- if([dataModel.type isEqualToString:@"video"]){
- videoPlayByAVPlayerViewController *vc = [videoPlayByAVPlayerViewController new];
- vc.VideoDataMode = (NASFileAndFolderDataModel*)dataModel;
- [self.navigationController pushViewController:vc animated:YES];
- }
- else if([dataModel.type isEqualToString:@"audio"]){
-
- // NSMutableArray *audioDataArr = [NSMutableArray new];
- // NSInteger index = 0;
- //
- // for (int i=0; i<_lastFileDataArr.count; i++) {
- // lastFileModel* audioDataModel = _lastFileDataArr[i];
- // if([audioDataModel.type isEqualToString:@"audio"]){
- //
- // if(i == row){
- // index = audioDataArr.count;
- // }
- //
- // [audioDataArr addObject:audioDataModel];
- // }
- // }
-
- audioPlayerViewController *vc = [audioPlayerViewController new];
- vc.isfirstEnterType = YES;
- vc.outSideDataModel = (NASFileAudioDataModel *)dataModel;
- [self.navigationController pushViewController:vc animated:YES];
-
- KWeakSelf
- vc.didNeedDeleteFile = ^(NSString * _Nonnull filePath) {
- [weakSelf getLastFileDataFun];
- };
- }
- else if([dataModel.type containsString:@"jpg"]){
-
- NSMutableArray *jpgDataArr = [NSMutableArray new];
- NSInteger index = 0;
-
- for (int i=0; i<_lastFileDataArr.count; i++) {
- lastFileModel* jpgDataModel = _lastFileDataArr[i];
- if([jpgDataModel.type containsString:@"jpg"]){
- if(i == row){
- index = jpgDataArr.count;
- }
- [jpgDataArr addObject:jpgDataModel];
- }
- }
-
- imageDetailsScrollViewController *vc = [imageDetailsScrollViewController new];
- vc.index = index;
- vc.totalDataArr = jpgDataArr;
- [self.navigationController pushViewController:vc animated:YES];
- vc.canShareType = canShareType;
-
- }
- }
- }
- #pragma mark 点击头部
- - (void)didClickHeadButtonFun:(UIButton*)but
- {
- if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
- {
- [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
- return;
- }
-
- NSInteger tag = but.tag;
-
- switch (tag) {
- case 1:
- {
- if(ksharedAppDelegate.DisabledFileTransferType){
- if(ksharedAppDelegate.isImageNewFor130){
- [[iToast makeText:NSLocalizedString(@"File_Transfer_Disable_tip",nil)] show];
- }
- else{
- [[iToast makeText:NSLocalizedString(@"File_Transfer_Disable_tip2",nil)] show];
- }
- return;
- }
-
- [self userDidClickUploadViewFun];
- }
- break;
- case 2:
- {
- uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
- [self pushViewController:vc animated:YES];
- }
- break;
-
- default:
- break;
- }
- }
- #pragma mark 点击我的空间模块
- - (void)didClickMySpaceFunBy:(NSInteger)tag
- {
- // if(tag ==1 ){
- // if(!ksharedAppDelegate.cloudPhoneExtraFileListMod){
- // //链接了
- // tryLinkNum ++;
- // [[webSocketManager shareInstance] getExtraFilesListFun];
- //
- // if(tryLinkNum >= 3){
- // tryLinkNum = 0;
- // [[iToast makeText:NSLocalizedString(@"box_link_error_show_tip",nil)] show];
- // return;
- // }
- //
- // KWeakSelf
- // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- // [weakSelf didClickMySpaceFunBy:tag];
- // });
- // return;
- // }
- // }
-
- if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
- {
- [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
- return;
- }
-
- // if (!ksharedAppDelegate.isWebSockLinkOKAginType) {//未链接
- // [[iToast makeText:NSLocalizedString(@"box_link_error_show_tip",nil)] show];
- // return;
- // }
-
- if(ksharedAppDelegate.DisabledFileTransferType){
- if(ksharedAppDelegate.isImageNewFor130){
- [[iToast makeText:NSLocalizedString(@"File_Transfer_Disable_tip",nil)] show];
- }
- else{
- [[iToast makeText:NSLocalizedString(@"File_Transfer_Disable_tip2",nil)] show];
- }
- return;
- }
-
- tryLinkNum = 0;
- switch (tag)
- {
- case 1:
- {
- NASMySpaceViewController *vc = [NASMySpaceViewController new];
- [self pushViewController:vc animated:YES];
- }
- break;
- case 10:{
- previewImageOrVideoViewController *vc = [previewImageOrVideoViewController new];
- vc.isPhotoType = YES;
- [self pushViewController:vc animated:YES];
- }
- break;
- case 11:{
- // previewImageOrVideoViewController *vc = [previewImageOrVideoViewController new];
- // vc.isPhotoType = NO;
- // [self pushViewController:vc animated:YES];
-
- NasPreviewVideoViewController *vc = [NasPreviewVideoViewController new];
- [self pushViewController:vc animated:YES];
- }
- break;
- case 12:{
- previewAudioOrDocumentViewController *vc = [previewAudioOrDocumentViewController new];
- vc.isAudioType = YES;
- [self pushViewController:vc animated:YES];
- }
- break;
- case 13:{
- previewFileAndFolderViewController *vc = [previewFileAndFolderViewController new];
- [self pushViewController:vc animated:YES];
- }
- break;
-
- default:
- break;
- }
- }
- #pragma mark 点击常用模块模块
- - (void)didClickCommonUsedFunBy:(NSInteger)tag
- {
- if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
- {
- [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
- return;
- }
-
- // if (!ksharedAppDelegate.isWebSockLinkOKAginType) {//未链接
- // [[iToast makeText:NSLocalizedString(@"box_link_error_show_tip",nil)] show];
- // return;
- // }
-
- switch (tag)
- {
- case 10:{
- backupsOptionViewController *vc = [backupsOptionViewController new];
- [self pushViewController:vc animated:YES];
- }
- break;
- case 11:
- {
- // if(!ksharedAppDelegate.isWebSockLinkOKAginType){
- // [[iToast makeText:NSLocalizedString(@"check_could_phone_state",nil)] show];
- // return;
- // }
- fileTransfeSetViewController *nextVC = [fileTransfeSetViewController new];
- [self pushViewController:nextVC animated:YES];
- }
- break;
- case 12:{
- shareRecordViewController *vc = [shareRecordViewController new];
- [self pushViewController:vc animated:YES];
- [self.NASCommonUsedV setRedPointShow:NO];
- [self updateShareBeMarkFun];
- }
- break;
-
- default:
- break;
- }
- }
- #pragma mark 点击最近文件模块
- - (void)didClickLastFileFunBy:(NSInteger)tag
- {
- if(tag == 2){
- [self getLastFileDataFun];
- }
- else if (tag ==1){
- nasLastFileViewController *vc = [nasLastFileViewController new];
- [self pushViewController:vc animated:YES];
- }
- }
- #pragma mark 用户点击上传文件
- - (void)userDidClickUploadViewFun
- {
- [self hideTabbarFun];
- previewToUploadFileView *previewToUploadFileV = [[previewToUploadFileView alloc] init];
- [self.view addSubview:previewToUploadFileV];
-
- [previewToUploadFileV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(10);
- make.top.mas_equalTo(0);
- }];
-
- KWeakSelf
- previewToUploadFileV.didClickButtonFun = ^(NSInteger tag) {
- [weakSelf gotoUploadFileFunWith:tag];
- };
-
- previewToUploadFileV.didClickCloseFun = ^{
- [weakSelf showTabbarFun];
- };
- }
- #pragma mark 调整文件上传
- - (void)gotoUploadFileFunWith:(NSInteger)tag
- {
- if(tag == 10 || tag == 11){
- uploadImageOrVideoViewController *vc = [uploadImageOrVideoViewController new];
- if(tag ==10){
- vc.isPhotoType = YES;
- }
- else{
- vc.isPhotoType = NO;
- }
- [self pushViewController:vc animated:YES];
- }
- else{
- KWeakSelf
- [[DocumentPickerManager shareManager] openDocumentPickerSuccess:^(NSArray * _Nonnull urls) {
- [weakSelf gotoUploadFileRecordByFileAppWithUrls:urls];
- }];
- }
- }
- #pragma mark 获取到云机磁盘相关信息
- - (void)getExtraFilesDoneFun:(NSNotification*)not
- {
- // mainBlock(^{
- // [self setMySpaceDataFun];
- // });
-
- [self getExtraFilesByFrpHttpFun];
- }
- #pragma mark 走frp方案 获取云机磁盘信息
- - (void)getExtraFilesByFrpHttpFun
- {
- NSMutableDictionary*paraDict = [NSMutableDictionary new];
-
- KWeakSelf
- [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"getExtra" Parameters:paraDict success:^(id _Nonnull responseObject) {
-
- cloudPhoneExtraFileListModel *model = [[cloudPhoneExtraFileListModel alloc] initWithDictionary:responseObject error:nil];
- if(model && model.status == 0){
- ksharedAppDelegate.cloudPhoneExtraFileListMod = model;
- [weakSelf setMySpaceDataFun];
- }
- } failure:^(NSError * _Nonnull error) {
- [weakSelf setMySpaceDataFun];
- }];
-
- }
- #pragma mark 设置我的空间信息
- - (void)setMySpaceDataFun
- {
- if(ksharedAppDelegate.cloudPhoneExtraFileListMod){
- tryLinkFrpNum = 0;
- [_NASMySpaceV setProgressFun];
- }
- else{
-
- // tryLinkFrpNum ++;
- //
- // if(tryLinkFrpNum == 3){
- // tryLinkFrpNum = 0;
- // [self checkBoxHeartbeatFun];
- // }
-
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- //[self setMySpaceDataFun];
- [self getExtraFilesByFrpHttpFun];
- });
- }
- }
- - (void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:animated];
- [self getLastFileDataFun];
-
- [self queryShareSwitchFunFun];
- [self queryShareBeMarkFun];
-
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [self checkFileTransferTask];
- });
-
- //[self beginShowAlertFun];
-
- [self handelAudioPlayingViewFun];
-
- [self showTabbarFun];
-
- //尝试修复偶现获取不到磁盘空间问题
- [self getExtraFilesByFrpHttpFun];
- }
- - (void)viewWillDisappear:(BOOL)animated{
- [super viewWillDisappear:animated];
-
- }
- - (void)pushViewController:(UIViewController*)vc animated:(BOOL)animated
- {
- [self.navigationController pushViewController:vc animated:animated];
- //[self hideTabbarFun];
- }
- - (void)showTabbarFun
- {
- // 显示 tab bar
- self.tabBarController.tabBar.hidden = NO;
- }
- - (void)hideTabbarFun
- {
- // 隐藏 tab bar
- self.tabBarController.tabBar.hidden = YES;
- }
- #pragma mark 获取最近文件数据
- - (void)getLastFileDataFun
- {
- _lastFileDataArr = [lastFileManager shareManager].lastFileListArr;
- //HLog(@"%@",_lastFileDataArr);
-
- BOOL isShowLastFileType = [HWDataManager getBoolWithKey:Const_last_file_show];
- if(!isShowLastFileType){
- _tableHeadView.frame = CGRectMake(0, 0, SCREEN_W, 165+ 15 +120 +54 + 15);
-
- [self.NASLastFileV mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(_NASCommonUsedV.mas_bottom).offset(15);
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.height.mas_equalTo(54);
- }];
-
- self.NASLastFileV.notDataImageV.hidden = YES;
- self.NASLastFileV.notDataLabel.hidden = YES;
-
- //全圆角
- UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-32 , 54)
- byRoundingCorners:UIRectCornerAllCorners
- cornerRadii:CGSizeMake(12, 12)];
- CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
- maskLayer.frame = self.NASLastFileV.bounds;
- maskLayer.path = maskPath.CGPath;
- self.NASLastFileV.whiteBgView.layer.mask = nil;
- self.NASLastFileV.whiteBgView.layer.mask = maskLayer;
-
- _lastFileDataArr = [NSMutableArray new];
-
- }
- else if(_lastFileDataArr.count > 0){
- _tableHeadView.frame = CGRectMake(0, 0, SCREEN_W, 165+ 15 +120 +54 + 15);
-
- [self.NASLastFileV mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(_NASCommonUsedV.mas_bottom).offset(15);
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.height.mas_equalTo(54);
- }];
-
- self.NASLastFileV.notDataImageV.hidden = YES;
- self.NASLastFileV.notDataLabel.hidden = YES;
-
- /*上圆角*/
- UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W- 32 , 54)
- byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight
- cornerRadii:CGSizeMake(12, 12)];
- CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
- maskLayer.frame = CGRectMake(0, 0, SCREEN_W -32, 54);
- maskLayer.path = maskPath.CGPath;
- self.NASLastFileV.whiteBgView.layer.mask = nil;
- self.NASLastFileV.whiteBgView.layer.mask = maskLayer;
-
- }
- else{
- _tableHeadView.frame = CGRectMake(0, 0, SCREEN_W, 165+ 15 +120 +254 + 15);
-
- [self.NASLastFileV mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(_NASCommonUsedV.mas_bottom).offset(15);
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.height.mas_equalTo(254);
- }];
-
- self.NASLastFileV.notDataImageV.hidden = NO;
- self.NASLastFileV.notDataLabel.hidden = NO;
-
- //全圆角
- UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-32 , 254)
- byRoundingCorners:UIRectCornerAllCorners
- cornerRadii:CGSizeMake(12, 12)];
- CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
- maskLayer.frame = self.NASLastFileV.bounds;
- maskLayer.path = maskPath.CGPath;
- self.NASLastFileV.whiteBgView.layer.mask = nil;
- self.NASLastFileV.whiteBgView.layer.mask = maskLayer;
- }
-
-
- KWeakSelf
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadData];
- });
-
- }
- #pragma mark 获取分享开关
- -(void)queryShareSwitchFunFun
- {
- NSMutableDictionary *paraDict = [NSMutableDictionary new];
-
- [paraDict setValue:@7 forKey:@"type"];
-
- //KWeakSelf
- [[netWorkManager shareInstance] CommonGetWithCallBackCode:queryShareSwitchFun Parameters:paraDict success:^(id _Nonnull responseObject){
- queryShareModel *queryShareMod = [[queryShareModel alloc] initWithDictionary:responseObject error:nil];
- if(queryShareMod){
- self->canShareType = queryShareMod.data.configValue;
- //[weakSelf.curEditTypeBottomView setCanShaewFunBy:queryShareMod.data.configValue];
- }
-
- } failure:^(NSError * _Nonnull error) {
- }];
- }
- - (void)checkFileTransferTask
- {//有个偶现的闪退在BGFMDB
-
- [[nasUploadFileManager shareInstance] checkHadUploadTaskWithComplete:^(BOOL isSuccess) {
- self->hadUploadTaskType = isSuccess;
- [self setRightButtonRedTypeFun];
- }];
-
- KWeakSelf
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [[nasDownloadFileManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
- self->hadDownloadTaskType = isSuccess;
- [weakSelf setRightButtonRedTypeFun];
- }];
- });
-
- }
- - (void)setRightButtonRedTypeFun
- {
- mainBlock(^{
- if(self->hadUploadTaskType || self->hadDownloadTaskType){
- self->rightRedView.hidden = NO;
- }
- else{
- self->rightRedView.hidden = YES;
- }
- });
- }
- #pragma mark 是否有新的分享被封禁
- -(void)queryShareBeMarkFun
- {
- NSMutableDictionary *paraDict = [NSMutableDictionary new];
-
- KWeakSelf
- [[netWorkManager shareInstance] CommonGetWithCallBackCode:queryShareReportMarkFun Parameters:paraDict success:^(id _Nonnull responseObject){
- queryShareReportMarkModel *ShareMarkMod = [[queryShareReportMarkModel alloc] initWithDictionary:responseObject error:nil];
- if(ShareMarkMod){
- [weakSelf.NASCommonUsedV setRedPointShow:ShareMarkMod.data.reportMark];
- }
-
- } failure:^(NSError * _Nonnull error) {
- }];
- }
- #pragma mark 修改分享被封禁的mark状态()
- -(void)updateShareBeMarkFun
- {
- NSMutableDictionary *paraDict = [NSMutableDictionary new];
-
- //KWeakSelf
- [[netWorkManager shareInstance] CommonPostCallBackCode:updateShareReportMarkFun Parameters:paraDict success:^(id _Nonnull responseObject){
- // SuperModel *ShareMarkMod = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
- // if(ShareMarkMod){
- //
- // }
-
- } failure:^(NSError * _Nonnull error) {
- }];
- }
- #pragma mark 处理音频播放中的视图状态
- - (void)handelAudioPlayingViewFun
- {
- audioPlayingView * audioPlayingV = [audioPlayingView sharedInstance];
-
- if([DFPlayer sharedPlayer].state == DFPlayerStateBuffering
- ||[DFPlayer sharedPlayer].state == DFPlayerStatePlaying
- ||[DFPlayer sharedPlayer].state == DFPlayerStatePause){//播放中
-
- [self showAudioPlayingViewFun];
- }
- else{
- [self hideAudioPlayingViewFun];
- }
-
- KWeakSelf
- audioPlayingV.didClickButtonFun = ^(NSInteger tag) {
- if(tag == 1){
- [weakSelf hideAudioPlayingViewFun];
- }
- else if(tag == 5){
- [weakSelf AudioPlayingGotoAudioPlayerVCFun];
- }
- };
- }
- - (void)AudioPlayingGotoAudioPlayerVCFun{
- audioPlayerViewController *vc = [audioPlayerViewController new];
- vc.isfirstEnterType = NO;
- [self.navigationController pushViewController:vc animated:YES];
- }
-
- #pragma mark 显示音频播放中的视图
- - (void)showAudioPlayingViewFun
- {
- audioPlayingView * audioPlayingV = [audioPlayingView sharedInstance];
- [self.view addSubview:audioPlayingV];
-
- if([DFPlayer sharedPlayer].state == DFPlayerStatePlaying){
- [audioPlayingV startRotatingImage];
- }
- else if ([DFPlayer sharedPlayer].state == DFPlayerStatePause){
- [audioPlayingV stopRotatingImage];
- }
-
- [audioPlayingV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(49);
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(-TABBARHEIGHT);
- }];
-
- [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.top.equalTo(welcomeImageV.mas_bottom).offset(20);
- make.bottom.mas_equalTo(-TABBARHEIGHT -49);
- }];
-
- }
- #pragma mark 隐藏音频播放中的视图
- - (void)hideAudioPlayingViewFun
- {
- // audioPlayingView * audioPlayingV = [audioPlayingView sharedInstance];
- // [audioPlayingV removeFromSuperview];
-
- [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.top.equalTo(welcomeImageV.mas_bottom).offset(20);
- make.bottom.mas_equalTo(-TABBARHEIGHT);
- }];
- }
- - (void)applicationDidBecomeActive:(NSNotification *)notification
- {
- //[self beginShowAlertFun];
- //后台回来点击首页无效问题
- //self.tableView.userInteractionEnabled = YES;
- [self checkBoxHeartbeatFun];
- }
- #pragma mark 检测盒子的心跳情况
- - (void)checkBoxHeartbeatFun
- {
- //2、点击系统升级弹框确定按钮后30分钟内不弹;
- NSNumber *preSecondNum = [HWDataManager getNumberWithKey:stringKeyAddSn(@"disenable_type1_BoxHeartbeat")];
- if(preSecondNum){
- long seconds = [iTools getNowTimeStamp];
- if(seconds - preSecondNum.longValue <= 60*30){
- return;
- }
- }
-
- //3、重启、恢复出厂设备、首次设置密码 3个情况下8分钟之内不弹
- NSNumber *preSecondNum2 = [HWDataManager getNumberWithKey:stringKeyAddSn(@"disenable_type2_BoxHeartbeat")];
- if(preSecondNum2){
- long seconds = [iTools getNowTimeStamp];
- if(seconds - preSecondNum2.longValue <= 60*8){
- return;
- }
- }
-
- if(ksharedAppDelegate.didShowBoxHeartbeatAlertType
- ||[webRtcManager shareManager].isResetingType
- ||[webRtcManager shareManager].isRebootIngType
- || [ksharedAppDelegate didShowImageRenewViewFun]){
- return;
- }
-
- //1.隐私模式密码界面 3秒检测一次是否输入完成密码了
- if(ksharedAppDelegate.isDidShowPwdType){
- KWeakSelf
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf checkBoxHeartbeatFun];
- });
-
- return;
- }
-
- //test code
- // [[BoxHeartbeatAlertTool shareInstance] showBoxHeartbeatAlertFun:2 didClickBut:^(NSInteger tag) {
- //
- // }];
-
- if(ksharedAppDelegate.isWebSockLinkOKAginType && ksharedAppDelegate.cloudPhoneExtraFileListMod){
- return;
- }
-
- NSMutableDictionary *paraDict = [NSMutableDictionary new];
-
- KWeakSelf
- [[netWorkManager shareInstance] CommonGetWithCallBackCode:queryHeartbeat Parameters:paraDict success:^(id _Nonnull responseObject){
- queryHeartbeatModel *heartbeatMod = [[queryHeartbeatModel alloc] initWithDictionary:responseObject error:nil];
- if(heartbeatMod && heartbeatMod.data){
- [weakSelf checkBoxHeartbeatToShowPopViewFunBy:heartbeatMod];
- }
-
- } failure:^(NSError * _Nonnull error) {
- }];
- }
- #pragma mark 根据盒子的心跳情况 显示异常谈了
- - (void)checkBoxHeartbeatToShowPopViewFunBy:(queryHeartbeatModel*)heartbeatMod
- {
- if(!heartbeatMod || !heartbeatMod.data){
- return;
- }
-
- if (//!heartbeatMod.data.frpStatus&&
- !heartbeatMod.data.hostAgentStatus
- &&!heartbeatMod.data.containerAgentStatus) {//全部异常
- [[BoxHeartbeatAlertTool shareInstance] showBoxHeartbeatAlertFun:1 didClickBut:^(NSInteger tag) {
-
- }];
- }
- else if (heartbeatMod.data.hostAgentStatus
- //&& !heartbeatMod.data.frpStatus
- && !heartbeatMod.data.containerAgentStatus) {//frp异常
- [[BoxHeartbeatAlertTool shareInstance] showBoxHeartbeatAlertFun:2 didClickBut:^(NSInteger tag) {
-
- }];
- }
- }
- #pragma mark 输入密码完成
- - (void)didInpuPwdOkFun
- {
- // KWeakSelf
- // mainBlock(^{
- // //weakSelf.tableView.userInteractionEnabled = YES;
- // });
- }
- #pragma mark 文件上传跳转上传记录
- - (void)gotoUploadFileRecordByFileAppWithUrls:(NSArray*)urls
- {
- if(!urls || urls.count == 0){
- [self showTabbarFun];
- return;
- }
- uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
- [self.navigationController pushViewController:vc animated:YES];
- vc.isUploadingType = YES;
- [vc gotoUploadFileByFileApp:urls];
-
- }
- @end
|