diff --git a/Vector/AppDelegate.m b/Vector/AppDelegate.m index 5c655f606..e135a7ebd 100644 --- a/Vector/AppDelegate.m +++ b/Vector/AppDelegate.m @@ -1360,16 +1360,8 @@ NSString *const kAppDelegateDidTapStatusBarNotification = @"kAppDelegateDidTapSt // Report this session to contact manager [[MXKContactManager sharedManager] addMatrixSession:mxSession]; - // Update recents data source (The recents view controller will be updated by its data source) - if (!mxSessionArray.count) - { - // This is the first added session, list all the recents for the logged user - [_homeViewController displayWithSession:mxSession]; - } - else - { - [_homeViewController addMatrixSession:mxSession]; - } + // Update home data sources + [_homeViewController addMatrixSession:mxSession]; [mxSessionArray addObject:mxSession]; } diff --git a/Vector/Assets/en.lproj/Vector.strings b/Vector/Assets/en.lproj/Vector.strings index 4e20d7188..e03a0dd17 100644 --- a/Vector/Assets/en.lproj/Vector.strings +++ b/Vector/Assets/en.lproj/Vector.strings @@ -103,8 +103,8 @@ "search_people" = "People"; // Directory -"directory_title" = "Browse directory"; -"directory_description" = "%tu rooms"; +"directory_cell_title" = "Browse directory"; +"directory_cell_description" = "%tu rooms"; "directory_search_results_title" = "Browse directory results"; "directory_search_results" = "%tu results found for %@"; "directory_searching_title" = "Searching directory..."; diff --git a/Vector/ViewController/AuthenticationViewController.m b/Vector/ViewController/AuthenticationViewController.m index d27193d61..0769206e0 100644 --- a/Vector/ViewController/AuthenticationViewController.m +++ b/Vector/ViewController/AuthenticationViewController.m @@ -121,7 +121,7 @@ id tracker = [[GAI sharedInstance] defaultTracker]; if (tracker) { - [tracker set:kGAIScreenName value:[NSString stringWithFormat:@"%@", self.class]]; + [tracker set:kGAIScreenName value:@"Authentication"]; [tracker send:[[GAIDictionaryBuilder createScreenView] build]]; } } diff --git a/Vector/ViewController/DirectoryViewController.m b/Vector/ViewController/DirectoryViewController.m index 3e00e612e..01dd7d1fa 100644 --- a/Vector/ViewController/DirectoryViewController.m +++ b/Vector/ViewController/DirectoryViewController.m @@ -58,7 +58,7 @@ id tracker = [[GAI sharedInstance] defaultTracker]; if (tracker) { - [tracker set:kGAIScreenName value:[NSString stringWithFormat:@"%@", self.class]]; + [tracker set:kGAIScreenName value:@"Directory"]; [tracker send:[[GAIDictionaryBuilder createScreenView] build]]; } diff --git a/Vector/ViewController/HomeSearchViewController.m b/Vector/ViewController/HomeSearchViewController.m index 0ad0c0fdf..2f357ebc5 100644 --- a/Vector/ViewController/HomeSearchViewController.m +++ b/Vector/ViewController/HomeSearchViewController.m @@ -56,7 +56,7 @@ id tracker = [[GAI sharedInstance] defaultTracker]; if (tracker) { - [tracker set:kGAIScreenName value:[NSString stringWithFormat:@"%@", self.class]]; + [tracker set:kGAIScreenName value:@"MessagesGlobalSearch"]; [tracker send:[[GAIDictionaryBuilder createScreenView] build]]; } } diff --git a/Vector/ViewController/HomeViewController.h b/Vector/ViewController/HomeViewController.h index f22f58874..a6ebcd2eb 100644 --- a/Vector/ViewController/HomeViewController.h +++ b/Vector/ViewController/HomeViewController.h @@ -53,13 +53,6 @@ */ - (void)showAuthenticationScreenWithRegistrationParameters:(NSDictionary*)parameters; -/** - Start displaying the screen with a user Matrix session. - - @param session the user Matrix session. - */ -- (void)displayWithSession:(MXSession*)session; - /** Open the room with the provided identifier in a specific matrix session. diff --git a/Vector/ViewController/HomeViewController.m b/Vector/ViewController/HomeViewController.m index 3a76b1f4c..217f5a8ae 100644 --- a/Vector/ViewController/HomeViewController.m +++ b/Vector/ViewController/HomeViewController.m @@ -92,11 +92,8 @@ // Add the Vector background image when search bar is empty [self addBackgroundImageViewToView:self.view]; - if (self.mainSession) - { - // Report the session into each created tab. - [self displayWithSession:self.mainSession]; - } + // Initialize here the data sources if a matrix session has been already set. + [self initializeDataSources]; } - (void)dealloc @@ -309,28 +306,63 @@ } } -- (void)displayWithSession:(MXSession *)mxSession +- (void)initializeDataSources { - [super addMatrixSession:mxSession]; - - // Init the recents data source - recentsDataSource = [[RecentsDataSource alloc] initWithMatrixSession:mxSession]; - [recentsViewController displayList:recentsDataSource fromHomeViewController:self]; - - // Init the search for messages - searchDataSource = [[MXKSearchDataSource alloc] initWithMatrixSession:mxSession]; - [searchViewController displaySearch:searchDataSource]; + MXSession *mainSession = self.mainSession; - // Do not go to search mode when first opening the home - [self hideSearch:NO]; + if (mainSession) + { + // Init the recents data source + recentsDataSource = [[RecentsDataSource alloc] initWithMatrixSession:mainSession]; + [recentsViewController displayList:recentsDataSource fromHomeViewController:self]; + + // Init the search for messages + searchDataSource = [[MXKSearchDataSource alloc] initWithMatrixSession:mainSession]; + [searchViewController displaySearch:searchDataSource]; + + // Check whether there are others sessions + NSArray* mxSessions = self.mxSessions; + if (mxSessions.count > 1) + { + for (MXSession *mxSession in mxSessions) + { + if (mxSession != mainSession) + { + // Add the session to the recents data source + [recentsDataSource addMatrixSession:mxSession]; + + // FIXME: Update searchDataSource + } + } + } + + // Do not go to search mode when first opening the home + [self hideSearch:NO]; + } } - (void)addMatrixSession:(MXSession *)mxSession { - // Add the session to the existing recents data source - if (recentsDataSource) + // Check whether the controller'€™s view is loaded into memory. + if (recentsViewController) { - [recentsDataSource addMatrixSession:mxSession]; + // Check whether the data sources have been initialized. + if (!recentsDataSource) + { + // Add first the session. The updated sessions list will be used during data sources initialization. + [super addMatrixSession:mxSession]; + + // Prepare data sources and return + [self initializeDataSources]; + return; + } + else + { + // Add the session to the existing recents data source + [recentsDataSource addMatrixSession:mxSession]; + + // FIXME: Update searchDataSource + } } [super addMatrixSession:mxSession]; @@ -703,6 +735,14 @@ tableViewMaskLayer.hidden = YES; [self updateSearch]; + + // Screen tracking (via Google Analytics) + id tracker = [[GAI sharedInstance] defaultTracker]; + if (tracker) + { + [tracker set:kGAIScreenName value:@"RoomsGlobalSearch"]; + [tracker send:[[GAIDictionaryBuilder createScreenView] build]]; + } } - (void)hideSearch:(BOOL)animated @@ -715,8 +755,20 @@ [recentsDataSource searchWithPatterns:nil]; - recentsDataSource.hideRecents = NO; - recentsDataSource.hidePublicRoomsDirectory = YES; + recentsDataSource.hideRecents = NO; + recentsDataSource.hidePublicRoomsDirectory = YES; + + // Screen tracking (via Google Analytics) + id tracker = [[GAI sharedInstance] defaultTracker]; + if (tracker) + { + NSString *currentScreenName = [tracker get:kGAIScreenName]; + if (!currentScreenName || ![currentScreenName isEqualToString:@"RoomsList"]) + { + [tracker set:kGAIScreenName value:@"RoomsList"]; + [tracker send:[[GAIDictionaryBuilder createScreenView] build]]; + } + } } // Update search results under the currently selected tab diff --git a/Vector/ViewController/MediaAlbumContentViewController.m b/Vector/ViewController/MediaAlbumContentViewController.m index 5635c99aa..2085e13a2 100644 --- a/Vector/ViewController/MediaAlbumContentViewController.m +++ b/Vector/ViewController/MediaAlbumContentViewController.m @@ -102,7 +102,7 @@ id tracker = [[GAI sharedInstance] defaultTracker]; if (tracker) { - [tracker set:kGAIScreenName value:[NSString stringWithFormat:@"%@", self.class]]; + [tracker set:kGAIScreenName value:@"MediaAlbumContent"]; [tracker send:[[GAIDictionaryBuilder createScreenView] build]]; } diff --git a/Vector/ViewController/MediaPickerViewController.m b/Vector/ViewController/MediaPickerViewController.m index e4a5fc6bf..177dd82f0 100644 --- a/Vector/ViewController/MediaPickerViewController.m +++ b/Vector/ViewController/MediaPickerViewController.m @@ -163,7 +163,7 @@ static void *RecordingContext = &RecordingContext; id tracker = [[GAI sharedInstance] defaultTracker]; if (tracker) { - [tracker set:kGAIScreenName value:[NSString stringWithFormat:@"%@", self.class]]; + [tracker set:kGAIScreenName value:@"MediaPicker"]; [tracker send:[[GAIDictionaryBuilder createScreenView] build]]; } diff --git a/Vector/ViewController/RecentsViewController.m b/Vector/ViewController/RecentsViewController.m index 4851bef90..dee2142f7 100644 --- a/Vector/ViewController/RecentsViewController.m +++ b/Vector/ViewController/RecentsViewController.m @@ -134,27 +134,37 @@ { [super viewWillAppear:animated]; - // Screen tracking (via Google Analytics) - id tracker = [[GAI sharedInstance] defaultTracker]; - if (tracker) + // Check whether the view controller is displayed in its "parent" segmented view controller. + if (homeViewController) { - [tracker set:kGAIScreenName value:[NSString stringWithFormat:@"%@", self.class]]; - [tracker send:[[GAIDictionaryBuilder createScreenView] build]]; - } - - // Deselect the current selected row, it will be restored on viewDidAppear (if any) - NSIndexPath *indexPath = [self.recentsTableView indexPathForSelectedRow]; - if (indexPath) - { - [self.recentsTableView deselectRowAtIndexPath:indexPath animated:NO]; - } - - // Observe kAppDelegateDidTapStatusBarNotificationObserver. - kAppDelegateDidTapStatusBarNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kAppDelegateDidTapStatusBarNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) { + // Screen tracking (via Google Analytics) + id tracker = [[GAI sharedInstance] defaultTracker]; + if (tracker) + { + NSString *screenName = homeViewController.searchBarHidden ? @"RoomsList" : @"RoomsGlobalSearch"; + NSString *currentScreenName = [tracker get:kGAIScreenName]; + + if (!currentScreenName || ![currentScreenName isEqualToString:screenName]) + { + [tracker set:kGAIScreenName value:screenName]; + [tracker send:[[GAIDictionaryBuilder createScreenView] build]]; + } + } - [self scrollToTop:YES]; + // Deselect the current selected row, it will be restored on viewDidAppear (if any) + NSIndexPath *indexPath = [self.recentsTableView indexPathForSelectedRow]; + if (indexPath) + { + [self.recentsTableView deselectRowAtIndexPath:indexPath animated:NO]; + } - }]; + // Observe kAppDelegateDidTapStatusBarNotificationObserver. + kAppDelegateDidTapStatusBarNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kAppDelegateDidTapStatusBarNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) { + + [self scrollToTop:YES]; + + }]; + } } - (void)viewWillDisappear:(BOOL)animated diff --git a/Vector/ViewController/RoomMemberDetailsViewController.m b/Vector/ViewController/RoomMemberDetailsViewController.m index 1ae654f62..db35501ca 100644 --- a/Vector/ViewController/RoomMemberDetailsViewController.m +++ b/Vector/ViewController/RoomMemberDetailsViewController.m @@ -137,7 +137,7 @@ id tracker = [[GAI sharedInstance] defaultTracker]; if (tracker) { - [tracker set:kGAIScreenName value:[NSString stringWithFormat:@"%@", self.class]]; + [tracker set:kGAIScreenName value:@"RoomMemberDetails"]; [tracker send:[[GAIDictionaryBuilder createScreenView] build]]; } diff --git a/Vector/ViewController/RoomParticipantsViewController.m b/Vector/ViewController/RoomParticipantsViewController.m index 1602d5488..bdf125338 100644 --- a/Vector/ViewController/RoomParticipantsViewController.m +++ b/Vector/ViewController/RoomParticipantsViewController.m @@ -164,7 +164,7 @@ id tracker = [[GAI sharedInstance] defaultTracker]; if (tracker) { - [tracker set:kGAIScreenName value:[NSString stringWithFormat:@"%@", self.class]]; + [tracker set:kGAIScreenName value:@"RoomParticipants"]; [tracker send:[[GAIDictionaryBuilder createScreenView] build]]; } diff --git a/Vector/ViewController/RoomSearchViewController.m b/Vector/ViewController/RoomSearchViewController.m index cd5373c12..aa28d709b 100644 --- a/Vector/ViewController/RoomSearchViewController.m +++ b/Vector/ViewController/RoomSearchViewController.m @@ -73,7 +73,7 @@ id tracker = [[GAI sharedInstance] defaultTracker]; if (tracker) { - [tracker set:kGAIScreenName value:[NSString stringWithFormat:@"%@", self.class]]; + [tracker set:kGAIScreenName value:@"RoomMessagesSearch"]; [tracker send:[[GAIDictionaryBuilder createScreenView] build]]; } diff --git a/Vector/ViewController/RoomSettingsViewController.m b/Vector/ViewController/RoomSettingsViewController.m index a3b9539ee..d3f11edc4 100644 --- a/Vector/ViewController/RoomSettingsViewController.m +++ b/Vector/ViewController/RoomSettingsViewController.m @@ -124,7 +124,7 @@ id tracker = [[GAI sharedInstance] defaultTracker]; if (tracker) { - [tracker set:kGAIScreenName value:[NSString stringWithFormat:@"%@", self.class]]; + [tracker set:kGAIScreenName value:@"RoomSettings"]; [tracker send:[[GAIDictionaryBuilder createScreenView] build]]; } diff --git a/Vector/ViewController/RoomViewController.m b/Vector/ViewController/RoomViewController.m index fd2411a2c..a4c507d30 100644 --- a/Vector/ViewController/RoomViewController.m +++ b/Vector/ViewController/RoomViewController.m @@ -262,7 +262,7 @@ id tracker = [[GAI sharedInstance] defaultTracker]; if (tracker) { - [tracker set:kGAIScreenName value:[NSString stringWithFormat:@"%@", self.class]]; + [tracker set:kGAIScreenName value:@"ChatRoom"]; [tracker send:[[GAIDictionaryBuilder createScreenView] build]]; } diff --git a/Vector/ViewController/SegmentedViewController.m b/Vector/ViewController/SegmentedViewController.m index b5d417998..f4507fc08 100644 --- a/Vector/ViewController/SegmentedViewController.m +++ b/Vector/ViewController/SegmentedViewController.m @@ -468,8 +468,6 @@ { // update the selected index self.selectedIndex = pos; - - [self displaySelectedViewController]; } } diff --git a/Vector/ViewController/SettingsViewController.m b/Vector/ViewController/SettingsViewController.m index 15f73aee6..83d617569 100644 --- a/Vector/ViewController/SettingsViewController.m +++ b/Vector/ViewController/SettingsViewController.m @@ -227,7 +227,7 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(); id tracker = [[GAI sharedInstance] defaultTracker]; if (tracker) { - [tracker set:kGAIScreenName value:[NSString stringWithFormat:@"%@", self.class]]; + [tracker set:kGAIScreenName value:@"Settings"]; [tracker send:[[GAIDictionaryBuilder createScreenView] build]]; } diff --git a/Vector/Views/RoomList/DirectoryRecentTableViewCell.m b/Vector/Views/RoomList/DirectoryRecentTableViewCell.m index 1c82dd3b5..3eb3a8f34 100644 --- a/Vector/Views/RoomList/DirectoryRecentTableViewCell.m +++ b/Vector/Views/RoomList/DirectoryRecentTableViewCell.m @@ -49,8 +49,8 @@ } else { - self.titleLabel.text = NSLocalizedStringFromTable(@"directory_title", @"Vector", nil); - self.descriptionLabel.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"directory_description", @"Vector", nil), + self.titleLabel.text = NSLocalizedStringFromTable(@"directory_cell_title", @"Vector", nil); + self.descriptionLabel.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"directory_cell_description", @"Vector", nil), publicRoomsDirectoryDataSource.rooms.count]; }