12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028 |
- //
- // JXSettingsViewController.m
- // shiku_im
- //
- // Created by Apple on 16/5/6.
- // Copyright © 2016年 Reese. All rights reserved.
- //
- #import "JXSettingsViewController.h"
- #import "UIImage+Tint.h"
- #import "loginVC.h"
- #import "JXMoreSelectVC.h"
- #import "JXActionSheetVC.h"
- #define HEIGHT 50
- typedef enum : NSUInteger {
- Type_chatRecordTimeOut = 1,
- Type_chatSyncTimeLen,
- Type_groupChatSyncTimeLen,
- } PickerViewType;
- @interface JXSettingsViewController ()<UIAlertViewDelegate, UIPickerViewDelegate,JXMoreSelectVCDelegate,JXActionSheetVCDelegate>{
- ATMHud* _wait;
- }
- @property (weak, nonatomic) IBOutlet NSLayoutConstraint *topCon;
- @property (nonatomic, strong) UILabel *timeOutLabel;
- @property (nonatomic, strong) UILabel *syncTimeLenLabel;
- @property (nonatomic, strong) UILabel *groupSyncTimeLenLabel;
- @property (nonatomic, strong) UIView *selectView;
- @property (nonatomic, strong) UIPickerView *pickerView;
- @property (nonatomic, strong) NSArray *pickerArr;
- @property (nonatomic, assign) PickerViewType selType;
- @property (nonatomic, strong) JXMoreSelectVC *moreVC;
- @property (nonatomic, strong) NSString *indexStr;
- @property (nonatomic, strong) UILabel *addMeTypeLab;
- @property (nonatomic, strong) UILabel *seeTimeTypeLab;
- @property (nonatomic, strong) UILabel *seeNumTypeLab;
- @property (nonatomic, strong) NSArray *loginTimeArr;
- @property (nonatomic, assign) BOOL isShowNum;
- @end
- @implementation JXSettingsViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.view.frame = CGRectMake(JX_SCREEN_WIDTH, 0, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT);
- [self createHeaderView];
-
- self.topCon.constant = JX_SCREEN_TOP;
-
- //self.view.frame = CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT);
-
- // self.dataSorce = [[NSDictionary alloc]init];
- // [self getData];
-
- //获取服务器的好友状态
- [self changeSettingsNum];
-
- _pickerArr = @[Localized(@"JX_OutOfSync"),Localized(@"JX_OneHour"), Localized(@"JX_OneDay"), Localized(@"JX_OneWeeks"), Localized(@"JX_OneMonth"), Localized(@"JX_OneQuarter"), Localized(@"JX_OneYear"),Localized(@"JX_Forever")];
- _loginTimeArr = @[Localized(@"JX_SetContactYES"),Localized(@"JX_SetAllFriendYES"),Localized(@"JX_SetAllYES"),Localized(@"JX_SetAllNO")];
- UIView *headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, 130)];
- headView.backgroundColor = HEXCOLOR(0xF2F2F2);
- [self.myTableView addSubview:headView];
-
- CGFloat y = 0;
- // JXImageView *iv = [self createButton:Localized(@"JX_SetTheChatMsgSaveTime") drawTop:NO drawBottom:YES must:NO click:@selector(chatTimeOut:) superView:headView];
- // iv.frame = CGRectMake(0,0, JX_SCREEN_WIDTH, HEIGHT);
- // _timeOutLabel = [[UILabel alloc]initWithFrame:CGRectMake(JX_SCREEN_WIDTH-135,11,100,30)];
- // _timeOutLabel.textAlignment = NSTextAlignmentRight;
- // _timeOutLabel.userInteractionEnabled = NO;
- // _timeOutLabel.font = g_factory.font15;
- // double outTime = [[self.dataSorce objectForKey:@"chatRecordTimeOut"] doubleValue];
- // _timeOutLabel.text = [self getPickerContentWithDay:outTime];
- // [iv addSubview:_timeOutLabel];
- // y = CGRectGetMaxY(iv.frame);
-
- JXImageView *iv = [self createButtonWithFrame:CGRectMake(0,y, JX_SCREEN_WIDTH, HEIGHT) title:Localized(@"JX_SingleRoamTime") drawTop:NO drawBottom:NO must:NO click:@selector(syncTimeLen:) superView:headView];
- _syncTimeLenLabel = [[UILabel alloc]initWithFrame:CGRectMake(JX_SCREEN_WIDTH-135,11,100,30)];
- _syncTimeLenLabel.textAlignment = NSTextAlignmentRight;
- _syncTimeLenLabel.userInteractionEnabled = NO;
- _syncTimeLenLabel.font = g_factory.font15;
- double syncTimeLen = [[self.dataSorce objectForKey:@"chatSyncTimeLen"] doubleValue];
- _syncTimeLenLabel.text = [self getPickerContentWithDay:syncTimeLen];
- [iv addSubview:_syncTimeLenLabel];
- y = CGRectGetMaxY(iv.frame);
-
- y += 10;
- //谁可以看到我的上线时间
- iv = [self createButtonWithFrame:CGRectMake(0,y, JX_SCREEN_WIDTH, 68) title:Localized(@"JX_WhoCanSeeMyOnlineTime") drawTop:NO drawBottom:YES must:YES click:@selector(showLastLoginTime) superView:headView];
-
- self.seeNumTypeLab = [[UILabel alloc] initWithFrame:CGRectMake(15, 37, 300, 20)];
- self.seeNumTypeLab.textColor = [UIColor grayColor];
- self.seeNumTypeLab.font = SYSFONT(14);
- self.seeNumTypeLab.text = [self getSeeLgoinLastTime:[self.dataSorce objectForKey:@"showLastLoginTime"]];
- [iv addSubview:self.seeNumTypeLab];
-
- if ([g_config.regeditPhoneOrName intValue] == 0) {
- //谁可以看到我的手机号码
- y += iv.frame.size.height;
- iv = [self createButtonWithFrame:CGRectMake(0,y, JX_SCREEN_WIDTH, 68) title:Localized(@"JX_WhoCanSeeMyNo.") drawTop:NO drawBottom:NO must:YES click:@selector(showNumber) superView:headView];
-
- self.seeTimeTypeLab = [[UILabel alloc] initWithFrame:CGRectMake(15, 37, 300, 20)];
- self.seeTimeTypeLab.textColor = [UIColor grayColor];
- self.seeTimeTypeLab.font = SYSFONT(14);
- self.seeTimeTypeLab.text = [self getSeeLgoinLastTime:[self.dataSorce objectForKey:@"showTelephone"]];
- [iv addSubview:self.seeTimeTypeLab];
- }
- //允许加我的方式
- y += iv.frame.size.height;
- iv = [self createButtonWithFrame:CGRectMake(0,y, JX_SCREEN_WIDTH, 68) title:Localized(@"JX_AddMeToWay") drawTop:YES drawBottom:NO must:YES click:@selector(selectAddMeType) superView:headView];
-
- self.addMeTypeLab = [[UILabel alloc] initWithFrame:CGRectMake(15, 37, 300, 20)];
- self.addMeTypeLab.textColor = [UIColor grayColor];
- self.addMeTypeLab.font = SYSFONT(14);
- self.addMeTypeLab.text = [self getaddMeTypeText:[self.dataSorce objectForKey:@"friendFromList"]];
- [iv addSubview:self.addMeTypeLab];
- // iv = [self createButton:Localized(@"JX_GroupRoamTime") drawTop:NO drawBottom:YES must:NO click:@selector(groupSyncTimeLen:) superView:headView];
- // iv.frame = CGRectMake(0,y, JX_SCREEN_WIDTH, HEIGHT);
- // _groupSyncTimeLenLabel = [[UILabel alloc]initWithFrame:CGRectMake(JX_SCREEN_WIDTH-135,11,100,30)];
- // _groupSyncTimeLenLabel.textAlignment = NSTextAlignmentRight;
- // _groupSyncTimeLenLabel.userInteractionEnabled = NO;
- // _groupSyncTimeLenLabel.font = g_factory.font15;
- // double groupSyncTimeLen = [[self.dataSorce objectForKey:@"groupChatSyncTimeLen"] doubleValue];
- // _groupSyncTimeLenLabel.text = [self getPickerContentWithDay:groupSyncTimeLen];
- // [iv addSubview:_groupSyncTimeLenLabel];
-
- headView.frame = CGRectMake(headView.frame.origin.x, headView.frame.origin.y, headView.frame.size.width, CGRectGetMaxY(iv.frame)+10);
-
- self.myTableView.backgroundColor = HEXCOLOR(0xF2F2F2);
- self.myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- self.myTableView.delegate = self;
- self.myTableView.dataSource = self;
- self.myTableView.tableHeaderView = headView;
- [self.myTableView reloadData];
-
- // UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)];
- // [self.myTableView addGestureRecognizer:tap];
-
-
-
- _selectView = [[UIView alloc] initWithFrame:CGRectMake(0, JX_SCREEN_TOP, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT-JX_SCREEN_TOP)];
- _selectView.backgroundColor = [UIColor clearColor];
- _selectView.hidden = YES;
- [self.view addSubview:_selectView];
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(cancelBtnAction)];
- [_selectView addGestureRecognizer:tap];
-
- UIView *selV = [[UIView alloc] initWithFrame:CGRectMake(0, _selectView.frame.size.height - 220, JX_SCREEN_WIDTH, 220)];
- selV.backgroundColor = HEXCOLOR(0xF2F2F2);
- [_selectView addSubview:selV];
- UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(selV.frame.size.width - 80, 20, 60, 20)];
- [btn setTitle:Localized(@"JX_Confirm") forState:UIControlStateNormal];
- btn.titleLabel.font = [UIFont systemFontOfSize:16.0];
- [btn setTitleColor:THEMECOLOR forState:UIControlStateNormal];
- [btn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
- [selV addSubview:btn];
-
- btn = [[UIButton alloc] initWithFrame:CGRectMake(20, 20, 50, 20)];
- [btn setTitle:Localized(@"JX_Cencal") forState:UIControlStateNormal];
- btn.titleLabel.font = [UIFont systemFontOfSize:16.0];
- [btn setTitleColor:THEMECOLOR forState:UIControlStateNormal];
- [btn addTarget:self action:@selector(cancelBtnAction) forControlEvents:UIControlEventTouchUpInside];
- [selV addSubview:btn];
-
- _pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 40, selV.frame.size.width, selV.frame.size.height - 40)];
- _pickerView.delegate = self;
- // [_pickerView selectRow:index inComponent:0 animated:NO];
- [selV addSubview:_pickerView];
-
- _pSelf = self;
- [g_notify addObserver:self selector:@selector(updateCurData:) name:kXMPPMessageUpadtePasswordNotification object:nil];
- }
- - (void)getData {
- //获取服务器的好友状态
- [self changeSettingsNum];
-
-
- double syncTimeLen = [[self.dataSorce objectForKey:@"chatSyncTimeLen"] doubleValue];
- _syncTimeLenLabel.text = [self getPickerContentWithDay:syncTimeLen];
-
- self.seeNumTypeLab.text = [self getSeeLgoinLastTime:[self.dataSorce objectForKey:@"showLastLoginTime"]];
- self.seeTimeTypeLab.text = [self getSeeLgoinLastTime:[self.dataSorce objectForKey:@"showTelephone"]];
- self.addMeTypeLab.text = [self getaddMeTypeText:[self.dataSorce objectForKey:@"friendFromList"]];
- [self.myTableView reloadData];
- }
- - (void)updateCurData:(NSNotification *)noti {
- JXMessageObject *msg = noti.object;
- if ([msg.objectId isEqualToString:SYNC_PRIVATE_SETTINGS]) {
- [g_server getFriendSettings:g_myself.userId toView:self];
- }
- }
- - (void)showNumber {
- self.isShowNum = YES;
- JXActionSheetVC *actionVC = [[JXActionSheetVC alloc] initWithImages:@[] names:self.loginTimeArr];
- actionVC.delegate = self;
- [self presentViewController:actionVC animated:NO completion:nil];
- }
- - (void)showLastLoginTime {
- self.isShowNum = NO;
- JXActionSheetVC *actionVC = [[JXActionSheetVC alloc] initWithImages:@[] names:self.loginTimeArr];
- actionVC.delegate = self;
- [self presentViewController:actionVC animated:NO completion:nil];
- }
- - (void)actionSheet:(JXActionSheetVC *)actionSheet didButtonWithIndex:(NSInteger)index {
- NSNumber *timeIndex = 0;
- if (index == 0) {
- timeIndex = @3;
- }
- else if (index == 1) {
- timeIndex = @2;
- }
- else if (index == 2) {
- timeIndex = @1;
- }
- else if (index == 3) {
- timeIndex = @-1;
- }
- NSString *key = [NSString string];
- if (self.isShowNum) {
- key = @"showTelephone";
- self.seeTimeTypeLab.text = self.loginTimeArr[index];
- }else {
- key = @"showLastLoginTime";
- self.seeNumTypeLab.text = self.loginTimeArr[index];
- }
- [g_server changeFriendSetting:nil allowAtt:nil allowGreet:nil key:key value:[NSString stringWithFormat:@"%@",timeIndex] toView:self];
- }
- - (NSString *)getSeeLgoinLastTime:(NSNumber *)str {
- NSDictionary *type =@{@"-1":Localized(@"JX_SetAllNO"),@"1":Localized(@"JX_SetAllYES"),@"2":Localized(@"JX_SetAllFriendYES"),@"3":Localized(@"JX_SetContactYES")};
- return [type objectForKey:[NSString stringWithFormat:@"%@",str]];
- }
- - (NSString *)getaddMeTypeText:(NSString *)indexStr {
- NSArray *type = @[Localized(@"JXQR_QRImage"),Localized(@"JX_Card"),Localized(@"JX_ManyPerChat"),Localized(@"JX_MobileSearch"),Localized(@"JX_NicknameSearch"),Localized(@"OTHER")];
- NSMutableArray *indexArr = [NSMutableArray arrayWithArray:[indexStr componentsSeparatedByString:@","]];
- NSMutableArray *typeArr = [NSMutableArray array];
- [indexArr enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
- if ([obj intValue] == 0) {
- [indexArr removeObject:obj];
- }else {
- [typeArr addObject:[type objectAtIndex:[obj intValue]-1]];
- }
- }];
-
- if (indexArr.count <= 0) {
- return Localized(@"JX_SetAllNO");
- }else if (indexArr.count >= type.count){
- return Localized(@"JX_SetAllYES");
- }
- return [typeArr componentsJoinedByString:@","];
- }
- - (void)selectAddMeType {
- self.moreVC = [[JXMoreSelectVC alloc] initWithTitle:Localized(@"JX_AddMeToWay") dataArray:@[Localized(@"JXQR_QRImage"),Localized(@"JX_Card"),Localized(@"JX_ManyPerChat"),Localized(@"JX_MobileSearch"),Localized(@"JX_NicknameSearch"),Localized(@"OTHER")]];
- self.moreVC.indexStr = self.indexStr.length > 0 ? self.indexStr : [NSString stringWithFormat:@"%@",[self.dataSorce objectForKey:@"friendFromList"]];
- self.moreVC.delegate = self;
- [self.view addSubview:self.moreVC.view];
- }
- - (void)didSureBtn:(JXMoreSelectVC *)moreSelectVC indexStr:(NSString *)indexStr {
- self.indexStr = indexStr; // 记录一下历史选项
- self.addMeTypeLab.text = [self getaddMeTypeText:indexStr];
- [g_server changeFriendSetting:nil allowAtt:nil allowGreet:nil key:@"friendFromList" value:indexStr toView:self];
- }
- - (NSString *)getPickerContentWithDay:(double)day{
- NSString *str;
- if (day == -2) {
- str = _pickerArr[0];
-
- }else if (day == 0 || day == -1) {
- str = _pickerArr[7];
-
- }else if (day == 0.04) {
- str = _pickerArr[1];
-
- }else if (day == 1) {
- str = _pickerArr[2];
-
- }else if (day == 7) {
- str = _pickerArr[3];
-
- }else if (day == 30) {
- str = _pickerArr[4];
-
- }else if (day == 90) {
- str = _pickerArr[5];
-
- }else{
- str = _pickerArr[6];
- }
-
- return str;
- }
- - (NSInteger)getPickerIndexWithDay:(double)day {
- NSInteger index;
- if (day == -2) {
- index = 0;
- }else if (day == 0 || day == -1) {
- index = 7;
- }else if (day == 0.04) {
- index = 1;
- }else if (day == 1) {
- index = 2;
- }else if (day == 7) {
- index = 3;
- }else if (day == 30) {
- index = 4;
- }else if (day == 90) {
- index = 5;
- }else{
- index = 6;
- }
- return index;
- }
- - (void)chatTimeOut:(JXImageView *)imageView {
- self.selType = Type_chatRecordTimeOut;
- double outTime = [[self.dataSorce objectForKey:@"chatRecordTimeOut"] doubleValue];
- NSInteger index = [self getPickerIndexWithDay:outTime];
- [_pickerView selectRow:index inComponent:0 animated:NO];
- _selectView.hidden = NO;
- }
- - (void)syncTimeLen:(JXImageView *)imageView {
- self.selType = Type_chatSyncTimeLen;
- double chatSyncTimeLen = [[self.dataSorce objectForKey:@"chatSyncTimeLen"] doubleValue];
- NSInteger index = [self getPickerIndexWithDay:chatSyncTimeLen];
- [_pickerView selectRow:index inComponent:0 animated:NO];
- _selectView.hidden = NO;
- }
- - (void)groupSyncTimeLen:(JXImageView *)imageView {
- self.selType = Type_groupChatSyncTimeLen;
- double groupChatSyncTimeLen = [[self.dataSorce objectForKey:@"groupChatSyncTimeLen"] doubleValue];
- NSInteger index = [self getPickerIndexWithDay:groupChatSyncTimeLen];
- [_pickerView selectRow:index inComponent:0 animated:NO];
- _selectView.hidden = NO;
- }
- - (void)btnAction:(UIButton *)btn {
- _selectView.hidden = YES;
- NSInteger row = [_pickerView selectedRowInComponent:0];
-
- NSString *str = [NSString stringWithFormat:@"%ld", row];
- switch (row) {
- case 0:
- str = @"-2";
- break;
- case 1:
- str = @"0.04";
- break;
- case 2:
- str = @"1";
- break;
- case 3:
- str = @"7";
- break;
- case 4:
- str = @"30";
- break;
- case 5:
- str = @"90";
- break;
- case 6:
- str = @"365";
- break;
- case 7:
- str = @"-1";
- break;
- default:
- break;
- }
- NSString *key;
- switch (self.selType) {
- case Type_chatRecordTimeOut: {
- key = @"chatRecordTimeOut";
- g_myself.chatRecordTimeOut = str;
- _timeOutLabel.text = _pickerArr[row];
- }
- break;
-
- case Type_chatSyncTimeLen: {
- key = @"chatSyncTimeLen";
- g_myself.chatSyncTimeLen = str;
- _syncTimeLenLabel.text = _pickerArr[row];
- }
- break;
-
- case Type_groupChatSyncTimeLen: {
- key = @"groupChatSyncTimeLen";
- g_myself.groupChatSyncTimeLen = str;
- _groupSyncTimeLenLabel.text = _pickerArr[row];
- }
- break;
-
- default:
- break;
- }
-
- [g_server changeFriendSetting:nil allowAtt:nil allowGreet:nil key:key value:str toView:self];
- }
- - (void)cancelBtnAction {
- _selectView.hidden = YES;
- }
- - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
- {
- return 1;
- }
- - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
- {
- return _pickerArr.count;
- }
- - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
- {
- return _pickerArr[row];
- }
- - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
- {
- }
- - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
-
- }
- - (void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:animated];
- NSLog(@"CurrentController = %@",[self class]);
- // UIView *view = g_window.subviews.lastObject;
- // //NSLog(@"lastObject = %@",g_window.subviews.lastObject);
- // [UIView animateWithDuration:0.3 animations:^{
- // view.frame = CGRectMake(-85, 0, JX_SCREEN_WIDTH, self.view.frame.size.height);
- // }];
- [self resetViewFrame];
-
- }
- -(void)createHeaderView{
- int heightHeader = JX_SCREEN_TOP;
-
- UIView * tableHeader = [[UIView alloc]initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, heightHeader)];
- UIImageView* iv = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, heightHeader)];
- if (THESIMPLESTYLE) {
- iv.image = [[UIImage imageNamed:@"navBarBackground"] imageWithTintColor:[UIColor whiteColor]];
- }else {
- iv.image = [g_theme themeTintImage:@"navBarBackground"];//[UIImage imageNamed:@"navBarBackground"];
- }
- iv.userInteractionEnabled = YES;
- [tableHeader addSubview:iv];
- // [iv release];
-
- JXLabel* p = [[JXLabel alloc]initWithFrame:CGRectMake(40, JX_SCREEN_TOP - 32, self_width-40*2, 16)];
- p.center = CGPointMake(tableHeader.center.x, p.center.y);
- p.backgroundColor = [UIColor clearColor];
- p.textAlignment = NSTextAlignmentCenter;
- p.textColor = THESIMPLESTYLE ? [UIColor blackColor] : [UIColor whiteColor];
- p.text = Localized(@"JX_PrivacySettings");
- p.userInteractionEnabled = YES;
- p.didTouch = @selector(actionTitle:);
- p.delegate = self;
- p.changeAlpha = NO;
- [tableHeader addSubview:p];
-
- UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(0, JX_SCREEN_TOP - 46, 46, 46)];
- [btn setBackgroundImage:[UIImage imageNamed:@"title_back_black_big"] forState:UIControlStateNormal];
- [btn addTarget:self action:@selector(actionQuitSet) forControlEvents:UIControlEventTouchUpInside];
- // btn.showsTouchWhenHighlighted = YES;
- [tableHeader addSubview:btn];
- [self.view addSubview:tableHeader];
- }
- -(JXImageView*)createButtonWithFrame:(CGRect)frame title:(NSString*)title drawTop:(BOOL)drawTop drawBottom:(BOOL)drawBottom must:(BOOL)must click:(SEL)click superView:(UIView *)superView{
- JXImageView* btn = [[JXImageView alloc] init];
- btn.frame = frame;
- btn.backgroundColor = [UIColor whiteColor];
- btn.userInteractionEnabled = YES;
- if(click)
- btn.didTouch = click;
- else
- btn.didTouch = @selector(hideKeyboard);
- btn.delegate = self;
- [superView addSubview:btn];
-
- JXLabel* p = [[JXLabel alloc] init];
- p.text = title;
- p.font = [UIFont systemFontOfSize:16.0];
- p.backgroundColor = [UIColor clearColor];
- p.textColor = [UIColor blackColor];
- [btn addSubview:p];
-
- if(must){
- p.frame = CGRectMake(15, 14, 200, 20);
- }else {
- p.frame = CGRectMake(15, (HEIGHT-20)/2, 200, 20);
- }
- if(drawTop){
- UIView* line = [[UIView alloc] initWithFrame:CGRectMake(15,0,JX_SCREEN_WIDTH-15,LINE_WH)];
- line.backgroundColor = THE_LINE_COLOR;
- [btn addSubview:line];
- }
-
- if(drawBottom){
- UIView* line = [[UIView alloc]initWithFrame:CGRectMake(15,frame.size.height-LINE_WH,JX_SCREEN_WIDTH-15,LINE_WH)];
- line.backgroundColor = THE_LINE_COLOR;
- [btn addSubview:line];
- }
-
- if(click){
- UIImageView* iv;
- iv = [[UIImageView alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH-15-7, (HEIGHT-13)/2, 7, 13)];
- iv.image = [UIImage imageNamed:@"new_icon_>"];
- [btn addSubview:iv];
- if (must) {
- iv.frame = CGRectMake(JX_SCREEN_WIDTH-15-6, (68-12)/2, 6, 12);
- }
- }
- return btn;
- }
- -(void)actionQuitSet{
- [_wait stop];
- [g_server stopConnection:self];
-
- [g_navigation dismissViewController:self animated:YES];
-
- // CGContextRef context = UIGraphicsGetCurrentContext();
- // [UIView beginAnimations:nil context:context];
- // [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
- // [UIView setAnimationDuration:0.2];
- // [UIView setAnimationDelegate:self];
- // [UIView setAnimationDidStopSelector:@selector(actionQuit)];
- //
- // self.view.frame = CGRectMake (JX_SCREEN_WIDTH, 0, self_width, self.view.frame.size.height);
- // UIView *view = g_window.subviews[g_window.subviews.count - 2];
- // view.frame = CGRectMake (0, 0, self_width, self.view.frame.size.height);
- //
- // [UIView commitAnimations];
- }
- -(void)actionQuit{
- [self.view removeFromSuperview];
- _pSelf = nil;
- }
- ////获取设置状态
- //- (void)getData{
- //
- // [g_server getFriendSettings:[NSString stringWithFormat:@"%ld",g_server.user_id] toView:self];
- //}
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- - (void)onSettings:(UISwitch *)switchButton{
- // if (switchButton.isOn) {
- //// if (switchButton.tag == 0) {//
- //// self.att = @"1";
- //// }else if (switchButton.tag == 1){//
- //// self.greet = @"1";
- //// }else
- // if (switchButton.tag == 0){
- // self.friends = @"1";
- // }else if (switchButton.tag == 1){
- // self.isEncrypt = YES;
- // g_xmpp.isEncryptAll = YES;
- // [[NSUserDefaults standardUserDefaults] setBool:YES forKey:kMESSAGE_isEncrypt];
- //
- // }
- // }else{
- //// if (switchButton.tag == 0) {//
- //// self.att = @"0";
- //// }else if (switchButton.tag == 1){//
- //// self.greet = @"0";
- //// }else
- // if (switchButton.tag == 0){
- // self.friends = @"0";
- // }else if (switchButton.tag == 1){
- // self.isEncrypt = NO;
- // g_xmpp.isEncryptAll = NO;
- // [[NSUserDefaults standardUserDefaults] setBool:NO forKey:kMESSAGE_isEncrypt];
- // }
- // }
- if (switchButton.tag == 0) {
- self.friends = [NSString stringWithFormat:@"%@",switchButton.isOn ? @"1" : @"0"];
- g_myself.friendsVerify = [NSString stringWithFormat:@"%@",switchButton.isOn ? @"1" : @"0"];
- [g_server changeFriendSetting:self.friends allowAtt:self.att allowGreet:self.greet key:nil value:nil toView:self];
- }
- if (switchButton.tag == 1) { // 允许手机号搜索我
- g_myself.phoneSearch = [NSString stringWithFormat:@"%@",switchButton.isOn ? @"1" : @"0"];
- [g_server changeFriendSetting:nil allowAtt:nil allowGreet:nil key:@"phoneSearch" value:g_myself.phoneSearch toView:self];
- }
- if (switchButton.tag == 2) {// 允许昵称搜索我
- g_myself.nameSearch = [NSString stringWithFormat:@"%@",switchButton.isOn ? @"1" : @"0"];
- [g_server changeFriendSetting:nil allowAtt:nil allowGreet:nil key:@"nameSearch" value:g_myself.nameSearch toView:self];
- }
- if (switchButton.tag == 3) {
- self.isEncrypt = switchButton.isOn;
- g_myself.isEncrypt = [NSString stringWithFormat:@"%@",switchButton.isOn ? @"1" : @"0"];
- [g_server changeFriendSetting:nil allowAtt:nil allowGreet:nil key:@"isEncrypt" value:g_myself.isEncrypt toView:self];
- }
- if (switchButton.tag == 4) {
- g_myself.isTyping = [NSString stringWithFormat:@"%@",switchButton.isOn ? @"1" : @"0"];
- [g_server changeFriendSetting:nil allowAtt:nil allowGreet:nil key:@"isTyping" value:g_myself.isTyping toView:self];
- // [g_default setBool:switchButton.isOn forKey:kStartEnteringStatus];
- // [g_default synchronize];
- }else if (switchButton.tag == 5) {//是否振动
- g_myself.isVibration = [NSString stringWithFormat:@"%@",switchButton.isOn ? @"1" : @"0"];
- [g_server changeFriendSetting:nil allowAtt:nil allowGreet:nil key:@"isVibration" value:g_myself.isVibration toView:self];
- // [g_default setBool:switchButton.isOn forKey:kMsgComeVibration];
- // [g_default synchronize];
- }else if (switchButton.tag == 6) {//是否静音
- g_myself.isMute = [NSString stringWithFormat:@"%@",switchButton.isOn ? @"1" : @"0"];
-
- // 先不做网络同步
- // [g_server changeFriendSetting:nil allowAtt:nil allowGreet:nil key:@"isVibration" value:g_myself.isVibration toView:self];
- // 本地
- [g_default setBool:switchButton.isOn forKey:kMsgComeMute];
- [g_default synchronize];
- }else if (switchButton.tag == 7) {//是否多点登录
- g_myself.multipleDevices = [NSString stringWithFormat:@"%@",switchButton.isOn ? @"1" : @"0"];
- [g_server changeFriendSetting:nil allowAtt:nil allowGreet:nil key:@"multipleDevices" value:g_myself.multipleDevices toView:self];
-
- // [g_default setBool:switchButton.isOn forKey:kISMultipleLogin];
- // [g_default synchronize];
- // if (switchButton.isOn) {
- // g_myself.isMultipleLogin = [NSNumber numberWithLong:1];
- // }else {
- //
- // g_myself.isMultipleLogin = [NSNumber numberWithLong:0];
- // }
- }else if (switchButton.tag == 8) {//是否屠龙推送
- // g_myself.isMute = [NSString stringWithFormat:@"%@",switchButton.isOn ? @"1" : @"0"];
-
- // 先不做网络同步
- // [g_server changeFriendSetting:nil allowAtt:nil allowGreet:nil key:@"isVibration" value:g_myself.isVibration toView:self];
- // 本地
- [g_default setBool:YES forKey:kLongComePushIsFirstSetUp];
- [g_default setBool:switchButton.isOn forKey:kLongComePush];
- [g_default synchronize];
- }else if (switchButton.tag == 7) {//是否多点登录
- g_myself.multipleDevices = [NSString stringWithFormat:@"%@",switchButton.isOn ? @"1" : @"0"];
- [g_server changeFriendSetting:nil allowAtt:nil allowGreet:nil key:@"multipleDevices" value:g_myself.multipleDevices toView:self];
-
- // [g_default setBool:switchButton.isOn forKey:kISMultipleLogin];
- // [g_default synchronize];
- // if (switchButton.isOn) {
- // g_myself.isMultipleLogin = [NSNumber numberWithLong:1];
- // }else {
- //
- // g_myself.isMultipleLogin = [NSNumber numberWithLong:0];
- // }
- }
- // else if (switchButton.tag == 8){//新设备登录是否需要授权
- // g_myself.authSwitch = [NSString stringWithFormat:@"%@",switchButton.isOn ? @"1" : @"0"];
- // [g_server changeFriendSetting:nil allowAtt:nil allowGreet:nil key:@"authSwitch" value:g_myself.authSwitch toView:self];
- // }//else if (switchButton.tag == 7) {//是否使用Google地图
- //
- // g_myself.isUseGoogleMap = [NSString stringWithFormat:@"%@",switchButton.isOn ? @"1" : @"0"];
- // [g_server changeFriendSetting:nil allowAtt:nil allowGreet:nil key:@"isUseGoogleMap" value:g_myself.isUseGoogleMap toView:self];
- //
- //// BOOL isShowGooMap = NO;
- //// if (switchButton.isOn) {
- //// isShowGooMap = YES;
- //// }else {
- //// isShowGooMap = NO;
- //// }
- //// [g_default setBool:isShowGooMap forKey:kUseGoogleMap];
- //
- // }
- // else{
- // [g_server changeFriendSetting:self.friends allowAtt:self.att allowGreet:self.greet key:nil value:nil toView:self];
- // }
-
- }
- #pragma mark - tableView代理
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- int number = 9;
- if ([g_config.isOpenPositionService intValue] == 1) {
- number = 8;
- }
- return number;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- JXSettingsCell * cell = [tableView dequeueReusableCellWithIdentifier:@"JXSC"];
- if (cell == nil) {
- cell = [[NSBundle mainBundle] loadNibNamed:@"JXSettingsCell" owner:self options:nil][0];
-
- cell.mySwitch = [[UISwitch alloc]initWithFrame:CGRectMake(JX_SCREEN_WIDTH -70, 10, 0, 0)];
-
- [cell.mySwitch addTarget:self action:@selector(onSettings:) forControlEvents:UIControlEventValueChanged];
- cell.mySwitch.tag = indexPath.row;
- cell.mySwitch.onTintColor = THEMECOLOR;
- cell.inTableView = self;
-
- [cell addSubview:cell.mySwitch];
- int number = 8;
- if ([g_config.isOpenPositionService intValue] == 1) {
- number = 7;
- }
- if (indexPath.row != number-1) {
- cell.line = [[UIView alloc] initWithFrame:CGRectMake(15, 56-LINE_WH, JX_SCREEN_WIDTH-15, LINE_WH)];
- cell.line.backgroundColor = THE_LINE_COLOR;
- [cell addSubview:cell.line];
- }
- }
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- //从服务器获取数据后,改变switch的状态
- // if (indexPath.row == 0) {
- // cell.myLabel.text = Localized(@"JXSettings_AllowFollow");
- // if([[self.dataSorce objectForKey:@"allowAtt"] integerValue] == 1){
- //
- // cell.mySwitch.on = YES;
- // }else{
- //
- // cell.mySwitch.on = NO;
- // }
- //
- // }else if(indexPath.row == 1){
- // cell.myLabel.text = Localized(@"JXSettings_AllowSayHi");
- // if([[self.dataSorce objectForKey:@"allowGreet"] integerValue] == 1){
- //
- // cell.mySwitch.on = YES;
- // }else{
- //
- // cell.mySwitch.on = NO;
- // }
- // }else
- if(indexPath.row == 0){
- cell.myLabel.text = Localized(@"JXSettings_FirendVerify");
- if([[self.dataSorce objectForKey:@"friendsVerify"] integerValue] == 1){
- cell.mySwitch.on = YES;
- }else{
- cell.mySwitch.on = NO;
- }
- }
- else if(indexPath.row == 1){
- cell.myLabel.text = Localized(@"JX_AllowMeToSearchByNO.");
- if([[self.dataSorce objectForKey:@"phoneSearch"] integerValue] == 1){
-
- cell.mySwitch.on = YES;
- }else{
-
- cell.mySwitch.on = NO;
- }
- }
- else if(indexPath.row == 2){
- cell.myLabel.text = Localized(@"JX_AllowMeToSearchByNickname");
- if([[self.dataSorce objectForKey:@"nameSearch"] integerValue] == 1){
-
- cell.mySwitch.on = YES;
- }else{
-
- cell.mySwitch.on = NO;
- }
- }
- else if(indexPath.row == 3){
- cell.myLabel.text = Localized(@"JXSettings_Encrypt");
- if([[self.dataSorce objectForKey:@"isEncrypt"] integerValue] == 1){
-
- cell.mySwitch.on = YES;
- }else{
-
- cell.mySwitch.on = NO;
- }
- }
- else if(indexPath.row == 4){
- cell.myLabel.text = Localized(@"JX_StartEntering");
- if([[self.dataSorce objectForKey:@"isTyping"] integerValue] == 1){
-
- cell.mySwitch.on = YES;
- }else{
-
- cell.mySwitch.on = NO;
- }
- }
- else if(indexPath.row == 5){
- cell.myLabel.text = Localized(@"JX_Vibration");
- if([[self.dataSorce objectForKey:@"isVibration"] integerValue] == 1){
-
- cell.mySwitch.on = YES;
- }else{
-
- cell.mySwitch.on = NO;
- }
- }
- else if(indexPath.row == 6){
- cell.myLabel.text = @"是否静音";
- if([g_default boolForKey:kMsgComeMute] == 1){
-
- cell.mySwitch.on = YES;
- }else{
-
- cell.mySwitch.on = NO;
- }
- }
- else if(indexPath.row == 7){
- cell.myLabel.text = Localized(@"JX_OpenMultipointLogin");
- if([[self.dataSorce objectForKey:@"multipleDevices"] integerValue] == 1){
-
- cell.mySwitch.on = YES;
- }else{
-
- cell.mySwitch.on = NO;
- }
- }
- else if(indexPath.row == 8){
- cell.myLabel.text = @"是否屠龙推送";
- // 第一次设置
- if ([g_default boolForKey:kLongComePushIsFirstSetUp] != 1) {
- cell.mySwitch.on = YES;
- } else {
-
- if ([g_default boolForKey:kLongComePush] == 1) {
- cell.mySwitch.on = YES;
- }else{
- cell.mySwitch.on = NO;
- }
- }
-
-
- }
- // else if(indexPath.row == 8){
- // cell.myLabel.text = Localized(@"JX_LoginRequiresDeviceAuthorization");
- // if ([[self.dataSorce objectForKey:@"authSwitch"] integerValue] == 1) {
- // cell.mySwitch.on = YES;
- // }else{
- // cell.mySwitch.on = NO;
- // }
- // }
- // else if(indexPath.row == 7){
- // cell.myLabel.text = Localized(@"JX_UseGoogleMap");
- // if([[self.dataSorce objectForKey:@"isUseGoogleMap"] integerValue] == 1){
- //
- // cell.mySwitch.on = YES;
- // }else{
- //
- // cell.mySwitch.on = NO;
- // }
- // }
- return cell;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return 56;
- }
- - (void)changeSettingsNum{
- if([[self.dataSorce objectForKey:@"allowAtt"] integerValue] == 1){
- self.att = @"1";
- }else{
- self.att = @"0";
- }
-
- if([[self.dataSorce objectForKey:@"allowGreet"] integerValue] == 1){
- self.greet = @"1";
- }else{
- self.greet = @"0";
- }
- if([[self.dataSorce objectForKey:@"friendsVerify"] integerValue] == 1){
- self.friends = @"1";
- }else{
- self.friends = @"0";
- }
- if ([[self.dataSorce objectForKey:@"isEncrypt"] integerValue] == 1) {
- self.isEncrypt = YES;
- }else{
- self.isEncrypt = NO;
- }
- }
- - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
-
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-
- [self doLogout];
- });
- }
- -(void)doLogout{
- JXUserObject *user = [JXUserObject sharedInstance];
- [g_server logout:user.areaCode toView:self];
-
- }
- -(void)relogin{
-
- g_server.access_token = nil;
-
- [g_notify postNotificationName:kSystemLogoutNotifaction object:nil];
- [[JXXMPP sharedInstance] logout];
-
- NSLog(@"XMPP --- jxsettingsVC");
-
- loginVC* vc = [loginVC alloc];
- vc.isAutoLogin = NO;
- vc.isSwitchUser= NO;
- vc = [vc init];
- [g_mainVC.view removeFromSuperview];
- g_mainVC = nil;
- [self.view removeFromSuperview];
- self.view = nil;
-
- g_navigation.rootViewController = vc;
- [_wait stop];
- #if TAR_IM
- #ifdef Meeting_Version
- [g_meeting stopMeeting];
- #endif
- #endif
- }
- #pragma mark - 返回数据
- -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
- [_wait hide];
- if ([aDownload.action isEqualToString:act_SettingsUpdate]) {//更改了好友验证
-
- self.dataSorce = [dict objectForKey:@"settings"];
-
- [self changeSettingsNum];
-
-
- }
- if ([aDownload.action isEqualToString:act_UserUpdate]) {
- [g_App showAlert:Localized(@"JX_ModifiedMultipointLogonNeedsToBeLoggedIn") delegate:self tag:3333 onlyConfirm:YES];
- }
-
- if( [aDownload.action isEqualToString:act_UserLogout] ){
- [self relogin];
- }
- if ([aDownload.action isEqualToString:act_Settings]){
- // [g_server showMsg:@"其他端修改了隐私设置,已更新"];
- self.dataSorce = dict;
- [self getData];
- }
- }
- -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
- if( [aDownload.action isEqualToString:act_UserLogout] ){
- [self performSelector:@selector(doSwitch) withObject:nil afterDelay:1];
- }
- return hide_error;
- }
- -(int) didServerConnectError:(JXConnection*)aDownload error:(NSError *)error{//error为空时,代表超时
- [_wait hide];
- return show_error;
- }
- -(void) didServerConnectStart:(JXConnection*)aDownload{
- [_wait start];
-
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- - (void)dealloc {
- // [_myTableView release];
- // [_myView release];
- // [super dealloc];
- [g_notify removeObserver:self];
- }
- //归位
- - (void)resetViewFrame{
- [UIView animateWithDuration:0.3 animations:^{
- self.view.frame = CGRectMake(0, 0, JX_SCREEN_WIDTH, self.view.frame.size.height);
- }];
- }
- @end
|