123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373 |
- //
- // privacyModeViewController.m
- // 隐私保护
- //
- // Created by xd h on 2023/11/28.
- //
- #import "privacyModeViewController.h"
- #import "connectDeviceManager.h"
- #import "MineViewCell.h"
- #import "ModifyPWDFirstViewController.h"
- #import "ChangeLogoViewController.h"
- #import "inputPWDViewController.h"
- @interface privacyModeViewController ()<UITableViewDelegate,UITableViewDataSource>
- @property(nonatomic,strong)UIView* headView;//
- @property(nonatomic, strong) UISwitch *privacySwitch;
- @property (nonatomic, strong, nullable) UITableView *tableView;
- @end
- @implementation privacyModeViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- [self.view setBackgroundColor:HWF5F7FAColor];
- [self.toolBar setHidden:YES];
- [self.navigationBar setHidden:YES];
- [self.navBarBGView setHidden:NO];
- [self.titleLabel setText:NSLocalizedString(@"my_set_Privacy_Model",nil)];
-
- [self drawAnyView];
-
- //数据埋点
- [[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"Private_mode"];
- }
- - (void)drawAnyView{
- [self initHeadUIFun];
-
- [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(_headView.mas_bottom).offset(20.f);
- }];
- }
- - (void)initHeadUIFun
- {
- _headView = [[UIView alloc] init];
- _headView.backgroundColor = [UIColor whiteColor];
- _headView.layer.cornerRadius = 8;
- [self.view addSubview:_headView];
-
- [_headView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(15);
- make.right.mas_equalTo(-15);
- make.height.mas_equalTo(108);
- make.top.equalTo(self.navBarBGView.mas_bottom).offset(16.f);
- }];
-
- UIImageView *topImageV = [[UIImageView alloc] init];
- topImageV.image = [UIImage imageNamed:@"icon_Privacy_model"];
- [_headView addSubview:topImageV];
-
- [topImageV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(15);
- make.top.mas_equalTo(15);
- make.width.mas_equalTo(28);
- make.height.mas_equalTo(28);
- }];
-
- UILabel *topLab = [[UILabel alloc] init];
- topLab.text = NSLocalizedString(@"my_set_Privacy_Model",nil);
- topLab.font = [UIFont boldSystemFontOfSize:14.0];
- topLab.textColor = [UIColor hwColor:@"#0A132B" alpha:1.0];
- [_headView addSubview:topLab];
-
- [topLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(topImageV.mas_right).offset(5);
- make.top.mas_equalTo(topImageV.mas_top).offset(0);
- make.width.mas_equalTo(200);
- make.height.mas_equalTo(28);
- }];
-
- _privacySwitch = [[UISwitch alloc] init];
- [_headView addSubview:_privacySwitch];
- [_privacySwitch mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(-15.f);
- make.centerY.equalTo(topImageV.mas_centerY);
- }];
- [_privacySwitch setOnTintColor:HW13B2EBColor];
- [_privacySwitch addTarget:self action:@selector(maskSwitchPressed:) forControlEvents:(UIControlEventValueChanged)];
- [self setPrivacySwitchStateFun];
-
- UILabel *tipLab = [[UILabel alloc] init];
- tipLab.text = NSLocalizedString(@"my_set_Privacy_Model_tip",nil);
- tipLab.font = [UIFont systemFontOfSize:12.0];
- tipLab.textColor = [UIColor hwColor:@"#6A6A6A" alpha:1.0];
- tipLab.numberOfLines = 0;
- [_headView addSubview:tipLab];
-
- [tipLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(topImageV.mas_bottom).offset(10);
- make.left.mas_equalTo(topImageV.mas_left).offset(0);
- make.right.mas_equalTo(_privacySwitch.mas_right).offset(0);
- }];
- }
- #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];
- if (@available(iOS 15.0, *)) {
- _tableView.sectionHeaderTopPadding = 0;
- }
-
- }
-
- return _tableView;
- }
- #pragma mark - 列表委托
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- #if 1//def developJSQ
- return 2;
- #else
- return 3;
- #endif
-
- }
- - (MineViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- NSInteger row = indexPath.row;
- static NSString *identifier = @"MineViewCell";
-
- MineViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- if (!cell){
- cell = [[MineViewCell 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:NO];
- [cell.lineView setHidden:NO];
- [cell.maskSwitch setHidden:YES];
- if (row == 0){
- [cell.titleLabel setText:NSLocalizedString(@"my_set_no_modify_pwd",nil)];
- [cell.mImageView setImage:[UIImage imageNamed:@"mdoify_pwd"]];
-
- /*上圆角*/
- //设置部分圆角 贝塞尔曲线
- UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
- byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
- 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;
- }
- #if 1//def developJSQ
- else if (row == 1){
- [cell.titleLabel setText:NSLocalizedString(@"my_set_no_fanzhuan_exit",nil)];
- [cell.mImageView setImage:[UIImage imageNamed:@"fanzhuan"]];
- [cell.rightImage setHidden:YES];
- [cell.maskSwitch setHidden:NO];
-
- BOOL haveOpenMask = [HWDataManager getBoolWithKey:Consn_Fanzhuan_Exit_app_Open];
- [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];
- }
- #else
- else if (row == 1){
- [cell.titleLabel setText:NSLocalizedString(@"my_set_no_change_login",nil)];
- [cell.mImageView setImage:[UIImage imageNamed:@"icon_change_logo"]];
- // }else if (row == 2){
- // [cell.titleLabel setText:NSLocalizedString(@"mask_view_hiden_set_hiden",nil)];
- // [cell.mImageView setImage:[UIImage imageNamed:@"icon-jincheng"]];
- // }else if (row == 3){
- }else if (row == 2){
- [cell.titleLabel setText:NSLocalizedString(@"my_set_no_fanzhuan_exit",nil)];
- [cell.mImageView setImage:[UIImage imageNamed:@"fanzhuan"]];
- [cell.rightImage setHidden:YES];
- [cell.maskSwitch setHidden:NO];
-
- BOOL haveOpenMask = [HWDataManager getBoolWithKey:Consn_Fanzhuan_Exit_app_Open];
- [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];
- }
- #endif
-
-
- return cell;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return 60;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
-
- NSInteger row = indexPath.row;
- if (0 == row){
- /*修改密码*/
- ModifyPWDFirstViewController *nextVC = [[ModifyPWDFirstViewController alloc] init];
- [self.navigationController pushViewController:nextVC animated:YES];
- }
- #if 1//def developJSQ
- //
- #else
- else if (1 == row){
- /*更换图标*/
- ChangeLogoViewController *nextVC = [[ChangeLogoViewController alloc] init];
- [self.navigationController pushViewController:nextVC animated:YES];
- }
- // else if (1 == row){/*进城隐藏*/
- // HidenMaskSetViewController *nextVC = [[HidenMaskSetViewController alloc] init];
- // [self.navigationController pushViewController:nextVC animated:YES];
- // }
- else if (2 == row){/*设备翻转*/
- ;
- }
- #endif
-
-
- }
- - (void)maskSwitchPressed:(UISwitch *)privacySwitch{
- [self setPrivacySwitchStateFun];
-
- // inputPWDViewController *nextVC = [inputPWDViewController new];
- // nextVC.isCheckPwdType = YES;
- // [self.navigationController pushViewController:nextVC animated:YES];
- //
- // KWeakSelf
- // nextVC.didInputRightPwdFun = ^{
- // [weakSelf updatePrivacyModeFun];
- // };
-
-
- [self updatePrivacyModeFun];
- }
- #pragma mark 设置tabview 是否隐藏
- - (void)setPrivacySwitchStateFun{
- BOOL haveOpenMask = ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode;
-
- [_privacySwitch setOn:haveOpenMask];
-
- if(haveOpenMask){
- self.tableView.hidden = NO;
- }
- else{
- self.tableView.hidden = YES;
- [self HandleEnterNotPrivacyModeFun];
- }
-
- [self.tableView reloadData];
- }
- #pragma mark 处理进来是非隐私模式的情况
- - (void)HandleEnterNotPrivacyModeFun
- {
- NSInteger maskModel = [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
- if (maskModel != 0){
- [HWDataManager setIntegerWithKey:Const_Mask_View_Model value:0];
- [iTools lc_setAlternateIconName:@"AppIcon1"];
- }
-
- [HWDataManager setBoolWithKey:Consn_Fanzhuan_Exit_app_Open value:NO];
- }
- #pragma mark 联网设置隐私模式
- - (void)updatePrivacyModeFun{
-
- [self showNewIndicatorWithCanBack:YES canTouch:NO];
- BOOL haveOpenMask = ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode;
- NSString* curSn = ksharedAppDelegate.DeviceThirdIdMod.data.changeSn;
- if(!curSn || curSn.length == 0){
- curSn = ksharedAppDelegate.DeviceThirdIdMod.data.sn;
- }
-
- NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
- [paraDict setValue:curSn forKey:@"sn"];
- [paraDict setValue:[NSNumber numberWithBool:!haveOpenMask] forKey:@"isPrivacyMode"];
-
- KWeakSelf
- [[netWorkManager shareInstance] CommonPostCallBackCode:updatePrivacyMode Parameters:paraDict success:^(id _Nonnull responseObject) {
- HLog(@"%@", responseObject);
- [self removeNewIndicator];
- SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
- if (model.status == 0) {
- ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode = !ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode;
-
- [weakSelf setPrivacySwitchStateFun];
-
- if(!haveOpenMask)
- {
- [HWDataManager setBoolWithKey:Consn_Fanzhuan_Exit_app_Open value:NO];
- }
- }
- else
- {
- [[iToast makeText:model.msg] show];
- }
- } failure:^(NSError * _Nonnull error) {
- HLog(@"%@", error);
- [[iToast makeText:NSLocalizedString(@"player_link_fail_tip",nil)] show];
- [self removeNewIndicator];
- }];
-
- //数据埋点
- if(haveOpenMask){
- [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Private_mode_off"];
- }
- else{
- [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Private_mode_on"];
- }
- }
- @end
|