萤石云 iOSSDK,移植跨平台相关工程
Davin
2024-12-18 b4e1288a9b63eb820e9c9489c56aac4bf6b31067
EZSDK/EZSDK/EZ/UIViewControllers/EZSettingViewController.m
@@ -13,10 +13,12 @@
#import "EZDeviceTableViewController.h"
#import "EZEditViewController.h"
#import "EZDeviceVersion.h"
#import <EZOpenSDKFramework/EZDeviceVersion.h>
#import "EZDeviceUpgradeViewController.h"
#import "EZStorageInfo.h"
#import <EZOpenSDKFramework/EZStorageInfo.h>
#import "Toast+UIView.h"
#import "HDLEZDetectionTypeViewController.h"
#import "HDLEZMirrorFlipView.h"
//#import "EzvizDeviceManager.h"
@@ -25,14 +27,23 @@
@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;
@property (nonatomic, weak) IBOutlet UILabel *nameLabel;
@property (nonatomic, weak) IBOutlet UILabel *serialLabel;
@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
@@ -47,6 +58,14 @@
    [super viewDidLoad];
    
    self.title = NSLocalizedString(@"setting_device_set_title", @"设备设置");
    // 猫眼 CS-DH1, CS-DP1, CS-CV336, CS-CTQ1P
    // 门锁 DL30V,Y3000FV,DL20VC,DL31FS,DL30F,DL30,Y3000FVS,Y3000F
    self.isCatEye = NO;
    self.privacyMasking = NO;
    self.privacyMaskSwitch.on = NO;
    if ([self.deviceInfo.deviceType containsString:@"CS-DH1"] || [self.deviceInfo.deviceType containsString:@"CS-DP1"] || [self.deviceInfo.deviceType containsString:@"CS-CV336"] || [self.deviceInfo.deviceType containsString:@"CS-CTQ1P"]) {
        self.isCatEye = YES;
    }
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
@@ -78,26 +97,57 @@
        self.videoSwitch.on = self.deviceInfo.isEncrypt;
    }
    [_settingList addObject:@[NSLocalizedString(@"setting_hardware_decoding", @"硬解码")]];
    if (!self.isCatEye) {
        [_settingList addObject:@[NSLocalizedString(@"setting_privacy_masking", @"隐私遮蔽")]];
        [_settingList addObject:@[NSLocalizedString(@"setting_sd_card_formatting", @"SD卡格式化")]];
    }
    [_settingList addObject:@[NSLocalizedString(@"delete", @"删除")]];
    
    self.serialLabel.text = self.deviceInfo.deviceSerial;
    
    self.updateImageView.hidden = YES;
    __weak __typeof(self)weakSelf = self;
    [EZOPENSDK getDeviceVersion:self.deviceInfo.deviceSerial
                     completion:^(EZDeviceVersion *version, NSError *error) {
                         _deviceVersion = version;
                         self.currentVersionLabel.text = version.currentVersion;
                         if(version.isNeedUpgrade)
                         {
                             self.nVersionLabel.text = version.latestVersion;
                             self.updateImageView.hidden = NO;
                         }
                         else
                         {
                             self.updateImageView.hidden = YES;
                             self.nVersionLabel.text = version.currentVersion;
                         }
                     }];
        weakSelf.deviceVersion = version;
        weakSelf.currentVersionLabel.text = version.currentVersion;
        if(version.isNeedUpgrade) {
            weakSelf.nVersionLabel.text = version.latestVersion;
            weakSelf.updateImageView.hidden = NO;
        } else {
            weakSelf.updateImageView.hidden = YES;
            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;
    [self.privacyMaskSwitch addSubview:self.privacyMaskButton];
    [self.privacyMaskButton addTarget:self action:@selector(privacyMaskingAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.privacyMaskButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(UIEdgeInsetsZero);
    }];
//    [[EzvizDeviceManager sharedManager] startP2PHolePunching:_cameraInfo.cameraId completion:^(BOOL result, NSError *error) {
//        NSLog(@"result = %d, error = %@", result, error);
//    }];
@@ -142,6 +192,7 @@
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = NO;//2021-02-01
    [self.tableView reloadData];
}
@@ -150,13 +201,30 @@
        [_timer invalidate];
        _timer = nil;
    }
