123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813 |
- //
- // fileTransfeSetViewController.m
- // 隐私保护
- //
- // Created by xd h on 2023/12/28.
- //
- #import "fileTransfeSetViewController.h"
- #import "fileSetTableViewCell.h"
- #import "fileTransferPathCheckViewController.h"
- //#import "uploadFileManager.h"
- #import "nasUploadFileManager.h"
- //#import "backupsFileManager.h"
- #import "nasBackupsManager.h"
- @interface fileTransfeSetViewController ()<UITableViewDelegate,UITableViewDataSource,UITextViewDelegate>
- @property (nonatomic, strong) UITableView *tableView;
- @property (nonatomic, strong) UIView *tailView;
- @property (nonatomic, strong) UILabel *uploadFilePathLabel;
- @property (nonatomic, strong) UILabel *backupsFilePathLabel;
- @property (nonatomic, strong) UILabel *saveBoxFilePathLabel;
- @end
- @implementation fileTransfeSetViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
-
- [self.toolBar setHidden:YES];
- [self.navigationBar setHidden:YES];
- [self.navBarBGView setHidden:NO];
- [self.titleLabel setText:NSLocalizedString(@"set_file_Transfer_WWAN_title",nil)];
- [self.view setBackgroundColor:HWF5F7FAColor];
-
- [self drawAnyView];
-
- //数据埋点
- [[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"Nas_Settings"];
- }
- - (void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
-
- [self setUploadFilePathLabelTitleFun];
- [self setBackupsFilePathLabelTitleFun];
- [self setSaveFileToBoxPathLabelTitleFun];
- }
- - (void)drawAnyView{
-
- [self.view addSubview:self.tableView];
- [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
- }];
-
- self.tableView.tableFooterView = [self tailView];
- }
- #pragma mark - 懒加载
- - (UITableView *)tableView{
- if (!_tableView) {
- _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H - TABBARHEIGHT) 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 clearColor]];
- [_tableView setTableFooterView:[UIView new]];
- [_tableView setBounces:YES];
-
- //_tableView.scrollEnabled = NO;
-
- if (@available(iOS 15.0, *)) {
- _tableView.sectionHeaderTopPadding = 0;
- }
-
- }
-
- return _tableView;
- }
- #pragma mark - 懒加载
- - (UIView *)tailView{
- if (!_tailView) {
- _tailView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 90 + 15 + 90 + 15 + 90 + 15)];
-
- UIView *tailBgView = [[UIView alloc] init];
- tailBgView.backgroundColor = [UIColor whiteColor];
- tailBgView.layer.cornerRadius = 8;
- tailBgView.tag = 1;
- [_tailView addSubview:tailBgView];
-
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didClickTailViewFun:)];
- [tailBgView addGestureRecognizer:tap];
-
- [tailBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(15);
- make.right.mas_equalTo(-15);
- make.height.mas_equalTo(90);
- make.top.mas_equalTo(15);
- }];
-
- UILabel *titleLab = [[UILabel alloc] init];
- titleLab.text = NSLocalizedString(@"File_upload_path_set",nil);
- titleLab.font = [UIFont boldSystemFontOfSize:14.0];
- titleLab.textColor = [UIColor hwColor:@"#0A132B" alpha:1.0];
- [tailBgView addSubview:titleLab];
-
- [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(10);
- make.right.mas_equalTo(-50);
- make.height.mas_equalTo(20);
- make.top.mas_equalTo(20);
- }];
-
- /*右侧箭头*/
- UIImageView *rightImage = [[UIImageView alloc] init];
- [rightImage setBackgroundColor:[UIColor clearColor]];
- [rightImage setImage:[UIImage imageNamed:@"cell_right_access"]];
- [tailBgView addSubview:rightImage];
- [rightImage mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(28);
- make.right.mas_equalTo(-15.f);
- make.height.mas_equalTo(28);
- make.centerY.equalTo(titleLab.mas_centerY);
- }];
-
- _uploadFilePathLabel=[[UILabel alloc] init];
- //titleLab.text = NSLocalizedString(@"File_upload_path_set",nil);
- _uploadFilePathLabel.font = [UIFont systemFontOfSize:12.0];
- _uploadFilePathLabel.textColor = [UIColor hwColor:@"#6A6A6A" alpha:1.0];
- _uploadFilePathLabel.numberOfLines = 0;
- [tailBgView addSubview:_uploadFilePathLabel];
-
- [_uploadFilePathLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(10);
- make.right.mas_equalTo(-15);
- make.bottom.mas_equalTo(-20);
- make.top.mas_equalTo(titleLab.mas_bottom).offset(10.0);
- }];
-
- [self setUploadFilePathLabelTitleFun];
-
- //相册备份设置
- UIView *tailBgView2 = [[UIView alloc] init];
- tailBgView2.backgroundColor = [UIColor whiteColor];
- tailBgView2.layer.cornerRadius = 8;
- tailBgView2.tag = 2;
- [_tailView addSubview:tailBgView2];
-
- UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didClickTailViewFun:)];
- [tailBgView2 addGestureRecognizer:tap2];
-
- [tailBgView2 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(15);
- make.right.mas_equalTo(-15);
- make.height.mas_equalTo(90);
- make.top.mas_equalTo(tailBgView.mas_bottom).offset(15.0);
- }];
-
- UILabel *titleLab2 = [[UILabel alloc] init];
- titleLab2.text = NSLocalizedString(@"File_backups_path_set",nil);
- titleLab2.font = [UIFont boldSystemFontOfSize:14.0];
- titleLab2.textColor = [UIColor hwColor:@"#0A132B" alpha:1.0];
- [tailBgView2 addSubview:titleLab2];
-
- [titleLab2 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(10);
- make.right.mas_equalTo(-50);
- make.height.mas_equalTo(20);
- make.top.mas_equalTo(20);
- }];
-
- /*右侧箭头*/
- UIImageView *rightImage2 = [[UIImageView alloc] init];
- [rightImage2 setBackgroundColor:[UIColor clearColor]];
- [rightImage2 setImage:[UIImage imageNamed:@"cell_right_access"]];
- [tailBgView2 addSubview:rightImage2];
- [rightImage2 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(28);
- make.right.mas_equalTo(-15.f);
- make.height.mas_equalTo(28);
- make.centerY.equalTo(titleLab2.mas_centerY);
- }];
-
- _backupsFilePathLabel=[[UILabel alloc] init];
- //titleLab.text = NSLocalizedString(@"File_upload_path_set",nil);
- _backupsFilePathLabel.font = [UIFont systemFontOfSize:12.0];
- _backupsFilePathLabel.textColor = [UIColor hwColor:@"#6A6A6A" alpha:1.0];
- _backupsFilePathLabel.numberOfLines = 0;
- [tailBgView2 addSubview:_backupsFilePathLabel];
-
- [_backupsFilePathLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(15);
- make.right.mas_equalTo(-15);
- make.bottom.mas_equalTo(-10);
- make.top.mas_equalTo(titleLab2.mas_bottom).offset(10.0);
- }];
-
- [self setBackupsFilePathLabelTitleFun];
-
- ////相册备份设置
- UIView *tailBgView3 = [[UIView alloc] init];
- tailBgView3.backgroundColor = [UIColor whiteColor];
- tailBgView3.layer.cornerRadius = 8;
- tailBgView3.tag = 3;
- [_tailView addSubview:tailBgView3];
-
- UITapGestureRecognizer *tap3 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didClickTailViewFun:)];
- [tailBgView3 addGestureRecognizer:tap3];
-
- [tailBgView3 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(15);
- make.right.mas_equalTo(-15);
- make.height.mas_equalTo(90);
- make.top.mas_equalTo(tailBgView2.mas_bottom).offset(15.0);
- }];
-
- UILabel *titleLab3 = [[UILabel alloc] init];
- titleLab3.text = NSLocalizedString(@"File_save_to_box_path_set",nil);
- titleLab3.font = [UIFont boldSystemFontOfSize:14.0];
- titleLab3.textColor = [UIColor hwColor:@"#0A132B" alpha:1.0];
- [tailBgView3 addSubview:titleLab3];
-
- [titleLab3 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(10);
- make.right.mas_equalTo(-50);
- make.height.mas_equalTo(20);
- make.top.mas_equalTo(20);
- }];
-
- /*右侧箭头*/
- UIImageView *rightImage3 = [[UIImageView alloc] init];
- [rightImage3 setBackgroundColor:[UIColor clearColor]];
- [rightImage3 setImage:[UIImage imageNamed:@"cell_right_access"]];
- [tailBgView3 addSubview:rightImage3];
- [rightImage3 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(28);
- make.right.mas_equalTo(-15.f);
- make.height.mas_equalTo(28);
- make.centerY.equalTo(titleLab3.mas_centerY);
- }];
-
- _saveBoxFilePathLabel=[[UILabel alloc] init];
- //titleLab.text = NSLocalizedString(@"File_upload_path_set",nil);
- _saveBoxFilePathLabel.font = [UIFont systemFontOfSize:12.0];
- _saveBoxFilePathLabel.textColor = [UIColor hwColor:@"#6A6A6A" alpha:1.0];
- _saveBoxFilePathLabel.numberOfLines = 0;
- [tailBgView3 addSubview:_saveBoxFilePathLabel];
-
- [_saveBoxFilePathLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(15);
- make.right.mas_equalTo(-15);
- make.bottom.mas_equalTo(-10);
- make.top.mas_equalTo(titleLab3.mas_bottom).offset(10.0);
- }];
-
- [self setSaveFileToBoxPathLabelTitleFun];
- }
-
- return _tailView;
- }
- - (void)setUploadFilePathLabelTitleFun
- {
- NSString * leftStr = NSLocalizedString(@"File_upload_path_way",nil);
-
- NSString * uploadDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_photo_upload_default_path)];
- if(!uploadDefaultPath || uploadDefaultPath.length == 0){
- [HWDataManager setStringWithKey:stringKeyAddSn(Const_photo_upload_default_path) value:Const_default_upload_path];
- uploadDefaultPath = Const_default_upload_path;
- }
-
- uploadDefaultPath = [iTools changePathToShowPathBy:uploadDefaultPath];
-
- NSString * rightStr = uploadDefaultPath;
-
- NSString *totalStr = [[NSString alloc] initWithFormat:@"%@%@",leftStr,rightStr];
-
- NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:totalStr];
-
- NSRange redRange = NSMakeRange([totalStr rangeOfString:rightStr].location, [totalStr rangeOfString:rightStr].length);
- [noteStr addAttribute:NSForegroundColorAttributeName value:[UIColor hwColor:@"#01B7EA" alpha:0.8] range:redRange];
- [noteStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12.0] range:redRange];
- // 设置行间距
- NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
- [paragraphStyle setLineSpacing:5]; //设置行间距
-
- [noteStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [totalStr length])];
-
- _uploadFilePathLabel.attributedText = noteStr;
- }
- - (void)setBackupsFilePathLabelTitleFun
- {
- NSString * leftStr = NSLocalizedString(@"File_backups_path_way_tip2",nil);
-
- NSString * backupsDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_photo_backups_default_path)];
-
- if(!backupsDefaultPath || backupsDefaultPath.length == 0){
- backupsDefaultPath = Const_default_backups_path;
- [HWDataManager setStringWithKey:stringKeyAddSn(Const_photo_backups_default_path) value:backupsDefaultPath];
- }
-
- backupsDefaultPath = [iTools changePathToShowPathBy:backupsDefaultPath];
-
- NSString * rightStr = backupsDefaultPath;
-
- NSString *totalStr = [[NSString alloc] initWithFormat:@"%@%@",leftStr,rightStr];
-
- NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:totalStr];
-
- NSRange redRange = NSMakeRange([totalStr rangeOfString:rightStr].location, [totalStr rangeOfString:rightStr].length);
- [noteStr addAttribute:NSForegroundColorAttributeName value:[UIColor hwColor:@"#01B7EA" alpha:0.8] range:redRange];
- [noteStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12.0] range:redRange];
- // 设置行间距
- NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
- [paragraphStyle setLineSpacing:5]; //设置行间距
-
- [noteStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [totalStr length])];
-
- _backupsFilePathLabel.attributedText = noteStr;
- }
- #pragma mark 设置 盒子的接收路径
- - (void)setSaveFileToBoxPathLabelTitleFun
- {
- NSString * leftStr = NSLocalizedString(@"File_upload_path_way",nil);
-
- NSString * boxSaveDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_box_save_default_path)];
-
- if(!boxSaveDefaultPath || boxSaveDefaultPath.length == 0){
- boxSaveDefaultPath = Const_default_save_path;
- [HWDataManager setStringWithKey:stringKeyAddSn(Const_box_save_default_path) value:boxSaveDefaultPath];
- }
-
- boxSaveDefaultPath = [iTools changePathToShowPathBy:boxSaveDefaultPath];
-
- NSString * rightStr = boxSaveDefaultPath;
-
- NSString *totalStr = [[NSString alloc] initWithFormat:@"%@%@",leftStr,rightStr];
-
- NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:totalStr];
-
- NSRange redRange = NSMakeRange([totalStr rangeOfString:rightStr].location, [totalStr rangeOfString:rightStr].length);
- [noteStr addAttribute:NSForegroundColorAttributeName value:[UIColor hwColor:@"#01B7EA" alpha:0.8] range:redRange];
- [noteStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12.0] range:redRange];
- // 设置行间距
- NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
- [paragraphStyle setLineSpacing:5]; //设置行间距
-
- [noteStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [totalStr length])];
-
- _saveBoxFilePathLabel.attributedText = noteStr;
- }
- #pragma mark 尾部事件
- - (void)didClickTailViewFun:(UITapGestureRecognizer*)tap
- {
- UIView *curView = tap.view;
-
- if(curView.tag == 1){
- [self gotoSetUploadPathFun];
- }
- else if (curView.tag == 2){
- [self gotoSetBackupsPathFun];
- }
- else if (curView.tag == 3){
- [self gotofileTransferPathCheckVCFunWithType:3];
- }
- }
- -(void)gotoSetUploadPathFun
- {
- [self gotofileTransferPathCheckVCFunWithType:1];
-
- // uploadFileDataModel* model = [uploadFileManager shareInstance].curUploadFileDataModel;
- //
- // if(!model){
- // [[uploadFileManager shareInstance] getDataInDatabaseFun:YES complete:^(NSMutableArray * _Nonnull Arr) {
- // mainBlock(^{
- // if(Arr && Arr.count== 3){
- // NSArray *uploadingArr = Arr.firstObject;
- // if(uploadingArr.count == 0){
- // [self gotofileTransferPathCheckVCFunWithType:1];
- // }
- // else{
- // [[iToast makeText:NSLocalizedString(@"File_upload_set_default_path_tip",nil)] show];
- // }
- // }
- // });
- //
- // }];
- // }
- // else if(model.curUploadStateType == uploadStateUploading
- // ||model.curUploadStateType == uploadStateSuspend
- // ){
- //
- // //判断尺寸路径是否存在
- //
- // NSString * uploadDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_photo_upload_default_path)];
- //
- // BOOL isExtraFileType = NO;
- // BOOL isExtraPathFind = NO;
- // if(uploadDefaultPath){
- // if(![uploadDefaultPath containsString:@"sdcard/"]){
- // isExtraFileType = YES;
- // }
- // }
- //
- // if(uploadDefaultPath && ksharedAppDelegate.cloudPhoneExtraFileListMod){
- // NSArray*arr = ksharedAppDelegate.cloudPhoneExtraFileListMod.data;
- //
- // for (cloudPhoneExtraFileModel*model in arr) {
- // if([uploadDefaultPath containsString:model.extraPath]){
- // isExtraPathFind = YES;
- // break;
- // }
- // }
- //
- //
- // }
- //
- // if(isExtraFileType && !isExtraPathFind){
- // [self gotofileTransferPathCheckVCFunWithType:1];
- // }
- // else{
- // [[iToast makeText:NSLocalizedString(@"File_upload_set_default_path_tip",nil)] show];
- // }
- //
- // }
- // else{
- // [self gotofileTransferPathCheckVCFunWithType:1];
- // }
- }
- #pragma mark 设置备份路径相关
- - (void)gotoSetBackupsPathFun
- {
-
- //photosBackupsTaskModel* model = [backupsFileManager shareInstance].curPhotosBackupsTaskMod;
- photosBackupsTaskModel* model = [nasBackupsManager shareInstance].curPhotosBackupsTaskMod;
- if(!model){
- [self gotofileTransferPathCheckVCFunWithType:2];
- // KWeakSelf
- // [photosBackupsTaskModel bg_findAsync:backups_photos_tableName limit:1 orderBy:nil desc:YES complete:^(NSArray * _Nullable array) {
- // mainBlock(^{
- // if(array && array.count > 0){
- // photosBackupsTaskModel *preModel = array.lastObject;
- // if(preModel.curBackupsState == backupsStateUploading
- // ||preModel.curBackupsState == backupsStateSuspend
- // ){
- // [[iToast makeText:NSLocalizedString(@"File_backups_set_default_path_tip",nil)] show];
- // }
- // else{
- // [self gotofileTransferPathCheckVCFunWithType:2];
- // }
- // }
- // else{
- // [self gotofileTransferPathCheckVCFunWithType:2];
- // }
- // });
- //
- // }];
-
- }
- else if(model.curBackupsState == backupsStateUploading
- //|| model.curBackupsState == backupsStateSuspend
- )
- {
-
- //判断尺寸路径是否存在
-
- NSString * uploadDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_photo_backups_default_path)];
-
- BOOL isExtraFileType = NO;
- BOOL isExtraPathFind = NO;
- if(uploadDefaultPath){
- if(![uploadDefaultPath containsString:@"sdcard/"]){
- isExtraFileType = YES;
- }
- }
-
- if(uploadDefaultPath && ksharedAppDelegate.cloudPhoneExtraFileListMod){
- NSArray*arr = ksharedAppDelegate.cloudPhoneExtraFileListMod.data;
-
- for (cloudPhoneExtraFileModel*model in arr) {
- if([uploadDefaultPath containsString:model.extraPath]){
-
- isExtraPathFind = YES;
- break;
- }
- }
-
-
- }
-
- if(isExtraFileType && !isExtraPathFind){
- [self gotofileTransferPathCheckVCFunWithType:2];
- }
- else{
- [[iToast makeText:NSLocalizedString(@"File_backups_set_default_path_tip",nil)] show];
- }
-
- }
- else{
- [self gotofileTransferPathCheckVCFunWithType:2];
- }
-
- }
- //type 1 上传 2备份
- - (void)gotofileTransferPathCheckVCFunWithType:(NSInteger)type
- {
- fileTransferPathCheckViewController *vc = [fileTransferPathCheckViewController new];
- vc.curType = type;
- [self.navigationController pushViewController:vc animated:YES];
- }
- #pragma mark - 列表委托
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 2;
- //return 3;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- //return 2;
- return 1;
- }
- - (fileSetTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- //__block NSInteger row = indexPath.row;
- __block NSInteger section = indexPath.section;
- static NSString *identifier = @"fileSetTableViewCell";
-
- fileSetTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- if (!cell){
- cell = [[fileSetTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
- [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
- [cell setBackgroundColor:[UIColor clearColor]];
- [cell setAccessoryType:(UITableViewCellAccessoryNone)];
-
- [cell.bgViewLayer removeFromSuperlayer];
- [cell.titleLabel2 setHidden:YES];
- [cell.rightImage setHidden:YES];
- [cell.lineView setHidden:NO];
- [cell.maskSwitch setHidden:NO];
-
- }
-
- UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
- byRoundingCorners:UIRectCornerAllCorners
- cornerRadii:CGSizeMake(8, 8)];
- CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
- maskLayer.frame = cell.cellBgView.bounds;
- maskLayer.path = maskPath.CGPath;
- cell.bgViewLayer = maskLayer;
- cell.cellBgView.layer.mask = cell.bgViewLayer;
-
- [cell.lineView setHidden:YES];
-
-
- if (section == 0){
- [cell.titleLabel setText:NSLocalizedString(@"file_Transfer_By_Cellular",nil)];
-
- BOOL haveOpenMask = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_canUse_Cellular_all)];
- [cell.maskSwitch setOn:haveOpenMask];
-
- /*上圆角*/
- //设置部分圆角 贝塞尔曲线
- // UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
- // byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
- // cornerRadii:CGSizeMake(8, 8)];
- }
- else if (section == 1){
- [cell.titleLabel setText:NSLocalizedString(@"File_Transfer_background_working",nil)];
-
- BOOL haveOpenMask = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_working_background)];
- [cell.maskSwitch setOn:haveOpenMask];
- }
- else if (section == 2){
- [cell.titleLabel setText:NSLocalizedString(@"File_Transfer_full_speed",nil)];
-
- BOOL haveOpenMask = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_full_speed)];
- [cell.maskSwitch setOn:haveOpenMask];
- }
-
-
- // else if (row == 1){
- // [cell.titleLabel setText:NSLocalizedString(@"File_Transfer_set_battery_level",nil)];
- //
- // BOOL haveOpenMask = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_battery_level)];
- // [cell.maskSwitch setOn:haveOpenMask];
- //
- // /*下圆角*/
- // UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
- // byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
- // cornerRadii:CGSizeMake(8, 8)];
- // CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
- // maskLayer.frame = cell.cellBgView.bounds;
- // maskLayer.path = maskPath.CGPath;
- // cell.bgViewLayer = maskLayer;
- // cell.cellBgView.layer.mask = cell.bgViewLayer;
- //
- // [cell.lineView setHidden:YES];
- // }
- KWeakSelf
- cell.didClickSwitch = ^(BOOL SwitchOn) {
- [weakSelf didClickSwitchBy:SwitchOn withRow:section];
- };
-
- return cell;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return 60;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
- if(section==2){
- return 5+10+30;
- }
- else if (section==1){
- return 5+10+40;
- }
-
- return 5+10+20;
- }
- - (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
-
- UIView *tailView = [[UIView alloc] init];
- // if(section==2){
- // tailView.frame = CGRectMake(0, 0, SCREEN_W, 5+10+30);
- // }
-
- if(section==0){
- tailView.frame = CGRectMake(0, 0, SCREEN_W, 5+10+20);
- UILabel *lab = [[UILabel alloc] init];
- lab.font = [UIFont systemFontOfSize:12.0];
- lab.textColor = [UIColor hwColor:@"666666" alpha:1.0];
- lab.numberOfLines = 0;
- //lab.backgroundColor = [UIColor redColor];
- [tailView addSubview:lab];
- CGFloat height = 20.0;
-
- [lab setText:NSLocalizedString(@"File_Transfer_By_Cellular_tip2",nil)];
-
- [lab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(15);
- make.right.mas_equalTo(-15);
- //make.bottom.mas_equalTo(-10);
- make.height.mas_equalTo(height);
- make.top.mas_equalTo(5);
- }];
- }
- else if(section==1){
- tailView.frame = CGRectMake(0, 0, SCREEN_W, 5+10+40.0);
-
- UITextView *contentTV = [[UITextView alloc] init];
- contentTV.backgroundColor = [UIColor clearColor];
- // contentTV.textColor = [UIColor hwColor:@"#666666"];
- contentTV.font = [UIFont systemFontOfSize:12.0];
- // contentTV.textAlignment = NSTextAlignmentCenter;
- contentTV.delegate = self;
- contentTV.editable = NO; //必须禁止输入,否则点击将弹出输入键盘
- contentTV.scrollEnabled = NO;
- [tailView addSubview:contentTV];
-
- [contentTV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(15);
- make.right.mas_equalTo(-15);
- make.bottom.mas_equalTo(0);
- make.top.mas_equalTo(5);
- }];
-
- // 创建长按手势识别器
- UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress)];
- // 设置长按手势的最小按压时间
- longPress.minimumPressDuration = 0.5; // 2
- // 将手势识别器添加到视图上
- [contentTV addGestureRecognizer:longPress];
- NSString *title1 = NSLocalizedString(@"File_Transfer_background_working_tip_2",nil);
- NSString *title2 = @"";//NSLocalizedString(@"go_setting_title",nil);
- NSString *fullTitle = [[NSString alloc] initWithFormat:@"%@ %@",title1,title2];
-
- NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:fullTitle];
-
- UIColor *noteColor = [UIColor hwColor:@"#6A6A6A" alpha:1.0];
- NSRange leftRange = NSMakeRange([fullTitle rangeOfString:title1].location, [fullTitle rangeOfString:title1].length);
- [attrStr addAttribute:NSForegroundColorAttributeName value:noteColor range:leftRange];
-
- // UIColor *rightColor = [UIColor hwColor:@"#01B7EA" alpha:0.8];
- // NSRange rightRange = NSMakeRange([fullTitle rangeOfString:title2].location, [fullTitle rangeOfString:title2].length);
-
- // [attrStr addAttribute:NSLinkAttributeName
- // value:@"didclick1://"
- // range:rightRange];
-
- // [attrStr addAttribute:NSForegroundColorAttributeName value:rightColor range:rightRange];
-
-
- // 设置段落样式以实现水平中间对齐
- // NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
- // paragraphStyle.alignment = NSTextAlignmentLeft; // 水平中间对齐
- // [attrStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, attrStr.length)];
-
-
- contentTV.attributedText = attrStr;
- }
-
-
- return tailView;
- }
- - (void)didClickSwitchBy:(BOOL)SwitchOn withRow:(NSInteger)row
- {
- if(row == 0){
- [HWDataManager setBoolWithKey:stringKeyAddSn(Const_file_Transfe_canUse_Cellular_all) value:SwitchOn];
-
- if(SwitchOn){
- [[iToast makeText:NSLocalizedString(@"File_Transfer_WWAN_working_open",nil)] show];
-
- //检测下备份任务
- if([nasBackupsManager shareInstance].isWifiNeedReBackupsType
- ||[nasBackupsManager shareInstance].isWWANNeedReBackupsType){
- [[nasBackupsManager shareInstance] reBackupsFileFun];
- }
-
- [[nasUploadFileManager shareInstance] reUploadFileFunByNetWork];
- [[nasDownloadFileManager shareInstance] reDownloadloadFileFunByNetWork];
- }
- else{
- [[iToast makeText:NSLocalizedString(@"File_Transfer_WWAN_working_close",nil)] show];
-
- //检测当前有没有任务传输 有就暂停
- [[nasUploadFileManager shareInstance] saveUploadingTaskByNetWorkErrorFun];
- [[nasDownloadFileManager shareInstance] saveDownloadloadingTaskByNetWorkErrorFun];
- if([[nasBackupsManager shareInstance] checkBackupsingFun]){
- [[nasBackupsManager shareInstance] suspendBackupsFileFun];
- [nasBackupsManager shareInstance].isWWANNeedReBackupsType = YES;
- }
-
- }
- }
- else if(row == 1){
- [HWDataManager setBoolWithKey:stringKeyAddSn(Const_file_Transfe_working_background) value:SwitchOn];
-
- if(SwitchOn){
- [[iToast makeText:NSLocalizedString(@"File_Transfer_background_working_open",nil)] show];
- }
- else{
- [[iToast makeText:NSLocalizedString(@"File_Transfer_background_working_close",nil)] show];
- }
- }
- else if(row == 2){
- [HWDataManager setBoolWithKey:stringKeyAddSn(Const_file_Transfe_full_speed) value:SwitchOn];
- }
- // else{
- // [HWDataManager setBoolWithKey:stringKeyAddSn(Const_file_Transfe_battery_level) value:SwitchOn];
- // }
- }
- #pragma mark ---- textView Delegate ----
- - (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange interaction:(UITextItemInteraction)interaction
- {
-
- if([[URL scheme] isEqualToString:@"didclick1"]){
- [self gotoSettingFun];
- return NO;
- }
-
- return YES;
-
- }
- #pragma mark 拦截长按事件
- - (void)longPress{
- HLog(@"拦截长按事件")
- }
- #pragma mark 跳转设置界面
- - (void)gotoSettingFun
- {
- // 打开应用的设置页面(不适用于全局设置如低电量模式)
- NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
- //NSURL *url = [NSURL URLWithString:@"Prefs:root=BATTERY_USAGE"];
- // NSURL *url = [NSURL URLWithString:@"Prefs:root=General"];
- // [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
- if ([[UIApplication sharedApplication] canOpenURL:url]) {
- [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
- } else {
- HLog(@"无法打开系统设置");
- }
- }
- @end
|