From 48c5a2c66c549d26fecadc6d2dad1924fdd1cc8b Mon Sep 17 00:00:00 2001
From: Davin <591807572@qq.com>
Date: 星期四, 27 七月 2023 13:52:08 +0800
Subject: [PATCH] bugfix 猫眼呼叫问题修复
---
EZSDK/EZSDK/EZ/UIViewControllers/EZSettingViewController.m | 260 +++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 209 insertions(+), 51 deletions(-)
diff --git a/EZSDK/EZSDK/EZ/UIViewControllers/EZSettingViewController.m b/EZSDK/EZSDK/EZ/UIViewControllers/EZSettingViewController.m
index eb184f6..95f6ae0 100644
--- a/EZSDK/EZSDK/EZ/UIViewControllers/EZSettingViewController.m
+++ b/EZSDK/EZSDK/EZ/UIViewControllers/EZSettingViewController.m
@@ -33,8 +33,12 @@
@property (nonatomic, weak) IBOutlet UILabel *currentVersionLabel;
@property (nonatomic, weak) IBOutlet UILabel *nVersionLabel;
@property (nonatomic, weak) IBOutlet UIImageView *updateImageView;
+@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; // 闅愮閬斀璁剧疆涓�
@end
@@ -49,6 +53,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;
@@ -80,28 +92,37 @@
self.videoSwitch.on = self.deviceInfo.isEncrypt;
}
[_settingList addObject:@[NSLocalizedString(@"setting_hardware_decoding", @"纭В鐮�")]];
- [_settingList addObject:@[NSLocalizedString(@"setting_privacy_masking", @"闅愮閬斀")]];
- [_settingList addObject:@[NSLocalizedString(@"setting_sd_card_formatting", @"SD鍗℃牸寮忓寲")]];
+ 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;
+ }
+ }];
+ [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);
// }];
@@ -164,6 +185,23 @@
// 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
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
@@ -178,16 +216,23 @@
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;
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);
}];
@@ -218,14 +263,27 @@
}
else if (indexPath.section == 6)
{
- [cell.contentView addSubview:self.privacyMaskSwitch];
- [self.privacyMaskSwitch mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.trailing.mas_equalTo(@(-17));
- make.centerY.mas_equalTo(cell.contentView.mas_centerY);
- make.width.mas_equalTo(@51);
- make.height.mas_equalTo(@31);
- }];
- self.privacyMaskSwitch.on = !self.privacyMaskSwitch.on;
+ if (self.isCatEye) { // 鐚溂
+ cell.backgroundColor = [UIColor clearColor];
+ cell.contentView.backgroundColor = [UIColor clearColor];
+ cell.textLabel.text = @"";
+ [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(@(-17));
+ make.centerY.mas_equalTo(cell.contentView.mas_centerY);
+ make.width.mas_equalTo(@51);
+ make.height.mas_equalTo(@31);
+ }];
+ }
}
else if (indexPath.section == 7)
{
@@ -233,14 +291,23 @@
[self.rightArrowImg mas_remakeConstraints:^(MASConstraintMaker *make) {
make.trailing.mas_equalTo(@(-17));
make.centerY.mas_equalTo(cell.contentView.mas_centerY);
- make.width.mas_equalTo(@20);
- make.height.mas_equalTo(@20);
+ make.width.mas_equalTo(@16);
+ make.height.mas_equalTo(@16);
}];
}
else if (indexPath.section == 8)
{
- cell.textLabel.textColor = [UIColor redColor];
- cell.textLabel.textAlignment = NSTextAlignmentCenter;
+ cell.backgroundColor = [UIColor clearColor];
+ cell.contentView.backgroundColor = [UIColor clearColor];
+ cell.textLabel.text = @"";
+ [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)
{
@@ -294,9 +361,24 @@
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)) ? 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
@@ -307,21 +389,21 @@
// 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];
+// __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)
@@ -341,13 +423,17 @@
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) {
}];
- __weak __typeof(self)weakSelf = self;
UIAlertAction *sure=[UIAlertAction actionWithTitle:HDLEZLocallizedString(@"device_temp_sure") style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[EZOPENSDK formatStorage:self.deviceInfo.deviceSerial
storageIndex:0
completion:^(NSError *error) {
- NSLog(@"format command error = %@", error);
- [UIView dd_showMessage:error.description];
+ 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];
@@ -547,6 +633,37 @@
- (IBAction)privacyMasking:(id)sender {
UISwitch *pmSwitch = (UISwitch*)sender;
BOOL status = pmSwitch.isOn;
+
+// if (self.privacyMasking) {
+// self.privacyMaskSwitch.on = !status;
+// [UIView dd_showMessage:@"姝e湪鎵ц涓紝璇风◢鍚庡啀璇�"];
+// 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", @"姝e湪鎵ц涓紝璇风◢鍚庡啀璇�")];
+}
+
+- (void)delayPrivacyMasking {
+ self.privacyMaskButton.hidden = YES;
+// self.privacyMaskSwitch.enabled = YES;
}
- (IBAction)encryptChanged:(id)sender
@@ -580,4 +697,45 @@
}
}
+- (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];
+}
+
+#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;
+}
+
@end
--
Gitblit v1.8.0