//    self.navigationController.navigationBarHidden = YES;//2021-02-01 添加隐藏navigationBarHidden
    [super viewWillDisappear:animated];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)getPrivacyMaskSwitchStatus {    // 获取镜头遮蔽开关状态
    __weak __typeof(self)weakSelf = self;
    [EZHttpUtil.sharedManager getCoverSwitchStatus:self.deviceInfo.deviceSerial completion:^(ResponseData * _Nonnull responseData) {
        if(responseData.success) {
            NSDictionary *dataDic = responseData.data;
            if (dataDic && [[dataDic allKeys] containsObject:@"enable"]) {  // 包含隐私遮蔽功能属性
                weakSelf.privacyMaskSwitch.enabled = YES;
                [weakSelf.privacyMaskSwitch setOn:[[dataDic objectForKey:@"enable"] boolValue]];
            } else {    // 不包含该功能
                weakSelf.privacyMaskSwitch.enabled = NO;
            }
        } else {
            weakSelf.privacyMaskSwitch.enabled = NO;
        }
    }];
}
#pragma mark - Table view data source
@@ -173,68 +241,154 @@
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"EZSettingCell" forIndexPath:indexPath];
    
    // Configure the cell...
    cell.backgroundColor = [UIColor whiteColor];
    cell.contentView.backgroundColor = [UIColor whiteColor];
    cell.textLabel.text = [[_settingList dd_objectAtIndex:indexPath.section] dd_objectAtIndex:indexPath.row];
    cell.textLabel.textColor = HDLEZHEXCOLOR(0x1B2D4D, 1.0);
    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];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
//        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        UIImageView *accessoryImgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"hdl_ez_list_next"]];
        accessoryImgView.frame = CGRectMake(0, 0, 16, 16);
        cell.accessoryView = accessoryImgView;
        [self.nameLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.leading.mas_equalTo(@140);
            make.trailing.mas_equalTo(cell.contentView.mas_trailing);
            make.trailing.mas_equalTo(cell.contentView.mas_trailing).offset(-10);
            make.centerY.mas_equalTo(cell.contentView.mas_centerY);
            make.height.mas_equalTo(@20);
        }];
//        self.nameLabel.text = self.cameraInfo.deviceName;
        self.nameLabel.text = self.deviceInfo.deviceName;
    }
    else if (indexPath.section == 1)
    {
        [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)
    {
        cell.textLabel.textColor = [UIColor redColor];
        cell.textLabel.textAlignment = NSTextAlignmentCenter;
        if (self.isCatEye) {    // 猫眼
            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) {
                make.centerX.mas_equalTo(cell.contentView.mas_centerX);
                make.left.mas_equalTo(cell.contentView.mas_left).offset(77.);
                make.bottom.mas_equalTo(cell.contentView.mas_bottom);
                make.height.mas_equalTo(@44);
            }];
        } else {    // 摄像头
            [cell.contentView addSubview:self.privacyMaskSwitch];
            [self.privacyMaskSwitch 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);
            }];
        }
    }
    else if (indexPath.section == 7)
    {
        [cell.contentView addSubview:self.rightArrowImg];
        [self.rightArrowImg mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.trailing.mas_equalTo(@(-16));
            make.centerY.mas_equalTo(cell.contentView.mas_centerY);
            make.width.mas_equalTo(@16);
            make.height.mas_equalTo(@16);
        }];
    }
    else if (indexPath.section == 8)
    {
        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) {
            make.centerX.mas_equalTo(cell.contentView.mas_centerX);
            make.left.mas_equalTo(cell.contentView.mas_left).offset(77.);
            make.bottom.mas_equalTo(cell.contentView.mas_bottom);
            make.height.mas_equalTo(@44);
        }];
    }
    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
    {
@@ -243,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);
            }];
@@ -268,18 +423,50 @@
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 5.0f;
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    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 {
    return 0.0001f;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return (section == 0 || section == 2 || (!self.isCatEye && section == 6)) ? 8.0f : 0.001f;
}
- (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    return nil;
}
- (nullable UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    return nil;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.section == 6)
    if (indexPath.section == 8)
    {
        UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:NSLocalizedString(@"cancel", @"取消") destructiveButtonTitle:NSLocalizedString(@"delete",@"删除") otherButtonTitles:nil];
        [actionSheet showInView:self.view];
