privacyModeViewController.m 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. //
  2. // privacyModeViewController.m
  3. // 隐私保护
  4. //
  5. // Created by xd h on 2023/11/28.
  6. //
  7. #import "privacyModeViewController.h"
  8. #import "connectDeviceManager.h"
  9. #import "MineViewCell.h"
  10. #import "ModifyPWDFirstViewController.h"
  11. #import "ChangeLogoViewController.h"
  12. #import "inputPWDViewController.h"
  13. @interface privacyModeViewController ()<UITableViewDelegate,UITableViewDataSource>
  14. @property(nonatomic,strong)UIView* headView;//
  15. @property(nonatomic, strong) UISwitch *privacySwitch;
  16. @property (nonatomic, strong, nullable) UITableView *tableView;
  17. @end
  18. @implementation privacyModeViewController
  19. - (void)viewDidLoad {
  20. [super viewDidLoad];
  21. // Do any additional setup after loading the view.
  22. [self.view setBackgroundColor:HWF5F7FAColor];
  23. [self.toolBar setHidden:YES];
  24. [self.navigationBar setHidden:YES];
  25. [self.navBarBGView setHidden:NO];
  26. [self.titleLabel setText:NSLocalizedString(@"my_set_Privacy_Model",nil)];
  27. [self drawAnyView];
  28. //数据埋点
  29. [[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"Private_mode"];
  30. }
  31. - (void)drawAnyView{
  32. [self initHeadUIFun];
  33. [self.view addSubview:self.tableView];
  34. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.left.mas_equalTo(0);
  36. make.right.mas_equalTo(0);
  37. make.bottom.mas_equalTo(0);
  38. make.top.equalTo(_headView.mas_bottom).offset(20.f);
  39. }];
  40. }
  41. - (void)initHeadUIFun
  42. {
  43. _headView = [[UIView alloc] init];
  44. _headView.backgroundColor = [UIColor whiteColor];
  45. _headView.layer.cornerRadius = 8;
  46. [self.view addSubview:_headView];
  47. [_headView mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.left.mas_equalTo(15);
  49. make.right.mas_equalTo(-15);
  50. make.height.mas_equalTo(108);
  51. make.top.equalTo(self.navBarBGView.mas_bottom).offset(16.f);
  52. }];
  53. UIImageView *topImageV = [[UIImageView alloc] init];
  54. topImageV.image = [UIImage imageNamed:@"icon_Privacy_model"];
  55. [_headView addSubview:topImageV];
  56. [topImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.left.mas_equalTo(15);
  58. make.top.mas_equalTo(15);
  59. make.width.mas_equalTo(28);
  60. make.height.mas_equalTo(28);
  61. }];
  62. UILabel *topLab = [[UILabel alloc] init];
  63. topLab.text = NSLocalizedString(@"my_set_Privacy_Model",nil);
  64. topLab.font = [UIFont boldSystemFontOfSize:14.0];
  65. topLab.textColor = [UIColor hwColor:@"#0A132B" alpha:1.0];
  66. [_headView addSubview:topLab];
  67. [topLab mas_makeConstraints:^(MASConstraintMaker *make) {
  68. make.left.mas_equalTo(topImageV.mas_right).offset(5);
  69. make.top.mas_equalTo(topImageV.mas_top).offset(0);
  70. make.width.mas_equalTo(200);
  71. make.height.mas_equalTo(28);
  72. }];
  73. _privacySwitch = [[UISwitch alloc] init];
  74. [_headView addSubview:_privacySwitch];
  75. [_privacySwitch mas_makeConstraints:^(MASConstraintMaker *make) {
  76. make.right.mas_equalTo(-15.f);
  77. make.centerY.equalTo(topImageV.mas_centerY);
  78. }];
  79. [_privacySwitch setOnTintColor:HW13B2EBColor];
  80. [_privacySwitch addTarget:self action:@selector(maskSwitchPressed:) forControlEvents:(UIControlEventValueChanged)];
  81. [self setPrivacySwitchStateFun];
  82. UILabel *tipLab = [[UILabel alloc] init];
  83. tipLab.text = NSLocalizedString(@"my_set_Privacy_Model_tip",nil);
  84. tipLab.font = [UIFont systemFontOfSize:12.0];
  85. tipLab.textColor = [UIColor hwColor:@"#6A6A6A" alpha:1.0];
  86. tipLab.numberOfLines = 0;
  87. [_headView addSubview:tipLab];
  88. [tipLab mas_makeConstraints:^(MASConstraintMaker *make) {
  89. make.top.mas_equalTo(topImageV.mas_bottom).offset(10);
  90. make.left.mas_equalTo(topImageV.mas_left).offset(0);
  91. make.right.mas_equalTo(_privacySwitch.mas_right).offset(0);
  92. }];
  93. }
  94. #pragma mark - 懒加载
  95. - (UITableView *)tableView{
  96. if (!_tableView) {
  97. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H - TABBARHEIGHT) style:UITableViewStylePlain];
  98. _tableView.delegate = self;
  99. _tableView.dataSource = self;
  100. _tableView.showsVerticalScrollIndicator = NO;
  101. _tableView.showsHorizontalScrollIndicator = NO;
  102. // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
  103. [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
  104. [_tableView setSeparatorColor:[UIColor clearColor]];
  105. [_tableView setBackgroundColor:[UIColor clearColor]];
  106. [_tableView setTableFooterView:[UIView new]];
  107. [_tableView setBounces:YES];
  108. if (@available(iOS 15.0, *)) {
  109. _tableView.sectionHeaderTopPadding = 0;
  110. }
  111. }
  112. return _tableView;
  113. }
  114. #pragma mark - 列表委托
  115. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  116. return 1;
  117. }
  118. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  119. #ifdef developJSQ
  120. return 2;
  121. #else
  122. return 3;
  123. #endif
  124. }
  125. - (MineViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  126. NSInteger row = indexPath.row;
  127. static NSString *identifier = @"MineViewCell";
  128. MineViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  129. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  130. if (!cell){
  131. cell = [[MineViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  132. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  133. [cell setBackgroundColor:[UIColor clearColor]];
  134. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  135. }
  136. [cell.bgViewLayer removeFromSuperlayer];
  137. [cell.titleLabel2 setHidden:YES];
  138. [cell.rightImage setHidden:NO];
  139. [cell.lineView setHidden:NO];
  140. [cell.maskSwitch setHidden:YES];
  141. if (row == 0){
  142. [cell.titleLabel setText:NSLocalizedString(@"my_set_no_modify_pwd",nil)];
  143. [cell.mImageView setImage:[UIImage imageNamed:@"mdoify_pwd"]];
  144. /*上圆角*/
  145. //设置部分圆角 贝塞尔曲线
  146. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  147. byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
  148. cornerRadii:CGSizeMake(8, 8)];
  149. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  150. maskLayer.frame = cell.cellBgView.bounds;
  151. maskLayer.path = maskPath.CGPath;
  152. cell.bgViewLayer = maskLayer;
  153. cell.cellBgView.layer.mask = cell.bgViewLayer;
  154. }
  155. #ifdef developJSQ
  156. else if (row == 1){
  157. [cell.titleLabel setText:NSLocalizedString(@"my_set_no_fanzhuan_exit",nil)];
  158. [cell.mImageView setImage:[UIImage imageNamed:@"fanzhuan"]];
  159. [cell.rightImage setHidden:YES];
  160. [cell.maskSwitch setHidden:NO];
  161. BOOL haveOpenMask = [HWDataManager getBoolWithKey:Consn_Fanzhuan_Exit_app_Open];
  162. [cell.maskSwitch setOn:haveOpenMask];
  163. /*下圆角*/
  164. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  165. byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
  166. cornerRadii:CGSizeMake(8, 8)];
  167. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  168. maskLayer.frame = cell.cellBgView.bounds;
  169. maskLayer.path = maskPath.CGPath;
  170. cell.bgViewLayer = maskLayer;
  171. cell.cellBgView.layer.mask = cell.bgViewLayer;
  172. [cell.lineView setHidden:YES];
  173. }
  174. #else
  175. else if (row == 1){
  176. [cell.titleLabel setText:NSLocalizedString(@"my_set_no_change_login",nil)];
  177. [cell.mImageView setImage:[UIImage imageNamed:@"icon_change_logo"]];
  178. // }else if (row == 2){
  179. // [cell.titleLabel setText:NSLocalizedString(@"mask_view_hiden_set_hiden",nil)];
  180. // [cell.mImageView setImage:[UIImage imageNamed:@"icon-jincheng"]];
  181. // }else if (row == 3){
  182. }else if (row == 2){
  183. [cell.titleLabel setText:NSLocalizedString(@"my_set_no_fanzhuan_exit",nil)];
  184. [cell.mImageView setImage:[UIImage imageNamed:@"fanzhuan"]];
  185. [cell.rightImage setHidden:YES];
  186. [cell.maskSwitch setHidden:NO];
  187. BOOL haveOpenMask = [HWDataManager getBoolWithKey:Consn_Fanzhuan_Exit_app_Open];
  188. [cell.maskSwitch setOn:haveOpenMask];
  189. /*下圆角*/
  190. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  191. byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
  192. cornerRadii:CGSizeMake(8, 8)];
  193. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  194. maskLayer.frame = cell.cellBgView.bounds;
  195. maskLayer.path = maskPath.CGPath;
  196. cell.bgViewLayer = maskLayer;
  197. cell.cellBgView.layer.mask = cell.bgViewLayer;
  198. [cell.lineView setHidden:YES];
  199. }
  200. #endif
  201. return cell;
  202. }
  203. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  204. return 60;
  205. }
  206. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  207. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  208. NSInteger row = indexPath.row;
  209. if (0 == row){
  210. /*修改密码*/
  211. ModifyPWDFirstViewController *nextVC = [[ModifyPWDFirstViewController alloc] init];
  212. [self.navigationController pushViewController:nextVC animated:YES];
  213. }
  214. #ifdef developJSQ
  215. //
  216. #else
  217. else if (1 == row){
  218. /*更换图标*/
  219. ChangeLogoViewController *nextVC = [[ChangeLogoViewController alloc] init];
  220. [self.navigationController pushViewController:nextVC animated:YES];
  221. }
  222. // else if (1 == row){/*进城隐藏*/
  223. // HidenMaskSetViewController *nextVC = [[HidenMaskSetViewController alloc] init];
  224. // [self.navigationController pushViewController:nextVC animated:YES];
  225. // }
  226. else if (2 == row){/*设备翻转*/
  227. ;
  228. }
  229. #endif
  230. }
  231. - (void)maskSwitchPressed:(UISwitch *)privacySwitch{
  232. [self setPrivacySwitchStateFun];
  233. // inputPWDViewController *nextVC = [inputPWDViewController new];
  234. // nextVC.isCheckPwdType = YES;
  235. // [self.navigationController pushViewController:nextVC animated:YES];
  236. //
  237. // KWeakSelf
  238. // nextVC.didInputRightPwdFun = ^{
  239. // [weakSelf updatePrivacyModeFun];
  240. // };
  241. [self updatePrivacyModeFun];
  242. }
  243. #pragma mark 设置tabview 是否隐藏
  244. - (void)setPrivacySwitchStateFun{
  245. BOOL haveOpenMask = ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode;
  246. [_privacySwitch setOn:haveOpenMask];
  247. if(haveOpenMask){
  248. self.tableView.hidden = NO;
  249. }
  250. else{
  251. self.tableView.hidden = YES;
  252. [self HandleEnterNotPrivacyModeFun];
  253. }
  254. [self.tableView reloadData];
  255. }
  256. #pragma mark 处理进来是非隐私模式的情况
  257. - (void)HandleEnterNotPrivacyModeFun
  258. {
  259. NSInteger maskModel = [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
  260. if (maskModel != 0){
  261. [HWDataManager setIntegerWithKey:Const_Mask_View_Model value:0];
  262. [iTools lc_setAlternateIconName:@"AppIcon1"];
  263. }
  264. [HWDataManager setBoolWithKey:Consn_Fanzhuan_Exit_app_Open value:NO];
  265. }
  266. #pragma mark 联网设置隐私模式
  267. - (void)updatePrivacyModeFun{
  268. [self showNewIndicatorWithCanBack:YES canTouch:NO];
  269. BOOL haveOpenMask = ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode;
  270. NSString* curSn = ksharedAppDelegate.DeviceThirdIdMod.data.changeSn;
  271. if(!curSn || curSn.length == 0){
  272. curSn = ksharedAppDelegate.DeviceThirdIdMod.data.sn;
  273. }
  274. NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
  275. [paraDict setValue:curSn forKey:@"sn"];
  276. [paraDict setValue:[NSNumber numberWithBool:!haveOpenMask] forKey:@"isPrivacyMode"];
  277. KWeakSelf
  278. [[netWorkManager shareInstance] CommonPostCallBackCode:updatePrivacyMode Parameters:paraDict success:^(id _Nonnull responseObject) {
  279. HLog(@"%@", responseObject);
  280. [self removeNewIndicator];
  281. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  282. if (model.status == 0) {
  283. ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode = !ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode;
  284. [weakSelf setPrivacySwitchStateFun];
  285. if(!haveOpenMask)
  286. {
  287. [HWDataManager setBoolWithKey:Consn_Fanzhuan_Exit_app_Open value:NO];
  288. }
  289. }
  290. else
  291. {
  292. [[iToast makeText:model.msg] show];
  293. }
  294. } failure:^(NSError * _Nonnull error) {
  295. HLog(@"%@", error);
  296. [[iToast makeText:NSLocalizedString(@"player_link_fail_tip",nil)] show];
  297. [self removeNewIndicator];
  298. }];
  299. //数据埋点
  300. if(haveOpenMask){
  301. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Private_mode_off"];
  302. }
  303. else{
  304. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Private_mode_on"];
  305. }
  306. }
  307. @end