萤石云 iOSSDK,移植跨平台相关工程
Davin
2024-12-18 b4e1288a9b63eb820e9c9489c56aac4bf6b31067
EZSDK/EZSDK/EZ/UIViewControllers/EZSettingViewController.m
@@ -17,6 +17,8 @@
#import "EZDeviceUpgradeViewController.h"
#import <EZOpenSDKFramework/EZStorageInfo.h>
#import "Toast+UIView.h"
#import "HDLEZDetectionTypeViewController.h"
#import "HDLEZMirrorFlipView.h"
//#import "EzvizDeviceManager.h"
@@ -25,6 +27,7 @@
@property (nonatomic, strong) NSMutableArray *settingList;
@property (nonatomic, weak) IBOutlet UISwitch *videoSwitch;
@property (nonatomic, weak) IBOutlet UISwitch *actionSwitch;
@property (nonatomic, strong) UIImageView *actionRightArrow;
@property (weak, nonatomic) IBOutlet UISwitch *hdSwitch;
@property (weak, nonatomic) IBOutlet UISwitch *privacyMaskSwitch;
@property (weak, nonatomic) IBOutlet UIImageView *rightArrowImg;
@@ -33,12 +36,14 @@
@property (nonatomic, weak) IBOutlet UILabel *currentVersionLabel;
@property (nonatomic, weak) IBOutlet UILabel *nVersionLabel;
@property (nonatomic, weak) IBOutlet UIImageView *updateImageView;
@property (nonatomic, strong) HDLEZMirrorFlipView *mirrorFlipView;
@property (nonatomic, strong) UIButton *deleteButton;
@property (nonatomic, strong) UIButton *privacyMaskButton;  // 隐私遮蔽执行过程提醒按钮
@property (nonatomic, strong) EZDeviceVersion *deviceVersion;
@property (nonatomic, strong) NSTimer *timer;
@property (nonatomic, assign) BOOL isCatEye;    // 是否为猫眼
@property (nonatomic, assign) BOOL privacyMasking;    // 隐私遮蔽设置中
@property (nonatomic, copy) NSString *mirrorFlipCommand;  // 镜像翻转命令
@end
@@ -114,6 +119,26 @@
            weakSelf.nVersionLabel.text = version.currentVersion;
        }
    }];
    [[EZHttpUtil sharedManager] getDeviceCapacity:self.deviceInfo.deviceSerial completion:^(ResponseData * _Nonnull responseData) {
        NSLog(@"#######镜像翻转值返回结果:%@", [responseData yy_modelToJSONString]);
        if (responseData.success && responseData.data) {
            NSLog(@"#######镜像翻转值为:%@", responseData.data);
            BOOL ptzCenterMirror = [[responseData.data objectForKey:@"ptzCenterMirror"] boolValue];
            BOOL ptzLeftRightMirror = [[responseData.data objectForKey:@"ptzLeftRightMirror"] boolValue];
            BOOL ptzTopBottomMirror = [[responseData.data objectForKey:@"ptzTopBottomMirror"] boolValue];
            if (ptzTopBottomMirror) {
                weakSelf.mirrorFlipCommand = @"0";
            }
            if (ptzLeftRightMirror) {
                weakSelf.mirrorFlipCommand = @"1";
            }
            if (ptzCenterMirror) {
                weakSelf.mirrorFlipCommand = @"2";
            }
            [weakSelf.tableView reloadData];
        }
    }];
    [self.privacyMaskSwitch setOn:NO];
    [self getPrivacyMaskSwitchStatus];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