//        UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:NSLocalizedString(@"cancel", @"取消") destructiveButtonTitle:NSLocalizedString(@"delete",@"删除") otherButtonTitles:nil];
//        [actionSheet showInView:self.view];
//        __weak __typeof(self)weakSelf = self;
//        UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
//
//        [actionSheet addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"cancel", @"取消") style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
//            [weakSelf dismissViewControllerAnimated:YES completion:^{
//            }];
//        }]];
//
//        [actionSheet addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"delete",@"删除") style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
//            [weakSelf deleteCurrentDevice];
//            [weakSelf dismissViewControllerAnimated:YES completion:^{
//            }];
//        }]];
//
//        [self presentViewController:actionSheet animated:YES completion:nil];
    }
//    else if (indexPath.section == 5)
//    {
@@ -292,10 +479,34 @@
    else if (indexPath.section == 2 && indexPath.row == 1 && self.updateImageView.hidden == NO)
    {
        [self performSegueWithIdentifier:@"go2Upgrade" sender:nil];
    }
    else if (indexPath.section == 1)
    }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)
    {
        UIAlertController *alert=[UIAlertController alertControllerWithTitle:HDLEZLocallizedString(@"alert_title") message:HDLEZLocallizedString(@"setting_formatting_alert_message") preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction *cancle=[UIAlertAction actionWithTitle:HDLEZLocallizedString(@"device_temp_cancle") style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        }];
        UIAlertAction *sure=[UIAlertAction actionWithTitle:HDLEZLocallizedString(@"device_temp_sure") style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            [EZOPENSDK formatStorage:self.deviceInfo.deviceSerial
                        storageIndex:0
                          completion:^(NSError *error) {
                if (error) {
                    NSLog(@"format command error = %@", error);
                    [UIView dd_showMessage:NSLocalizedString(@"setting_sd_card_fail", @"格式化失败,请重新再试")];
                } else {
                    NSLog(@"format command error = %@", error);
                    [UIView dd_showMessage:NSLocalizedString(@"setting_sd_card_success", @"格式化成功")];
                }
            }];
        }];
        [alert addAction:cancle];
        [alert addAction:sure];
        [self presentViewController:alert animated:YES completion:nil];
    }
}
@@ -352,31 +563,77 @@
}
#pragma mark - UIActionSheetDelegate Methods
- (void)deleteCurrentDevice {
    __weak MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    hud.labelText = NSLocalizedString(@"message_deleting", @"正在删除,请稍候...");
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if(buttonIndex == 0)
    {
        __weak MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
        hud.labelText = NSLocalizedString(@"message_deleting", @"正在删除,请稍候...");
        [EZOPENSDK deleteDevice:self.deviceInfo.deviceSerial completion:^(NSError *error) {
            if(!error)
    [EZHttpUtil.sharedManager deleteDeviceByHDL:self.deviceInfo.deviceSerial completion:^(ResponseData *responseData) {
        [hud hide:YES];
        if(responseData.success) {
            NSArray *viewControllers = self.navigationController.viewControllers;
            for (UIViewController *vc in viewControllers)
            {
                [hud hide:YES];
                NSArray *viewControllers = self.navigationController.viewControllers;
                for (UIViewController *vc in viewControllers)
                if([vc isKindOfClass:[EZDeviceTableViewController class]])
                {
                    if([vc isKindOfClass:[EZDeviceTableViewController class]])
                    {
                        ((EZDeviceTableViewController *)vc).needRefresh = YES;
                        [self.navigationController popToViewController:vc animated:YES];
                        break;
                    }
                    ((EZDeviceTableViewController *)vc).needRefresh = YES;
                    [self.navigationController popToViewController:vc animated:YES];
                    break;
                }
            }
        }];
    }
        } else {
            NSString *mes = [NSString stringWithFormat:@"%@(%@)",NSLocalizedString(@"setting_opration_fail", @"操作失败"),responseData.code];
            [self.view makeToast:mes duration:2.0 position:@"center"];
        }
    }];
}
//- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
//{
//    if(buttonIndex == 0)
//    {
//        __weak MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
//        hud.labelText = NSLocalizedString(@"message_deleting", @"正在删除,请稍候...");
////        [EZOPENSDK deleteDevice:self.deviceInfo.deviceSerial completion:^(NSError *error) {
////            if(!error)
////            {
////                [hud hide:YES];
////                NSArray *viewControllers = self.navigationController.viewControllers;
////                for (UIViewController *vc in viewControllers)
////                {
////                    if([vc isKindOfClass:[EZDeviceTableViewController class]])
////                    {
////                        ((EZDeviceTableViewController *)vc).needRefresh = YES;
////                        [self.navigationController popToViewController:vc animated:YES];
////                        break;
////                    }
////                }
////            }
////        }];
//
//        [EZHttpUtil.sharedManager deleteDeviceByHDL:self.deviceInfo.deviceSerial completion:^(ResponseData *responseData) {
//            [hud hide:YES];
//            if(responseData.success)
//            {
//                NSArray *viewControllers = self.navigationController.viewControllers;
//                for (UIViewController *vc in viewControllers)
//                {
//                    if([vc isKindOfClass:[EZDeviceTableViewController class]])
//                    {
//                        ((EZDeviceTableViewController *)vc).needRefresh = YES;
//                        [self.navigationController popToViewController:vc animated:YES];
//                        break;
//                    }
//                }
//            }else{
//                NSString *mes = [NSString stringWithFormat:@"%@(%@)",NSLocalizedString(@"setting_opration_fail", @"操作失败"),responseData.code];
//
//                [self.view makeToast:mes duration:2.0 position:@"center"];
//            }
//        }];
//
//
//    }
//}
#pragma mark - UIAlertViewDelegate Methods
@@ -441,6 +698,42 @@
    [[NSUserDefaults standardUserDefaults] synchronize];
}
- (IBAction)privacyMasking:(id)sender {
    UISwitch *pmSwitch = (UISwitch*)sender;
    BOOL status = pmSwitch.isOn;
//    if (self.privacyMasking) {
//        self.privacyMaskSwitch.on = !status;
//        [UIView dd_showMessage:@"正在执行中,请稍后再试"];
//        return;
//    }
//
//    NSLog(@"#############设置状态:%@", status ? @"开启" : @"关闭");
    __weak __typeof(self)weakSelf = self;
    self.privacyMaskSwitch.enabled = NO;
    self.privacyMaskButton.hidden = NO;
    [self performSelector:@selector(delayPrivacyMasking) withObject:nil afterDelay:10.0];
    [EZHttpUtil.sharedManager coverSwitchStatus:self.deviceInfo.deviceSerial enable:(status ? 1 : 0) completion:^(ResponseData * _Nonnull responseData) {
        if(responseData.success) {
            NSLog(@"#############设置成功:%@", responseData.data);
        } else {
            NSLog(@"#############设置失败:%@", responseData.message);
            [UIView dd_showMessage:NSLocalizedString(@"setting_privacy_masking_fail", @"设置失败,请稍后再试")];
            [weakSelf.privacyMaskSwitch setOn:!status];
        }
        weakSelf.privacyMaskSwitch.enabled = YES;
    }];
}
- (void)privacyMaskingAction:(id)sender {
    [UIView dd_showMessage:NSLocalizedString(@"setting_privacy_masking_ing", @"正在执行中,请稍后再试")];
}
- (void)delayPrivacyMasking {
    self.privacyMaskButton.hidden = YES;
//    self.privacyMaskSwitch.enabled = YES;
}
- (IBAction)encryptChanged:(id)sender
{
    if(!self.videoSwitch.on)
@@ -472,4 +765,75 @@
    }
}
- (void)deleteAction {
    __weak __typeof(self)weakSelf = self;
    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
    [actionSheet addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"cancel", @"取消") style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
        [weakSelf dismissViewControllerAnimated:YES completion:^{
        }];
    }]];
    [actionSheet addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"delete",@"删除") style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
        [weakSelf deleteCurrentDevice];
        [weakSelf dismissViewControllerAnimated:YES completion:^{
        }];
    }]];
    [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) {
        _deleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _deleteButton.backgroundColor = [UIColor whiteColor];
        [_deleteButton setTitle:NSLocalizedString(@"delete", @"删除") forState:UIControlStateNormal];
        [_deleteButton setTitleColor:HDLEZHEXCOLOR(0xFF4747, 1.0) forState:UIControlStateNormal];
        _deleteButton.titleLabel.font = HDLEZ_Get_FontRegularWithSize(HDLEZ_FontSize_16);
        _deleteButton.layer.cornerRadius = 22.;
        _deleteButton.clipsToBounds = YES;
    }
    return _deleteButton;
}
- (UIButton *)privacyMaskButton {
    if (!_privacyMaskButton) {
        _privacyMaskButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _privacyMaskButton.backgroundColor = [UIColor clearColor];
        _privacyMaskButton.hidden = YES;
    }
    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