diff --git a/.gitignore b/.gitignore index a63cea8f8..260d787a9 100644 --- a/.gitignore +++ b/.gitignore @@ -32,4 +32,4 @@ Pods/ # Fastlane fastlane/report.xml fastlane/Reports -fastlane/README.md +fastlane/README.md \ No newline at end of file diff --git a/CHANGES.rst b/CHANGES.rst index 44506e3e9..2d9d5796f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,10 @@ +Changes in 0.7.5 (2018-10-05) +=============================================== + +Improvements: +* Upgrade MatrixKit version (v0.8.5). +* Server Quota Notices: Implement the blue banner (#1937). + Changes in 0.7.4 (2018-09-26) =============================================== diff --git a/Gemfile b/Gemfile index 82d1e3049..cacbc44b6 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,8 @@ source "https://rubygems.org" +gem "xcode-install" gem "fastlane" -gem "cocoapods" +gem "cocoapods", '~>1.5.3' + +plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') +eval_gemfile(plugins_path) if File.exist?(plugins_path) diff --git a/Gemfile.lock b/Gemfile.lock index a7582038d..621171f3d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -102,6 +102,7 @@ GEM xcodeproj (>= 1.6.0, < 2.0.0) xcpretty (~> 0.3.0) xcpretty-travis-formatter (>= 0.0.3) + fastlane-plugin-versioning (0.3.4) fourflusher (2.0.1) fuzzy_match (2.0.4) gh_inspector (1.1.3) @@ -133,7 +134,7 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2018.0812) mini_magick (4.5.1) - minitest (5.8.5) + minitest (5.11.3) molinillo (0.6.6) multi_json (1.13.1) multi_xml (0.6.0) @@ -151,7 +152,7 @@ GEM uber (< 0.2.0) retriable (3.1.2) rouge (2.0.7) - ruby-macho (1.2.0) + ruby-macho (1.3.1) rubyzip (1.2.2) security (0.1.3) signet (0.10.0) @@ -179,6 +180,9 @@ GEM unf_ext (0.0.7.5) unicode-display_width (1.4.0) word_wrap (1.0.0) + xcode-install (2.4.4) + claide (>= 0.9.1, < 1.1.0) + fastlane (>= 2.1.0, < 3.0.0) xcodeproj (1.6.0) CFPropertyList (>= 2.3.3, < 4.0) atomos (~> 0.1.3) @@ -194,8 +198,10 @@ PLATFORMS ruby DEPENDENCIES - cocoapods + cocoapods (~> 1.5.3) fastlane + fastlane-plugin-versioning + xcode-install BUNDLED WITH - 1.16.4 + 1.16.2 diff --git a/Podfile b/Podfile index d4fc9246a..c5f6ef045 100644 --- a/Podfile +++ b/Podfile @@ -9,7 +9,7 @@ source 'https://github.com/CocoaPods/Specs.git' # Different flavours of pods to MatrixKit # The current MatrixKit pod version -$matrixKitVersion = '0.8.4' +$matrixKitVersion = '0.8.5' # The develop branch version #$matrixKitVersion = 'develop' @@ -102,16 +102,6 @@ post_install do |installer| config.build_settings['ENABLE_BITCODE'] = 'NO' config.build_settings['SWIFT_VERSION'] = '4.0' # Required for PiwikTracker. Should be removed end - - # Set the right identity to build pods frameworks to be able to make release builds - # See https://github.com/CocoaPods/CocoaPods/issues/3156#issuecomment-102022787 - if target.to_s.include? 'Pods' - target.build_configurations.each do |config| - if !config.to_s.include? 'Debug' - config.build_settings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'] = 'iPhone Distribution' - end - end - end end end diff --git a/Podfile.lock b/Podfile.lock index 651d079ac..e92df0d33 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -43,37 +43,37 @@ PODS: - GZIP (1.2.2) - HPGrowingTextView (1.1) - libPhoneNumber-iOS (0.9.13) - - MatrixKit (0.8.4): + - MatrixKit (0.8.5): - cmark (~> 0.24.1) - DTCoreText (~> 1.6.21) - HPGrowingTextView (~> 1.1) - libPhoneNumber-iOS (~> 0.9.13) - - MatrixKit/Core (= 0.8.4) - - MatrixSDK (= 0.11.4) - - MatrixKit/AppExtension (0.8.4): + - MatrixKit/Core (= 0.8.5) + - MatrixSDK (= 0.11.5) + - MatrixKit/AppExtension (0.8.5): - cmark (~> 0.24.1) - DTCoreText (~> 1.6.21) - DTCoreText/Extension - HPGrowingTextView (~> 1.1) - libPhoneNumber-iOS (~> 0.9.13) - - MatrixSDK (= 0.11.4) - - MatrixKit/Core (0.8.4): + - MatrixSDK (= 0.11.5) + - MatrixKit/Core (0.8.5): - cmark (~> 0.24.1) - DTCoreText (~> 1.6.21) - HPGrowingTextView (~> 1.1) - libPhoneNumber-iOS (~> 0.9.13) - - MatrixSDK (= 0.11.4) - - MatrixSDK (0.11.4): - - MatrixSDK/Core (= 0.11.4) - - MatrixSDK/Core (0.11.4): + - MatrixSDK (= 0.11.5) + - MatrixSDK (0.11.5): + - MatrixSDK/Core (= 0.11.5) + - MatrixSDK/Core (0.11.5): - AFNetworking (~> 3.2.0) - GZIP (~> 1.2.1) - OLMKit (~> 2.3.0) - Realm (~> 3.9.0) - - MatrixSDK/JingleCallStack (0.11.4): + - MatrixSDK/JingleCallStack (0.11.5): - MatrixSDK/Core - WebRTC (= 63.11.20455) - - MatrixSDK/SwiftSupport (0.11.4): + - MatrixSDK/SwiftSupport (0.11.5): - MatrixSDK/Core - OLMKit (2.3.0): - OLMKit/olmc (= 2.3.0) @@ -92,8 +92,8 @@ DEPENDENCIES: - cmark - DTCoreText - GBDeviceInfo (~> 5.2.0) - - MatrixKit (= 0.8.4) - - MatrixKit/AppExtension (= 0.8.4) + - MatrixKit (= 0.8.5) + - MatrixKit/AppExtension (= 0.8.5) - MatrixSDK/JingleCallStack - MatrixSDK/SwiftSupport - OLMKit @@ -134,13 +134,13 @@ SPEC CHECKSUMS: GZIP: 12374d285e3b5d46cfcd480700fcfc7e16caf4f1 HPGrowingTextView: 88a716d97fb853bcb08a4a08e4727da17efc9b19 libPhoneNumber-iOS: e444379ac18bbfbdefad571da735b2cd7e096caa - MatrixKit: 33f4361bd62342b6cdacb79fd60f3d9d704366b1 - MatrixSDK: 9d9f5e9b1fa19f8a84ebfce846d87b138af9999b + MatrixKit: 475ded18f6e1ca6e2461467540fb58b2822deb04 + MatrixSDK: 71c30d30fa258c2d8b79298bf9f0d38718d78ff3 OLMKit: dd79cdc5fab9ec04c940a901e025195b7801f306 PiwikTracker: 42862c7b13028065c3dfd36b4dc38db8a5765acf Realm: 3d36f208bf3aff8335dc3298742140182bde4edb WebRTC: f2a6203584745fe53532633397557876b5d71640 -PODFILE CHECKSUM: 9085b1000f60244804f8bc6285a05a39a4795d76 +PODFILE CHECKSUM: 80264d2625b7551d0278cd95f0eb29ef43269cb0 COCOAPODS: 1.6.0.beta.1 diff --git a/Riot/Assets/en.lproj/Vector.strings b/Riot/Assets/en.lproj/Vector.strings index 043a1609b..3c519c4d7 100644 --- a/Riot/Assets/en.lproj/Vector.strings +++ b/Riot/Assets/en.lproj/Vector.strings @@ -281,6 +281,10 @@ "room_resource_limit_exceeded_message_contact_1" = " Please "; "room_resource_limit_exceeded_message_contact_2_link" = "contact your service administrator"; "room_resource_limit_exceeded_message_contact_3" = " to continue using this service."; +"room_resource_usage_limit_reached_message_1_default" = "This homeserver has exceeded one of its resource limits so "; +"room_resource_usage_limit_reached_message_1_monthly_active_user" = "This homeserver has hit its Monthly Active User limit so "; +"room_resource_usage_limit_reached_message_2" = "some users will not be able to log in."; +"room_resource_usage_limit_reached_message_contact_3" = " to get this limit increased."; // Unknown devices "unknown_devices_alert_title" = "Room contains unknown devices"; diff --git a/Riot/Constants/RiotDesignValues.h b/Riot/Constants/RiotDesignValues.h index a6db623b6..35c4d05c8 100644 --- a/Riot/Constants/RiotDesignValues.h +++ b/Riot/Constants/RiotDesignValues.h @@ -53,6 +53,7 @@ extern UIColor *kRiotColorRed; extern UIColor *kRiotColorIndigo; extern UIColor *kRiotColorOrange; extern UIColor *kRiotColorBlue; +extern UIColor *kRiotColorCuriousBlue; #pragma mark - Riot Standard Room Member Power Level extern NSInteger const kRiotRoomModeratorLevel; diff --git a/Riot/Constants/RiotDesignValues.m b/Riot/Constants/RiotDesignValues.m index 1c381a36e..a6d4ce672 100644 --- a/Riot/Constants/RiotDesignValues.m +++ b/Riot/Constants/RiotDesignValues.m @@ -47,6 +47,7 @@ UIColor *kRiotColorRed; UIColor *kRiotColorIndigo; UIColor *kRiotColorOrange; UIColor *kRiotColorBlue; +UIColor *kRiotColorCuriousBlue; // Riot Background Colors UIColor *kRiotBgColorWhite; @@ -101,7 +102,8 @@ UIKeyboardAppearance kRiotKeyboard; kRiotColorIndigo = UIColorFromRGB(0xBD79CC); kRiotColorOrange = UIColorFromRGB(0xF8A15F); kRiotColorBlue = UIColorFromRGB(0x81BDDB); - + kRiotColorCuriousBlue = UIColorFromRGB(0x2A9EDB); + kRiotBgColorWhite = [UIColor whiteColor]; kRiotBgColorBlack = UIColorFromRGB(0x2D2D2D); kRiotBgColorOLEDBlack = [UIColor blackColor]; diff --git a/Riot/Modules/Room/RoomViewController.h b/Riot/Modules/Room/RoomViewController.h index 292459be6..9d79bf0fe 100644 --- a/Riot/Modules/Room/RoomViewController.h +++ b/Riot/Modules/Room/RoomViewController.h @@ -27,7 +27,7 @@ #import "UIViewController+RiotSearch.h" -@interface RoomViewController : MXKRoomViewController +@interface RoomViewController : MXKRoomViewController // The expanded header @property (weak, nonatomic) IBOutlet UIView *expandedHeaderContainer; diff --git a/Riot/Modules/Room/RoomViewController.m b/Riot/Modules/Room/RoomViewController.m index e3991c9bc..ea535c7c4 100644 --- a/Riot/Modules/Room/RoomViewController.m +++ b/Riot/Modules/Room/RoomViewController.m @@ -123,7 +123,7 @@ #import "Riot-Swift.h" -@interface RoomViewController () +@interface RoomViewController () { // The expanded header ExpandedRoomTitleView *expandedHeader; @@ -211,6 +211,9 @@ // Listener for `m.room.tombstone` event type id tombstoneEventNotificationsListener; + + // Homeserver notices + MXServerNotices *serverNotices; } @end @@ -821,6 +824,8 @@ if (self.roomDataSource) { + [self listenToServerNotices]; + self.eventsAcknowledgementEnabled = YES; // Set room title view @@ -1166,6 +1171,7 @@ [self removeWidgetNotificationsListeners]; [self removeTombstoneEventNotificationsListener]; [self removeMXSessionStateChangeNotificationsListener]; + [self removeServerNoticesListener]; if (previewHeader || (self.expandedHeaderContainer.isHidden == NO)) { @@ -3810,6 +3816,32 @@ }]; } + +#pragma mark - Server notices management + +- (void)removeServerNoticesListener +{ + if (serverNotices) + { + [serverNotices close]; + serverNotices = nil; + } +} + +- (void)listenToServerNotices +{ + if (!serverNotices) + { + serverNotices = [[MXServerNotices alloc] initWithMatrixSession:self.roomDataSource.mxSession]; + serverNotices.delegate = self; + } +} + +- (void)serverNoticesDidChangeState:(MXServerNotices *)serverNotices +{ + [self refreshActivitiesViewDisplay]; +} + #pragma mark - Widget notifications management - (void)removeWidgetNotificationsListeners @@ -4026,6 +4058,20 @@ }]; } + else if (serverNotices.usageLimit && serverNotices.usageLimit.isServerNoticeUsageLimit) + { + [roomActivitiesView showResourceUsageLimitNotice:serverNotices.usageLimit onAdminContactTapped:^(NSURL *adminContact) { + + if ([[UIApplication sharedApplication] canOpenURL:adminContact]) + { + [[UIApplication sharedApplication] openURL:adminContact]; + } + else + { + NSLog(@"[RoomVC] refreshActivitiesViewDisplay: adminContact(%@) cannot be opened", adminContact); + } + }]; + } else { [self refreshTypingNotification]; diff --git a/Riot/Modules/Room/Views/Activities/RoomActivitiesView.h b/Riot/Modules/Room/Views/Activities/RoomActivitiesView.h index df8b66581..f28e47c44 100644 --- a/Riot/Modules/Room/Views/Activities/RoomActivitiesView.h +++ b/Riot/Modules/Room/Views/Activities/RoomActivitiesView.h @@ -93,6 +93,14 @@ */ - (void)showResourceLimitExceededError:(NSDictionary *)errorDict onAdminContactTapped:(void (^)(NSURL *adminContact))onAdminContactTapped; +/** + Display a usage limit notice sent in a system alert room. + + @param usageLimit the usage limit data. + @param onAdminContactTapped a callback indicating if the user wants to contact their admin. + */ +- (void)showResourceUsageLimitNotice:(MXServerNoticeContent *)usageLimit onAdminContactTapped:(void (^)(NSURL *adminContact))onAdminContactTapped; + /** Remove any displayed information. */ diff --git a/Riot/Modules/Room/Views/Activities/RoomActivitiesView.m b/Riot/Modules/Room/Views/Activities/RoomActivitiesView.m index f456a7986..586f572af 100644 --- a/Riot/Modules/Room/Views/Activities/RoomActivitiesView.m +++ b/Riot/Modules/Room/Views/Activities/RoomActivitiesView.m @@ -376,32 +376,63 @@ - (void)showResourceLimitExceededError:(NSDictionary *)errorDict onAdminContactTapped:(void (^)(NSURL *adminContact))onAdminContactTapped { - [self reset]; - - CGFloat fontSize = 15; - // Parse error data NSString *limitType, *adminContactString; - NSURL *adminContact; MXJSONModelSetString(limitType, errorDict[kMXErrorResourceLimitExceededLimitTypeKey]); MXJSONModelSetString(adminContactString, errorDict[kMXErrorResourceLimitExceededAdminContactKey]); + [self showResourceLimit:limitType adminContactString:adminContactString hardLimit:YES onAdminContactTapped:(void (^)(NSURL *adminContact))onAdminContactTapped]; +} + +- (void)showResourceUsageLimitNotice:(MXServerNoticeContent *)usageLimit onAdminContactTapped:(void (^)(NSURL *))onAdminContactTapped +{ + [self showResourceLimit:usageLimit.limitType adminContactString:usageLimit.adminContact hardLimit:NO onAdminContactTapped:onAdminContactTapped]; +} + +- (void)showResourceLimit:(NSString *)limitType adminContactString:(NSString *)adminContactString hardLimit:(BOOL)hardLimit onAdminContactTapped:(void (^)(NSURL *adminContact))onAdminContactTapped +{ + [self reset]; + + CGFloat fontSize = 15; + + NSURL *adminContact; if (adminContactString) { adminContact = [NSURL URLWithString:adminContactString]; } // Build the message content - // Reuse MatrixKit as is for the beginning NSMutableString *message = [NSMutableString new]; - if ([limitType isEqualToString:kMXErrorResourceLimitExceededLimitTypeMonthlyActiveUserValue]) + NSAttributedString *message2; + if (hardLimit) { - [message appendString:[NSBundle mxk_localizedStringForKey:@"login_error_resource_limit_exceeded_message_monthly_active_user"]]; + // Reuse MatrixKit as is for the beginning of hardLimit + if ([limitType isEqualToString:kMXErrorResourceLimitExceededLimitTypeMonthlyActiveUserValue]) + { + [message appendString:[NSBundle mxk_localizedStringForKey:@"login_error_resource_limit_exceeded_message_monthly_active_user"]]; + } + else + { + [message appendString:[NSBundle mxk_localizedStringForKey:@"login_error_resource_limit_exceeded_message_default"]]; + } } else { - [message appendString:[NSBundle mxk_localizedStringForKey:@"login_error_resource_limit_exceeded_message_default"]]; + if ([limitType isEqualToString:kMXErrorResourceLimitExceededLimitTypeMonthlyActiveUserValue]) + { + [message appendString:NSLocalizedStringFromTable(@"room_resource_usage_limit_reached_message_1_monthly_active_user", @"Vector", nil)]; + } + else + { + [message appendString:NSLocalizedStringFromTable(@"room_resource_usage_limit_reached_message_1_default", @"Vector", nil)]; + } + + message2 = [[NSAttributedString alloc] initWithString:NSLocalizedStringFromTable(@"room_resource_usage_limit_reached_message_2", @"Vector", nil) + attributes:@{ + NSFontAttributeName: [UIFont boldSystemFontOfSize:fontSize], + NSForegroundColorAttributeName: kRiotPrimaryBgColor + }]; } NSDictionary *attributes = @{ @@ -430,9 +461,21 @@ NSAttributedString *messageContact1 = [[NSAttributedString alloc] initWithString:NSLocalizedStringFromTable(@"room_resource_limit_exceeded_message_contact_1", @"Vector", nil) attributes:attributes]; NSAttributedString *messageContact2Link = [[NSAttributedString alloc] initWithString:NSLocalizedStringFromTable(@"room_resource_limit_exceeded_message_contact_2_link", @"Vector", nil) attributes:messageContact2LinkAttributes]; - NSAttributedString *messageContact3 = [[NSAttributedString alloc] initWithString:NSLocalizedStringFromTable(@"room_resource_limit_exceeded_message_contact_3", @"Vector", nil) attributes:attributes]; + NSAttributedString *messageContact3; + if (hardLimit) + { + messageContact3 = [[NSAttributedString alloc] initWithString:NSLocalizedStringFromTable(@"room_resource_limit_exceeded_message_contact_3", @"Vector", nil) attributes:attributes]; + } + else + { + messageContact3 = [[NSAttributedString alloc] initWithString:NSLocalizedStringFromTable(@"room_resource_usage_limit_reached_message_contact_3", @"Vector", nil) attributes:attributes]; + } NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:message attributes:attributes]; + if (message2) + { + [attributedText appendAttributedString:message2]; + } [attributedText appendAttributedString:messageContact1]; [attributedText appendAttributedString:messageContact2Link]; [attributedText appendAttributedString:messageContact3]; @@ -441,8 +484,16 @@ self.messageTextView.tintColor = kRiotPrimaryBgColor; self.messageTextView.hidden = NO; - self.backgroundColor = kRiotColorPinkRed; - self.messageTextView.backgroundColor = kRiotColorPinkRed; + if (hardLimit) + { + self.backgroundColor = kRiotColorPinkRed; + self.messageTextView.backgroundColor = kRiotColorPinkRed; + } + else + { + self.backgroundColor = kRiotColorCuriousBlue; + self.messageTextView.backgroundColor = kRiotColorCuriousBlue; + } // Hide the separator to display correctly the banner self.separatorView.hidden = YES;