@@ -223,6 +248,17 @@
    cell.textLabel.textAlignment = NSTextAlignmentLeft;
    cell.accessoryType = UITableViewCellAccessoryNone;
    cell.accessoryView = nil;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    UIView *separatorLine = [[UIView alloc] init];
    separatorLine.hidden = YES; //   默认隐藏分割线
    [cell.contentView addSubview:separatorLine];
    separatorLine.backgroundColor = HDLEZHEXCOLOR(0xECEDEE, 1.);
    [separatorLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(cell.contentView.mas_left).offset(16.);
        make.bottom.mas_equalTo(cell.contentView.mas_bottom);
        make.right.mas_equalTo(cell.contentView.mas_right).offset(-16.);
        make.height.mas_equalTo(0.5);
    }];
    if (indexPath.section == 0)
    {
        [cell.contentView addSubview:self.nameLabel];
@@ -243,23 +279,25 @@
        [cell.contentView addSubview:self.serialLabel];
        [self.serialLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.leading.mas_equalTo(@140);
            make.trailing.mas_equalTo(cell.contentView.mas_trailing).offset(-34);
            make.trailing.mas_equalTo(cell.contentView.mas_trailing).offset(-16);
            make.centerY.mas_equalTo(cell.contentView.mas_centerY);
            make.height.mas_equalTo(@20);
        }];
        self.serialLabel.text = self.deviceInfo.deviceSerial;
        separatorLine.hidden = NO;
    }
    else if (indexPath.section == 5)
    {
        [cell.contentView addSubview:self.hdSwitch];
        [self.hdSwitch mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.trailing.mas_equalTo(@(-17));
            make.trailing.mas_equalTo(@(-16));
            make.centerY.mas_equalTo(cell.contentView.mas_centerY);
            make.width.mas_equalTo(@51);
            make.height.mas_equalTo(@31);
        }];
        BOOL hdStatus = [[NSUserDefaults standardUserDefaults] boolForKey:[NSString stringWithFormat:@"EZVideoPlayHardDecodingStatus_%@", self.deviceInfo.deviceSerial]];
        self.hdSwitch.on = hdStatus;
        separatorLine.hidden = NO;
    }
    else if (indexPath.section == 6)
    {
@@ -267,6 +305,13 @@
            cell.backgroundColor = [UIColor clearColor];
            cell.contentView.backgroundColor = [UIColor clearColor];
            cell.textLabel.text = @"";
            if (self.mirrorFlipCommand && self.mirrorFlipCommand.length > 0) {
                [cell.contentView addSubview:self.mirrorFlipView];
                __weak __typeof(self)weakSelf = self;
                [self.mirrorFlipView configTitle:NSLocalizedString(@"api_mirror_flip", @"画面翻转") subTitle:NSLocalizedString(@"api_mirror_flip_trip", @"点击后视频画面会翻转展示,适合倒装的场景") click:^{
                    [weakSelf mirrorFlipAction];
                }];
            }
            [cell.contentView addSubview:self.deleteButton];
            [self.deleteButton addTarget:self action:@selector(deleteAction) forControlEvents:UIControlEventTouchUpInside];
            [self.deleteButton mas_remakeConstraints:^(MASConstraintMaker *make) {
@@ -278,7 +323,7 @@
        } else {    // 摄像头
            [cell.contentView addSubview:self.privacyMaskSwitch];
            [self.privacyMaskSwitch mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.trailing.mas_equalTo(@(-17));
                make.trailing.mas_equalTo(@(-16));
                make.centerY.mas_equalTo(cell.contentView.mas_centerY);
                make.width.mas_equalTo(@51);
                make.height.mas_equalTo(@31);
@@ -289,7 +334,7 @@
    {
        [cell.contentView addSubview:self.rightArrowImg];
        [self.rightArrowImg mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.trailing.mas_equalTo(@(-17));
            make.trailing.mas_equalTo(@(-16));
            make.centerY.mas_equalTo(cell.contentView.mas_centerY);
            make.width.mas_equalTo(@16);
            make.height.mas_equalTo(@16);
@@ -300,6 +345,13 @@
        cell.backgroundColor = [UIColor clearColor];
        cell.contentView.backgroundColor = [UIColor clearColor];
        cell.textLabel.text = @"";
        if (self.mirrorFlipCommand && self.mirrorFlipCommand.length > 0) {
            [cell.contentView addSubview:self.mirrorFlipView];
            __weak __typeof(self)weakSelf = self;
            [self.mirrorFlipView configTitle:NSLocalizedString(@"api_mirror_flip", @"画面翻转") subTitle:NSLocalizedString(@"api_mirror_flip_trip", @"点击后视频画面会翻转展示,适合倒装的场景") click:^{
                [weakSelf mirrorFlipAction];
            }];
        }
        [cell.contentView addSubview:self.deleteButton];
        [self.deleteButton addTarget:self action:@selector(deleteAction) forControlEvents:UIControlEventTouchUpInside];
        [self.deleteButton mas_remakeConstraints:^(MASConstraintMaker *make) {
@@ -311,23 +363,32 @@
    }
    else if (indexPath.section == 3)
    {
        [cell.contentView addSubview:self.actionSwitch];
        [self.actionSwitch mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.trailing.mas_equalTo(@(-17));
//        [cell.contentView addSubview:self.actionSwitch];
//        [self.actionSwitch mas_remakeConstraints:^(MASConstraintMaker *make) {
//            make.trailing.mas_equalTo(@(-16));
//            make.centerY.mas_equalTo(cell.contentView.mas_centerY);
//            make.width.mas_equalTo(@51);
//            make.height.mas_equalTo(@31);
//        }];
        [cell.contentView addSubview:self.actionRightArrow];
        [self.actionRightArrow mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.trailing.mas_equalTo(@(-16));
            make.centerY.mas_equalTo(cell.contentView.mas_centerY);
            make.width.mas_equalTo(@51);
            make.height.mas_equalTo(@31);
            make.width.mas_equalTo(@16);
            make.height.mas_equalTo(@16);
        }];
        separatorLine.hidden = NO;
    }
    else if (indexPath.section == 4)
    {
        [cell.contentView addSubview:self.videoSwitch];
        [self.videoSwitch mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.trailing.mas_equalTo(@(-17));
            make.trailing.mas_equalTo(@(-16));
            make.centerY.mas_equalTo(cell.contentView.mas_centerY);
            make.width.mas_equalTo(@51);
            make.height.mas_equalTo(@31);
        }];
        separatorLine.hidden = NO;
    }
    else
    {
@@ -336,17 +397,18 @@
            [cell.contentView addSubview:self.currentVersionLabel];
            [self.currentVersionLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.leading.mas_equalTo(@140);
                make.trailing.mas_equalTo(cell.contentView.mas_trailing).offset(-34);
                make.trailing.mas_equalTo(cell.contentView.mas_trailing).offset(-16);
                make.centerY.mas_equalTo(cell.contentView.mas_centerY);
                make.height.mas_equalTo(@20);
            }];
            separatorLine.hidden = NO;
        }
        else
        {
            [cell.contentView addSubview:self.nVersionLabel];
            [self.nVersionLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.leading.mas_equalTo(@140);
                make.trailing.mas_equalTo(cell.contentView.mas_trailing).offset(-34);
                make.trailing.mas_equalTo(cell.contentView.mas_trailing).offset(-16);
                make.centerY.mas_equalTo(cell.contentView.mas_centerY);
                make.height.mas_equalTo(@20);
            }];
@@ -362,7 +424,7 @@
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return ((!self.isCatEye && indexPath.section == 8) || (self.isCatEye && indexPath.section == 6)) ? 92 : 50.;
    return ((!self.isCatEye && indexPath.section == 8) || (self.isCatEye && indexPath.section == 6)) ? (self.mirrorFlipCommand && self.mirrorFlipCommand.length > 0 ? 192 : 92) : 50.;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
@@ -417,6 +479,12 @@
    else if (indexPath.section == 2 && indexPath.row == 1 && self.updateImageView.hidden == NO)
    {
        [self performSegueWithIdentifier:@"go2Upgrade" sender:nil];
    }else if (indexPath.section == 3)
    {
        HDLEZDetectionTypeViewController *detectionTypeVC = [[HDLEZDetectionTypeViewController alloc] init];
        detectionTypeVC.deviceInfo = self.deviceInfo;
        [self.navigationController pushViewController:detectionTypeVC animated:YES];
    }
    else if (indexPath.section == 7)
    {
@@ -715,6 +783,20 @@
    [self presentViewController:actionSheet animated:YES completion:nil];
}
- (void)mirrorFlipAction {
    __weak MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    __weak __typeof(self)weakSelf = self;
    [[EZHttpUtil sharedManager] setPtzMiroor:self.deviceInfo.deviceSerial command:self.mirrorFlipCommand completion:^(ResponseData * _Nonnull responseData) {
        NSLog(@"#######设置镜像翻转值返回结果:%@", [responseData yy_modelToJSONString]);
        [hud hide:YES];
        if (responseData.success) {
            [UIView dd_showMessage:NSLocalizedString(@"api_mirror_flip_success", @"画面翻转成功")];
        } else {
            [UIView dd_showMessage:responseData.message];
        }
    }];
}
#pragma mark - Getter
- (UIButton *)deleteButton {
    if (!_deleteButton) {
@@ -738,4 +820,20 @@
    return _privacyMaskButton;
}
- (UIImageView *)actionRightArrow {
    if (!_actionRightArrow) {
        _actionRightArrow = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"hdl_ez_list_next"]];
        _actionRightArrow.contentMode = UIViewContentModeScaleAspectFill;
        _actionRightArrow.backgroundColor = UIColor.clearColor;
    }
    return _actionRightArrow;
}
- (HDLEZMirrorFlipView *)mirrorFlipView {
    if (!_mirrorFlipView) {
        _mirrorFlipView = [[HDLEZMirrorFlipView alloc] initWithFrame:CGRectMake(0, 0, HDLEZ_APP_SCREEN_WIDTH, 100)];
    }
    return _mirrorFlipView;
}
@end