From 5b5780bc1957c7be6d98537ce56ac768b0ee7773 Mon Sep 17 00:00:00 2001 From: SBiOSoftWhare Date: Thu, 25 Apr 2019 11:52:33 +0200 Subject: [PATCH 1/4] Remove iOS 9 local notification API usage --- Riot/AppDelegate.m | 335 ++++++++++----------------------------------- 1 file changed, 72 insertions(+), 263 deletions(-) diff --git a/Riot/AppDelegate.m b/Riot/AppDelegate.m index ae676dba6..5efcbe598 100644 --- a/Riot/AppDelegate.m +++ b/Riot/AppDelegate.m @@ -1159,60 +1159,36 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN if (!isPushRegistered) { - if (@available(iOS 10, *)) { - UNTextInputNotificationAction *quickReply = [UNTextInputNotificationAction - actionWithIdentifier:@"inline-reply" - title:NSLocalizedStringFromTable(@"room_message_short_placeholder", @"Vector", nil) - options:UNNotificationActionOptionAuthenticationRequired - ]; - - UNNotificationCategory *quickReplyCategory = [UNNotificationCategory - categoryWithIdentifier:@"QUICK_REPLY" - actions:@[quickReply] - intentIdentifiers:@[] - options:UNNotificationCategoryOptionNone]; - - UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; - [center setNotificationCategories:[[NSSet alloc] initWithArray:@[quickReplyCategory]]]; - [center setDelegate:self]; // commenting this out will fall back to using the same AppDelegate methods as the iOS 9 way of doing this - - UNAuthorizationOptions authorizationOptions = (UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge); - - [center requestAuthorizationWithOptions:authorizationOptions - completionHandler:^(BOOL granted, NSError *error) - { // code here is equivalent to self:application:didRegisterUserNotificationSettings: - if (granted) { - [self registerForRemoteNotificationsWithCompletion:nil]; - } - else - { - // Clear existing token - [self clearPushNotificationToken]; - } - }]; - } - else // DEPRECATED, for iOS 9 - { - NSMutableSet *notificationCategories = [NSMutableSet set]; - - UIMutableUserNotificationAction *quickReply = [[UIMutableUserNotificationAction alloc] init]; - quickReply.title = NSLocalizedStringFromTable(@"room_message_short_placeholder", @"Vector", nil); - quickReply.identifier = @"inline-reply"; - quickReply.activationMode = UIUserNotificationActivationModeBackground; - quickReply.authenticationRequired = true; - quickReply.behavior = UIUserNotificationActionBehaviorTextInput; - - UIMutableUserNotificationCategory *quickReplyCategory = [[UIMutableUserNotificationCategory alloc] init]; - quickReplyCategory.identifier = @"QUICK_REPLY"; - [quickReplyCategory setActions:@[quickReply] forContext:UIUserNotificationActionContextDefault]; - [notificationCategories addObject:quickReplyCategory]; - - // Registration on iOS 8 and later - UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert) categories:notificationCategories]; - - NSLog(@"[AppDelegate][Push] registerUserNotificationSettings: %@", settings); - [[UIApplication sharedApplication] registerUserNotificationSettings:settings]; - } + UNTextInputNotificationAction *quickReply = [UNTextInputNotificationAction + actionWithIdentifier:@"inline-reply" + title:NSLocalizedStringFromTable(@"room_message_short_placeholder", @"Vector", nil) + options:UNNotificationActionOptionAuthenticationRequired + ]; + + UNNotificationCategory *quickReplyCategory = [UNNotificationCategory + categoryWithIdentifier:@"QUICK_REPLY" + actions:@[quickReply] + intentIdentifiers:@[] + options:UNNotificationCategoryOptionNone]; + + UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; + [center setNotificationCategories:[[NSSet alloc] initWithArray:@[quickReplyCategory]]]; + [center setDelegate:self]; // commenting this out will fall back to using the same AppDelegate methods as the iOS 9 way of doing this + + UNAuthorizationOptions authorizationOptions = (UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge); + + [center requestAuthorizationWithOptions:authorizationOptions + completionHandler:^(BOOL granted, NSError *error) + { // code here is equivalent to self:application:didRegisterUserNotificationSettings: + if (granted) { + [self registerForRemoteNotificationsWithCompletion:nil]; + } + else + { + // Clear existing token + [self clearPushNotificationToken]; + } + }]; } } @@ -1227,23 +1203,6 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN self.pushRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP]; } -// DEPRECATED, for iOS 9 -- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings -{ - NSLog(@"[AppDelegate][Push] didRegisterUserNotificationSettings: notificationSettings.types: %@", @(notificationSettings.types)); - - // Register for remote notifications only if user provide access to notification feature - if (notificationSettings.types != UIUserNotificationTypeNone) - { - [self registerForRemoteNotificationsWithCompletion:nil]; - } - else - { - // Clear existing token - [self clearPushNotificationToken]; - } -} - // iOS 10+, see application:handleActionWithIdentifier:forLocalNotification:withResponseInfo:completionHandler: - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler { @@ -1297,38 +1256,6 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN } } -// DEPRECATED, for iOS 9 -// "This block is not a prototype" - don't fix this, or it won't match Apple's definition -- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification withResponseInfo:(NSDictionary *)responseInfo completionHandler:(void (^)())completionHandler -{ - NSLog(@"[AppDelegate][Push] handleActionWithIdentifier: identifier: %@", identifier); - - NSString* roomId = notification.userInfo[@"room_id"]; - - if ([identifier isEqualToString: @"inline-reply"]) - { - NSString* responseText = responseInfo[UIUserNotificationActionResponseTypedTextKey]; - - [self handleNotificationInlineReplyForRoomId:roomId withResponseText:responseText success:^(NSString *eventId) { - completionHandler(); - } failure:^(NSError *error) { - - UILocalNotification* failureNotification = [[UILocalNotification alloc] init]; - failureNotification.alertBody = NSLocalizedStringFromTable(@"room_event_failed_to_send", @"Vector", nil); - failureNotification.userInfo = notification.userInfo; - [[UIApplication sharedApplication] scheduleLocalNotification: failureNotification]; - NSLog(@"[AppDelegate][Push] handleActionWithIdentifier: error sending text message: %@", error); - - completionHandler(); - }]; - } - else - { - NSLog(@"[AppDelegate][Push] handleActionWithIdentifier: unhandled identifier %@", identifier); - completionHandler(); - } -} - // iOS 10+, this is called when a notification is about to display in foreground. - (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler { @@ -1337,15 +1264,6 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN completionHandler(UNNotificationPresentationOptionNone); } -// DEPRECATED, for iOS 9 -- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification -{ - NSLog(@"[AppDelegate][Push] didReceiveLocalNotification: applicationState: %@", @(application.applicationState)); - - NSString* roomId = notification.userInfo[@"room_id"]; - [self navigateToRoomById:roomId]; -} - - (void)navigateToRoomById:(NSString *)roomId { if (roomId.length) @@ -1522,15 +1440,6 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN BOOL checkReadEvent = YES; MXEvent *event; - // Ignore event already notified to the user - // only necessary on iOS 9, iOS 10 will just overwrite notifications with identical IDs - if (@available(iOS 10, *)) {} - else if ([self displayedLocalNotificationForEvent:eventId andUser:userId type:nil]) - { - NSLog(@"[AppDelegate][Push] handleLocalNotificationsForAccount: Skip event already displayed in a notification. Event id: %@", eventId); - continue; - } - if (eventId && roomId) { event = [account.mxSession.store eventWithEventId:eventId inRoom:roomId]; @@ -1540,16 +1449,8 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN { if (event.isRedactedEvent) { - if (@available(iOS 10, *)) - { - // Collect redacted event ids to remove possible delivered redacted notifications - [redactedEventIds addObject:eventId]; - } - else - { - // Ignore redacted event. - NSLog(@"[AppDelegate][Push] handleLocalNotificationsForAccount: Skip redacted event. Event id: %@", eventId); - } + // Collect redacted event ids to remove possible delivered redacted notifications + [redactedEventIds addObject:eventId]; continue; } @@ -1594,81 +1495,43 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN // Prepare the local notification MXPushRule *rule = eventDict[@"push_rule"]; - if (@available(iOS 10, *)) - { - [self notificationContentForEvent:event pushRule:rule inAccount:account onComplete:^(UNNotificationContent * _Nullable notificationContent) { + [self notificationContentForEvent:event pushRule:rule inAccount:account onComplete:^(UNNotificationContent * _Nullable notificationContent) { + + if (notificationContent) + { + UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:eventId + content:notificationContent + trigger:nil]; - if (notificationContent) - { - UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:eventId - content:notificationContent - trigger:nil]; + [[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) { - [[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) { - - if (error) - { - NSLog(@"[AppDelegate][Push] handleLocalNotificationsForAccount: Fail to display notification for event %@ with error: %@", eventId, error); - } - else - { - NSLog(@"[AppDelegate][Push] handleLocalNotificationsForAccount: Display notification for event %@", eventId); - } - }]; - - scheduledNotifications++; - } - else - { - NSLog(@"[AppDelegate][Push] handleLocalNotificationsForAccount: Skip event with empty generated content. Event id: %@", eventId); - } - }]; - } - else - { - [self notificationBodyForEvent:event pushRule:rule inAccount:account onComplete:^(NSString *_Nullable notificationBody) - { - if (notificationBody) - { - NSLog(@"[AppDelegate][Push] handleLocalNotificationsForAccount: Display notification for event %@", eventId); - - // Printf style escape characters are stripped from the string prior to display; - // to include a percent symbol (%) in the message, use two percent symbols (%%). - NSString *fixedNotificationBody = [notificationBody stringByReplacingOccurrencesOfString:@"%" withString:@"%%"]; - - NSDictionary *notificationUserInfo = [self notificationUserInfoForEvent:event andUserId:userId]; - NSString *categoryIdentifier = [self notificationCategoryIdentifierForEvent:event]; - NSString *soundName = [self notificationSoundNameFromPushRule:rule]; - - UILocalNotification *eventNotification = [[UILocalNotification alloc] init]; - eventNotification.alertBody = fixedNotificationBody; - eventNotification.userInfo = notificationUserInfo; - eventNotification.category = categoryIdentifier; - eventNotification.soundName = soundName; - - [[UIApplication sharedApplication] scheduleLocalNotification:eventNotification]; - - scheduledNotifications++; - } - else - { - NSLog(@"[AppDelegate][Push] handleLocalNotificationsForAccount: Skip event with empty generated notificationBody. Event id: %@", eventId); - } - }]; - } + if (error) + { + NSLog(@"[AppDelegate][Push] handleLocalNotificationsForAccount: Fail to display notification for event %@ with error: %@", eventId, error); + } + else + { + NSLog(@"[AppDelegate][Push] handleLocalNotificationsForAccount: Display notification for event %@", eventId); + } + }]; + + scheduledNotifications++; + } + else + { + NSLog(@"[AppDelegate][Push] handleLocalNotificationsForAccount: Skip event with empty generated content. Event id: %@", eventId); + } + }]; } } - if (@available(iOS 10, *)) + // Remove possible pending and delivered notifications having a redacted event id + if (redactedEventIds.count) { - // Remove possible pending and delivered notifications having a redacted event id - if (redactedEventIds.count) - { - NSLog(@"[AppDelegate][Push] handleLocalNotificationsForAccount: Remove possible notification with redacted event ids: %@", redactedEventIds); - - [[UNUserNotificationCenter currentNotificationCenter] removePendingNotificationRequestsWithIdentifiers:redactedEventIds]; - [[UNUserNotificationCenter currentNotificationCenter] removeDeliveredNotificationsWithIdentifiers:redactedEventIds]; - } + NSLog(@"[AppDelegate][Push] handleLocalNotificationsForAccount: Remove possible notification with redacted event ids: %@", redactedEventIds); + + [[UNUserNotificationCenter currentNotificationCenter] removePendingNotificationRequestsWithIdentifiers:redactedEventIds]; + [[UNUserNotificationCenter currentNotificationCenter] removeDeliveredNotificationsWithIdentifiers:redactedEventIds]; } NSLog(@"[AppDelegate][Push] handleLocalNotificationsForAccount: Sent %tu local notifications for %tu events", scheduledNotifications, eventsArray.count); @@ -2059,15 +1922,6 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN for (NSString *eventId in events) { - // Ignore event already notified to the user - // only necessary on iOS 9, iOS 10 will just overwrite notifications with identical IDs - if (@available(iOS 10, *)) {} - else if ([self displayedLocalNotificationForEvent:eventId andUser:userId type:nil]) - { - NSLog(@"[AppDelegate][Push] handleLocalNotificationsForAccount: Skip event already displayed in a notification. Event id: %@", eventId); - continue; - } - // Build notification user info NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{ @"type": @"limited", @@ -2087,27 +1941,15 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN NSLog(@"[AppDelegate][Push] handleLocalNotificationsForFailedSync: room_id is missing for event %@ in payload %@", eventId, payload); } - if (@available(iOS 10, *)) - { - UNMutableNotificationContent *localNotificationContentForFailedSync = [[UNMutableNotificationContent alloc] init]; - localNotificationContentForFailedSync.userInfo = userInfo; - localNotificationContentForFailedSync.body = [self limitedNotificationBodyForEvent:eventId inMatrixSession:mxSession]; - localNotificationContentForFailedSync.threadIdentifier = roomId; - - UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:eventId content:localNotificationContentForFailedSync trigger:nil]; - - NSLog(@"[AppDelegate][Push] handleLocalNotificationsForFailedSync: Display notification for event %@", eventId); - [[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:request withCompletionHandler:nil]; - } - else // DEPRECATED, for iOS 9 - { - UILocalNotification *localNotificationForFailedSync = [[UILocalNotification alloc] init]; - localNotificationForFailedSync.userInfo = userInfo; - localNotificationForFailedSync.alertBody = [self limitedNotificationBodyForEvent:eventId inMatrixSession:mxSession]; - - NSLog(@"[AppDelegate][Push] handleLocalNotificationsForFailedSync: Display notification for event %@", eventId); - [[UIApplication sharedApplication] scheduleLocalNotification:localNotificationForFailedSync]; - } + UNMutableNotificationContent *localNotificationContentForFailedSync = [[UNMutableNotificationContent alloc] init]; + localNotificationContentForFailedSync.userInfo = userInfo; + localNotificationContentForFailedSync.body = [self limitedNotificationBodyForEvent:eventId inMatrixSession:mxSession]; + localNotificationContentForFailedSync.threadIdentifier = roomId; + + UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:eventId content:localNotificationContentForFailedSync trigger:nil]; + + NSLog(@"[AppDelegate][Push] handleLocalNotificationsForFailedSync: Display notification for event %@", eventId); + [[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:request withCompletionHandler:nil]; } } @@ -2147,39 +1989,6 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN return notificationBody; } -/** - Return the already displayed notification for an event. - - @param eventId the id of the event attached to the notification to find. - @param userId the id of the user attached to the notification to find. - @param type the type of notification. @"full" or @"limited". nil for any type. - @return the local notification if any. - */ -// DEPRECATED, for iOS 9 -// TODO: This method does not work: [[UIApplication sharedApplication] scheduledLocalNotifications] is not reliable -- (UILocalNotification*)displayedLocalNotificationForEvent:(NSString*)eventId andUser:(NSString*)userId type:(NSString*)type -{ - NSLog(@"[AppDelegate][Push] displayedLocalNotificationForEvent: %@ andUser: %@. Current scheduledLocalNotifications: %@", eventId, userId, [[UIApplication sharedApplication] scheduledLocalNotifications]); - - UILocalNotification *limitedLocalNotification; - for (UILocalNotification *localNotification in [[UIApplication sharedApplication] scheduledLocalNotifications]) - { - NSLog(@" - %@", localNotification.userInfo); - - if ([localNotification.userInfo[@"event_id"] isEqualToString:eventId] - && [localNotification.userInfo[@"user_id"] isEqualToString:userId] - && (!type || [localNotification.userInfo[@"type"] isEqualToString:type])) - { - limitedLocalNotification = localNotification; - break; - } - } - - NSLog(@"[AppDelegate][Push] displayedLocalNotificationForEvent: found: %@", limitedLocalNotification); - - return limitedLocalNotification; -} - - (void)refreshApplicationIconBadgeNumber { // Consider the total number of missed discussions including the invites. From 29bb68cfc3c182acde0d66415e89a41f17cbae8b Mon Sep 17 00:00:00 2001 From: SBiOSoftWhare Date: Thu, 25 Apr 2019 11:53:38 +0200 Subject: [PATCH 2/4] Remove iOS 10 availability condition in MasterTabBarController. --- Riot/Modules/TabBar/MasterTabBarController.m | 30 ++++++++------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/Riot/Modules/TabBar/MasterTabBarController.m b/Riot/Modules/TabBar/MasterTabBarController.m index 0b18392bf..c85c8b969 100644 --- a/Riot/Modules/TabBar/MasterTabBarController.m +++ b/Riot/Modules/TabBar/MasterTabBarController.m @@ -816,15 +816,12 @@ self.tabBar.items[index].badgeValue = badgeValue; - if (@available(iOS 10, *)) - { - self.tabBar.items[index].badgeColor = badgeColor; - - [self.tabBar.items[index] setBadgeTextAttributes:@{ - NSForegroundColorAttributeName: ThemeService.shared.theme.baseTextPrimaryColor - } - forState:UIControlStateNormal]; - } + self.tabBar.items[index].badgeColor = badgeColor; + + [self.tabBar.items[index] setBadgeTextAttributes:@{ + NSForegroundColorAttributeName: ThemeService.shared.theme.baseTextPrimaryColor + } + forState:UIControlStateNormal]; } else { @@ -837,16 +834,13 @@ if (mark) { self.tabBar.items[index].badgeValue = mark; + + self.tabBar.items[index].badgeColor = badgeColor; - if (@available(iOS 10, *)) - { - self.tabBar.items[index].badgeColor = badgeColor; - - [self.tabBar.items[index] setBadgeTextAttributes:@{ - NSForegroundColorAttributeName: ThemeService.shared.theme.baseTextPrimaryColor - } - forState:UIControlStateNormal]; - } + [self.tabBar.items[index] setBadgeTextAttributes:@{ + NSForegroundColorAttributeName: ThemeService.shared.theme.baseTextPrimaryColor + } + forState:UIControlStateNormal]; } else { From 079ac6335edcb03f250bb0807ed8ca913b483a5f Mon Sep 17 00:00:00 2001 From: SBiOSoftWhare Date: Thu, 25 Apr 2019 11:57:16 +0200 Subject: [PATCH 3/4] Update changes --- CHANGES.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.rst b/CHANGES.rst index 9ad7db0cd..fbfb3875e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -11,6 +11,7 @@ Improvements: * Notifications: When navigate to a room, remove associated delivered notifications (#2337). * Key backup: Adjust wording for untrusted backup to match Riot Web. * Jitsi integration: Use the matching WebRTC framework (#1483). + * Remove code used for iOS 9 only (PR #2386). Bug fix: * Share extension: Fix a crash when receive a memory warning (PR #2352). From 7ad8790ca35ecb1c59fb6bb0ddf39689bdc6de81 Mon Sep 17 00:00:00 2001 From: SBiOSoftWhare Date: Thu, 25 Apr 2019 12:27:31 +0200 Subject: [PATCH 4/4] Remove check for `+[UIFont systemFontOfSize:weight:]` availability. --- Riot/AppDelegate.m | 11 ++----- .../Recents/Views/RecentTableViewCell.m | 20 ++----------- .../Home/Views/RoomCollectionViewCell.m | 30 ++++--------------- Riot/Utils/EventFormatter.m | 9 +----- 4 files changed, 11 insertions(+), 59 deletions(-) diff --git a/Riot/AppDelegate.m b/Riot/AppDelegate.m index 5efcbe598..872f3bf8a 100644 --- a/Riot/AppDelegate.m +++ b/Riot/AppDelegate.m @@ -3930,15 +3930,8 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN [_callStatusBarButton setTitle:buttonTitle forState:UIControlStateNormal]; [_callStatusBarButton setTitle:buttonTitle forState:UIControlStateHighlighted]; _callStatusBarButton.titleLabel.textColor = ThemeService.shared.theme.backgroundColor; - - if ([UIFont respondsToSelector:@selector(systemFontOfSize:weight:)]) - { - _callStatusBarButton.titleLabel.font = [UIFont systemFontOfSize:17 weight:UIFontWeightMedium]; - } - else - { - _callStatusBarButton.titleLabel.font = [UIFont boldSystemFontOfSize:17]; - } + + _callStatusBarButton.titleLabel.font = [UIFont systemFontOfSize:17 weight:UIFontWeightMedium]; [_callStatusBarButton setBackgroundColor:ThemeService.shared.theme.tintColor]; [_callStatusBarButton addTarget:self action:@selector(onCallStatusBarButtonPressed) forControlEvents:UIControlEventTouchUpInside]; diff --git a/Riot/Modules/Common/Recents/Views/RecentTableViewCell.m b/Riot/Modules/Common/Recents/Views/RecentTableViewCell.m index 8f993f99b..1f7e1b443 100644 --- a/Riot/Modules/Common/Recents/Views/RecentTableViewCell.m +++ b/Riot/Modules/Common/Recents/Views/RecentTableViewCell.m @@ -125,28 +125,14 @@ static const CGFloat kDirectRoomBorderWidth = 3.0; } // Use bold font for the room title - if ([UIFont respondsToSelector:@selector(systemFontOfSize:weight:)]) - { - self.roomTitle.font = [UIFont systemFontOfSize:17 weight:UIFontWeightBold]; - } - else - { - self.roomTitle.font = [UIFont boldSystemFontOfSize:17]; - } + self.roomTitle.font = [UIFont systemFontOfSize:17 weight:UIFontWeightBold]; } else { self.lastEventDate.textColor = ThemeService.shared.theme.textSecondaryColor; - // The room title is not bold anymore - if ([UIFont respondsToSelector:@selector(systemFontOfSize:weight:)]) - { - self.roomTitle.font = [UIFont systemFontOfSize:17 weight:UIFontWeightMedium]; - } - else - { - self.roomTitle.font = [UIFont systemFontOfSize:17]; - } + // The room title is not bold anymore + self.roomTitle.font = [UIFont systemFontOfSize:17 weight:UIFontWeightMedium]; } self.directRoomBorderView.hidden = !roomCellData.roomSummary.room.isDirect; diff --git a/Riot/Modules/Home/Views/RoomCollectionViewCell.m b/Riot/Modules/Home/Views/RoomCollectionViewCell.m index 932ff775e..5c6ed3aa3 100644 --- a/Riot/Modules/Home/Views/RoomCollectionViewCell.m +++ b/Riot/Modules/Home/Views/RoomCollectionViewCell.m @@ -135,14 +135,7 @@ static const CGFloat kDirectRoomBorderWidth = 3.0; } // Use bold font for the room title - if ([UIFont respondsToSelector:@selector(systemFontOfSize:weight:)]) - { - self.roomTitle.font = self.roomTitle1.font = self.roomTitle2.font = [UIFont systemFontOfSize:13 weight:UIFontWeightBold]; - } - else - { - self.roomTitle.font = self.roomTitle1.font = self.roomTitle2.font = [UIFont boldSystemFontOfSize:13]; - } + self.roomTitle.font = self.roomTitle1.font = self.roomTitle2.font = [UIFont systemFontOfSize:13 weight:UIFontWeightBold]; } else if (roomCellData.roomSummary.room.summary.membership == MXMembershipInvite) { @@ -155,26 +148,13 @@ static const CGFloat kDirectRoomBorderWidth = 3.0; self.missedNotifAndUnreadBadgeBgViewWidthConstraint.constant = self.missedNotifAndUnreadBadgeLabel.frame.size.width + 18; // Use bold font for the room title - if ([UIFont respondsToSelector:@selector(systemFontOfSize:weight:)]) - { - self.roomTitle.font = self.roomTitle1.font = self.roomTitle2.font = [UIFont systemFontOfSize:13 weight:UIFontWeightBold]; - } - else - { - self.roomTitle.font = self.roomTitle1.font = self.roomTitle2.font = [UIFont boldSystemFontOfSize:13]; - } + self.roomTitle.font = self.roomTitle1.font = self.roomTitle2.font = [UIFont systemFontOfSize:13 weight:UIFontWeightBold]; } else { - // The room title is not bold anymore - if ([UIFont respondsToSelector:@selector(systemFontOfSize:weight:)]) - { - self.roomTitle.font = self.roomTitle1.font = self.roomTitle2.font = [UIFont systemFontOfSize:13 weight:UIFontWeightMedium]; - } - else - { - self.roomTitle.font = self.roomTitle1.font = self.roomTitle2.font = [UIFont systemFontOfSize:13]; - } + // The room title is not bold anymore + self.roomTitle.font = self.roomTitle1.font = self.roomTitle2.font = [UIFont systemFontOfSize:13 weight:UIFontWeightMedium]; + } self.directRoomBorderView.hidden = !roomCellData.roomSummary.room.isDirect; diff --git a/Riot/Utils/EventFormatter.m b/Riot/Utils/EventFormatter.m index 44d3feac1..7926f11cf 100644 --- a/Riot/Utils/EventFormatter.m +++ b/Riot/Utils/EventFormatter.m @@ -227,14 +227,7 @@ NSString *const kEventFormatterOnReRequestKeysLinkActionSeparator = @"/"; self.defaultTextFont = [UIFont systemFontOfSize:15]; self.prefixTextFont = [UIFont boldSystemFontOfSize:15]; - if ([UIFont respondsToSelector:@selector(systemFontOfSize:weight:)]) - { - self.bingTextFont = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium]; - } - else - { - self.bingTextFont = [UIFont systemFontOfSize:15]; - } + self.bingTextFont = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium]; self.stateEventTextFont = [UIFont italicSystemFontOfSize:15]; self.callNoticesTextFont = [UIFont italicSystemFontOfSize:15]; self.encryptedMessagesTextFont = [UIFont italicSystemFontOfSize:15];