diff --git a/Riot/Assets/en.lproj/Vector.strings b/Riot/Assets/en.lproj/Vector.strings index a8010e05d..e454f4bed 100644 --- a/Riot/Assets/en.lproj/Vector.strings +++ b/Riot/Assets/en.lproj/Vector.strings @@ -458,13 +458,17 @@ "group_details_home" = "Home"; "group_details_people" = "People"; "group_details_rooms" = "Rooms"; + +// Group Home +"group_home_one_member_format" = "1 member"; +"group_home_multi_members_format" = "%tu members"; +"group_home_one_room_format" = "1 room"; +"group_home_multi_rooms_format" = "%tu rooms"; "group_invitation_format" = "%@ has invited you to join this community"; // Group participants "group_participants_title" = "Participants"; "group_participants_add_participant" = "Add participant"; -"group_participants_one_participant" = "1 member"; -"group_participants_multi_participants" = "%d members"; "group_participants_leave_prompt_title" = "Leave group"; "group_participants_leave_prompt_msg" = "Are you sure you want to leave the group?"; "group_participants_remove_prompt_title" = "Confirmation"; diff --git a/Riot/Assets/fr.lproj/Vector.strings b/Riot/Assets/fr.lproj/Vector.strings index c8974539d..499b55cd0 100644 --- a/Riot/Assets/fr.lproj/Vector.strings +++ b/Riot/Assets/fr.lproj/Vector.strings @@ -372,12 +372,15 @@ "group_details_home" = "Accueil"; "group_details_people" = "Membres"; "group_details_rooms" = "Salons"; +// Group Home +"group_home_one_member_format" = "1 membre"; +"group_home_multi_members_format" = "%tu membres"; +"group_home_one_room_format" = "1 salon"; +"group_home_multi_rooms_format" = "%tu salons"; "group_invitation_format" = "%@ vous a invité à rejoindre cette communauté"; // Group participants "group_participants_title" = "Membres"; "group_participants_add_participant" = "Ajouter un membre"; -"group_participants_one_participant" = "1 membre"; -"group_participants_multi_participants" = "%d membres"; "group_participants_leave_prompt_title" = "Quitter le groupe"; "group_participants_leave_prompt_msg" = "Voulez-vous vraiment quitter le groupe?"; "group_participants_remove_prompt_title" = "Confirmation"; diff --git a/Riot/Utils/AvatarGenerator.m b/Riot/Utils/AvatarGenerator.m index 2e8964e8f..3d8bcd1eb 100644 --- a/Riot/Utils/AvatarGenerator.m +++ b/Riot/Utils/AvatarGenerator.m @@ -69,7 +69,7 @@ static UILabel* backgroundLabel = nil; */ + (NSString *)firstChar:(NSString *)text { - if ([text hasPrefix:@"@"] || [text hasPrefix:@"#"] || [text hasPrefix:@"!"]) + if ([text hasPrefix:@"@"] || [text hasPrefix:@"#"] || [text hasPrefix:@"!"] || [text hasPrefix:@"+"]) { text = [text substringFromIndex:1]; } diff --git a/Riot/ViewController/GroupHomeViewController.h b/Riot/ViewController/GroupHomeViewController.h index a926a3dee..41c9d08cd 100644 --- a/Riot/ViewController/GroupHomeViewController.h +++ b/Riot/ViewController/GroupHomeViewController.h @@ -24,6 +24,11 @@ @property (weak, nonatomic) IBOutlet UILabel *groupName; @property (weak, nonatomic) IBOutlet UIView *groupNameMask; @property (weak, nonatomic) IBOutlet UILabel *groupDescription; +@property (weak, nonatomic) IBOutlet UIView *countsContainer; +@property (weak, nonatomic) IBOutlet UIView *membersCountContainer; +@property (weak, nonatomic) IBOutlet UIView *roomsCountContainer; +@property (weak, nonatomic) IBOutlet UILabel *membersCountLabel; +@property (weak, nonatomic) IBOutlet UILabel *roomsCountLabel; @property (weak, nonatomic) IBOutlet UIView *inviteContainer; @property (weak, nonatomic) IBOutlet UILabel *inviteLabel; diff --git a/Riot/ViewController/GroupHomeViewController.m b/Riot/ViewController/GroupHomeViewController.m index 758d06951..a504d1e39 100644 --- a/Riot/ViewController/GroupHomeViewController.m +++ b/Riot/ViewController/GroupHomeViewController.m @@ -122,11 +122,11 @@ [self.leftButton.layer setCornerRadius:5]; self.leftButton.clipsToBounds = YES; - self.leftButton.backgroundColor = kRiotColorGreen; + self.leftButton.backgroundColor = kRiotColorBlue; [self.rightButton.layer setCornerRadius:5]; self.rightButton.clipsToBounds = YES; - self.rightButton.backgroundColor = kRiotColorGreen; + self.rightButton.backgroundColor = kRiotColorBlue; } - (UIStatusBarStyle)preferredStatusBarStyle @@ -150,7 +150,7 @@ if (_group) { // Force a screen refresh - [self refreshDisplayWithGroup:[self.mxSession groupWithGroupId:_group.groupId]]; + [self didUpdateGroupDetails:nil]; // Trigger a refresh on the group summary. [self.mxSession updateGroupSummary:_group success:nil failure:^(NSError *error) { @@ -158,6 +158,18 @@ NSLog(@"[GroupHomeViewController] viewWillAppear: group summary update failed %@", _group.groupId); }]; + // Trigger a refresh on the group members (ignore here the invited users). + [self.mxSession updateGroupUsers:_group success:nil failure:^(NSError *error) { + + NSLog(@"[GroupHomeViewController] viewWillAppear: group members update failed %@", _group.groupId); + + }]; + // Trigger a refresh on the group rooms. + [self.mxSession updateGroupRooms:_group success:nil failure:^(NSError *error) { + + NSLog(@"[GroupHomeViewController] viewWillAppear: group rooms update failed %@", _group.groupId); + + }]; } } @@ -202,7 +214,9 @@ { [self cancelRegistrationOnGroupChangeNotifications]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didUpdateGroupSummary:) name:kMXSessionDidUpdateGroupSummaryNotification object:self.mxSession]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didUpdateGroupDetails:) name:kMXSessionDidUpdateGroupSummaryNotification object:self.mxSession]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didUpdateGroupDetails:) name:kMXSessionDidUpdateGroupUsersNotification object:self.mxSession]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didUpdateGroupDetails:) name:kMXSessionDidUpdateGroupRoomsNotification object:self.mxSession]; } - (void)cancelRegistrationOnGroupChangeNotifications @@ -211,9 +225,12 @@ [[NSNotificationCenter defaultCenter] removeObserver:self]; } -- (void)didUpdateGroupSummary:(NSNotification *)notif +- (void)didUpdateGroupDetails:(NSNotification *)notif { - [self refreshDisplayWithGroup:[self.mxSession groupWithGroupId:_group.groupId]]; + // Update here the displayed group instance with the one stored in the session (if any). + MXGroup *group = [self.mxSession groupWithGroupId:_group.groupId]; + + [self refreshDisplayWithGroup:(group ? group : _group)]; } - (void)refreshDisplayWithGroup:(MXGroup*)group @@ -234,6 +251,40 @@ _groupDescription.text = _group.summary.profile.shortDescription; + if (_group.users.totalUserCountEstimate == 1) + { + _membersCountLabel.text = NSLocalizedStringFromTable(@"group_home_one_member_format", @"Vector", nil); + _membersCountContainer.hidden = NO; + } + else if (_group.users.totalUserCountEstimate > 1) + { + _membersCountLabel.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"group_home_multi_members_format", @"Vector", nil), _group.users.totalUserCountEstimate]; + _membersCountContainer.hidden = NO; + } + else + { + _membersCountLabel.text = nil; + _membersCountContainer.hidden = YES; + } + + if (_group.rooms.totalRoomCountEstimate == 1) + { + _roomsCountLabel.text = NSLocalizedStringFromTable(@"group_home_one_room_format", @"Vector", nil); + _roomsCountContainer.hidden = NO; + } + else if (_group.rooms.totalRoomCountEstimate > 1) + { + _roomsCountLabel.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"group_home_multi_rooms_format", @"Vector", nil), _group.rooms.totalRoomCountEstimate]; + _roomsCountContainer.hidden = NO; + } + else + { + _roomsCountLabel.text = nil; + _roomsCountContainer.hidden = YES; + } + + _countsContainer.hidden = (_membersCountContainer.isHidden && _roomsCountContainer.isHidden); + if (_group.membership == MXMembershipInvite) { self.inviteContainer.hidden = NO; @@ -252,7 +303,7 @@ } } - self.inviteLabel.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"group_invitation_format", @"Vector", nil), _group.inviter]; + self.inviteLabel.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"group_invitation_format", @"Vector", nil), inviter]; } else { @@ -303,6 +354,10 @@ _groupLongDescription.text = nil; _separatorViewTopConstraint.constant = 0; + + _membersCountLabel.text = nil; + _roomsCountLabel.text = nil; + _countsContainer.hidden = YES; } // Round image view for thumbnail @@ -320,7 +375,7 @@ { if (sender == self.rightButton) { - // Decline the invite + // Accept the invite __weak typeof(self) weakSelf = self; [self startActivityIndicator]; @@ -353,7 +408,7 @@ } else if (sender == self.leftButton) { - // Accept the invite + // Decline the invite __weak typeof(self) weakSelf = self; [self startActivityIndicator]; diff --git a/Riot/ViewController/GroupHomeViewController.xib b/Riot/ViewController/GroupHomeViewController.xib index ca48c14c5..1049f1367 100644 --- a/Riot/ViewController/GroupHomeViewController.xib +++ b/Riot/ViewController/GroupHomeViewController.xib @@ -14,6 +14,7 @@ + @@ -24,7 +25,11 @@ + + + + @@ -36,10 +41,10 @@ - + - + @@ -60,35 +65,108 @@ - - + + + - - + + + @@ -98,17 +176,17 @@ - + -