diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 2475d981..00000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2016 SealTalk 嗨豹 - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/RCDAboutRongCloudTableViewController.h b/RCDAboutRongCloudTableViewController.h index 4bf3e2c4..f4e249d1 100644 --- a/RCDAboutRongCloudTableViewController.h +++ b/RCDAboutRongCloudTableViewController.h @@ -9,5 +9,6 @@ #import @interface RCDAboutRongCloudTableViewController : UITableViewController +@property (weak, nonatomic) IBOutlet UILabel *VersionLabel; @end diff --git a/RCDAboutRongCloudTableViewController.m b/RCDAboutRongCloudTableViewController.m index 3e353c06..1ed6348d 100644 --- a/RCDAboutRongCloudTableViewController.m +++ b/RCDAboutRongCloudTableViewController.m @@ -10,9 +10,32 @@ @interface RCDAboutRongCloudTableViewController() @property (nonatomic, strong)NSArray *urls; +@property (nonatomic)BOOL hasNewVersion; +@property (nonatomic)NSString *versionUrl; +@property (nonatomic, strong)NSString *versionString; +@property (nonatomic, strong)NSURLConnection *connection; @end @implementation RCDAboutRongCloudTableViewController + +-(id)initWithCoder:(NSCoder *)aDecoder +{ + self = [super initWithCoder:aDecoder]; + if (self) { + self.versionUrl= [[NSUserDefaults standardUserDefaults] stringForKey:@"newVersionUrl"]; + self.versionUrl= [[NSUserDefaults standardUserDefaults] stringForKey:@"newVersionString"]; + // self.hasNewVersion = [[NSUserDefaults standardUserDefaults] boolForKey:@"hasNewVersion"]; + [self checkNewVersion]; + } + return self; +} +#if DEBUG +#define DEMO_VERSION_BOARD @"http://bj.rongcloud.net/list.php" +#else +#define DEMO_VERSION_BOARD @"http://rongcloud.cn/demo" +#endif + + -(void)viewDidLoad { [super viewDidLoad]; @@ -20,18 +43,45 @@ -(void)viewDidLoad } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - NSURL *url = [self getUrlAt:indexPath]; - if (url) { - [[UIApplication sharedApplication]openURL:[self getUrlAt:indexPath]]; + if (indexPath.section == 0 && indexPath.row == 5) { + if (self.hasNewVersion) { + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:self.versionUrl]]; + self.hasNewVersion = NO; + self.versionUrl = nil; + } else { + [self checkNewVersion]; + } + return; + } + if (indexPath.section == 0 && indexPath.row < 4) { + NSURL *url = [self getUrlAt:indexPath]; + if (url) { + [[UIApplication sharedApplication]openURL:[self getUrlAt:indexPath]]; + } } } +- (void)setHasNewVersion:(BOOL)hasNewVersion +{ + _hasNewVersion = hasNewVersion; + [[NSUserDefaults standardUserDefaults] setBool:self.hasNewVersion forKey:@"hasNewVersion"]; + [[NSUserDefaults standardUserDefaults] synchronize]; + [self updateNewVersionBadge]; +} + +-(void)viewWillAppear:(BOOL)animated +{ + [super viewWillAppear:animated]; + [self updateNewVersionBadge]; +} + + - (NSArray *)urls { if (!_urls) { - NSArray *section0 = [NSArray arrayWithObjects:@"http://rongcloud.cn/", @"http://rongcloud.cn/downloads/history/ios", @"http://rongcloud.cn/features", @"http://docs.rongcloud.cn/api/ios/imkit/index.html", nil]; - NSArray *section1 = [NSArray arrayWithObjects:@"http://rongcloud.cn/", nil]; - _urls = [NSArray arrayWithObjects:section0, section1, nil]; + NSArray *section0 = [NSArray arrayWithObjects:@"http://rongcloud.cn/", @"http://rongcloud.cn/downloads/history/ios", @"http://rongcloud.cn/features", @"http://rongcloud.cn/", nil]; +// NSArray *section1 = [NSArray arrayWithObjects:@"http://rongcloud.cn/", nil]; + _urls = [NSArray arrayWithObjects:section0, nil]; } return _urls; } @@ -45,4 +95,34 @@ - (NSURL *)getUrlAt:(NSIndexPath *)indexPath } return [NSURL URLWithString:urlString]; } + +- (void)checkNewVersion { + long lastCheckTime = [[NSUserDefaults standardUserDefaults] integerForKey:@"lastupdatetimestamp"]; + + NSDate *now = [[NSDate alloc] init]; + if (now.timeIntervalSince1970 - lastCheckTime > 0) { + if (DEMO_VERSION_BOARD.length == 0) { + return; + } + NSURL *url = [NSURL URLWithString:DEMO_VERSION_BOARD]; + NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10]; + self.connection = [[NSURLConnection alloc]initWithRequest:request delegate:self]; + } +} + +- (void)updateNewVersionBadge { +#if DEBUG + NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]; + if (self.hasNewVersion && ([self.versionString compare:version] == NSOrderedDescending)) { +#else + if (self.hasNewVersion) { +#endif + _VersionLabel.attributedText = [[NSAttributedString alloc] initWithString:@"有新版本啦。。。" attributes:@{NSForegroundColorAttributeName:[UIColor redColor]}]; + } else { + self.tabBarItem.badgeValue = nil; + NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]; + _VersionLabel.text=[NSString stringWithFormat:@"SDK 版本 %@",version]; + } + } + @end diff --git a/RCDAddFriendViewController.m b/RCDAddFriendViewController.m index 052e39f2..9afb067b 100644 --- a/RCDAddFriendViewController.m +++ b/RCDAddFriendViewController.m @@ -34,11 +34,13 @@ - (void)viewDidLoad { { [self.ivAva sd_setImageWithURL:[NSURL URLWithString:self.targetUserInfo.portraitUri] placeholderImage:[UIImage imageNamed:@"icon_person"]]; } - + self.ivAva.layer.masksToBounds = YES; + self.ivAva.layer.cornerRadius = 6.f; + self.ivAva.contentMode = UIViewContentModeScaleAspectFill; NSMutableArray *cacheList=[[NSMutableArray alloc]initWithArray:[[RCDataBaseManager shareInstance] getAllFriends]]; BOOL isFriend = NO; for (RCDUserInfo *user in cacheList) { - if ([user.userId isEqualToString:self.targetUserInfo.userId]) { + if ([user.userId isEqualToString:self.targetUserInfo.userId] && [user.status isEqualToString:@"20"]) { isFriend = YES; break; } diff --git a/RCDChangePasswordViewController.h b/RCDChangePasswordViewController.h index 3f9b00f7..d857846f 100644 --- a/RCDChangePasswordViewController.h +++ b/RCDChangePasswordViewController.h @@ -10,4 +10,12 @@ @interface RCDChangePasswordViewController : UIViewController +@property (weak, nonatomic) IBOutlet UIButton *DoneButton; + +@property (weak, nonatomic) IBOutlet UIView *OldPasswordView; + +@property (weak, nonatomic) IBOutlet UIView *NewPasswordView; + +@property (weak, nonatomic) IBOutlet UIView *ConfirmPasswordView; + @end diff --git a/RCDChangePasswordViewController.m b/RCDChangePasswordViewController.m index e990f436..be2d9583 100644 --- a/RCDChangePasswordViewController.m +++ b/RCDChangePasswordViewController.m @@ -22,12 +22,27 @@ @implementation RCDChangePasswordViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. - UIButton *rightBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 50, 34)]; - [rightBtn setTitle:@"保存" forState:UIControlStateNormal]; - [rightBtn addTarget:self action:@selector(saveNewPassword:) forControlEvents:UIControlEventTouchUpInside]; - UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithCustomView:rightBtn]; - [rightBtn setTintColor:[UIColor whiteColor]]; - self.navigationItem.rightBarButtonItem = rightButton; +// UIButton *rightBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 50, 34)]; +// [rightBtn setTitle:@"保存" forState:UIControlStateNormal]; +// [rightBtn addTarget:self action:@selector(saveNewPassword:) forControlEvents:UIControlEventTouchUpInside]; +// UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithCustomView:rightBtn]; +// [rightBtn setTintColor:[UIColor whiteColor]]; +// self.navigationItem.rightBarButtonItem = rightButton; + self.navigationItem.title = @"密码修改"; + + self.OldPasswordView.layer.borderWidth = 0.5; + self.OldPasswordView.layer.borderColor = [HEXCOLOR(0xdfdfdd) CGColor]; + + self.NewPasswordView.layer.borderWidth = 0.5; + self.NewPasswordView.layer.borderColor = [HEXCOLOR(0xdfdfdd) CGColor]; + + self.ConfirmPasswordView.layer.borderWidth = 0.5; + self.ConfirmPasswordView.layer.borderColor = [HEXCOLOR(0xdfdfdd) CGColor]; + + self.DoneButton.layer.borderWidth = 0.5; + self.DoneButton.layer.borderColor = [HEXCOLOR(0x0181dd) CGColor]; + [self.DoneButton addTarget:self action:@selector(saveNewPassword:) forControlEvents:UIControlEventTouchUpInside]; + } - (void)didReceiveMemoryWarning { diff --git a/RCDContactSelectedTableViewCell.m b/RCDContactSelectedTableViewCell.m index 8387e650..f3c3f0fe 100644 --- a/RCDContactSelectedTableViewCell.m +++ b/RCDContactSelectedTableViewCell.m @@ -14,8 +14,8 @@ - (void)awakeFromNib { // Initialization code } -- (void)setSelected:(BOOL)selected animated:(BOOL)animated { - [super setSelected:selected animated:animated]; +- (void)setSelected:(BOOL)selected{ + [super setSelected:selected]; if (selected) { _selectedImageView.image = [UIImage imageNamed:@"select"]; }else{ diff --git a/RCDContactSelectedTableViewController.m b/RCDContactSelectedTableViewController.m index be54e25e..baa45199 100644 --- a/RCDContactSelectedTableViewController.m +++ b/RCDContactSelectedTableViewController.m @@ -17,16 +17,20 @@ #import "RCDCreateGroupViewController.h" #import "DefaultPortraitView.h" #import "RCDChatViewController.h" +#import "MBProgressHUD.h" @interface RCDContactSelectedTableViewController () @property (nonatomic,strong) NSMutableArray *friends; @property (strong, nonatomic) NSMutableArray *friendsArr; @property (nonatomic,strong) NSMutableArray *tempOtherArr; -@property (nonatomic,strong) UILabel *noFriend; +//@property (nonatomic,strong) UILabel *noFriend; + +@property (nonatomic,strong) NSIndexPath *selectIndexPath; @end @implementation RCDContactSelectedTableViewController +MBProgressHUD* hud ; - (void)viewDidLoad { [super viewDidLoad]; @@ -53,6 +57,7 @@ - (void)viewDidLoad { // Uncomment the following line to display an Edit button in the navigation bar for this view controller. // self.navigationItem.rightBarButtonItem = self.editButtonItem; + self.navigationItem.rightBarButtonItem.enabled = NO; } - (void)didReceiveMemoryWarning { @@ -73,15 +78,27 @@ -(void)viewWillAppear:(BOOL)animated } +-(void)viewWillDisappear:(BOOL)animated +{ + self.navigationItem.rightBarButtonItem.enabled = YES; + [hud hide:YES]; +} + //clicked done -(void) clickedDone:(id) sender { + self.navigationItem.rightBarButtonItem.enabled = NO; + hud= [MBProgressHUD showHUDAddedTo:self.view animated:YES]; +// hud.labelText = @""; + [hud show:YES]; + NSArray *indexPaths = [self.tableView indexPathsForSelectedRows]; - if (!indexPaths||indexPaths.count == 0){ - UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"请选择!" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil]; - [alert show]; - return; - } +// if (!indexPaths||indexPaths.count == 0){ +// [hud hide:YES]; +// UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"请选择!" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil]; +// [alert show]; +// return; +// } //get seleted users NSMutableArray *seletedUsers = [NSMutableArray new]; @@ -107,6 +124,13 @@ -(void) clickedDone:(id) sender [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:@"addGroupMemberList" object:seletedUsers]]; [self.navigationController popViewControllerAnimated:YES]; } + else + { + [hud hide:YES]; + UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"添加成员失败" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil]; + [alert show]; + self.navigationItem.rightBarButtonItem.enabled = YES; + } }]; return; } @@ -118,6 +142,13 @@ -(void) clickedDone:(id) sender [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:@"deleteGroupMemberList" object:seletedUsers]]; [self.navigationController popViewControllerAnimated:YES]; } + else + { + [hud hide:YES]; + UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"删除成员失败" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil]; + [alert show]; + self.navigationItem.rightBarButtonItem.enabled = YES; + } }]; return; } @@ -299,14 +330,25 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N //override delegate -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + self.navigationItem.rightBarButtonItem.enabled = YES; RCDContactSelectedTableViewCell *cell = (RCDContactSelectedTableViewCell*)[tableView cellForRowAtIndexPath:indexPath]; [cell setSelected:YES]; + if (self.selectIndexPath && self.selectIndexPath.row == indexPath.row) { + [cell setSelected:NO]; + self.selectIndexPath = nil; + }else{ + self.selectIndexPath = indexPath; + } } -(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath { RCDContactSelectedTableViewCell *cell = (RCDContactSelectedTableViewCell*)[tableView cellForRowAtIndexPath:indexPath]; [cell setSelected:NO]; + if ([tableView.indexPathsForSelectedRows count] == 0) { + self.navigationItem.rightBarButtonItem.enabled = NO; + } + self.selectIndexPath = nil; } @@ -320,18 +362,18 @@ -(void) getAllData _allFriends = [NSMutableDictionary new]; _allKeys = [NSMutableArray new]; _friends = [NSMutableArray arrayWithArray:[[RCDataBaseManager shareInstance]getAllFriends ] ]; - if ([_friends count] == 0) { - _noFriend = [[UILabel alloc] init]; - _noFriend.frame = CGRectMake((self.view.frame.size.width / 2) - 50, (self.view.frame.size.height / 2) - 15 - self.navigationController.navigationBar.frame.size.height, 100, 30); - [_noFriend setText:@"暂无好友"]; - [_noFriend setTextColor:[UIColor grayColor]]; - _noFriend.textAlignment = UITextAlignmentCenter; - [self.view addSubview:_noFriend]; - _noFriend.hidden = NO; -// return; - } +// if ([_friends count] == 0) { +// _noFriend = [[UILabel alloc] init]; +// _noFriend.frame = CGRectMake((self.view.frame.size.width / 2) - 50, (self.view.frame.size.height / 2) - 15 - self.navigationController.navigationBar.frame.size.height, 100, 30); +// [_noFriend setText:@"暂无好友"]; +// [_noFriend setTextColor:[UIColor grayColor]]; +// _noFriend.textAlignment = UITextAlignmentCenter; +// [self.view addSubview:_noFriend]; +// _noFriend.hidden = NO; +//// return; +// } if (_friends==nil||_friends.count<1) { - _noFriend.hidden = YES; +// _noFriend.hidden = YES; [RCDDataSource syncFriendList:[RCIM sharedRCIM].currentUserInfo.userId complete:^(NSMutableArray * result) { _friends=result; for (RCDUserInfo *user in _friends) { @@ -357,7 +399,7 @@ -(void) getAllData // if (_friends.count < 20) { // self.hideSectionHeader = YES; // } - _noFriend.hidden = YES; +// _noFriend.hidden = YES; dispatch_async(dispatch_get_global_queue(0, 0), ^{ for (RCDUserInfo *user in _friends) { if ([user.status isEqualToString:@"20"]) { diff --git a/RCDContactViewController.m b/RCDContactViewController.m index baa32e9b..87c9717f 100644 --- a/RCDContactViewController.m +++ b/RCDContactViewController.m @@ -20,6 +20,7 @@ #import "RCDSearchFriendViewController.h" #import "DefaultPortraitView.h" #import "pinyin.h" +#import "RCDPublicServiceListViewController.h" @interface RCDContactViewController () //#字符索引对应的user object @@ -34,11 +35,16 @@ @interface RCDContactViewController () @end @implementation RCDContactViewController +{ + BOOL isSyncFriends; +} - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. + self.tabBarItem.selectedImage = [[UIImage imageNamed:@"contact_icon_hover"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; + //initial data _searchResult=[[NSMutableArray alloc] init]; _friendsArr = [[NSMutableArray alloc] init]; @@ -47,7 +53,7 @@ - (void)viewDidLoad { float colorFloat = 249.f / 255.f; self.friendsTabelView.backgroundColor = [[UIColor alloc] initWithRed:colorFloat green:colorFloat blue:colorFloat alpha:1]; - _defaultCellsTitle = [NSArray arrayWithObjects:@"新朋友",@"群组",@"公众号", nil]; + _defaultCellsTitle = [NSArray arrayWithObjects:@"新朋友",@"群组",@"公众号",@"我", nil]; _defaultCellsPortrait = [NSArray arrayWithObjects:@"newFriend",@"defaultGroup",@"publicNumber", nil]; } @@ -85,7 +91,7 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger { NSInteger rows = 0; if (section == 0) { - rows = 3; + rows = 4; } else { @@ -126,8 +132,13 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N if (indexPath.section == 0) { cell.nicknameLabel.text = [_defaultCellsTitle objectAtIndex:indexPath.row]; - [cell.portraitView setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@",[_defaultCellsPortrait objectAtIndex:indexPath.row]]]]; - + if (indexPath.row != 3) { + [cell.portraitView setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@",[_defaultCellsPortrait objectAtIndex:indexPath.row]]]]; + } + else + { + [cell.portraitView sd_setImageWithURL:[NSURL URLWithString:[DEFAULTS stringForKey:@"userPortraitUri"]] placeholderImage:[UIImage imageNamed:@"icon_person"]]; + } } else { @@ -200,13 +211,24 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath case 2: { - RCPublicServiceListViewController *publicServiceVC = [[RCPublicServiceListViewController alloc] init]; + RCDPublicServiceListViewController *publicServiceVC = [[RCDPublicServiceListViewController alloc] init]; [self.navigationController pushViewController:publicServiceVC animated:YES]; return; } break; + case 3: + { + UIStoryboard *storyboard = + [UIStoryboard storyboardWithName:@"Main" bundle:nil]; + RCDPersonDetailViewController *detailViewController = [storyboard instantiateViewControllerWithIdentifier:@"RCDPersonDetailViewController"]; + + [self.navigationController pushViewController:detailViewController animated:YES]; + detailViewController.userInfo = [RCIM sharedRCIM].currentUserInfo; + return; + } + default: break; } @@ -266,21 +288,15 @@ -(void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText } - dispatch_async(dispatch_get_global_queue(0, 0), ^{ + dispatch_async(dispatch_get_main_queue(), ^{ _allFriends = [self sortedArrayWithPinYinDic:_searchResult]; - dispatch_async(dispatch_get_main_queue(), ^{ [self.friendsTabelView reloadData]; - - }); }); } if ([searchText length] == 0) { - dispatch_async(dispatch_get_global_queue(0, 0), ^{ + dispatch_async(dispatch_get_main_queue(), ^{ _allFriends = [self sortedArrayWithPinYinDic:_friends]; - dispatch_async(dispatch_get_main_queue(), ^{ - [self.friendsTabelView reloadData]; - - }); + [self.friendsTabelView reloadData]; }); } @@ -345,40 +361,40 @@ -(void) getAllData // self.hideSectionHeader = YES; // } - dispatch_async(dispatch_get_global_queue(0, 0), ^{ + dispatch_async(dispatch_get_main_queue(), ^{ for (RCDUserInfo *user in _friends) { if ([user.status isEqualToString:@"20"]) { [_friendsArr addObject:user]; } } _allFriends = [self sortedArrayWithPinYinDic:_friendsArr]; - dispatch_async(dispatch_get_main_queue(), ^{ - [self.friendsTabelView reloadData]; - - }); + [self.friendsTabelView reloadData]; }); } - [RCDDataSource syncFriendList:[RCIM sharedRCIM].currentUserInfo.userId complete:^(NSMutableArray * result) { - _friends=result; - NSMutableArray *tmpFriends = [[NSMutableArray alloc] init]; - for (RCDUserInfo *user in _friends) { - if ([user.status isEqualToString:@"20"]) { - [tmpFriends addObject:user]; - } - } - // if (_friends.count < 20) { - // self.hideSectionHeader = YES; - // } - dispatch_async(dispatch_get_global_queue(0, 0), ^{ - NSMutableDictionary *tmpDict = [self sortedArrayWithPinYinDic:tmpFriends]; - dispatch_async(dispatch_get_main_queue(), ^{ - _allFriends = tmpDict; - [self.friendsTabelView reloadData]; - - }); - }); - - }]; + if ([_friends count] == 0 && isSyncFriends == NO) { + [RCDDataSource syncFriendList:[RCIM sharedRCIM].currentUserInfo.userId complete:^(NSMutableArray * result) { + isSyncFriends = YES; + [self getAllData]; + }]; + } +// [RCDDataSource syncFriendList:[RCIM sharedRCIM].currentUserInfo.userId complete:^(NSMutableArray * result) { +// _friends=result; +// NSMutableArray *tmpFriends = [[NSMutableArray alloc] init]; +// for (RCDUserInfo *user in _friends) { +// if ([user.status isEqualToString:@"20"]) { +// [tmpFriends addObject:user]; +// } +// } +// // if (_friends.count < 20) { +// // self.hideSectionHeader = YES; +// // } +// dispatch_async(dispatch_get_main_queue(), ^{ +// NSMutableDictionary *tmpDict = [self sortedArrayWithPinYinDic:tmpFriends]; +// _allFriends = tmpDict; +// [self.friendsTabelView reloadData]; +// }); +// +// }]; diff --git a/RCDCreateGroupViewController.m b/RCDCreateGroupViewController.m index e5d51c34..24a978de 100644 --- a/RCDCreateGroupViewController.m +++ b/RCDCreateGroupViewController.m @@ -147,30 +147,32 @@ - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField //} - (IBAction)ClickDoneBtn:(id)sender { + self.navigationItem.rightBarButtonItem.enabled = NO; [self moveView:deafultY]; [_GroupName resignFirstResponder]; //需要添加群组头像 - if (image == nil) { - [self Alert:@"请添加群组头像"]; - return; - } +// if (image == nil) { +// [self Alert:@"请添加群组头像"]; +// self.navigationItem.rightBarButtonItem.enabled = YES; +// return; +// } NSString *nameStr = [self.GroupName.text copy]; nameStr = [nameStr stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; //群组名称需要大于2位 if ([nameStr length] == 0) { [self Alert:@"群组名称不能为空"]; - return; + self.navigationItem.rightBarButtonItem.enabled = YES; } //群组名称需要大于2个字 - if ([nameStr length] < 2) { + else if ([nameStr length] < 2) { [self Alert:@"群组名称过短"]; - return; + self.navigationItem.rightBarButtonItem.enabled = YES; } //群组名称需要小于10个字 - if ([nameStr length] > 10) { + else if ([nameStr length] > 10) { [self Alert:@"群组名称不能超过10个字"]; - return; + self.navigationItem.rightBarButtonItem.enabled = YES; } else { @@ -192,51 +194,105 @@ - (IBAction)ClickDoneBtn:(id)sender { hud.labelText = @"群组创建中..."; [hud show:YES]; - [[RCDHttpTool shareInstance] createGroupWithGroupName:nameStr - GroupMemberList:_GroupMemberIdList - complete:^(NSString *groupId) { - if (groupId) { - [RCDHTTPTOOL uploadImageToQiNiu:[RCIM sharedRCIM].currentUserInfo.userId - ImageData:data - success:^(NSString *url) { - RCGroup *groupInfo = [RCGroup new]; - groupInfo.portraitUri = url; - groupInfo.groupId =groupId; - groupInfo.groupName =nameStr; - dispatch_async(dispatch_get_main_queue(), ^{ - [RCDHTTPTOOL setGroupPortraitUri:url groupId:groupId - complete:^(BOOL result) { - [[RCIM sharedRCIM] refreshGroupInfoCache:groupInfo - withGroupId:groupId]; -// [[RCDataBaseManager shareInstance] insertGroupToDB:groupInfo]; - if (result == YES) { - [self.navigationController popToRootViewControllerAnimated:YES]; //关闭HUD - [hud hide:YES]; - } - if (result == NO) { - //关闭HUD - [hud hide:YES]; - [self Alert:@"创建群组失败,请检查你的网络设置。"]; - } - }]; - }); - - } failure:^(NSError *err) { - //关闭HUD - [hud hide:YES]; - [self Alert:@"创建群组失败,请检查你的网络设置。"]; - }]; - - -// dispatch_sync(dispatch_get_main_queue(), ^{ -// [self.navigationController popToRootViewControllerAnimated:YES]; -// }); - } - else - { - [self Alert:@"创建群组失败,请检查你的网络设置。"]; - } - }]; + [[RCDHttpTool shareInstance] + createGroupWithGroupName:nameStr + GroupMemberList:_GroupMemberIdList + complete:^(NSString *groupId) { + + if (groupId) { + if (image != nil) { + [RCDHTTPTOOL + uploadImageToQiNiu:[RCIM sharedRCIM].currentUserInfo.userId + ImageData:data + success:^(NSString *url) { + RCGroup *groupInfo = [RCGroup new]; + groupInfo.portraitUri = url; + groupInfo.groupId =groupId; + groupInfo.groupName =nameStr; + dispatch_async(dispatch_get_main_queue(), ^{ + [RCDHTTPTOOL + setGroupPortraitUri:url groupId:groupId + complete:^(BOOL result) { + [[RCIM sharedRCIM] refreshGroupInfoCache:groupInfo + withGroupId:groupId]; + // [[RCDataBaseManager shareInstance] insertGroupToDB:groupInfo]; + if (result == YES) { + + [self.navigationController popToRootViewControllerAnimated:YES]; //关闭HUD + [hud hide:YES]; + } + if (result == NO) { + self.navigationItem.rightBarButtonItem.enabled = YES; //关闭HUD + [hud hide:YES]; + [self Alert:@"创建群组失败,请检查你的网络设置。"]; + } + }]; + }); + + } failure:^(NSError *err) { + self.navigationItem.rightBarButtonItem.enabled = YES; + //关闭HUD + [hud hide:YES]; + [self Alert:@"创建群组失败,请检查你的网络设置。"]; + }]; + } + else + { + + RCGroup *groupInfo = [RCGroup new]; + groupInfo.portraitUri = [self createDefaultPortrait:groupId GroupName:nameStr]; + groupInfo.groupId =groupId; + groupInfo.groupName =nameStr; + [[RCIM sharedRCIM] refreshGroupInfoCache:groupInfo + withGroupId:groupId]; + [self.navigationController popToRootViewControllerAnimated:YES]; + } + +// [RCDHTTPTOOL +// uploadImageToQiNiu:[RCIM sharedRCIM].currentUserInfo.userId +// ImageData:data +// success:^(NSString *url) { +// RCGroup *groupInfo = [RCGroup new]; +// groupInfo.portraitUri = url; +// groupInfo.groupId =groupId; +// groupInfo.groupName =nameStr; +// dispatch_async(dispatch_get_main_queue(), ^{ +// [RCDHTTPTOOL +// setGroupPortraitUri:url groupId:groupId +// complete:^(BOOL result) { +// +// // [[RCDataBaseManager shareInstance] insertGroupToDB:groupInfo]; +// if (result == YES) { +// [self.navigationController popToRootViewControllerAnimated:YES]; //关闭HUD +// [hud hide:YES]; +// } +// if (result == NO) { +// self.navigationItem.rightBarButtonItem.enabled = YES; //关闭HUD +// [hud hide:YES]; +// [self Alert:@"创建群组失败,请检查你的网络设置。"]; +// } +// }]; +// }); +// +// } failure:^(NSError *err) { +// self.navigationItem.rightBarButtonItem.enabled = YES; +// //关闭HUD +// [hud hide:YES]; +// [self Alert:@"创建群组失败,请检查你的网络设置。"]; +// }]; + + + // dispatch_sync(dispatch_get_main_queue(), ^{ + // [self.navigationController popToRootViewControllerAnimated:YES]; + // }); + } + else + { + [hud hide:YES]; + self.navigationItem.rightBarButtonItem.enabled = YES; + [self Alert:@"创建群组失败,请检查你的网络设置。"]; + } + }]; } } @@ -355,4 +411,36 @@ - (void)moveView:(CGFloat)Y self.view.frame = CGRectMake(0, Y, self.view.frame.size.width, self.view.frame.size.height); [UIView commitAnimations]; } + +- (NSString *)createDefaultPortrait:(NSString *)groupId GroupName:(NSString *)groupName +{ + DefaultPortraitView *defaultPortrait = [[DefaultPortraitView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; + [defaultPortrait setColorAndLabel:groupId Nickname:groupName]; + UIImage *portrait = [defaultPortrait imageFromView]; + + + NSString *filePath = [self getIconCachePath:[NSString stringWithFormat:@"group%@.png",groupId]]; + + BOOL result = [UIImagePNGRepresentation(portrait)writeToFile: filePath atomically:YES]; + if (result == YES) { + NSURL *portraitPath = [NSURL fileURLWithPath:filePath]; + return [portraitPath absoluteString]; + } + return nil; +} + +- (NSString *)getIconCachePath:(NSString *)fileName { + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); + NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"CachedIcons/%@",fileName]]; // 保存文件的名称 + + NSString *dirPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"CachedIcons"]]; + NSFileManager *fileManager = [NSFileManager defaultManager]; + if (![fileManager fileExistsAtPath:dirPath]) { + [fileManager createDirectoryAtPath:dirPath + withIntermediateDirectories:YES + attributes:nil + error:nil]; + } + return filePath; +} @end diff --git a/RCDGroupMembersTableViewController.m b/RCDGroupMembersTableViewController.m index 55c820b4..f42f1786 100644 --- a/RCDGroupMembersTableViewController.m +++ b/RCDGroupMembersTableViewController.m @@ -13,6 +13,8 @@ #import "UIImageView+WebCache.h" #import "RCDPersonDetailViewController.h" #import "RCDMeInfoTableViewController.h" +#import "RCDataBaseManager.h" +#import "RCDAddFriendViewController.h" @interface RCDGroupMembersTableViewController () @@ -69,7 +71,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N } cell.portraitView.layer.masksToBounds = YES; cell.portraitView.layer.cornerRadius = 6.f; - + cell.portraitView.contentMode = UIViewContentModeScaleAspectFill; cell.nicknameLabel.text = user.name; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; cell.selectionStyle = UITableViewCellSelectionStyleNone; @@ -89,13 +91,36 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath RCDMeInfoTableViewController *MeInfoVC = [mainStoryboard instantiateViewControllerWithIdentifier:@"RCDMeInfoTableViewController"]; [self.navigationController pushViewController:MeInfoVC animated:YES]; + return; + } + BOOL isFriend = NO; + NSArray *friendList = [[RCDataBaseManager shareInstance] getAllFriends]; + for (RCDUserInfo *friend in friendList) { + if ([user.userId isEqualToString:friend.userId] && [friend.status isEqualToString:@"20"]) { + isFriend = YES; + } + } + if (isFriend == YES) { + UIStoryboard *storyboard = + [UIStoryboard storyboardWithName:@"Main" bundle:nil]; + RCDPersonDetailViewController *detailViewController = [storyboard instantiateViewControllerWithIdentifier:@"RCDPersonDetailViewController"]; + + [self.navigationController pushViewController:detailViewController animated:YES]; + detailViewController.userInfo = _GroupMembers[indexPath.row]; } else { - RCDPersonDetailViewController *PersonDetailVC = [mainStoryboard instantiateViewControllerWithIdentifier:@"RCDPersonDetailViewController"]; - PersonDetailVC.userInfo = _GroupMembers[indexPath.row]; - [self.navigationController pushViewController:PersonDetailVC animated:YES]; + UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; + RCDAddFriendViewController *addViewController = [mainStoryboard instantiateViewControllerWithIdentifier:@"RCDAddFriendViewController"]; + addViewController.targetUserInfo = _GroupMembers[indexPath.row]; + [self.navigationController pushViewController:addViewController animated:YES]; } +// else +// { +// RCDPersonDetailViewController *PersonDetailVC = [mainStoryboard instantiateViewControllerWithIdentifier:@"RCDPersonDetailViewController"]; +// PersonDetailVC.userInfo = _GroupMembers[indexPath.row]; +// [self.navigationController pushViewController:PersonDetailVC animated:YES]; +// } } /* diff --git a/RCDGroupSettingsTableViewController.m b/RCDGroupSettingsTableViewController.m index 9cf46ceb..3475c107 100644 --- a/RCDGroupSettingsTableViewController.m +++ b/RCDGroupSettingsTableViewController.m @@ -20,6 +20,7 @@ #import "DefaultPortraitView.h" #import "RCDGroupMembersTableViewController.h" #import "RCDataBaseManager.h" +#import "RCDAddFriendViewController.h" @interface RCDGroupSettingsTableViewController () //开始会话 @@ -74,11 +75,10 @@ - (void)viewDidLoad { UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom]; backBtn.frame = CGRectMake(0, 6, 87, 23); UIImageView *backImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"navigator_btn_back"]]; - backImg.frame = CGRectMake(-10, 0, 22, 22); + backImg.frame = CGRectMake(-12, 0, 22, 22); [backBtn addSubview:backImg]; - UILabel *backText = [[UILabel alloc] initWithFrame:CGRectMake(12, 0, 85, 22)]; + UILabel *backText = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 85, 22)]; backText.text =@"返回"; - backText.font = [UIFont systemFontOfSize:15]; [backText setBackgroundColor:[UIColor clearColor]]; [backText setTextColor:[UIColor whiteColor]]; [backBtn addSubview:backText]; @@ -88,6 +88,18 @@ - (void)viewDidLoad { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addGroupMemberList:) name:@"addGroupMemberList" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deleteGroupMemberList:) name:@"deleteGroupMemberList" object:nil]; + + CGRect tempRect = + CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, headerView.collectionViewLayout.collectionViewContentSize.height); + UICollectionViewFlowLayout *flowLayout = + [[UICollectionViewFlowLayout alloc] init]; + flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical; + headerView = [[UICollectionView alloc] initWithFrame:tempRect collectionViewLayout:flowLayout]; + headerView.delegate = self; + headerView.dataSource = self; + headerView.scrollEnabled = NO; + [headerView registerClass:[RCDConversationSettingTableViewHeaderItem class] + forCellWithReuseIdentifier:@"RCDConversationSettingTableViewHeaderItem"]; } -(void)viewWillAppear:(BOOL)animated @@ -138,7 +150,7 @@ -(void)startLoad } else { - numberOfSections = 2; + numberOfSections = 3; [[RCIMClient sharedRCIMClient] getConversationNotificationStatus:ConversationType_GROUP targetId:groupId success:^(RCConversationNotificationStatus nStatus) { @@ -159,17 +171,18 @@ -(void)startLoad /******************添加headerview*******************/ GroupMembers = [[NSMutableArray alloc] initWithArray:_GroupMemberList]; collectionViewResource = [[NSMutableArray alloc] initWithArray:_GroupMemberList]; - CGRect tempRect = - CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, headerView.collectionViewLayout.collectionViewContentSize.height); - UICollectionViewFlowLayout *flowLayout = - [[UICollectionViewFlowLayout alloc] init]; - flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical; - headerView = [[UICollectionView alloc] initWithFrame:tempRect collectionViewLayout:flowLayout]; - headerView.delegate = self; - headerView.dataSource = self; - headerView.scrollEnabled = NO; - [headerView registerClass:[RCDConversationSettingTableViewHeaderItem class] - forCellWithReuseIdentifier:@"RCDConversationSettingTableViewHeaderItem"]; + [self limitDisplayMemberCount]; +// CGRect tempRect = +// CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, headerView.collectionViewLayout.collectionViewContentSize.height); +// UICollectionViewFlowLayout *flowLayout = +// [[UICollectionViewFlowLayout alloc] init]; +// flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical; +// headerView = [[UICollectionView alloc] initWithFrame:tempRect collectionViewLayout:flowLayout]; +// headerView.delegate = self; +// headerView.dataSource = self; +// headerView.scrollEnabled = NO; +// [headerView registerClass:[RCDConversationSettingTableViewHeaderItem class] +// forCellWithReuseIdentifier:@"RCDConversationSettingTableViewHeaderItem"]; UIImage *addImage = [UIImage imageNamed:@"add_member"]; [collectionViewResource addObject:addImage]; //判断如果是创建者,添加踢人按钮 @@ -191,6 +204,7 @@ -(void)startLoad [GroupMembers addObjectsFromArray:result]; [collectionViewResource removeAllObjects]; [collectionViewResource addObjectsFromArray:result]; + [self limitDisplayMemberCount]; UIImage *addImage = [UIImage imageNamed:@"add_member"]; [collectionViewResource addObject:addImage]; if (isCreator == YES) { @@ -198,6 +212,8 @@ -(void)startLoad [collectionViewResource addObject:delImage]; } [headerView reloadData]; + headerView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, headerView.collectionViewLayout.collectionViewContentSize.height); + self.tableView.tableHeaderView = headerView; [self.tableView reloadData]; [[RCDataBaseManager shareInstance] insertGroupMemberToDB:result groupId:groupId]; } @@ -443,8 +459,10 @@ - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { if (actionSheet.tag == 100) { - [[RCIMClient sharedRCIMClient] clearMessages:ConversationType_GROUP targetId:groupId]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"ClearHistoryMsg" object:nil]; + if (buttonIndex == 0) { + [[RCIMClient sharedRCIMClient] clearMessages:ConversationType_GROUP targetId:groupId]; + [[NSNotificationCenter defaultCenter] postNotificationName:@"ClearHistoryMsg" object:nil]; + } } if (actionSheet.tag == 101) { @@ -462,12 +480,12 @@ - (void)actionSheet:(UIActionSheet *)actionSheet targetId:groupId]; [[RCDataBaseManager shareInstance] deleteGroupToDB:groupId]; - NSArray *defaultGroupIdList = [DEFAULTS objectForKey:@"defaultGroupIdList"]; - for (NSString *tempId in defaultGroupIdList) { - if ([tempId isEqualToString:groupId]) { - [[NSNotificationCenter defaultCenter] postNotificationName:@"quitDefaultGroup" object:groupId]; - } - } +// NSArray *defaultGroupIdList = [DEFAULTS objectForKey:@"defaultGroupIdList"]; +// for (NSString *tempId in defaultGroupIdList) { +// if ([tempId isEqualToString:groupId]) { +// [[NSNotificationCenter defaultCenter] postNotificationName:@"quitDefaultGroup" object:groupId]; +// } +// } [self.navigationController popToRootViewControllerAnimated:YES]; } else { UIAlertView *alertView = @@ -529,10 +547,14 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger NSInteger rows; switch (section) { case 0: - rows = 3; + rows = 1; break; case 1: + rows = 2; + break; + + case 2: rows = 3; break; @@ -548,17 +570,25 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N RCDGroupSettingsTableViewCell *cell = (RCDGroupSettingsTableViewCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (indexPath.section == 0) { + cell.TitleLabel.text = [NSString stringWithFormat:@"群组成员(%@)",_Group.number]; + cell.PortraitImg.hidden = YES; + cell.arrowImg.hidden = NO; + cell.switchBtn.hidden = YES; + cell.ContentLabel.hidden = YES; + } + + if (indexPath.section == 1) { switch (indexPath.row) { +// case 0: +// { +// cell.TitleLabel.text = [NSString stringWithFormat:@"群组成员(%@)",_Group.number]; +// cell.PortraitImg.hidden = YES; +// cell.arrowImg.hidden = NO; +// cell.switchBtn.hidden = YES; +// cell.ContentLabel.hidden = YES; +// } +// break; case 0: - { - cell.TitleLabel.text = [NSString stringWithFormat:@"群组成员(%@)",_Group.number]; - cell.PortraitImg.hidden = YES; - cell.arrowImg.hidden = NO; - cell.switchBtn.hidden = YES; - cell.ContentLabel.hidden = YES; - } - break; - case 1: { cell.PortraitImg.contentMode = UIViewContentModeScaleAspectFill; if ([RCIM sharedRCIM].globalConversationAvatarStyle == RC_USER_AVATAR_CYCLE && [RCIM sharedRCIM].globalMessageAvatarStyle == RC_USER_AVATAR_CYCLE) { @@ -592,9 +622,10 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N } } break; - case 2: + case 1: { cell.TitleLabel.text = @"群组名称"; + cell.PortraitImg.hidden = YES; cell.switchBtn.hidden = YES; cell.arrowImg.hidden = NO; cell.ContentLabel.hidden = NO; @@ -606,27 +637,12 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N } break; - case 3: - { - cell.TitleLabel.text = @"群人数"; - cell.switchBtn.hidden = YES; - cell.ContentLabel.text = [NSString stringWithFormat:@"%@/500",_Group.number]; - } - break; - -// case 2: -// { -// cell.TitleLabel.text = @"群名片"; -// cell.switchBtn.hidden = YES; -// } -// break; - default: break; } } - if (indexPath.section == 1) { + if (indexPath.section == 2) { switch (indexPath.row) { case 0: { @@ -670,25 +686,33 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { + if (section == 0) { + return 0; + } return 20.f; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section == 0) { - if (indexPath.row == 0) { - RCDGroupMembersTableViewController *GroupMembersVC = [[RCDGroupMembersTableViewController alloc] init]; - GroupMembersVC.GroupMembers = GroupMembers; - [self.navigationController pushViewController:GroupMembersVC animated:YES]; - } + RCDGroupMembersTableViewController *GroupMembersVC = [[RCDGroupMembersTableViewController alloc] init]; + GroupMembersVC.GroupMembers = GroupMembers; + [self.navigationController pushViewController:GroupMembersVC animated:YES]; + } + if (indexPath.section == 1) { +// if (indexPath.row == 0) { +// RCDGroupMembersTableViewController *GroupMembersVC = [[RCDGroupMembersTableViewController alloc] init]; +// GroupMembersVC.GroupMembers = GroupMembers; +// [self.navigationController pushViewController:GroupMembersVC animated:YES]; +// } - if (indexPath.row == 1) { + if (indexPath.row == 0) { if (isCreator == YES) { [self chosePortrait]; } } - if (indexPath.row == 2) { + if (indexPath.row == 1) { if (isCreator == YES) { UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; RCDEditGroupNameViewController *editGroupNameVC = [mainStoryboard instantiateViewControllerWithIdentifier:@"RCDEditGroupNameViewController"]; @@ -699,7 +723,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath } } } - if (indexPath.section == 1) { + if (indexPath.section == 2) { if (indexPath.row == 2) { UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"确定清除聊天记录?" @@ -798,24 +822,9 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell RCUserInfo *user = collectionViewResource[indexPath.row]; if ([user.userId isEqualToString:[RCIMClient sharedRCIMClient].currentUserInfo.userId]) { - [cell.btnImg setHidden:YES]; - } - // else - // { - // [cell.btnImg setHidden:!self.showDeleteTip]; - // } - if ([user.portraitUri isEqualToString:@""]) { - DefaultPortraitView *defaultPortrait = [[DefaultPortraitView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; - [defaultPortrait setColorAndLabel:user.userId Nickname:user.name]; - UIImage *portrait = [defaultPortrait imageFromView]; - cell.ivAva.image = portrait; - } - else - { - [cell.ivAva sd_setImageWithURL:[NSURL URLWithString:user.portraitUri] placeholderImage:[UIImage imageNamed:@"icon_person"]]; + [cell.btnImg setHidden:YES]; } - cell.titleLabel.text = user.name; - cell.userId=user.userId; + [cell setUserModel:user]; } else { @@ -860,7 +869,13 @@ - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPa // [allMembersId addObject:userId]; // } contactSelectedVC.titleStr = @"移除成员"; - contactSelectedVC.delGroupMembers = _GroupMemberList; + NSMutableArray *members = [NSMutableArray new]; + for (RCUserInfo *user in _GroupMemberList) { + if (![user.userId isEqualToString:creatorId]) { + [members addObject:user]; + } + } + contactSelectedVC.delGroupMembers = members; _Group = nil; [self.navigationController pushViewController:contactSelectedVC animated:YES]; return; @@ -878,12 +893,29 @@ - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPa } } - UIStoryboard *storyboard = - [UIStoryboard storyboardWithName:@"Main" bundle:nil]; - RCDPersonDetailViewController *detailViewController = [storyboard instantiateViewControllerWithIdentifier:@"RCDPersonDetailViewController"]; - - [self.navigationController pushViewController:detailViewController animated:YES]; - detailViewController.userInfo = [membersInfo objectAtIndex:indexPath.row]; + RCUserInfo *selectedUser = [membersInfo objectAtIndex:indexPath.row]; + BOOL isFriend = NO; + NSArray *friendList = [[RCDataBaseManager shareInstance] getAllFriends]; + for (RCDUserInfo *friend in friendList) { + if ([selectedUser.userId isEqualToString:friend.userId] && [friend.status isEqualToString:@"20"]) { + isFriend = YES; + } + } + if (isFriend == YES || [selectedUser.userId isEqualToString:[RCIM sharedRCIM].currentUserInfo.userId]) { + UIStoryboard *storyboard = + [UIStoryboard storyboardWithName:@"Main" bundle:nil]; + RCDPersonDetailViewController *detailViewController = [storyboard instantiateViewControllerWithIdentifier:@"RCDPersonDetailViewController"]; + + [self.navigationController pushViewController:detailViewController animated:YES]; + detailViewController.userInfo = [membersInfo objectAtIndex:indexPath.row]; + } + else + { + UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; + RCDAddFriendViewController *addViewController = [mainStoryboard instantiateViewControllerWithIdentifier:@"RCDAddFriendViewController"]; + addViewController.targetUserInfo = [membersInfo objectAtIndex:indexPath.row]; + [self.navigationController pushViewController:addViewController animated:YES]; + } } @@ -900,6 +932,18 @@ -(void) deleteGroupMemberList:(NSNotification *)notify } } +- (void)limitDisplayMemberCount +{ + if (isCreator == YES && [collectionViewResource count] > 28) { + NSRange rang = NSMakeRange(28, [collectionViewResource count] - 28); + [collectionViewResource removeObjectsInRange:rang]; + } + else if ([collectionViewResource count] > 29) { + NSRange rang = NSMakeRange(29, [collectionViewResource count] - 29); + [collectionViewResource removeObjectsInRange:rang]; + } +} + /* #pragma mark - Navigation diff --git a/RCDHttpTool.m b/RCDHttpTool.m index be0b16b4..a60680c1 100644 --- a/RCDHttpTool.m +++ b/RCDHttpTool.m @@ -12,12 +12,12 @@ #import "RCDUserInfo.h" #import "RCDRCIMDataSource.h" #import "RCDataBaseManager.h" +#import "RCDUtilities.h" @implementation RCDHttpTool -+ (RCDHttpTool*)shareInstance -{ ++ (RCDHttpTool*)shareInstance { static RCDHttpTool* instance = nil; static dispatch_once_t predicate; dispatch_once(&predicate, ^{ @@ -27,16 +27,15 @@ + (RCDHttpTool*)shareInstance return instance; } --(void) isMyFriendWithUserInfo:(RCDUserInfo *)userInfo - completion:(void(^)(BOOL isFriend)) completion -{ +-(void)isMyFriendWithUserInfo:(RCDUserInfo *)userInfo + completion:(void(^)(BOOL isFriend))completion { [self getFriends:userInfo.userId complete:^(NSMutableArray *result) { for (RCDUserInfo *user in result) { if ([user.userId isEqualToString:userInfo.userId] && completion && [@"1" isEqualToString:user.status]) { if (completion) { completion(YES); } - return ; + return; } } if(completion){ @@ -46,50 +45,43 @@ -(void) isMyFriendWithUserInfo:(RCDUserInfo *)userInfo } //创建群组 --(void) createGroupWithGroupName:(NSString *)groupName - GroupMemberList:(NSArray *)groupMemberList - complete:(void (^)(NSString *))userId -{ +-(void)createGroupWithGroupName:(NSString *)groupName + GroupMemberList:(NSArray *)groupMemberList + complete:(void (^)(NSString *))userId { [AFHttpTool createGroupWithGroupName:groupName groupMemberList:groupMemberList success:^(id response) { if ([response[@"code"] integerValue] == 200) { NSDictionary *result = response[@"result"]; userId(result[@"id"]); + } else { + userId(nil); } - } failure:^(NSError *err) { userId(nil); }]; - - - } //设置群组头像 --(void) setGroupPortraitUri:(NSString *)portraitUri - groupId:(NSString *)groupId - complete:(void (^)(BOOL))result -{ +-(void)setGroupPortraitUri:(NSString *)portraitUri + groupId:(NSString *)groupId + complete:(void (^)(BOOL))result { [AFHttpTool setGroupPortraitUri:portraitUri groupId:groupId - success:^(id response) { - if ([response[@"code"] intValue] == 200) { - result(YES); - } - - }failure:^(NSError *err) { - result(NO); - }]; + success:^(id response) { + if ([response[@"code"] intValue] == 200) { + result(YES); + } else { + result(NO); + } + }failure:^(NSError *err) { + result(NO); + }]; } //根据id获取单个群组 --(void) getGroupByID:(NSString *) groupID - successCompletion:(void (^)(RCDGroupInfo *group)) completion -{ -// RCGroup *groupInfo=[[RCDataBaseManager shareInstance] getGroupByGroupId:groupID]; -// if(groupInfo==nil) -// { +-(void)getGroupByID:(NSString *) groupID + successCompletion:(void (^)(RCDGroupInfo *group))completion { [AFHttpTool getGroupByID:groupID success:^(id response) { NSString *code = [NSString stringWithFormat:@"%@",response[@"code"]]; NSDictionary *result = response[@"result"]; @@ -98,12 +90,12 @@ -(void) getGroupByID:(NSString *) groupID group.groupId = [result objectForKey:@"id"]; group.groupName = [result objectForKey:@"name"]; group.portraitUri = [result objectForKey:@"portraitUri"]; - if (group.portraitUri == nil || group.portraitUri.length == 0) { - group.portraitUri=@""; + if (!group.portraitUri || group.portraitUri.length <= 0) { + group.portraitUri = [RCDUtilities defaultGroupPortrait:group]; } group.creatorId = [result objectForKey:@"creatorId"]; group.introduce = [result objectForKey:@"introduce"]; - if (group.introduce) { + if (!group.introduce) { group.introduce=@""; } group.number = [result objectForKey:@"memberCount"]; @@ -111,173 +103,115 @@ -(void) getGroupByID:(NSString *) groupID group.creatorTime = [result objectForKey:@"creat_datetime"]; if (![[result objectForKey:@"deletedAt"] isKindOfClass:[NSNull class]]) { group.isDismiss = @"YES"; - } - else - { + } else { group.isDismiss = @"NO"; } [[RCDataBaseManager shareInstance] insertGroupToDB:group]; if ([group.groupId isEqualToString:groupID] && completion) { completion(group); + } else if (completion) { + completion(nil); + } + } else { + if (completion) { + completion(nil); } } - } failure:^(NSError* err){ - RCDGroupInfo *group=[[RCDataBaseManager shareInstance] getGroupByGroupId:groupID]; + RCDGroupInfo *group = [[RCDataBaseManager shareInstance] getGroupByGroupId:groupID]; + if (!group.portraitUri || group.portraitUri.length <= 0) { + group.portraitUri = [RCDUtilities defaultGroupPortrait:group]; + } completion(group); }]; -// }else{ -// if (completion) { -// completion(groupInfo); -// } -// -// } } --(void) getUserInfoByUserID:(NSString *) userID - completion:(void (^)(RCUserInfo *user)) completion -{ - - RCUserInfo *userInfo=[[RCDataBaseManager shareInstance] getUserByUserId:userID]; - if (userInfo==nil) { +-(void)getUserInfoByUserID:(NSString *) userID + completion:(void (^)(RCUserInfo *user))completion { + RCUserInfo *userInfo = [[RCDataBaseManager shareInstance] getUserByUserId:userID]; + if (!userInfo) { [AFHttpTool getUserInfo:userID success:^(id response) { if (response) { NSString *code = [NSString stringWithFormat:@"%@",response[@"code"]]; - if ([code isEqualToString:@"200"]) { - NSDictionary *dic = response[@"result"]; - // NSLog(@"isMainThread > %d", [NSThread isMainThread]); RCUserInfo *user = [RCUserInfo new]; user.userId = dic[@"id"]; - user.portraitUri = [dic objectForKey:@"portraitUri"]; user.name = [dic objectForKey:@"nickname"]; + user.portraitUri = [dic objectForKey:@"portraitUri"]; + if (!user.portraitUri || user.portraitUri.length <= 0) { + user.portraitUri = [RCDUtilities defaultUserPortrait:user]; + } [[RCDataBaseManager shareInstance] insertUserToDB:user]; - if (completion) { dispatch_async(dispatch_get_main_queue(), ^{ completion(user); }); } - } - else - { + } else { RCUserInfo *user = [RCUserInfo new]; - user.userId = userID; - user.portraitUri = @""; user.name = [NSString stringWithFormat:@"name%@", userID]; + user.portraitUri = [RCDUtilities defaultUserPortrait:user]; + + if (completion) { + dispatch_async(dispatch_get_main_queue(), ^{ + completion(user); + }); + } + } + } else { + RCUserInfo *user = [RCUserInfo new]; + user.userId = userID; + user.name = [NSString stringWithFormat:@"name%@", userID]; + user.portraitUri = [RCDUtilities defaultUserPortrait:user]; + + if (completion) { dispatch_async(dispatch_get_main_queue(), ^{ completion(user); }); } - } - } failure:^(NSError *err) { NSLog(@"getUserInfoByUserID error"); if (completion) { - @try { - dispatch_async(dispatch_get_main_queue(), ^{ - RCUserInfo *user = [RCUserInfo new]; - - user.userId = userID; - user.portraitUri = @""; - user.name = [NSString stringWithFormat:@"name%@", userID]; - - completion(user); - }); - } - @catch (NSException *exception) { - - } - @finally { + dispatch_async(dispatch_get_main_queue(), ^{ + RCUserInfo *user = [RCUserInfo new]; + user.userId = userID; + user.name = [NSString stringWithFormat:@"name%@", userID]; + user.portraitUri = [RCDUtilities defaultUserPortrait:user]; - } - + completion(user); + }); } }]; - - }else - { + } else { if (completion) { dispatch_async(dispatch_get_main_queue(), ^{ + if (!userInfo.portraitUri || userInfo.portraitUri.length <= 0) { + userInfo.portraitUri = [RCDUtilities defaultUserPortrait:userInfo]; + } completion(userInfo); }); } - } -// __block NSArray * regDataArray; -// [AFHttpTool getFriendsSuccess:^(id response) { -// if (response) { -// NSString *code = [NSString stringWithFormat:@"%@",response[@"code"]]; -// -// if ([code isEqualToString:@"200"]) { -// -// regDataArray = response[@"result"]; -// // NSLog(@"isMainThread > %d", [NSThread isMainThread]); -// -// dispatch_group_leave(groupQueue); -// -// } -// -// } -// -// } failure:^(NSError *err) { -// NSLog(@"getUserInfoByUserID error"); -// }]; -// -// dispatch_group_notify(groupQueue, dispatch_get_main_queue(), ^{ -// -// dispatch_queue_t queue = dispatch_queue_create("handleResponseData.friends", DISPATCH_QUEUE_SERIAL); -// -// dispatch_async(queue, ^{ -// -// for(int i = 0;i < regDataArray.count;i++){ -// NSDictionary *dic = [regDataArray objectAtIndex:i]; -// //NSLog(@"userID > %@, id > %@, i > %d", userID, [dic objectForKey:@"id"], i); -// if ([userID isEqualToString:[dic objectForKey:@"id"]]) { -// // NSLog(@"Matched i > %d, dic>%@", i, dic); -// RCUserInfo *userInfo = [RCUserInfo new]; -// NSNumber *idNum = [dic objectForKey:@"id"]; -// userInfo.userId = [NSString stringWithFormat:@"%d",idNum.intValue]; -// userInfo.portraitUri = [dic objectForKey:@"portrait"]; -// userInfo.name = [dic objectForKey:@"username"]; -// [[RCDataBaseManager shareInstance] insertUserToDB:userInfo]; -// -// if (completion) { -// dispatch_async(dispatch_get_main_queue(), ^{ -// completion(userInfo); -// }); -// } -// -// } -//// }else{ -//// NSLog(@"no matched userid > %d", i); -//// } -// } -// }); -// }); -// -} - --(void) setUserPortraitUri:(NSString *)portraitUri - complete:(void (^)(BOOL))result -{ - [AFHttpTool setUserPortraitUri:portraitUri - success:^(id response) { - if ([response[@"code"] intValue] == 200) { - result(YES); - } - - }failure:^(NSError *err) { - result(NO); - }]; } -- (void)getAllGroupsWithCompletion:(void (^)(NSMutableArray* result))completion -{ +-(void)setUserPortraitUri:(NSString *)portraitUri + complete:(void (^)(BOOL))result { + [AFHttpTool setUserPortraitUri:portraitUri + success:^(id response) { + if ([response[@"code"] intValue] == 200) { + result(YES); + } else { + result(NO); + } + }failure:^(NSError *err) { + result(NO); + }]; +} +- (void)getAllGroupsWithCompletion:(void (^)(NSMutableArray* result))completion { [AFHttpTool getAllGroupsSuccess:^(id response) { NSMutableArray *tempArr = [NSMutableArray new]; NSArray *allGroups = response[@"result"]; @@ -288,12 +222,12 @@ - (void)getAllGroupsWithCompletion:(void (^)(NSMutableArray* result))completion group.groupId = [dic objectForKey:@"id"]; group.groupName = [dic objectForKey:@"name"]; group.portraitUri = [dic objectForKey:@"portrait"]; - if (group.portraitUri) { - group.portraitUri=@""; + if (!group.portraitUri || group.portraitUri.length <= 0) { + group.portraitUri = [RCDUtilities defaultGroupPortrait:group]; } group.creatorId = [dic objectForKey:@"create_user_id"]; group.introduce = [dic objectForKey:@"introduce"]; - if (group.introduce) { + if (!group.introduce) { group.introduce=@""; } group.number = [dic objectForKey:@"number"]; @@ -311,7 +245,6 @@ - (void)getAllGroupsWithCompletion:(void (^)(NSMutableArray* result))completion groupInfo.isJoin = YES; [[RCDataBaseManager shareInstance] insertGroupToDB:groupInfo]; } - } } if (completion) { @@ -320,40 +253,44 @@ - (void)getAllGroupsWithCompletion:(void (^)(NSMutableArray* result))completion completion(tempArr); } - }]; + } else { + completion(nil); } - } failure:^(NSError* err){ NSMutableArray *cacheGroups=[[NSMutableArray alloc]initWithArray:[[RCDataBaseManager shareInstance] getAllGroup]]; + for (RCDGroupInfo *group in cacheGroups) { + if (!group.portraitUri || group.portraitUri.length <= 0) { + group.portraitUri = [RCDUtilities defaultGroupPortrait:group]; + } + } completion(cacheGroups); }]; } - --(void) getMyGroupsWithBlock:(void(^)(NSMutableArray* result)) block -{ +-(void)getMyGroupsWithBlock:(void(^)(NSMutableArray* result))block { [AFHttpTool getMyGroupsSuccess:^(id response) { NSArray *allGroups = response[@"result"]; NSMutableArray *tempArr = [NSMutableArray new]; if (allGroups) { + [[RCDataBaseManager shareInstance] clearGroupfromDB]; for (NSDictionary *dic in allGroups) { NSDictionary *groupInfo = dic[@"group"]; RCDGroupInfo *group = [[RCDGroupInfo alloc] init]; group.groupId = [groupInfo objectForKey:@"id"]; group.groupName = [groupInfo objectForKey:@"name"]; group.portraitUri = [groupInfo objectForKey:@"portraitUri"]; - if (group.portraitUri == nil || group.portraitUri.length == 0) { - group.portraitUri=@""; + if (!group.portraitUri || group.portraitUri.length == 0) { + group.portraitUri = [RCDUtilities defaultGroupPortrait:group]; } group.creatorId = [groupInfo objectForKey:@"creatorId"]; // group.introduce = [dic objectForKey:@"introduce"]; - if (group.introduce) { + if (!group.introduce) { group.introduce=@""; } group.number = [groupInfo objectForKey:@"memberCount"]; -// group.maxNumber = [dic objectForKey:@"max_number"]; group.maxNumber = @"500"; +// group.maxNumber = [dic objectForKey:@"max_number"]; // group.creatorTime = [dic objectForKey:@"creat_datetime"]; if (!group.number) { group.number=@""; @@ -363,27 +300,33 @@ -(void) getMyGroupsWithBlock:(void(^)(NSMutableArray* result)) block } [tempArr addObject:group]; group.isJoin = YES; - [[RCDataBaseManager shareInstance] insertGroupToDB:group]; - //[_allGroups addObject:group]; + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ + [[RCDataBaseManager shareInstance] insertGroupToDB:group]; + }); } if (block) { block(tempArr); } + } else { + block(nil); } - } failure:^(NSError *err) { NSMutableArray *tempArr = [NSMutableArray new]; tempArr = [[RCDataBaseManager shareInstance] getAllGroup]; + for (RCDGroupInfo *group in tempArr) { + if (!group.portraitUri || group.portraitUri.length <= 0) { + group.portraitUri = [RCDUtilities defaultGroupPortrait:group]; + } + } block(tempArr); }]; } --(void) getGroupMembersWithGroupId:(NSString *)groupId Block:(void(^)(NSMutableArray* result)) block -{ +-(void)getGroupMembersWithGroupId:(NSString *)groupId + Block:(void(^)(NSMutableArray* result))block { [AFHttpTool getGroupMembersByID:groupId - success:^(id response) - { + success:^(id response) { NSMutableArray *tempArr = [NSMutableArray new]; if ([response[@"code"] integerValue] == 200) { NSArray *members = response[@"result"]; @@ -393,6 +336,9 @@ -(void) getGroupMembersWithGroupId:(NSString *)groupId Block:(void(^)(NSMutableA member.userId = tempInfo[@"id"]; member.name = tempInfo[@"nickname"]; member.portraitUri = tempInfo[@"portraitUri"]; + if (!member.portraitUri || member.portraitUri <= 0) { + member.portraitUri = [RCDUtilities defaultUserPortrait:member]; + } [tempArr addObject:member]; } } @@ -400,42 +346,39 @@ -(void) getGroupMembersWithGroupId:(NSString *)groupId Block:(void(^)(NSMutableA if (block) { block(tempArr); } - - } failure:^(NSError *err) { - + block(nil); }]; } //加入群组 - (void)joinGroupWithGroupId:(NSString *)groupID - complete:(void (^)(BOOL))result -{ + complete:(void (^)(BOOL))result { [AFHttpTool joinGroupWithGroupId:groupID success:^(id response) { if ([response[@"code"] integerValue] == 200) { result(YES); + } else { + result(NO); } - } - failure:^(NSError *err) { + } failure:^(NSError *err) { result(NO); }]; } - //添加群组成员 - (void)addUsersIntoGroup:(NSString *)groupID usersId:(NSMutableArray *)usersId - complete:(void (^)(BOOL))result -{ + complete:(void (^)(BOOL))result { [AFHttpTool addUsersIntoGroup:groupID usersId:usersId success:^(id response) { if ([response[@"code"] integerValue] == 200) { result(YES); + } else { + result(NO); } - } - failure:^(NSError *err) { + } failure:^(NSError *err) { result(NO); }]; } @@ -443,45 +386,45 @@ - (void)addUsersIntoGroup:(NSString *)groupID //将用户踢出群组 - (void)kickUsersOutOfGroup:(NSString *)groupID usersId:(NSMutableArray *)usersId - complete:(void (^)(BOOL))result -{ + complete:(void (^)(BOOL))result { [AFHttpTool kickUsersOutOfGroup:groupID usersId:usersId success:^(id response) { if ([response[@"code"] integerValue] == 200) { result(YES); + } else { + result(NO); } - } - failure:^(NSError *err) { + } failure:^(NSError *err) { result(NO); }]; } //退出群组 --(void) quitGroupWithGroupId:(NSString *) groupID - complete:(void (^)(BOOL))result -{ +-(void)quitGroupWithGroupId:(NSString *) groupID + complete:(void (^)(BOOL))result { [AFHttpTool quitGroupWithGroupId:groupID success:^(id response) { if ([response[@"code"] integerValue] == 200) { result (YES); + } else { + result(NO); } - } failure:^(NSError *err) { result(NO); }]; } //解散群组 --(void) dismissGroupWithGroupId:(NSString *) groupID - complete:(void (^)(BOOL))result -{ +-(void)dismissGroupWithGroupId:(NSString *) groupID + complete:(void (^)(BOOL))result { [AFHttpTool dismissGroupWithGroupId:groupID success:^(id response) { if ([response[@"code"] integerValue] == 200) { - result (YES); + result(YES); + } else { + result(NO); } - } failure:^(NSError *err) { result(NO); }]; @@ -490,47 +433,42 @@ -(void) dismissGroupWithGroupId:(NSString *) groupID //修改群组名称 -(void)renameGroupWithGoupId:(NSString *) groupID groupName:(NSString *) groupName - complete:(void (^)(BOOL))result -{ + complete:(void (^)(BOOL))result { [AFHttpTool renameGroupWithGroupId:groupID GroupName:groupName success:^(id response) { if ([response[@"code"] integerValue] == 200) { - result (YES); + result(YES); + } else { + result(NO); } } failure:^(NSError *err) { result(NO); }]; - - } -- (void)joinGroup:(int)groupID withGroupName:(NSString *)groupName complete:(void (^)(BOOL))joinResult -{ +- (void)joinGroup:(int)groupID + withGroupName:(NSString *)groupName + complete:(void (^)(BOOL))joinResult { [AFHttpTool joinGroupByID:groupID success:^(id response) { NSString *code = [NSString stringWithFormat:@"%@",response[@"code"]]; - if (joinResult) { - if ([code isEqualToString:@"200"]) { - [[RCIMClient sharedRCIMClient]joinGroup:[NSString stringWithFormat:@"%d",groupID] groupName:groupName success:^{ - for (RCDGroupInfo *group in _allGroups) { - if ([group.groupId isEqualToString:[NSString stringWithFormat:@"%d",groupID]]) { - group.isJoin=YES; - [[RCDataBaseManager shareInstance] insertGroupToDB:group]; - } + if (joinResult && [code isEqualToString:@"200"]) { + [[RCIMClient sharedRCIMClient]joinGroup:[NSString stringWithFormat:@"%d",groupID] groupName:groupName success:^{ + for (RCDGroupInfo *group in _allGroups) { + if ([group.groupId isEqualToString:[NSString stringWithFormat:@"%d",groupID]]) { + group.isJoin=YES; + [[RCDataBaseManager shareInstance] insertGroupToDB:group]; } - - dispatch_async(dispatch_get_main_queue(), ^(void) { - joinResult(YES); - }); - - } error:^(RCErrorCode status) { - joinResult(NO); - }]; + } - }else{ + dispatch_async(dispatch_get_main_queue(), ^(void) { + joinResult(YES); + }); + } error:^(RCErrorCode status) { joinResult(NO); - } - + }]; + } else { + joinResult(NO); } } failure:^(id response) { if (joinResult) { @@ -539,28 +477,25 @@ - (void)joinGroup:(int)groupID withGroupName:(NSString *)groupName complete:(vo }]; } -- (void)quitGroup:(int)groupID complete:(void (^)(BOOL))result -{ +- (void)quitGroup:(int)groupID + complete:(void (^)(BOOL))result { [AFHttpTool quitGroupByID:groupID success:^(id response) { NSString *code = [NSString stringWithFormat:@"%@",response[@"code"]]; - if (result) { - if ([code isEqualToString:@"200"]) { - [[RCIMClient sharedRCIMClient] quitGroup:[NSString stringWithFormat:@"%d",groupID] success:^{ - result(YES); - for (RCDGroupInfo *group in _allGroups) { - if ([group.groupId isEqualToString:[NSString stringWithFormat:@"%d",groupID]]) { - group.isJoin=NO; - [[RCDataBaseManager shareInstance] insertGroupToDB:group]; - } + if (result && [code isEqualToString:@"200"]) { + [[RCIMClient sharedRCIMClient] quitGroup:[NSString stringWithFormat:@"%d",groupID] success:^{ + result(YES); + for (RCDGroupInfo *group in _allGroups) { + if ([group.groupId isEqualToString:[NSString stringWithFormat:@"%d",groupID]]) { + group.isJoin=NO; + [[RCDataBaseManager shareInstance] insertGroupToDB:group]; } - } error:^(RCErrorCode status) { - result(NO); - }]; - }else{ + } + } error:^(RCErrorCode status) { result(NO); - } - + }]; + } else { + result(NO); } } failure:^(id response) { if (result) { @@ -569,31 +504,26 @@ - (void)quitGroup:(int)groupID complete:(void (^)(BOOL))result }]; } -- (void)updateGroupById:(int)groupID withGroupName:(NSString*)groupName andintroduce:(NSString*)introduce complete:(void (^)(BOOL))result - -{ +- (void)updateGroupById:(int)groupID + withGroupName:(NSString*)groupName + andintroduce:(NSString*)introduce + complete:(void (^)(BOOL))result { __block typeof(id) weakGroupId = [NSString stringWithFormat:@"%d", groupID]; [AFHttpTool updateGroupByID:groupID withGroupName:groupName andGroupIntroduce:introduce success:^(id response) { NSString *code = [NSString stringWithFormat:@"%@",response[@"code"]]; - if (result) { - if ([code isEqualToString:@"200"]) { - - for (RCDGroupInfo *group in _allGroups) { - if ([group.groupId isEqualToString:weakGroupId]) { - group.groupName=groupName; - group.introduce=introduce; - } - + if (result && [code isEqualToString:@"200"]) { + for (RCDGroupInfo *group in _allGroups) { + if ([group.groupId isEqualToString:weakGroupId]) { + group.groupName=groupName; + group.introduce=introduce; } - dispatch_async(dispatch_get_main_queue(), ^(void) { - result(YES); - }); - - }else{ - result(NO); } - + dispatch_async(dispatch_get_main_queue(), ^(void) { + result(YES); + }); + } else { + result(NO); } } failure:^(id response) { if (result) { @@ -602,22 +532,20 @@ - (void)updateGroupById:(int)groupID withGroupName:(NSString*)groupName andintro }]; } -- (void)getSquareInfoCompletion:(void (^)(NSMutableArray* result))completion -{ +- (void)getSquareInfoCompletion:(void (^)(NSMutableArray* result))completion { [AFHttpTool getSquareInfoSuccess:^(id response) { if ([response[@"code"] integerValue] == 200) { completion(response[@"result"]); + } else { + completion(nil); } - - } Failure:^(NSError *err) { - + completion(nil); }]; } - -- (void)getFriends:(NSString *)userId complete:(void (^)(NSMutableArray*))friendList -{ +- (void)getFriends:(NSString *)userId + complete:(void (^)(NSMutableArray*))friendList { NSMutableArray* list = [NSMutableArray new]; [AFHttpTool getFriendListFromServer:userId @@ -628,25 +556,34 @@ - (void)getFriends:(NSString *)userId complete:(void (^)(NSMutableArray*))friend [_allFriends removeAllObjects]; NSArray * regDataArray = response[@"result"]; [[RCDataBaseManager shareInstance] clearFriendsData]; - for(int i = 0;i < regDataArray.count;i++){ + for(int i = 0;i < regDataArray.count;i++) { NSDictionary *dic = [regDataArray objectAtIndex:i]; // if([[dic objectForKey:@"status"] intValue] != 1) // continue; NSDictionary *userDic = dic[@"user"]; - RCDUserInfo*userInfo = [RCDUserInfo new]; - userInfo.userId = userDic[@"id"]; - userInfo.portraitUri = userDic[@"portraitUri"]; - userInfo.name = userDic[@"nickname"]; - userInfo.status = [NSString stringWithFormat:@"%@",[dic objectForKey:@"status"]]; - [list addObject:userInfo]; - [_allFriends addObject:userInfo]; - - RCUserInfo *user = [RCUserInfo new]; - user.userId = userDic[@"id"]; - user.portraitUri = userDic[@"portraitUri"];; - user.name = userDic[@"nickname"]; - [[RCDataBaseManager shareInstance] insertUserToDB:user]; - [[RCDataBaseManager shareInstance] insertFriendToDB:userInfo]; + if (![userDic[@"id"] isEqualToString:userId]) { + RCDUserInfo*userInfo = [RCDUserInfo new]; + userInfo.userId = userDic[@"id"]; + userInfo.name = userDic[@"nickname"]; + userInfo.portraitUri = userDic[@"portraitUri"]; + if (!userInfo.portraitUri || userInfo.portraitUri <= 0) { + userInfo.portraitUri = [RCDUtilities defaultUserPortrait:userInfo]; + } + userInfo.status = [NSString stringWithFormat:@"%@",[dic objectForKey:@"status"]]; + userInfo.updatedAt = [NSString stringWithFormat:@"%@",[dic objectForKey:@"updatedAt"]]; + [list addObject:userInfo]; + [_allFriends addObject:userInfo]; + + RCUserInfo *user = [RCUserInfo new]; + user.userId = userDic[@"id"]; + user.name = userDic[@"nickname"]; + user.portraitUri = userDic[@"portraitUri"]; + if (!user.portraitUri || user.portraitUri <= 0) { + user.portraitUri = [RCDUtilities defaultUserPortrait:user]; + } + [[RCDataBaseManager shareInstance] insertUserToDB:user]; + [[RCDataBaseManager shareInstance] insertFriendToDB:userInfo]; + } } dispatch_async(dispatch_get_main_queue(), ^(void) { friendList(list); @@ -655,81 +592,85 @@ - (void)getFriends:(NSString *)userId complete:(void (^)(NSMutableArray*))friend }else{ friendList(list); } - + } else { + friendList(nil); } } failure:^(id response) { if (friendList) { NSMutableArray *cacheList=[[NSMutableArray alloc]initWithArray:[[RCDataBaseManager shareInstance] getAllFriends]]; + for (RCDUserInfo *userInfo in cacheList) { + if (!userInfo.portraitUri || userInfo.portraitUri <= 0) { + userInfo.portraitUri = [RCDUtilities defaultUserPortrait:userInfo]; + } + } friendList(cacheList); } }]; } --(void) searchUserByPhone:(NSString *)phone - complete:(void (^)(NSMutableArray*))userList -{ +-(void)searchUserByPhone:(NSString *)phone + complete:(void (^)(NSMutableArray*))userList { NSMutableArray* list = [NSMutableArray new]; [AFHttpTool findUserByPhone:phone success:^(id response) { - if (userList) { - if ([response[@"code"] intValue] == 200) { - id result = response[@"result"]; - if([result respondsToSelector:@selector(intValue)]) return ; - if([result respondsToSelector:@selector(objectForKey:)]) - { - RCDUserInfo*userInfo = [RCDUserInfo new]; - userInfo.userId = [result objectForKey:@"id"]; - userInfo.portraitUri = [result objectForKey:@"portraitUri"]; - userInfo.name = [result objectForKey:@"nickname"]; - [list addObject:userInfo]; - dispatch_async(dispatch_get_main_queue(), ^(void) { - userList(list); - }); + if (userList && [response[@"code"] intValue] == 200) { + id result = response[@"result"]; + if([result respondsToSelector:@selector(intValue)]) return; + if([result respondsToSelector:@selector(objectForKey:)]) { + RCDUserInfo*userInfo = [RCDUserInfo new]; + userInfo.userId = [result objectForKey:@"id"]; + userInfo.name = [result objectForKey:@"nickname"]; + userInfo.portraitUri = [result objectForKey:@"portraitUri"]; + if (!userInfo.portraitUri || userInfo.portraitUri <= 0) { + userInfo.portraitUri = [RCDUtilities defaultUserPortrait:userInfo]; } - + [list addObject:userInfo]; + dispatch_async(dispatch_get_main_queue(), ^(void) { + userList(list); + }); } + } else { + userList(nil); } } failure:^(NSError *err) { - + userList(nil); }]; } -- (void)searchFriendListByEmail:(NSString*)email complete:(void (^)(NSMutableArray*))friendList -{ +- (void)searchFriendListByEmail:(NSString*)email + complete:(void (^)(NSMutableArray*))friendList { NSMutableArray* list = [NSMutableArray new]; [AFHttpTool searchFriendListByEmail:email success:^(id response) { NSString *code = [NSString stringWithFormat:@"%@",response[@"code"]]; - if (friendList) { if ([code isEqualToString:@"200"]) { - id result = response[@"result"]; - if([result respondsToSelector:@selector(intValue)]) return ; - if([result respondsToSelector:@selector(objectForKey:)]) - { + if([result respondsToSelector:@selector(intValue)]) return; + if([result respondsToSelector:@selector(objectForKey:)]) { RCDUserInfo*userInfo = [RCDUserInfo new]; NSNumber *idNum = [result objectForKey:@"id"]; userInfo.userId = [NSString stringWithFormat:@"%d",idNum.intValue]; - userInfo.portraitUri = [result objectForKey:@"portrait"]; userInfo.name = [result objectForKey:@"username"]; + userInfo.portraitUri = [result objectForKey:@"portrait"]; + if (!userInfo.portraitUri || userInfo.portraitUri.length <= 0) { + userInfo.portraitUri = [RCDUtilities defaultUserPortrait:userInfo]; + } [list addObject:userInfo]; - - } - else - { + } else { NSArray * regDataArray = response[@"result"]; - for(int i = 0;i < regDataArray.count;i++){ - + for(int i = 0;i < regDataArray.count;i++) { NSDictionary *dic = [regDataArray objectAtIndex:i]; RCDUserInfo*userInfo = [RCDUserInfo new]; NSNumber *idNum = [dic objectForKey:@"id"]; userInfo.userId = [NSString stringWithFormat:@"%d",idNum.intValue]; - userInfo.portraitUri = [dic objectForKey:@"portrait"]; userInfo.name = [dic objectForKey:@"username"]; + userInfo.portraitUri = [dic objectForKey:@"portrait"]; + if (!userInfo.portraitUri || userInfo.portraitUri.length <= 0) { + userInfo.portraitUri = [RCDUtilities defaultUserPortrait:userInfo]; + } [list addObject:userInfo]; } - } dispatch_async(dispatch_get_main_queue(), ^(void) { @@ -739,7 +680,6 @@ - (void)searchFriendListByEmail:(NSString*)email complete:(void (^)(NSMutableArr }else{ friendList(list); } - } } failure:^(id response) { if (friendList) { @@ -748,34 +688,30 @@ - (void)searchFriendListByEmail:(NSString*)email complete:(void (^)(NSMutableArr }]; } -- (void)searchFriendListByName:(NSString*)name complete:(void (^)(NSMutableArray*))friendList -{ +- (void)searchFriendListByName:(NSString*)name + complete:(void (^)(NSMutableArray*))friendList { NSMutableArray* list = [NSMutableArray new]; [AFHttpTool searchFriendListByName:name success:^(id response) { NSString *code = [NSString stringWithFormat:@"%@",response[@"code"]]; - - if (friendList) { - if ([code isEqualToString:@"200"]) { - - NSArray * regDataArray = response[@"result"]; - for(int i = 0;i < regDataArray.count;i++){ - - NSDictionary *dic = [regDataArray objectAtIndex:i]; - RCDUserInfo*userInfo = [RCDUserInfo new]; - NSNumber *idNum = [dic objectForKey:@"id"]; - userInfo.userId = [NSString stringWithFormat:@"%d",idNum.intValue]; - userInfo.portraitUri = [dic objectForKey:@"portrait"]; - userInfo.name = [dic objectForKey:@"username"]; - [list addObject:userInfo]; + if (friendList && [code isEqualToString:@"200"]) { + NSArray * regDataArray = response[@"result"]; + for(int i = 0;i < regDataArray.count;i++){ + NSDictionary *dic = [regDataArray objectAtIndex:i]; + RCDUserInfo*userInfo = [RCDUserInfo new]; + NSNumber *idNum = [dic objectForKey:@"id"]; + userInfo.userId = [NSString stringWithFormat:@"%d",idNum.intValue]; + userInfo.name = [dic objectForKey:@"username"]; + userInfo.portraitUri = [dic objectForKey:@"portrait"]; + if (!userInfo.portraitUri || userInfo.portraitUri.length <= 0) { + userInfo.portraitUri = [RCDUtilities defaultUserPortrait:userInfo]; } - dispatch_async(dispatch_get_main_queue(), ^(void) { - friendList(list); - }); - - }else{ - friendList(list); + [list addObject:userInfo]; } - + dispatch_async(dispatch_get_main_queue(), ^(void) { + friendList(list); + }); + } else { + friendList(nil); } } failure:^(id response) { if (friendList) { @@ -783,93 +719,53 @@ - (void)searchFriendListByName:(NSString*)name complete:(void (^)(NSMutableArray } }]; } -- (void)requestFriend:(NSString*)userId complete:(void (^)(BOOL))result -{ + +- (void)requestFriend:(NSString*)userId + complete:(void (^)(BOOL))result { [AFHttpTool inviteUser:userId success:^(id response) { - if (result) { - if ([response[@"code"] intValue] == 200) { - dispatch_async(dispatch_get_main_queue(), ^(void) { - result(YES); - }); - - }else{ - result(NO); - } + if (result && [response[@"code"] intValue] == 200) { + dispatch_async(dispatch_get_main_queue(), ^(void) { + result(YES); + }); + } else { + result(NO); } } failure:^(NSError *err) { result(NO); }]; -// [AFHttpTool requestFriend:userId success:^(id response) { -// NSString *code = [NSString stringWithFormat:@"%@",response[@"code"]]; -// -// if (result) { -// if ([code isEqualToString:@"200"]) { -// dispatch_async(dispatch_get_main_queue(), ^(void) { -// result(YES); -// }); -// -// }else{ -// result(NO); -// } -// -// } -// } failure:^(id response) { -// if (result) { -// result(NO); -// } -// }]; -} -- (void)processInviteFriendRequest:(NSString*)userId complete:(void (^)(BOOL))result -{ -// NSDate* dat = [NSDate dateWithTimeIntervalSinceNow:0]; -// NSTimeInterval a=[dat timeIntervalSince1970]; -// NSString *timeString = [NSString stringWithFormat:@"%.0f", a]; - - [AFHttpTool processInviteFriendRequest:userId - success:^(id response) { - if ([response[@"code"] intValue] == 200) { - dispatch_async(dispatch_get_main_queue(), ^(void) { - result(YES); - }); - } - } failure:^(id response) { - if (result) { - result(NO); - } - }]; - -// [AFHttpTool processInviteFriendRequest:userId -// currentUseId:[RCIM sharedRCIM].currentUserInfo.userId -// time:timeString -// success:^(id response) { -// if ([response[@"code"] intValue] == 200) { -// dispatch_async(dispatch_get_main_queue(), ^(void) { -// result(YES); -// }); -// } -// } failure:^(id response) { -// if (result) { -// result(NO); -// } -// }]; -} - - -- (void)processRequestFriend:(NSString*)userId withIsAccess:(BOOL)isAccess complete:(void (^)(BOOL))result -{ +} + +- (void)processInviteFriendRequest:(NSString*)userId + complete:(void (^)(BOOL))result { + [AFHttpTool + processInviteFriendRequest:userId + success:^(id response) { + if ([response[@"code"] intValue] == 200) { + dispatch_async(dispatch_get_main_queue(), ^(void) { + result(YES); + }); + } else { + result(NO); + } + } failure:^(id response) { + if (result) { + result(NO); + } + }]; +} + +- (void)processRequestFriend:(NSString*)userId + withIsAccess:(BOOL)isAccess + complete:(void (^)(BOOL))result { [AFHttpTool processRequestFriend:userId withIsAccess:isAccess success:^(id response) { NSString *code = [NSString stringWithFormat:@"%@",response[@"code"]]; - - if (result) { - if ([code isEqualToString:@"200"]) { - dispatch_async(dispatch_get_main_queue(), ^(void) { - result(YES); - }); - - }else{ - result(NO); - } + if (result && [code isEqualToString:@"200"]) { + dispatch_async(dispatch_get_main_queue(), ^(void) { + result(YES); + }); + } else { + result(NO); } } failure:^(id response) { if (result) { @@ -878,22 +774,17 @@ - (void)processRequestFriend:(NSString*)userId withIsAccess:(BOOL)isAccess compl }]; } -- (void)deleteFriend:(NSString*)userId complete:(void (^)(BOOL))result -{ +- (void)deleteFriend:(NSString*)userId + complete:(void (^)(BOOL))result { [AFHttpTool deleteFriend:userId success:^(id response) { NSString *code = [NSString stringWithFormat:@"%@",response[@"code"]]; - - if (result) { - if ([code isEqualToString:@"200"]) { - dispatch_async(dispatch_get_main_queue(), ^(void) { - result(YES); - }); - [[RCDataBaseManager shareInstance]deleteFriendFromDB:userId]; - - }else{ - result(NO); - } - + if (result && [code isEqualToString:@"200"]) { + dispatch_async(dispatch_get_main_queue(), ^(void) { + result(YES); + }); + [[RCDataBaseManager shareInstance]deleteFriendFromDB:userId]; + } else { + result(NO); } } failure:^(id response) { if (result) { @@ -902,14 +793,15 @@ - (void)deleteFriend:(NSString*)userId complete:(void (^)(BOOL))result }]; } --(void) AddToBlacklist:(NSString*) userId - complete:(void (^)(BOOL result))result -{ +-(void)AddToBlacklist:(NSString*) userId + complete:(void (^)(BOOL result))result { [AFHttpTool addToBlacklist:userId success:^(id response) { NSString *code = [NSString stringWithFormat:@"%@",response[@"code"]]; if ([code isEqualToString:@"200"]) { - result(YES); + result(YES); + } else { + result(NO); } } failure:^(NSError *err) { if (result) { @@ -918,14 +810,15 @@ -(void) AddToBlacklist:(NSString*) userId }]; } --(void) RemoveToBlacklist:(NSString*) userId - complete:(void (^)(BOOL result))result -{ +-(void)RemoveToBlacklist:(NSString*) userId + complete:(void (^)(BOOL result))result { [AFHttpTool removeToBlacklist:userId success:^(id response) { NSString *code = [NSString stringWithFormat:@"%@",response[@"code"]]; if ([code isEqualToString:@"200"]) { result(YES); + } else { + result(NO); } } failure:^(NSError *err) { if (result) { @@ -934,13 +827,14 @@ -(void) RemoveToBlacklist:(NSString*) userId }]; } --(void)getBlacklistcomplete:(void (^)(NSMutableArray *))blacklist -{ +-(void)getBlacklistcomplete:(void (^)(NSMutableArray *))blacklist { [AFHttpTool getBlacklistsuccess:^(id response) { NSString *code = [NSString stringWithFormat:@"%@",response[@"code"]]; if ([code isEqualToString:@"200"]) { NSMutableArray *result = response[@"result"]; blacklist(result); + } else { + blacklist(nil); } } failure:^(NSError *err) { blacklist(nil); @@ -959,18 +853,19 @@ - (void)updateName:(NSString*) userName - (void)updateUserInfo:(NSString *) userID success:(void (^)(RCUserInfo * user))success - failure:(void (^)(NSError* err))failure{ - [AFHttpTool getUserById:userID success:^(id response) { + failure:(void (^)(NSError* err))failure { + [AFHttpTool getUserInfo:userID success:^(id response) { if (response) { NSString *code = [NSString stringWithFormat:@"%@",response[@"code"]]; if ([code isEqualToString:@"200"]) { NSDictionary *dic = response[@"result"]; - // NSLog(@"isMainThread > %d", [NSThread isMainThread]); RCUserInfo *user = [RCUserInfo new]; - NSNumber *idNum = [dic objectForKey:@"id"]; - user.userId = [NSString stringWithFormat:@"%d",idNum.intValue]; - user.portraitUri = [dic objectForKey:@"portrait"]; - user.name = [dic objectForKey:@"username"]; + user.userId = dic[@"id"]; + user.name = [dic objectForKey:@"nickname"]; + user.portraitUri = [dic objectForKey:@"portraitUri"]; + if (!user.portraitUri || user.portraitUri.length <= 0) { + user.portraitUri = [RCDUtilities defaultUserPortrait:user]; + } [[RCDataBaseManager shareInstance] insertUserToDB:user]; if (success) { dispatch_async(dispatch_get_main_queue(), ^{ @@ -979,9 +874,8 @@ - (void)updateUserInfo:(NSString *) userID } } } - } failure:^(NSError *err) { - failure(err); + failure(err); }]; } @@ -989,24 +883,18 @@ - (void)updateUserInfo:(NSString *) userID -(void)uploadImageToQiNiu:(NSString *)userId ImageData:(NSData *)image success:(void (^)(NSString *url))success - failure:(void (^)(NSError* err))failure{ - + failure:(void (^)(NSError* err))failure { [AFHttpTool uploadFile:image userId:userId - success:^(id response) - { - if ([response[@"key"] length] > 0) { - NSString *key = response[@"key"]; - NSString *QiNiuDomai = [DEFAULTS objectForKey:@"QiNiuDomain"]; - NSString *imageUrl = [NSString stringWithFormat:@"http://%@/%@",QiNiuDomai,key]; - success(imageUrl); - } - } failure:^(NSError *err) - { - - }]; - - - + success:^(id response) { + if ([response[@"key"] length] > 0) { + NSString *key = response[@"key"]; + NSString *QiNiuDomai = [DEFAULTS objectForKey:@"QiNiuDomain"]; + NSString *imageUrl = [NSString stringWithFormat:@"http://%@/%@",QiNiuDomai,key]; + success(imageUrl); + } + } failure:^(NSError *err) { + failure(err); + }]; } @end diff --git a/RCDMessageNoDisturbSettingController.m b/RCDMessageNoDisturbSettingController.m index f782a8e0..074fe0ff 100644 --- a/RCDMessageNoDisturbSettingController.m +++ b/RCDMessageNoDisturbSettingController.m @@ -117,7 +117,6 @@ -(void)viewWillDisappear:(BOOL)animated{ int timeDif = timeDiff/60; [[RCIMClient sharedRCIMClient] setNotificationQuietHours:startTime spanMins:timeDif success:^{ - [RCIM sharedRCIM].disableMessageNotificaiton = YES; [UserDefaults setObject:startTime forKey:@"startTime"]; [UserDefaults setObject:endTime forKey:@"endTime"]; } error:^(RCErrorCode status) { @@ -257,7 +256,6 @@ - (void)setSwitchState:(UISwitch *) swich{ __weak typeof(&*self) blockSelf = self; [[RCIMClient sharedRCIMClient] setNotificationQuietHours:startTimeStr spanMins:timeDif success:^{ - [RCIM sharedRCIM].disableMessageNotificaiton = YES; } error:^(RCErrorCode status) { dispatch_async(dispatch_get_main_queue(), ^{ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"设置失败" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil, nil]; @@ -268,7 +266,6 @@ - (void)setSwitchState:(UISwitch *) swich{ }else{ __weak typeof(&*self) blockSelf = self; [[RCIMClient sharedRCIMClient] removeNotificationQuietHours:^{ - [RCIM sharedRCIM].disableMessageNotificaiton = NO; } error:^(RCErrorCode status) { dispatch_async(dispatch_get_main_queue(), ^{ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"关闭失败" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil, nil]; diff --git a/RCDPersonDetailViewController.h b/RCDPersonDetailViewController.h index d4dd7d17..88165a6c 100644 --- a/RCDPersonDetailViewController.h +++ b/RCDPersonDetailViewController.h @@ -16,5 +16,7 @@ @property (nonatomic,strong) RCUserInfo *userInfo; @property (weak, nonatomic) IBOutlet UILabel *lblName; @property (weak, nonatomic) IBOutlet UIImageView *ivAva; - +@property (weak, nonatomic) IBOutlet UIButton *conversationBtn; +@property (weak, nonatomic) IBOutlet UIButton *audioCallBtn; +@property (weak, nonatomic) IBOutlet UIButton *videoCallBtn; @end diff --git a/RCDPersonDetailViewController.m b/RCDPersonDetailViewController.m index a39915d2..bdd52cdf 100644 --- a/RCDPersonDetailViewController.m +++ b/RCDPersonDetailViewController.m @@ -65,7 +65,13 @@ - (void)viewDidLoad { } }]; + self.conversationBtn.layer.borderWidth = 0.5; + self.audioCallBtn.layer.borderWidth = 0.5; + self.videoCallBtn.layer.borderWidth = 0.5; + self.conversationBtn.layer.borderColor = [HEXCOLOR(0x0181dd) CGColor]; + self.audioCallBtn.layer.borderColor = [HEXCOLOR(0xc9c9c9) CGColor]; + self.videoCallBtn.layer.borderColor = [HEXCOLOR(0xc9c9c9) CGColor]; } - (IBAction)btnConversation:(id)sender { @@ -83,15 +89,19 @@ - (IBAction)btnVoIP:(id)sender { [[RCCall sharedRCCall] startSingleCall:self.userInfo.userId mediaType:RCCallMediaAudio]; } +- (IBAction)btnVideoCall:(id)sender { + //视频通话 + [[RCCall sharedRCCall] startSingleCall:self.userInfo.userId mediaType:RCCallMediaVideo]; +} -(void) rightBarButtonItemClicked:(id) sender { if (self.inBlackList) { - UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"解除好友关系", @"取消黑名单", nil]; + UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"取消黑名单", nil]; [actionSheet showInView:self.view]; } else { - UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"解除好友关系", @"加入黑名单", nil]; + UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"加入黑名单", nil]; [actionSheet showInView:self.view]; } } @@ -106,18 +116,18 @@ - (void)didReceiveMemoryWarning { -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { switch (buttonIndex) { +// case 0: +// { +// //解除好友关系 +// [RCDHTTPTOOL deleteFriend:self.userInfo.userId complete:^(BOOL result) { +// UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:@"删除好友成功!" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil +// , nil]; +// [alertView show]; +// }]; +// +// } +// break; case 0: - { - //解除好友关系 - [RCDHTTPTOOL deleteFriend:self.userInfo.userId complete:^(BOOL result) { - UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:@"删除好友成功!" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil - , nil]; - [alertView show]; - }]; - - } - break; - case 1: { MBProgressHUD* hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; diff --git a/RCDPrivacyTableViewController.h b/RCDPrivacyTableViewController.h new file mode 100644 index 00000000..7513084a --- /dev/null +++ b/RCDPrivacyTableViewController.h @@ -0,0 +1,13 @@ +// +// RCDPrivacyTableViewController.h +// RCloudMessage +// +// Created by Jue on 16/6/28. +// Copyright © 2016年 RongCloud. All rights reserved. +// + +#import + +@interface RCDPrivacyTableViewController : UITableViewController + +@end diff --git a/RCDPrivacyTableViewController.m b/RCDPrivacyTableViewController.m new file mode 100644 index 00000000..2f4338fc --- /dev/null +++ b/RCDPrivacyTableViewController.m @@ -0,0 +1,96 @@ +// +// RCDPrivacyTableViewController.m +// RCloudMessage +// +// Created by Jue on 16/6/28. +// Copyright © 2016年 RongCloud. All rights reserved. +// + +#import "RCDPrivacyTableViewController.h" + +@interface RCDPrivacyTableViewController () + +@end + +@implementation RCDPrivacyTableViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + // Uncomment the following line to preserve selection between presentations. + // self.clearsSelectionOnViewWillAppear = NO; + + // Uncomment the following line to display an Edit button in the navigation bar for this view controller. + // self.navigationItem.rightBarButtonItem = self.editButtonItem; + self.navigationItem.title = @"隐私"; +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +#pragma mark - Table view data source + +- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section +{ + if (section == 0) { + return 15.f; + } + return 5.f; +} +/* +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath]; + + // Configure the cell... + + return cell; +} +*/ + +/* +// Override to support conditional editing of the table view. +- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { + // Return NO if you do not want the specified item to be editable. + return YES; +} +*/ + +/* +// Override to support editing the table view. +- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { + if (editingStyle == UITableViewCellEditingStyleDelete) { + // Delete the row from the data source + [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; + } else if (editingStyle == UITableViewCellEditingStyleInsert) { + // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view + } +} +*/ + +/* +// Override to support rearranging the table view. +- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { +} +*/ + +/* +// Override to support conditional rearranging of the table view. +- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { + // Return NO if you do not want the item to be re-orderable. + return YES; +} +*/ + +/* +#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. +} +*/ + +@end diff --git a/RCDPrivateSettingsTableViewController.m b/RCDPrivateSettingsTableViewController.m index 466ff67c..39d8bdc0 100644 --- a/RCDPrivateSettingsTableViewController.m +++ b/RCDPrivateSettingsTableViewController.m @@ -130,15 +130,18 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N cell.TitleLabel.text = @"新消息通知"; cell.SwitchButton.hidden = NO; cell.SwitchButton.on = enableNotification; + [cell.SwitchButton removeTarget:self action:@selector(clickIsTopBtn:) forControlEvents:UIControlEventValueChanged]; + [cell.SwitchButton addTarget:self action:@selector(clickNotificationBtn:) forControlEvents:UIControlEventValueChanged]; + } break; case 1: { - cell.TitleLabel.text = @"会话置顶"; + cell.TitleLabel.text = @"会话置顶"; cell.SwitchButton.hidden = NO; cell.SwitchButton.on = currentConversation.isTop; [cell.SwitchButton addTarget:self @@ -227,8 +230,10 @@ - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { if (actionSheet.tag == 100) { - [[RCIMClient sharedRCIMClient] clearMessages:ConversationType_PRIVATE targetId:self.userId]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"ClearHistoryMsg" object:nil]; + if (buttonIndex == 0) { + [[RCIMClient sharedRCIMClient] clearMessages:ConversationType_PRIVATE targetId:self.userId]; + [[NSNotificationCenter defaultCenter] postNotificationName:@"ClearHistoryMsg" object:nil]; + } } } diff --git a/RCDPublicServiceListViewController.m b/RCDPublicServiceListViewController.m index 26d259e3..1231a4bd 100644 --- a/RCDPublicServiceListViewController.m +++ b/RCDPublicServiceListViewController.m @@ -8,6 +8,7 @@ #import "RCDPublicServiceListViewController.h" #import "RCDChatViewController.h" + @interface RCDPublicServiceListViewController () @end @@ -17,6 +18,14 @@ @implementation RCDPublicServiceListViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. + + //自定义rightBarButtonItem + UIButton *rightBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 17, 17)]; + [rightBtn setImage:[UIImage imageNamed:@"add"] forState:UIControlStateNormal]; + [rightBtn addTarget:self action:@selector(pushAddPublicService:) forControlEvents:UIControlEventTouchUpInside]; + UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithCustomView:rightBtn]; + [rightBtn setTintColor:[UIColor whiteColor]]; + self.navigationItem.rightBarButtonItem = rightButton; } - (void)didReceiveMemoryWarning { @@ -36,6 +45,18 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath [self.navigationController pushViewController:_conversationVC animated:YES]; } +/** + * 添加公众号 + * + * @param sender sender description + */ +- (void) pushAddPublicService:(id) sender +{ + RCPublicServiceSearchViewController *searchFirendVC = [[RCPublicServiceSearchViewController alloc] init]; + [self.navigationController pushViewController:searchFirendVC animated:YES]; + +} + /* #pragma mark - Navigation diff --git a/RCDSquareTableViewCell.h b/RCDSquareTableViewCell.h index cc94757b..d05d90a6 100644 --- a/RCDSquareTableViewCell.h +++ b/RCDSquareTableViewCell.h @@ -10,13 +10,8 @@ @interface RCDSquareTableViewCell : UITableViewCell -@property (weak, nonatomic) IBOutlet UIImageView *GroupPortrait; +@property (weak, nonatomic) IBOutlet UIImageView *ChatroomPortrait; -@property (weak, nonatomic) IBOutlet UILabel *GroupName; +@property (weak, nonatomic) IBOutlet UILabel *ChatroomName; -@property (weak, nonatomic) IBOutlet UILabel *GroupNumber; - -@property (weak, nonatomic) IBOutlet UIButton *JoinGroupBtn; - -@property (weak, nonatomic) IBOutlet UIButton *ChatBtn; @end diff --git a/RCDSquareTableViewController.m b/RCDSquareTableViewController.m index 2aacdb58..3c056187 100644 --- a/RCDSquareTableViewController.m +++ b/RCDSquareTableViewController.m @@ -24,18 +24,16 @@ @interface RCDSquareTableViewController () @implementation RCDSquareTableViewController { - NSMutableArray *groupIdList; - NSMutableArray *groupList; NSMutableArray *chatRoomIdList; NSMutableArray *chatRoomNames; - NSMutableArray *isJoinIndex; - NSMutableArray *groupNames; MBProgressHUD* hud ; } - (void)viewDidLoad { [super viewDidLoad]; + self.tabBarItem.selectedImage = [[UIImage imageNamed:@"square_hover"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; + // Uncomment the following line to preserve selection between presentations. // self.clearsSelectionOnViewWillAppear = NO; @@ -44,9 +42,6 @@ - (void)viewDidLoad { self.tableView.tableFooterView = [UIView new]; - groupNames = [NSMutableArray new]; - groupIdList = [NSMutableArray new]; - groupList = [NSMutableArray new]; chatRoomNames = [NSMutableArray new]; chatRoomIdList = [NSMutableArray new]; @@ -54,105 +49,33 @@ - (void)viewDidLoad { NSMutableArray *squareInfoList = [userDefaults mutableArrayValueForKey:@"SquareInfoList"]; for (NSDictionary *info in squareInfoList) { NSString *type = info[@"type"]; - if ([type isEqualToString:@"group"]) { - [groupIdList addObject:info[@"id"]]; - [groupList addObject:info]; - [groupNames addObject:info[@"name"]]; - } if ([type isEqualToString:@"chatroom"]) { [chatRoomIdList addObject:info[@"id"]]; [chatRoomNames addObject:info[@"name"]]; } } - isJoinIndex = [NSMutableArray new]; - for (int i = 0; i < groupIdList.count; i++) { - RCDGroupInfo *group=[[RCDataBaseManager shareInstance] getGroupByGroupId:groupIdList[i]]; - if (group != nil) { - [isJoinIndex addObject:[NSString stringWithFormat:@"%d",i]]; - } - } [self.tableView reloadData]; [RCDHTTPTOOL getSquareInfoCompletion:^(NSMutableArray *result) { for (NSDictionary *info in result) { NSString *type = info[@"type"]; - if ([type isEqualToString:@"group"]) { - [groupIdList addObject:info[@"id"]]; - [groupList addObject:info]; - [groupNames addObject:info[@"name"]]; - } if ([type isEqualToString:@"chatroom"]) { [chatRoomIdList addObject:info[@"id"]]; [chatRoomNames addObject:info[@"name"]]; } } - //保存默认群组id和聊天室id - [DEFAULTS setObject:groupIdList forKey:@"defaultGroupIdList"]; + //保存默认聊天室id [DEFAULTS setObject:chatRoomIdList forKey:@"defaultChatRoomIdList"]; [DEFAULTS synchronize]; - [RCDHTTPTOOL getMyGroupsWithBlock:^(NSMutableArray *result) - { - isJoinIndex = [NSMutableArray new]; - for (RCDGroupInfo *group in result) { - NSString *groupId = group.groupId; - for (int i = 0; i < groupIdList.count; i++) - { - if ([groupIdList[i] isEqualToString:groupId]) { - [isJoinIndex addObject:[NSString stringWithFormat:@"%d",i]]; - } - } - } - [self.tableView reloadData]; - }]; }]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(quitDefaultGroup:) - name:@"quitDefaultGroup" object:nil]; } -(void)viewWillAppear:(BOOL)animated { -// UILabel *titleView = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 44)]; -// titleView.backgroundColor = [UIColor clearColor]; -// titleView.font = [UIFont boldSystemFontOfSize:19]; -// titleView.textColor = [UIColor whiteColor]; -// titleView.textAlignment = NSTextAlignmentCenter; -// titleView.text = @"广场"; -// self.tabBarController.navigationItem.titleView = titleView; + self.tabBarController.navigationItem.title = @"发现"; self.tabBarController.navigationItem.rightBarButtonItem = nil; - -// if (groupNames == nil || groupNames.count == 0) { -// return; -// } - [RCDHTTPTOOL getSquareInfoCompletion:^(NSMutableArray *result) { - [groupList removeAllObjects]; - for (int i = 0; i < result.count; i++) { - NSDictionary *info = result[i]; - NSString *type = info[@"type"]; - if ([type isEqualToString:@"group"]) { - [groupList addObject:info]; - RCDSquareTableViewCell *cell = (RCDSquareTableViewCell *)[self.tableView viewWithTag:i + 100]; - cell.GroupNumber.text = [NSString stringWithFormat:@"%@/%@",info[@"memberCount"],info[@"maxMemberCount"]]; - } - } - }]; - - [RCDHTTPTOOL getMyGroupsWithBlock:^(NSMutableArray *result) - { - isJoinIndex = [NSMutableArray new]; - for (RCDGroupInfo *group in result) { - NSString *groupId = group.groupId; - for (int i = 0; i < groupIdList.count; i++) - { - if ([groupIdList[i] isEqualToString:groupId]) { - [isJoinIndex addObject:[NSString stringWithFormat:@"%d",i]]; - } - } - } - [self.tableView reloadData]; - }]; + } - (void)didReceiveMemoryWarning { @@ -163,28 +86,24 @@ - (void)didReceiveMemoryWarning { #pragma mark - Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - if (groupNames.count == 0 ||chatRoomNames.count == 0) { + if (chatRoomNames.count == 0) { return 0; } else { - return 2; + return 1; } } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { NSInteger rows; - if (groupNames.count == 0 || chatRoomNames.count == 0) { + if (chatRoomNames.count == 0) { rows = 0; } else{ switch (section) { case 0: - rows = 1; - break; - - case 1: - rows = 3; + rows = chatRoomNames.count; break; default: @@ -197,139 +116,38 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - if (indexPath.section == 0) { if (chatRoomNames.count == 0 || chatRoomNames == nil) { return nil; } - static NSString *CellIdentifier = @"RCDSquareChatRoomTableViewCell"; - RCDSquareChatRoomTableViewCell *cell = (RCDSquareChatRoomTableViewCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; - cell.selectionStyle = UITableViewCellSelectionStyleNone; - cell.ChatRoom1Image.userInteractionEnabled = YES; - cell.ChatRoom1Image.tag = 10; - cell.ChatRoom1Title.text = [chatRoomNames objectAtIndex:0]; - cell.ChatRoom2Image.userInteractionEnabled = YES; - cell.ChatRoom2Image.tag = 11; - cell.ChatRoom2Title.text = [chatRoomNames objectAtIndex:1]; - cell.ChatRoom3Image.userInteractionEnabled = YES; - cell.ChatRoom3Image.tag = 12; - cell.ChatRoom3Title.text = [chatRoomNames objectAtIndex:2]; - cell.ChatRoom4Image.userInteractionEnabled = YES; - cell.ChatRoom4Image.tag = 13; - cell.ChatRoom4Title.text = [chatRoomNames objectAtIndex:3]; - - UITapGestureRecognizer *clickCR1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gotoChatRoomConversation:)]; - [cell.ChatRoom1Image addGestureRecognizer:clickCR1]; - - UITapGestureRecognizer *clickCR2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gotoChatRoomConversation:)]; - [cell.ChatRoom2Image addGestureRecognizer:clickCR2]; - - UITapGestureRecognizer *clickCR3 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gotoChatRoomConversation:)]; - [cell.ChatRoom3Image addGestureRecognizer:clickCR3]; - - UITapGestureRecognizer *clickCR4 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gotoChatRoomConversation:)]; - [cell.ChatRoom4Image addGestureRecognizer:clickCR4]; - - - // Configure the cell... - - return cell; - } - if (groupNames.count == 0 || groupNames == nil) { - return nil; - } static NSString *CellIdentifier = @"RCDSquareTableViewCell"; RCDSquareTableViewCell *cell = (RCDSquareTableViewCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; cell.selectionStyle = UITableViewCellSelectionStyleNone; - cell.tag = indexPath.row + 100; -// NSArray *groupIcons = [[NSArray alloc] initWithObjects:@"group_1",@"group_2",@"group_3", nil]; + + NSArray *chatroomIcons = [[NSArray alloc] initWithObjects:@"icon_1-1",@"icon_2-1",@"icon_3-1",@"icon_4-1", nil]; // Configure the cell... - cell.GroupName.text = groupNames[indexPath.row]; - if (groupList.count > 0) { - NSDictionary *groupInfo = groupList[indexPath.row]; - cell.GroupNumber.text = [NSString stringWithFormat:@"%@/%@",groupInfo[@"memberCount"],groupInfo[@"maxMemberCount"]]; - - DefaultPortraitView *defaultPortrait = [[DefaultPortraitView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; - [defaultPortrait setColorAndLabel:groupInfo[@"id"] Nickname:groupInfo[@"name"]]; - UIImage *portrait = [defaultPortrait imageFromView]; - cell.GroupPortrait.image = portrait; - cell.GroupPortrait.layer.masksToBounds = YES; - cell.GroupPortrait.layer.cornerRadius = 6.f; - } -// cell.GroupPortrait.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@",groupIcons[indexPath.row]]]; - [cell.JoinGroupBtn setBackgroundColor:[UIColor colorWithHexString:@"0195ff" alpha:1.0f]]; - [cell.JoinGroupBtn setTitle:@"加入" forState:UIControlStateNormal]; - [cell.JoinGroupBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; - cell.JoinGroupBtn.layer.cornerRadius = 6.f; - cell.JoinGroupBtn.hidden = YES; - cell.JoinGroupBtn.tag = indexPath.row; - [cell.JoinGroupBtn addTarget:self action:@selector(clickJoinGroupBtn:) forControlEvents:UIControlEventTouchUpInside]; - - [cell.ChatBtn setBackgroundColor:[UIColor colorWithHexString:@"F5F5F5" alpha:1.0f]]; - [cell.ChatBtn setTitle:@"聊天" forState:UIControlStateNormal]; - [cell.ChatBtn setTitleColor:[UIColor colorWithHexString:@"0195ff" alpha:1.0f] forState:UIControlStateNormal]; - cell.ChatBtn.layer.cornerRadius = 6.f; - cell.ChatBtn.hidden = YES; - cell.ChatBtn.tag = indexPath.row; - [cell.ChatBtn addTarget:self action:@selector(clickGroupChatBtn:) forControlEvents:UIControlEventTouchUpInside]; - + cell.ChatroomName.text = chatRoomNames[indexPath.row]; + cell.ChatroomPortrait.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@",chatroomIcons[indexPath.row]]]; - if (isJoinIndex != nil) - { -// if (isJoinIndex.count == 0) { -// cell.ChatBtn.hidden = YES; -// cell.JoinGroupBtn.hidden = NO; -// } - if (isJoinIndex.count > 0) - { - BOOL isJoin = NO; - for (NSString *index in isJoinIndex) { - if (index.intValue == indexPath.row) { - isJoin = YES; - break; - } - } - - if (isJoin == NO) { - cell.ChatBtn.hidden = YES; - cell.JoinGroupBtn.hidden = NO; - } else { - cell.ChatBtn.hidden = NO; - cell.JoinGroupBtn.hidden = YES; - } - } - else - { - cell.ChatBtn.hidden = YES; - cell.JoinGroupBtn.hidden = NO; - } - } - else - { - cell.ChatBtn.hidden = YES; - cell.JoinGroupBtn.hidden = NO; - } return cell; } - (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { - UIView *sectionHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, 40)]; + UIView *sectionHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, 35)]; + sectionHeaderView.backgroundColor = HEXCOLOR(0xf0f0f6); + sectionHeaderView.layer.borderColor = [HEXCOLOR(0xdfdfdd) CGColor]; + sectionHeaderView.layer.borderWidth = 0.5; - UIView *littleView = [[UIView alloc] initWithFrame:CGRectMake(0, 10, 3, 20)]; - littleView.backgroundColor = [UIColor colorWithHexString:@"0195ff" alpha:1.0f]; - [sectionHeaderView addSubview:littleView]; + UILabel *Title = [[UILabel alloc] initWithFrame:CGRectMake(15, 10, 200, 20)]; + [Title setTextColor:HEXCOLOR(0x000000)]; + [Title setFont:[UIFont systemFontOfSize:16.f]]; - UILabel *Title = [[UILabel alloc] initWithFrame:CGRectMake(20, 10, 200, 20)]; [sectionHeaderView addSubview:Title]; switch (section) { case 0: Title.text = @"聊天室"; break; - case 1: - Title.text = @"群组"; - break; - default: break; } @@ -342,11 +160,7 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa CGFloat height; switch (indexPath.section) { case 0: - height = 100; - break; - - case 1: - height = 70; + height = 68; break; default: @@ -357,22 +171,20 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { - return 40; + return 35; } -#pragma mark - 本类私有方法 --(void)quitDefaultGroup:(NSNotification *)notifycation +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - for (int i = 0; i < groupIdList.count; i++) { - if ([[notifycation object] isEqualToString:groupIdList[i]]) { - RCDSquareTableViewCell *cell = (RCDSquareTableViewCell *)[self.tableView viewWithTag:i + 100]; - - cell.JoinGroupBtn.hidden = NO; - cell.ChatBtn.hidden = YES; - } - } + NSString *chatroomId; + chatroomId = chatRoomIdList[indexPath.row]; + RCDChatViewController *chatVC = [[RCDChatViewController alloc] initWithConversationType:ConversationType_CHATROOM targetId:chatroomId]; + chatVC.title = chatRoomNames[indexPath.row]; + [self.navigationController pushViewController:chatVC animated:YES]; } +#pragma mark - 本类私有方法 + -(void)gotoChatRoomConversation:(UITapGestureRecognizer *)recognizer { NSArray *chatRoomNameArr = [[NSArray alloc] initWithObjects:@"聊天室1",@"聊天室2",@"聊天室3",@"聊天室4", nil]; @@ -387,50 +199,6 @@ -(void)gotoChatRoomConversation:(UITapGestureRecognizer *)recognizer [self.navigationController pushViewController:chatVC animated:YES]; } --(void)clickJoinGroupBtn:(id)sender -{ - hud= [MBProgressHUD showHUDAddedTo:self.view animated:YES]; - hud.labelText = @"加入中..."; - [hud show:YES]; - - NSInteger i = [sender tag]; - NSString *groupId = groupIdList[i]; - [RCDHTTPTOOL joinGroupWithGroupId:groupId - complete:^(BOOL result) { - if (result == YES) { - [groupIdList addObject:groupId]; - - RCDSquareTableViewCell *cell = (RCDSquareTableViewCell *)[self.tableView viewWithTag:i + 100]; - NSDictionary *groupInfo = groupList[i]; - NSString *memberCount = [NSString stringWithFormat:@"%d",[groupInfo[@"memberCount"] intValue] + 1]; - cell.GroupNumber.text = [NSString stringWithFormat:@"%@/%@",memberCount,groupInfo[@"maxMemberCount"]]; - - cell.JoinGroupBtn.hidden = YES; - cell.ChatBtn.hidden = NO; - //关闭HUD - [hud hide:YES]; - [RCDHTTPTOOL getMyGroupsWithBlock:^(NSMutableArray *result) { - - }]; - - } - else - { - //关闭HUD - [hud hide:YES]; - } - }]; -} - --(void)clickGroupChatBtn:(id)sender -{ - NSInteger i = [sender tag]; - NSString *groupId = groupIdList[i]; - RCDChatViewController *chatVC = [[RCDChatViewController alloc] initWithConversationType:ConversationType_GROUP targetId:groupId]; - chatVC.title = groupNames[i]; - [self.navigationController pushViewController:chatVC animated:YES]; -} - /* // Override to support conditional editing of the table view. - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { diff --git a/RCDataBaseManager.h b/RCDataBaseManager.h index 918626a9..2b17feec 100644 --- a/RCDataBaseManager.h +++ b/RCDataBaseManager.h @@ -57,6 +57,9 @@ //存储好友信息 -(void)insertFriendToDB:(RCDUserInfo *)friendInfo; +//清空表中的所有的群组信息 +-(BOOL)clearGroupfromDB; + //清空群组缓存数据 -(void)clearGroupsData; @@ -66,6 +69,9 @@ //从表中获取所有好友信息 //RCUserInfo -(NSArray *) getAllFriends; +//从表中获取某个好友的信息 +-(RCDUserInfo *) getFriendInfo:(NSString *)friendId; + //删除好友信息 -(void)deleteFriendFromDB:(NSString *)userId; diff --git a/RCDataBaseManager.m b/RCDataBaseManager.m index 57bb595a..3e0e0d9e 100644 --- a/RCDataBaseManager.m +++ b/RCDataBaseManager.m @@ -16,7 +16,7 @@ @implementation RCDataBaseManager static NSString * const userTableName = @"USERTABLE"; static NSString * const groupTableName = @"GROUPTABLEV2"; -static NSString * const friendTableName = @"FRIENDTABLE"; +static NSString * const friendTableName = @"FRIENDSTABLE"; static NSString * const blackTableName = @"BLACKTABLE"; static NSString * const groupMemberTableName = @"GROUPMEMBERTABLE"; @@ -53,9 +53,9 @@ -(void)CreateUserTable [db executeUpdate:createIndexSQL]; } if (![DBHelper isTableOK: friendTableName withDB:db]) { - NSString *createTableSQL = @"CREATE TABLE FRIENDTABLE (id integer PRIMARY KEY autoincrement, userid text,name text, portraitUri text, status text)"; + NSString *createTableSQL = @"CREATE TABLE FRIENDSTABLE (id integer PRIMARY KEY autoincrement, userid text,name text, portraitUri text, status text, updatedAt text)"; [db executeUpdate:createTableSQL]; - NSString *createIndexSQL=@"CREATE unique INDEX idx_friendId ON FRIENDTABLE(userid);"; + NSString *createIndexSQL=@"CREATE unique INDEX idx_friendsId ON FRIENDSTABLE(userid);"; [db executeUpdate:createIndexSQL]; } @@ -237,6 +237,21 @@ -(void)deleteGroupToDB:(NSString *)groupId }]; } +//清空表中的所有的群组信息 +-(BOOL)clearGroupfromDB +{ + __block BOOL result = NO; + NSString *clearSql =[NSString stringWithFormat:@"DELETE FROM GROUPTABLEV2"]; + FMDatabaseQueue *queue = [DBHelper getDatabaseQueue]; + if (queue==nil) { + return result; + } + + [queue inDatabase:^(FMDatabase *db) { + result = [db executeUpdate:clearSql]; + }]; + return result; +} //从表中获取所有群组信息 -(NSMutableArray *) getAllGroup @@ -312,10 +327,10 @@ -(NSMutableArray *)getGroupMember:(NSString *)groupId //-(void)insertFriendToDB:(RCUserInfo *)friend -(void)insertFriendToDB:(RCDUserInfo *)friendInfo { - NSString *insertSql = @"REPLACE INTO FRIENDTABLE (userid, name, portraitUri, status) VALUES (?, ?, ?, ?)"; + NSString *insertSql = @"REPLACE INTO FRIENDSTABLE (userid, name, portraitUri, status,updatedAt) VALUES (?, ?, ?, ?, ?)"; FMDatabaseQueue *queue = [DBHelper getDatabaseQueue]; [queue inDatabase:^(FMDatabase *db) { - [db executeUpdate:insertSql,friendInfo.userId, friendInfo.name, friendInfo.portraitUri, friendInfo.status]; + [db executeUpdate:insertSql,friendInfo.userId, friendInfo.name, friendInfo.portraitUri, friendInfo.status, friendInfo.updatedAt]; }]; } @@ -325,7 +340,7 @@ -(NSArray *) getAllFriends NSMutableArray *allUsers = [NSMutableArray new]; FMDatabaseQueue *queue = [DBHelper getDatabaseQueue]; [queue inDatabase:^(FMDatabase *db) { - FMResultSet *rs = [db executeQuery:@"SELECT * FROM FRIENDTABLE"]; + FMResultSet *rs = [db executeQuery:@"SELECT * FROM FRIENDSTABLE"]; while ([rs next]) { // RCUserInfo *model; RCDUserInfo *model; @@ -334,6 +349,7 @@ -(NSArray *) getAllFriends model.name = [rs stringForColumn:@"name"]; model.portraitUri = [rs stringForColumn:@"portraitUri"]; model.status = [rs stringForColumn:@"status"]; + model.updatedAt = [rs stringForColumn:@"updatedAt"]; [allUsers addObject:model]; } [rs close]; @@ -341,6 +357,25 @@ -(NSArray *) getAllFriends return allUsers; } +//从表中获取某个好友的信息 +-(RCDUserInfo *) getFriendInfo:(NSString *)friendId +{ + RCDUserInfo *friendInfo = [RCDUserInfo new]; + FMDatabaseQueue *queue = [DBHelper getDatabaseQueue]; + [queue inDatabase:^(FMDatabase *db) { + FMResultSet *rs = [db executeQuery:@"SELECT * FROM FRIENDSTABLE WHERE userid=?",friendId]; + while ([rs next]) { + friendInfo.userId = [rs stringForColumn:@"userid"]; + friendInfo.name = [rs stringForColumn:@"name"]; + friendInfo.portraitUri = [rs stringForColumn:@"portraitUri"]; + friendInfo.status = [rs stringForColumn:@"status"]; + friendInfo.updatedAt = [rs stringForColumn:@"updatedAt"]; + } + [rs close]; + }]; + return friendInfo; +} + //清空群组缓存数据 -(void)clearGroupsData { @@ -357,7 +392,7 @@ -(void)clearGroupsData //清空好友缓存数据 -(void)clearFriendsData { - NSString *deleteSql = @"DELETE FROM FRIENDTABLE"; + NSString *deleteSql = @"DELETE FROM FRIENDSTABLE"; FMDatabaseQueue *queue = [DBHelper getDatabaseQueue]; if (queue==nil) { return ; @@ -370,7 +405,7 @@ -(void)clearFriendsData -(void)deleteFriendFromDB:(NSString *)userId; { - NSString *deleteSql =[NSString stringWithFormat: @"DELETE FROM FRIENDTABLE WHERE userid=%@",userId]; + NSString *deleteSql =[NSString stringWithFormat: @"DELETE FROM FRIENDSTABLE WHERE userid=%@",userId]; FMDatabaseQueue *queue = [DBHelper getDatabaseQueue]; if (queue==nil) { return ; diff --git a/RCloudMessage.xcodeproj/project.pbxproj b/RCloudMessage.xcodeproj/project.pbxproj index 4f4766b9..b029b21a 100644 --- a/RCloudMessage.xcodeproj/project.pbxproj +++ b/RCloudMessage.xcodeproj/project.pbxproj @@ -30,6 +30,7 @@ 5C7629831B54F7E60027DA82 /* RCDBlackListCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 5C7629821B54F7E60027DA82 /* RCDBlackListCell.m */; }; 8C55EB511B2A8CE5004285F4 /* Emoji.plist in Resources */ = {isa = PBXBuildFile; fileRef = 8C55EB501B2A8CE5004285F4 /* Emoji.plist */; }; 8CCBC9871AEDDF8600BA1135 /* AssetsLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8CCBC9861AEDDF8600BA1135 /* AssetsLibrary.framework */; }; + 980235881D227F8100BCB1DD /* RCDPrivacyTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 980235871D227F8100BCB1DD /* RCDPrivacyTableViewController.m */; }; 9B447DE51CF82926005D3ED5 /* DefaultPortraitView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B447DBC1CF82926005D3ED5 /* DefaultPortraitView.m */; }; 9B447DE61CF82926005D3ED5 /* RCDChangePasswordViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B447DBE1CF82926005D3ED5 /* RCDChangePasswordViewController.m */; }; 9B447DE71CF82926005D3ED5 /* RCDContactSelectedTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B447DC01CF82926005D3ED5 /* RCDContactSelectedTableViewCell.m */; }; @@ -50,14 +51,13 @@ 9B447DF71CF82926005D3ED5 /* RCDSquareChatRoomTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B447DE01CF82926005D3ED5 /* RCDSquareChatRoomTableViewCell.m */; }; 9B447DF81CF82926005D3ED5 /* RCDSquareTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B447DE21CF82926005D3ED5 /* RCDSquareTableViewCell.m */; }; 9B447DF91CF82926005D3ED5 /* RCDSquareTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B447DE41CF82926005D3ED5 /* RCDSquareTableViewController.m */; }; - 9B447DFE1CF82A03005D3ED5 /* IsPhoneNumber.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B447DFB1CF82A03005D3ED5 /* IsPhoneNumber.m */; }; A60BAD0A1CD1ACB9003D2375 /* voip_call.caf in Resources */ = {isa = PBXBuildFile; fileRef = A60BAD091CD1ACB9003D2375 /* voip_call.caf */; }; A61647881BE9BF7C00E90813 /* RCDMeInfoTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A61647871BE9BF7C00E90813 /* RCDMeInfoTableViewController.m */; }; A616478B1BE9D97D00E90813 /* RCDEditUserNameViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A616478A1BE9D97D00E90813 /* RCDEditUserNameViewController.m */; }; A6447A0C1B1DBE6500EA2CEE /* InterfaceController.m in Sources */ = {isa = PBXBuildFile; fileRef = A6447A0B1B1DBE6500EA2CEE /* InterfaceController.m */; }; A6447A0F1B1DBE6500EA2CEE /* NotificationController.m in Sources */ = {isa = PBXBuildFile; fileRef = A6447A0E1B1DBE6500EA2CEE /* NotificationController.m */; }; A6447A111B1DBE6500EA2CEE /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A6447A101B1DBE6500EA2CEE /* Images.xcassets */; }; - A6447A151B1DBE6500EA2CEE /* 融云 Demo WatchKit App.app in Resources */ = {isa = PBXBuildFile; fileRef = A6447A141B1DBE6500EA2CEE /* 融云 Demo WatchKit App.app */; }; + A6447A151B1DBE6500EA2CEE /* SealTalk WatchKit App.app in Resources */ = {isa = PBXBuildFile; fileRef = A6447A141B1DBE6500EA2CEE /* SealTalk WatchKit App.app */; }; A6447A1D1B1DBE6500EA2CEE /* Interface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A6447A1B1B1DBE6500EA2CEE /* Interface.storyboard */; }; A6447A1F1B1DBE6500EA2CEE /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A6447A1E1B1DBE6500EA2CEE /* Images.xcassets */; }; A6447A3E1B1DC12500EA2CEE /* RCWKRequestHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = A6447A3B1B1DC12500EA2CEE /* RCWKRequestHandler.m */; }; @@ -313,6 +313,8 @@ 5C7629821B54F7E60027DA82 /* RCDBlackListCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = RCDBlackListCell.m; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 8C55EB501B2A8CE5004285F4 /* Emoji.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Emoji.plist; path = framework/Emoji.plist; sourceTree = SOURCE_ROOT; }; 8CCBC9861AEDDF8600BA1135 /* AssetsLibrary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AssetsLibrary.framework; path = System/Library/Frameworks/AssetsLibrary.framework; sourceTree = SDKROOT; }; + 980235861D227F8100BCB1DD /* RCDPrivacyTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCDPrivacyTableViewController.h; sourceTree = SOURCE_ROOT; }; + 980235871D227F8100BCB1DD /* RCDPrivacyTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCDPrivacyTableViewController.m; sourceTree = SOURCE_ROOT; }; 9B447DBB1CF82926005D3ED5 /* DefaultPortraitView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DefaultPortraitView.h; sourceTree = SOURCE_ROOT; }; 9B447DBC1CF82926005D3ED5 /* DefaultPortraitView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DefaultPortraitView.m; sourceTree = SOURCE_ROOT; }; 9B447DBD1CF82926005D3ED5 /* RCDChangePasswordViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCDChangePasswordViewController.h; sourceTree = SOURCE_ROOT; }; @@ -353,14 +355,12 @@ 9B447DE21CF82926005D3ED5 /* RCDSquareTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCDSquareTableViewCell.m; sourceTree = SOURCE_ROOT; }; 9B447DE31CF82926005D3ED5 /* RCDSquareTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCDSquareTableViewController.h; sourceTree = SOURCE_ROOT; }; 9B447DE41CF82926005D3ED5 /* RCDSquareTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCDSquareTableViewController.m; sourceTree = SOURCE_ROOT; }; - 9B447DFA1CF82A03005D3ED5 /* IsPhoneNumber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IsPhoneNumber.h; path = RCloudMessage/IsPhoneNumber.h; sourceTree = SOURCE_ROOT; }; - 9B447DFB1CF82A03005D3ED5 /* IsPhoneNumber.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IsPhoneNumber.m; path = RCloudMessage/IsPhoneNumber.m; sourceTree = SOURCE_ROOT; }; A60BAD091CD1ACB9003D2375 /* voip_call.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = voip_call.caf; sourceTree = SOURCE_ROOT; }; A61647861BE9BF7C00E90813 /* RCDMeInfoTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RCDMeInfoTableViewController.h; path = RCloudMessage/RCDMeInfoTableViewController.h; sourceTree = SOURCE_ROOT; }; A61647871BE9BF7C00E90813 /* RCDMeInfoTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RCDMeInfoTableViewController.m; path = RCloudMessage/RCDMeInfoTableViewController.m; sourceTree = SOURCE_ROOT; }; A61647891BE9D97D00E90813 /* RCDEditUserNameViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RCDEditUserNameViewController.h; path = RCloudMessage/RCDEditUserNameViewController.h; sourceTree = SOURCE_ROOT; }; A616478A1BE9D97D00E90813 /* RCDEditUserNameViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RCDEditUserNameViewController.m; path = RCloudMessage/RCDEditUserNameViewController.m; sourceTree = SOURCE_ROOT; }; - A6447A051B1DBE6500EA2CEE /* 融云 Demo WatchKit Extension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "融云 Demo WatchKit Extension.appex"; sourceTree = BUILT_PRODUCTS_DIR; }; + A6447A051B1DBE6500EA2CEE /* SealTalk WatchKit Extension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "SealTalk WatchKit Extension.appex"; sourceTree = BUILT_PRODUCTS_DIR; }; A6447A081B1DBE6500EA2CEE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; A6447A091B1DBE6500EA2CEE /* PushNotificationPayload.apns */ = {isa = PBXFileReference; lastKnownFileType = text; path = PushNotificationPayload.apns; sourceTree = ""; }; A6447A0A1B1DBE6500EA2CEE /* InterfaceController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InterfaceController.h; sourceTree = ""; }; @@ -368,7 +368,7 @@ A6447A0D1B1DBE6500EA2CEE /* NotificationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NotificationController.h; sourceTree = ""; }; A6447A0E1B1DBE6500EA2CEE /* NotificationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NotificationController.m; sourceTree = ""; }; A6447A101B1DBE6500EA2CEE /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; - A6447A141B1DBE6500EA2CEE /* 融云 Demo WatchKit App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "融云 Demo WatchKit App.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + A6447A141B1DBE6500EA2CEE /* SealTalk WatchKit App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "SealTalk WatchKit App.app"; sourceTree = BUILT_PRODUCTS_DIR; }; A6447A1A1B1DBE6500EA2CEE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; A6447A1C1B1DBE6500EA2CEE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Interface.storyboard; sourceTree = ""; }; A6447A1E1B1DBE6500EA2CEE /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; @@ -543,7 +543,7 @@ E4C497221A2484DB00098C8A /* MapKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MapKit.framework; path = System/Library/Frameworks/MapKit.framework; sourceTree = SDKROOT; }; E4C4E7E31A0A2F2800140067 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; E4C4E7E51A0A2F2E00140067 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; - E4D40F281A031F460045097C /* RCloudMessage.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RCloudMessage.app; sourceTree = BUILT_PRODUCTS_DIR; }; + E4D40F281A031F460045097C /* SealTalk.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SealTalk.app; sourceTree = BUILT_PRODUCTS_DIR; }; E4E938CD1AD65A95001E0AC6 /* AFHTTPRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFHTTPRequestOperation.h; sourceTree = ""; }; E4E938CE1AD65A95001E0AC6 /* AFHTTPRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPRequestOperation.m; sourceTree = ""; }; E4E938CF1AD65A95001E0AC6 /* AFHTTPRequestOperationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFHTTPRequestOperationManager.h; sourceTree = ""; }; @@ -806,8 +806,6 @@ 9B447DBA1CF828E8005D3ED5 /* new */ = { isa = PBXGroup; children = ( - 9B447DFA1CF82A03005D3ED5 /* IsPhoneNumber.h */, - 9B447DFB1CF82A03005D3ED5 /* IsPhoneNumber.m */, 9B447DBB1CF82926005D3ED5 /* DefaultPortraitView.h */, 9B447DBC1CF82926005D3ED5 /* DefaultPortraitView.m */, 9B447DBD1CF82926005D3ED5 /* RCDChangePasswordViewController.h */, @@ -848,6 +846,8 @@ 9B447DE21CF82926005D3ED5 /* RCDSquareTableViewCell.m */, 9B447DE31CF82926005D3ED5 /* RCDSquareTableViewController.h */, 9B447DE41CF82926005D3ED5 /* RCDSquareTableViewController.m */, + 980235861D227F8100BCB1DD /* RCDPrivacyTableViewController.h */, + 980235871D227F8100BCB1DD /* RCDPrivacyTableViewController.m */, ); name = new; sourceTree = ""; @@ -1318,9 +1318,9 @@ E4D40F291A031F460045097C /* Products */ = { isa = PBXGroup; children = ( - E4D40F281A031F460045097C /* RCloudMessage.app */, - A6447A051B1DBE6500EA2CEE /* 融云 Demo WatchKit Extension.appex */, - A6447A141B1DBE6500EA2CEE /* 融云 Demo WatchKit App.app */, + E4D40F281A031F460045097C /* SealTalk.app */, + A6447A051B1DBE6500EA2CEE /* SealTalk WatchKit Extension.appex */, + A6447A141B1DBE6500EA2CEE /* SealTalk WatchKit App.app */, ); name = Products; sourceTree = ""; @@ -1619,9 +1619,9 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - A6447A041B1DBE6500EA2CEE /* 融云 Demo WatchKit Extension */ = { + A6447A041B1DBE6500EA2CEE /* SealTalk WatchKit Extension */ = { isa = PBXNativeTarget; - buildConfigurationList = A6447A281B1DBE6500EA2CEE /* Build configuration list for PBXNativeTarget "融云 Demo WatchKit Extension" */; + buildConfigurationList = A6447A281B1DBE6500EA2CEE /* Build configuration list for PBXNativeTarget "SealTalk WatchKit Extension" */; buildPhases = ( A6447A011B1DBE6500EA2CEE /* Sources */, A6447A021B1DBE6500EA2CEE /* Frameworks */, @@ -1633,14 +1633,14 @@ dependencies = ( A6447A171B1DBE6500EA2CEE /* PBXTargetDependency */, ); - name = "融云 Demo WatchKit Extension"; + name = "SealTalk WatchKit Extension"; productName = "融云 Demo WatchKit Extension"; - productReference = A6447A051B1DBE6500EA2CEE /* 融云 Demo WatchKit Extension.appex */; + productReference = A6447A051B1DBE6500EA2CEE /* SealTalk WatchKit Extension.appex */; productType = "com.apple.product-type.watchkit-extension"; }; - A6447A131B1DBE6500EA2CEE /* 融云 Demo WatchKit App */ = { + A6447A131B1DBE6500EA2CEE /* SealTalk WatchKit App */ = { isa = PBXNativeTarget; - buildConfigurationList = A6447A271B1DBE6500EA2CEE /* Build configuration list for PBXNativeTarget "融云 Demo WatchKit App" */; + buildConfigurationList = A6447A271B1DBE6500EA2CEE /* Build configuration list for PBXNativeTarget "SealTalk WatchKit App" */; buildPhases = ( A6447A121B1DBE6500EA2CEE /* Resources */, ); @@ -1648,14 +1648,14 @@ ); dependencies = ( ); - name = "融云 Demo WatchKit App"; + name = "SealTalk WatchKit App"; productName = "融云 Demo WatchKit App"; - productReference = A6447A141B1DBE6500EA2CEE /* 融云 Demo WatchKit App.app */; + productReference = A6447A141B1DBE6500EA2CEE /* SealTalk WatchKit App.app */; productType = "com.apple.product-type.application.watchapp"; }; - E4D40F271A031F460045097C /* RCloudMessage */ = { + E4D40F271A031F460045097C /* SealTalk */ = { isa = PBXNativeTarget; - buildConfigurationList = E4D40F4E1A031F460045097C /* Build configuration list for PBXNativeTarget "RCloudMessage" */; + buildConfigurationList = E4D40F4E1A031F460045097C /* Build configuration list for PBXNativeTarget "SealTalk" */; buildPhases = ( E4D40F241A031F460045097C /* Sources */, E4D40F251A031F460045097C /* Frameworks */, @@ -1665,9 +1665,9 @@ ); dependencies = ( ); - name = RCloudMessage; + name = SealTalk; productName = RongCloud; - productReference = E4D40F281A031F460045097C /* RCloudMessage.app */; + productReference = E4D40F281A031F460045097C /* SealTalk.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ @@ -1683,6 +1683,9 @@ CreatedOnToolsVersion = 6.3.2; ProvisioningStyle = Automatic; SystemCapabilities = { + com.apple.ApplicationGroups.iOS = { + enabled = 1; + }; }; }; A6447A131B1DBE6500EA2CEE = { @@ -1693,6 +1696,9 @@ CreatedOnToolsVersion = 6.0.1; ProvisioningStyle = Automatic; SystemCapabilities = { + com.apple.ApplicationGroups.iOS = { + enabled = 1; + }; com.apple.BackgroundModes = { enabled = 1; }; @@ -1714,9 +1720,9 @@ projectDirPath = ""; projectRoot = ""; targets = ( - E4D40F271A031F460045097C /* RCloudMessage */, - A6447A041B1DBE6500EA2CEE /* 融云 Demo WatchKit Extension */, - A6447A131B1DBE6500EA2CEE /* 融云 Demo WatchKit App */, + E4D40F271A031F460045097C /* SealTalk */, + A6447A041B1DBE6500EA2CEE /* SealTalk WatchKit Extension */, + A6447A131B1DBE6500EA2CEE /* SealTalk WatchKit App */, ); }; /* End PBXProject section */ @@ -1726,7 +1732,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - A6447A151B1DBE6500EA2CEE /* 融云 Demo WatchKit App.app in Resources */, + A6447A151B1DBE6500EA2CEE /* SealTalk WatchKit App.app in Resources */, A6447A111B1DBE6500EA2CEE /* Images.xcassets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1882,7 +1888,6 @@ E4E939611AD65A95001E0AC6 /* RCDTextFieldValidate.m in Sources */, E4E9395F1AD65A95001E0AC6 /* RCAnimatedImagesView.m in Sources */, E4BFAE651A1219EA007165B1 /* RCDAddressBookViewController.m in Sources */, - 9B447DFE1CF82A03005D3ED5 /* IsPhoneNumber.m in Sources */, E4E939CF1AD65E30001E0AC6 /* pinyin.c in Sources */, E4E939451AD65A95001E0AC6 /* AFNetworkReachabilityManager.m in Sources */, E4E939B21AD65CD6001E0AC6 /* RCDSelectPersonViewController.m in Sources */, @@ -1907,6 +1912,7 @@ E4E939491AD65A95001E0AC6 /* AFURLResponseSerialization.m in Sources */, E4E939A61AD65CA3001E0AC6 /* RCDRegisterViewController.m in Sources */, 466684301B5DEC57000B7504 /* RCDConversationSettingTableViewHeader.m in Sources */, + 980235881D227F8100BCB1DD /* RCDPrivacyTableViewController.m in Sources */, A692A7321B69CD4200B18659 /* RCDFriendInvitationTableViewCell.m in Sources */, E4E939521AD65A95001E0AC6 /* UIWebView+AFNetworking.m in Sources */, E4E939641AD65A95001E0AC6 /* NSData+ImageContentType.m in Sources */, @@ -1966,7 +1972,7 @@ /* Begin PBXTargetDependency section */ A6447A171B1DBE6500EA2CEE /* PBXTargetDependency */ = { isa = PBXTargetDependency; - target = A6447A131B1DBE6500EA2CEE /* 融云 Demo WatchKit App */; + target = A6447A131B1DBE6500EA2CEE /* SealTalk WatchKit App */; targetProxy = A6447A161B1DBE6500EA2CEE /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ @@ -2076,7 +2082,7 @@ OTHER_LDFLAGS = "-ObjC"; OTHER_LIBTOOLFLAGS = "$(OTHER_LDFLAGS)"; PRODUCT_BUNDLE_IDENTIFIER = cn.rongcloud.im; - PRODUCT_NAME = RCloudMessage; + PRODUCT_NAME = SealTalk; PROVISIONING_PROFILE = $APP_PROFILE; VALID_ARCHS = "armv7 armv7s arm64 x86_64 i386"; }; @@ -2209,7 +2215,7 @@ OTHER_LDFLAGS = "-ObjC"; OTHER_LIBTOOLFLAGS = "$(OTHER_LDFLAGS)"; PRODUCT_BUNDLE_IDENTIFIER = cn.rongcloud.im; - PRODUCT_NAME = RCloudMessage; + PRODUCT_NAME = SealTalk; PROVISIONING_PROFILE = $APP_PROFILE; VALID_ARCHS = "armv7 armv7s arm64 x86_64 i386"; }; @@ -2487,7 +2493,7 @@ OTHER_LDFLAGS = "-ObjC"; OTHER_LIBTOOLFLAGS = "$(OTHER_LDFLAGS)"; PRODUCT_BUNDLE_IDENTIFIER = cn.rongcloud.im; - PRODUCT_NAME = RCloudMessage; + PRODUCT_NAME = SealTalk; PROVISIONING_PROFILE = ""; VALID_ARCHS = "armv7 armv7s arm64 x86_64 i386"; }; @@ -2522,7 +2528,7 @@ OTHER_LDFLAGS = "-ObjC"; OTHER_LIBTOOLFLAGS = "$(OTHER_LDFLAGS)"; PRODUCT_BUNDLE_IDENTIFIER = cn.rongcloud.im; - PRODUCT_NAME = RCloudMessage; + PRODUCT_NAME = SealTalk; PROVISIONING_PROFILE = ""; VALID_ARCHS = "armv7 armv7s arm64 x86_64 i386"; }; @@ -2531,7 +2537,7 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - A6447A271B1DBE6500EA2CEE /* Build configuration list for PBXNativeTarget "融云 Demo WatchKit App" */ = { + A6447A271B1DBE6500EA2CEE /* Build configuration list for PBXNativeTarget "SealTalk WatchKit App" */ = { isa = XCConfigurationList; buildConfigurations = ( A6447A251B1DBE6500EA2CEE /* Debug */, @@ -2542,7 +2548,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - A6447A281B1DBE6500EA2CEE /* Build configuration list for PBXNativeTarget "融云 Demo WatchKit Extension" */ = { + A6447A281B1DBE6500EA2CEE /* Build configuration list for PBXNativeTarget "SealTalk WatchKit Extension" */ = { isa = XCConfigurationList; buildConfigurations = ( A6447A231B1DBE6500EA2CEE /* Debug */, @@ -2564,7 +2570,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - E4D40F4E1A031F460045097C /* Build configuration list for PBXNativeTarget "RCloudMessage" */ = { + E4D40F4E1A031F460045097C /* Build configuration list for PBXNativeTarget "SealTalk" */ = { isa = XCConfigurationList; buildConfigurations = ( E4D40F4F1A031F460045097C /* Debug */, diff --git "a/RCloudMessage.xcodeproj/xcshareddata/xcschemes/Glance - \350\236\215\344\272\221 Demo WatchKit App.xcscheme" "b/RCloudMessage.xcodeproj/xcshareddata/xcschemes/Glance - \350\236\215\344\272\221 Demo WatchKit App.xcscheme" deleted file mode 100644 index 368972b5..00000000 --- "a/RCloudMessage.xcodeproj/xcshareddata/xcschemes/Glance - \350\236\215\344\272\221 Demo WatchKit App.xcscheme" +++ /dev/null @@ -1,145 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git "a/RCloudMessage.xcodeproj/xcshareddata/xcschemes/Notification - \350\236\215\344\272\221 Demo WatchKit App.xcscheme" "b/RCloudMessage.xcodeproj/xcshareddata/xcschemes/Notification - \350\236\215\344\272\221 Demo WatchKit App.xcscheme" deleted file mode 100644 index 8f0e57eb..00000000 --- "a/RCloudMessage.xcodeproj/xcshareddata/xcschemes/Notification - \350\236\215\344\272\221 Demo WatchKit App.xcscheme" +++ /dev/null @@ -1,145 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git "a/RCloudMessage.xcodeproj/xcshareddata/xcschemes/\350\236\215\344\272\221 Demo WatchKit App.xcscheme" b/RCloudMessage.xcodeproj/xcshareddata/xcschemes/SealTalk WatchKit App.xcscheme similarity index 62% rename from "RCloudMessage.xcodeproj/xcshareddata/xcschemes/\350\236\215\344\272\221 Demo WatchKit App.xcscheme" rename to RCloudMessage.xcodeproj/xcshareddata/xcschemes/SealTalk WatchKit App.xcscheme index 61c31c91..08c1b5eb 100644 --- "a/RCloudMessage.xcodeproj/xcshareddata/xcschemes/\350\236\215\344\272\221 Demo WatchKit App.xcscheme" +++ b/RCloudMessage.xcodeproj/xcshareddata/xcschemes/SealTalk WatchKit App.xcscheme @@ -1,6 +1,6 @@ - - - - - - - - @@ -61,8 +33,8 @@ @@ -82,12 +54,12 @@ + RemotePath = "/SealTalk"> @@ -95,8 +67,8 @@ @@ -112,12 +84,12 @@ + RemotePath = "/SealTalk"> @@ -125,8 +97,8 @@ diff --git a/RCloudMessage.xcodeproj/xcshareddata/xcschemes/SealTalk WatchKit Extension.xcscheme b/RCloudMessage.xcodeproj/xcshareddata/xcschemes/SealTalk WatchKit Extension.xcscheme new file mode 100644 index 00000000..da062209 --- /dev/null +++ b/RCloudMessage.xcodeproj/xcshareddata/xcschemes/SealTalk WatchKit Extension.xcscheme @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/RCloudMessage.xcodeproj/xcshareddata/xcschemes/RCloudMessage.xcscheme b/RCloudMessage.xcodeproj/xcshareddata/xcschemes/SealTalk.xcscheme similarity index 84% rename from RCloudMessage.xcodeproj/xcshareddata/xcschemes/RCloudMessage.xcscheme rename to RCloudMessage.xcodeproj/xcshareddata/xcschemes/SealTalk.xcscheme index 188a4553..a0aab599 100644 --- a/RCloudMessage.xcodeproj/xcshareddata/xcschemes/RCloudMessage.xcscheme +++ b/RCloudMessage.xcodeproj/xcshareddata/xcschemes/SealTalk.xcscheme @@ -1,6 +1,6 @@ @@ -33,8 +33,8 @@ @@ -56,17 +56,12 @@ - - diff --git a/RCloudMessage/AFHttpTool.m b/RCloudMessage/AFHttpTool.m index b9031938..cfa515cc 100644 --- a/RCloudMessage/AFHttpTool.m +++ b/RCloudMessage/AFHttpTool.m @@ -17,11 +17,8 @@ #define ProDemoServer @"http://119.254.110.79:8080/" //Beijing Liu-Bei 线上环境(北京) #define PrivateCloudDemoServer @"http://139.217.26.223/"//私有云测试 -//线上正式环境 -//#define DemoServer @"http://10.10.112.146:8585" -#define DemoServer @"http://api.sealtalk.im/" -//测试环境 -//#define DemoServer @"http://api.hitalk.im/" +#define DemoServer @"http://api.sealtalk.im/" //线上正式环境 +//#define DemoServer @"http://api.hitalk.im/" //测试环境 //#define ContentType @"text/plain" #define ContentType @"application/json" diff --git a/RCloudMessage/AppDelegate.m b/RCloudMessage/AppDelegate.m index d1c46a96..6d9126f8 100644 --- a/RCloudMessage/AppDelegate.m +++ b/RCloudMessage/AppDelegate.m @@ -25,7 +25,6 @@ #import "RCDTestMessage.h" #import "MobClick.h" -//#define RONGCLOUD_IM_APPKEY @"0vnjpoadn5iiz" //offline key //#define RONGCLOUD_IM_APPKEY @"e0x9wycfx7flq" //offline key #define RONGCLOUD_IM_APPKEY @"n19jmcy59f1q9" // online key @@ -131,35 +130,30 @@ - (BOOL)application:(UIApplication *)application [[RCUserInfo alloc] initWithUserId:userId name:userNickName portrait:userPortraitUri]; - [RCIM sharedRCIM].currentUserInfo = _currentUserInfo; + [RCIM sharedRCIM].currentUserInfo = _currentUserInfo; [[RCIM sharedRCIM] connectWithToken:token success:^(NSString *userId) { - [AFHttpTool loginWithPhone:userName - password:password - region:@"86" - success:^(id response) { - if ([response[@"code"] intValue] == 200) { - [RCDHTTPTOOL getUserInfoByUserID:userId - completion:^(RCUserInfo *user) { -// [[RCIM sharedRCIM] -// refreshUserInfoCache:user -// withUserId:userId]; - [RCDHTTPTOOL getUserInfoByUserID:userId - completion:^(RCUserInfo* user) { -// [[RCIM sharedRCIM]refreshUserInfoCache:user withUserId:userId]; - [DEFAULTS setObject:user.portraitUri forKey:@"userPortraitUri"]; - [DEFAULTS setObject:user.name forKey:@"userNickName"]; - [DEFAULTS synchronize]; - [RCIMClient sharedRCIMClient].currentUserInfo = user; - }]; - }]; - //登陆demoserver成功之后才能调demo 的接口 - [RCDDataSource syncGroups]; - [RCDDataSource syncFriendList:userId complete:^(NSMutableArray * result) {}]; - } - } - failure:^(NSError *err){ - }]; + [AFHttpTool + loginWithPhone:userName + password:password + region:@"86" + success:^(id response) { + if ([response[@"code"] intValue] == 200) { + [RCDHTTPTOOL + getUserInfoByUserID:userId + completion:^(RCUserInfo* user) { + [DEFAULTS setObject:user.portraitUri forKey:@"userPortraitUri"]; + [DEFAULTS setObject:user.name forKey:@"userNickName"]; + [DEFAULTS synchronize]; + [RCIMClient sharedRCIMClient].currentUserInfo = user; + }]; + //登陆demoserver成功之后才能调demo 的接口 + [RCDDataSource syncGroups]; + [RCDDataSource syncFriendList:userId complete:^(NSMutableArray * result) {}]; + } + } + failure:^(NSError *err){ + }]; //设置当前的用户信息 //同步群组 @@ -363,6 +357,15 @@ - (void)applicationWillResignActive:(UIApplication *)application { // and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down // OpenGL ES frame rates. Games should use this method to pause the game. + int unreadMsgCount = [[RCIMClient sharedRCIMClient] + getUnreadCount:@[ + @(ConversationType_PRIVATE), + @(ConversationType_DISCUSSION), + @(ConversationType_APPSERVICE), + @(ConversationType_PUBLICSERVICE), + @(ConversationType_GROUP) + ]]; + application.applicationIconBadgeNumber = unreadMsgCount; } - (void)applicationDidEnterBackground:(UIApplication *)application { @@ -371,14 +374,14 @@ - (void)applicationDidEnterBackground:(UIApplication *)application { // application to its current state in case it is terminated later. // If your application supports background execution, this method is called // instead of applicationWillTerminate: when the user quits. - int unreadMsgCount = [[RCIMClient sharedRCIMClient] getUnreadCount:@[ - @(ConversationType_PRIVATE), - @(ConversationType_DISCUSSION), - @(ConversationType_APPSERVICE), - @(ConversationType_PUBLICSERVICE), - @(ConversationType_GROUP) - ]]; - application.applicationIconBadgeNumber = unreadMsgCount; +// int unreadMsgCount = [[RCIMClient sharedRCIMClient] getUnreadCount:@[ +// @(ConversationType_PRIVATE), +// @(ConversationType_DISCUSSION), +// @(ConversationType_APPSERVICE), +// @(ConversationType_PUBLICSERVICE), +// @(ConversationType_GROUP) +// ]]; +// application.applicationIconBadgeNumber = unreadMsgCount; } - (void)applicationWillEnterForeground:(UIApplication *)application { @@ -556,6 +559,19 @@ -(void)onRCIMReceiveMessage:(RCMessage *)message left:(int)left [RCDDataSource syncFriendList:[RCIM sharedRCIM].currentUserInfo.userId complete:^(NSMutableArray *friends) { }]; } + }else if ([message.content isMemberOfClass:[RCGroupNotificationMessage class]]) { + RCGroupNotificationMessage *msg = (RCGroupNotificationMessage *)message.content; + if ([msg.operation isEqualToString:@"Dismiss"] && [msg.operatorUserId isEqualToString:[RCIM sharedRCIM].currentUserInfo.userId]){ + [[RCIMClient sharedRCIMClient] clearMessages:ConversationType_GROUP targetId:message.targetId]; + [[RCIMClient sharedRCIMClient] removeConversation:ConversationType_GROUP targetId:message.targetId]; + } else if ([msg.operation isEqualToString:@"Rename"]) { + [RCDHTTPTOOL getGroupByID:message.targetId + successCompletion:^(RCDGroupInfo *group) { + [[RCDataBaseManager shareInstance] insertGroupToDB:group]; + [[RCIM sharedRCIM] refreshGroupInfoCache:group + withGroupId:group.groupId]; + }]; + } } } diff --git a/RCloudMessage/Base.lproj/Main.storyboard b/RCloudMessage/Base.lproj/Main.storyboard index c90d0b45..adc2779c 100644 --- a/RCloudMessage/Base.lproj/Main.storyboard +++ b/RCloudMessage/Base.lproj/Main.storyboard @@ -754,17 +754,11 @@ - - - - - - -