diff --git a/CHANGES.md b/CHANGES.md index ee4133fae..25f3abef4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,22 @@ +## Changes in 1.11.1 (2023-08-29) + +✨ Features + +- New settings cell to manage your account through MAS if the home server allows it. ([#7653](https://github.com/vector-im/element-ios/issues/7653)) + +🙌 Improvements + +- Upgrade MatrixSDK version ([v0.27.1](https://github.com/matrix-org/matrix-ios-sdk/releases/tag/v0.27.1)). + +🐛 Bugfixes + +- Prevent mention crashes when room members are missing display names (objc interop) ([#7649](https://github.com/vector-im/element-ios/pull/7649)) +- Add email UI is hidden if the 3 pid changes capability is disabled. ([#7645](https://github.com/vector-im/element-ios/issues/7645)) +- You can now log out from other sessions using MAS on supported OIDC home servers. ([#7646](https://github.com/vector-im/element-ios/issues/7646)) +- Deactivate account is hidden for servers with OIDC auth. ([#7648](https://github.com/vector-im/element-ios/issues/7648)) +- Prevent pill crashes when room members are missing display names (objc interop) ([#7651](https://github.com/vector-im/element-ios/issues/7651)) + + ## Changes in 1.11.0 (2023-08-15) ✨ Features diff --git a/Config/AppVersion.xcconfig b/Config/AppVersion.xcconfig index ec41e80dc..37b603c0b 100644 --- a/Config/AppVersion.xcconfig +++ b/Config/AppVersion.xcconfig @@ -15,5 +15,5 @@ // // Version -MARKETING_VERSION = 1.11.0 -CURRENT_PROJECT_VERSION = 1.11.0 +MARKETING_VERSION = 1.11.1 +CURRENT_PROJECT_VERSION = 1.11.1 diff --git a/Podfile b/Podfile index 581fc76b0..6891bc511 100644 --- a/Podfile +++ b/Podfile @@ -16,7 +16,7 @@ use_frameworks! # - `{ :specHash => {sdk spec hash}` to depend on specific pod options (:git => …, :podspec => …) for MatrixSDK repo. Used by Fastfile during CI # # Warning: our internal tooling depends on the name of this variable name, so be sure not to change it -$matrixSDKVersion = '= 0.27.0' +$matrixSDKVersion = '= 0.27.1' # $matrixSDKVersion = :local # $matrixSDKVersion = { :branch => 'develop'} # $matrixSDKVersion = { :specHash => { git: 'https://git.io/fork123', branch: 'fix' } } diff --git a/Podfile.lock b/Podfile.lock index 988424488..561af4bce 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -26,7 +26,7 @@ PODS: - GBDeviceInfo/Core (= 7.1.0) - GBDeviceInfo/Core (7.1.0) - GZIP (1.3.0) - - Introspect (0.1.4) + - Introspect (0.11.0) - JitsiMeetSDKLite (8.1.2-lite): - JitsiWebRTC (~> 111.0) - JitsiWebRTC (111.0.2) @@ -177,7 +177,7 @@ SPEC CHECKSUMS: FlowCommoniOS: ca92071ab526dc89905495a37844fd7e78d1a7f2 GBDeviceInfo: 5d62fa85bdcce3ed288d83c28789adf1173e4376 GZIP: 416858efbe66b41b206895ac6dfd5493200d95b3 - Introspect: b62c4dd2063072327c21d618ef2bedc3c87bc366 + Introspect: 4cc1e4c34dd016540c8d86a591c231c09dafbee3 JitsiMeetSDKLite: 895213158cf62342069a10634a41d2f1c00057f7 JitsiWebRTC: 80f62908fcf2a1160e0d14b584323fb6e6be630b KeychainAccess: c0c4f7f38f6fc7bbe58f5702e25f7bd2f65abf51 @@ -210,4 +210,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: f8f66ce4fa24937192a493d3a0a5c2c2e429c8fc -COCOAPODS: 1.11.3 +COCOAPODS: 1.12.1 diff --git a/Riot/Assets/en.lproj/Vector.strings b/Riot/Assets/en.lproj/Vector.strings index 132e5dd25..e1244e81e 100644 --- a/Riot/Assets/en.lproj/Vector.strings +++ b/Riot/Assets/en.lproj/Vector.strings @@ -748,6 +748,9 @@ Tap the + to start adding people."; "settings_three_pids_management_information_part1" = "Manage which email addresses or phone numbers you can use to log in or recover your account here. Control who can find you in "; "settings_three_pids_management_information_part2" = "Discovery"; "settings_three_pids_management_information_part3" = "."; +"settings_manage_account_title" = "Account"; +"settings_manage_account_action" = "Manage account"; +"settings_manage_account_description" = "Manage your account at %@"; "settings_confirm_media_size" = "Confirm size when sending"; "settings_confirm_media_size_description" = "When this is on, you’ll be asked to confirm what size images and videos will be sent as."; @@ -964,6 +967,8 @@ Tap the + to start adding people."; "manage_session_trusted" = "Trusted by you"; "manage_session_not_trusted" = "Not trusted"; "manage_session_sign_out" = "Sign out of this session"; +"manage_session_redirect" = "You will be redirected to your server's authentication provider to complete sign out."; +"manage_session_redirect_error" = "Functionality currently unavailable. Please contact your homeserver admin"; "manage_session_rename" = "Rename session"; "manage_session_sign_out_other_sessions" = "Sign out of all other sessions"; // User sessions management diff --git a/Riot/Generated/Strings.swift b/Riot/Generated/Strings.swift index 1c2516fe9..aa3ca9d72 100644 --- a/Riot/Generated/Strings.swift +++ b/Riot/Generated/Strings.swift @@ -3667,6 +3667,14 @@ public class VectorL10n: NSObject { public static var manageSessionNotTrusted: String { return VectorL10n.tr("Vector", "manage_session_not_trusted") } + /// You will be redirected to your server's authentication provider to complete sign out. + public static var manageSessionRedirect: String { + return VectorL10n.tr("Vector", "manage_session_redirect") + } + /// Functionality currently unavailable. Please contact your homeserver admin + public static var manageSessionRedirectError: String { + return VectorL10n.tr("Vector", "manage_session_redirect_error") + } /// Rename session public static var manageSessionRename: String { return VectorL10n.tr("Vector", "manage_session_rename") @@ -7791,6 +7799,18 @@ public class VectorL10n: NSObject { public static var settingsLinks: String { return VectorL10n.tr("Vector", "settings_links") } + /// Manage account + public static var settingsManageAccountAction: String { + return VectorL10n.tr("Vector", "settings_manage_account_action") + } + /// Manage your account at %@ + public static func settingsManageAccountDescription(_ p1: String) -> String { + return VectorL10n.tr("Vector", "settings_manage_account_description", p1) + } + /// Account + public static var settingsManageAccountTitle: String { + return VectorL10n.tr("Vector", "settings_manage_account_title") + } /// Mark all messages as read public static var settingsMarkAllAsRead: String { return VectorL10n.tr("Vector", "settings_mark_all_as_read") diff --git a/Riot/Modules/Pills/PillsFormatter.swift b/Riot/Modules/Pills/PillsFormatter.swift index 1b6256835..ecdfac5fe 100644 --- a/Riot/Modules/Pills/PillsFormatter.swift +++ b/Riot/Modules/Pills/PillsFormatter.swift @@ -197,12 +197,14 @@ class PillsFormatter: NSObject { guard let roomMember = roomState.members.member(withUserId: userId) else { return } + + let displayName = roomMember.displayname ?? userId pill.data?.items = [ .avatar(url: roomMember.avatarUrl, - string: roomMember.displayname, - matrixId: roomMember.userId), - .text(roomMember.displayname) + string: displayName, + matrixId: userId), + .text(displayName) ] default: break diff --git a/Riot/Modules/Room/Views/WYSIWYGInputToolbar/WysiwygInputToolbarView.swift b/Riot/Modules/Room/Views/WYSIWYGInputToolbar/WysiwygInputToolbarView.swift index edd951fd6..60b6edf94 100644 --- a/Riot/Modules/Room/Views/WYSIWYGInputToolbar/WysiwygInputToolbarView.swift +++ b/Riot/Modules/Room/Views/WYSIWYGInputToolbar/WysiwygInputToolbarView.swift @@ -207,8 +207,14 @@ class WysiwygInputToolbarView: MXKRoomInputToolbarView, NibLoadable, HtmlRoomInp } func mention(_ member: MXRoomMember) { - self.wysiwygViewModel.setMention(url: MXTools.permalinkToUser(withUserId: member.userId), - name: member.displayname, + guard let userId = member.userId else { + return + } + + let displayName = member.displayname ?? userId + + self.wysiwygViewModel.setMention(url: MXTools.permalinkToUser(withUserId: userId), + name: displayName, mentionType: .user) } diff --git a/Riot/Modules/Settings/Security/ManageSession/ManageSessionViewController.m b/Riot/Modules/Settings/Security/ManageSession/ManageSessionViewController.m index 806e10cff..e1fd5c5e8 100644 --- a/Riot/Modules/Settings/Security/ManageSession/ManageSessionViewController.m +++ b/Riot/Modules/Settings/Security/ManageSession/ManageSessionViewController.m @@ -655,6 +655,52 @@ enum { } - (void)removeDevice +{ + MXWellKnownAuthentication *authentication = self.mainSession.homeserverWellknown.authentication; + if (authentication) + { + NSURL *logoutURL = [authentication getLogoutDeviceURLFromID:device.deviceId]; + if (logoutURL) + { + [self removeDeviceRedirectWithURL:logoutURL]; + } + else + { + [self showRemoveDeviceRedirectError]; + } + } + else + { + [self removeDeviceThroughAPI]; + } +} + +-(void) removeDeviceRedirectWithURL: (NSURL * _Nonnull) url +{ + UIAlertController *alert = [UIAlertController alertControllerWithTitle: [VectorL10n manageSessionRedirect] message: nil preferredStyle:UIAlertControllerStyleAlert]; + + __weak typeof(self) weakSelf = self; + UIAlertAction *action = [UIAlertAction actionWithTitle:[VectorL10n ok] + style:UIAlertActionStyleDefault + handler: ^(UIAlertAction * action) { + [UIApplication.sharedApplication openURL:url options:@{} completionHandler:^(BOOL success) { + if (success && weakSelf) + { + [weakSelf withdrawViewControllerAnimated:YES completion:nil]; + } + }]; + }]; + [alert addAction: action]; + [self presentViewController:alert animated:YES completion:nil]; +} + +-(void) showRemoveDeviceRedirectError +{ + UIAlertController *alert = [UIAlertController alertControllerWithTitle: [VectorL10n manageSessionRedirectError] message: nil preferredStyle:UIAlertControllerStyleAlert]; + [self presentViewController:alert animated:YES completion:nil]; +} + +-(void) removeDeviceThroughAPI { [self startActivityIndicator]; self.view.userInteractionEnabled = NO; diff --git a/Riot/Modules/Settings/SettingsViewController.m b/Riot/Modules/Settings/SettingsViewController.m index be87bea3b..4bc45f827 100644 --- a/Riot/Modules/Settings/SettingsViewController.m +++ b/Riot/Modules/Settings/SettingsViewController.m @@ -50,6 +50,7 @@ typedef NS_ENUM(NSUInteger, SECTION_TAG) { SECTION_TAG_SIGN_OUT = 0, SECTION_TAG_USER_SETTINGS, + SECTION_TAG_ACCOUNT, SECTION_TAG_SENDING_MEDIA, SECTION_TAG_LINKS, SECTION_TAG_SECURITY, @@ -185,6 +186,11 @@ typedef NS_ENUM(NSUInteger, SECURITY) DEVICE_MANAGER_INDEX }; +typedef NS_ENUM(NSUInteger, ACCOUNT) +{ + ACCOUNT_MANAGE_INDEX = 0, +}; + typedef void (^blockSettingsViewController_onReadyToDestroy)(void); #pragma mark - SettingsViewController @@ -365,7 +371,10 @@ ChangePasswordCoordinatorBridgePresenterDelegate> { [sectionUserSettings addRowWithTag: USER_SETTINGS_PHONENUMBERS_OFFSET + index]; } - if (BuildSettings.settingsScreenAllowAddingEmailThreepids) + if (BuildSettings.settingsScreenAllowAddingEmailThreepids && + // If the threePidChanges is nil we assume the capability to be true + (!self.mainSession.homeserverCapabilities.threePidChanges || + self.mainSession.homeserverCapabilities.threePidChanges.enabled)) { [sectionUserSettings addRowWithTag:USER_SETTINGS_ADD_EMAIL_INDEX]; } @@ -383,6 +392,16 @@ ChangePasswordCoordinatorBridgePresenterDelegate> sectionUserSettings.headerTitle = [VectorL10n settingsUserSettings]; [tmpSections addObject:sectionUserSettings]; + + NSString *manageAccountURL = self.mainSession.homeserverWellknown.authentication.account; + if (manageAccountURL) + { + Section *account = [Section sectionWithTag: SECTION_TAG_ACCOUNT]; + [account addRowWithTag:ACCOUNT_MANAGE_INDEX]; + account.headerTitle = [VectorL10n settingsManageAccountTitle]; + account.footerTitle = [VectorL10n settingsManageAccountDescription:manageAccountURL]; + [tmpSections addObject:account]; + } if (BuildSettings.settingsScreenShowConfirmMediaSize) { @@ -608,7 +627,7 @@ ChangePasswordCoordinatorBridgePresenterDelegate> } } - if (BuildSettings.settingsScreenAllowDeactivatingAccount) + if (BuildSettings.settingsScreenAllowDeactivatingAccount && !self.mainSession.homeserverWellknown.authentication) { Section *sectionDeactivate = [Section sectionWithTag:SECTION_TAG_DEACTIVATE_ACCOUNT]; [sectionDeactivate addRowWithTag:0]; @@ -2626,6 +2645,17 @@ ChangePasswordCoordinatorBridgePresenterDelegate> cell = deactivateAccountBtnCell; } + else if (section == SECTION_TAG_ACCOUNT) + { + switch (row) + { + case ACCOUNT_MANAGE_INDEX: + cell = [self getDefaultTableViewCell:tableView]; + cell.textLabel.text = [VectorL10n settingsManageAccountAction]; + [cell vc_setAccessoryDisclosureIndicatorWithCurrentTheme]; + break; + } + } return cell; } @@ -2975,6 +3005,14 @@ ChangePasswordCoordinatorBridgePresenterDelegate> break; } } + else if (section == SECTION_TAG_ACCOUNT) + { + switch(row) { + case ACCOUNT_MANAGE_INDEX: + [self onManageAccountTap]; + break; + } + } [tableView deselectRowAtIndexPath:indexPath animated:YES]; } @@ -3883,6 +3921,14 @@ ChangePasswordCoordinatorBridgePresenterDelegate> } } +- (void)onManageAccountTap +{ + NSURL *url = [NSURL URLWithString: self.mainSession.homeserverWellknown.authentication.account]; + if (url) { + [UIApplication.sharedApplication openURL:url options:@{} completionHandler:nil]; + } +} + - (void)showThemePicker { __weak typeof(self) weakSelf = self; diff --git a/RiotSwiftUI/Modules/Common/Util/ListBackground.swift b/RiotSwiftUI/Modules/Common/Util/ListBackground.swift index d4e087da8..ddfc362c2 100644 --- a/RiotSwiftUI/Modules/Common/Util/ListBackground.swift +++ b/RiotSwiftUI/Modules/Common/Util/ListBackground.swift @@ -49,10 +49,4 @@ extension View { func listBackgroundColor(_ color: Color) -> some View { modifier(ListBackgroundModifier(color: color)) } - - /// Finds a `UICollectionView` from a `SwiftUI.List`, or `SwiftUI.List` child. - /// Stop gap until https://github.com/siteline/SwiftUI-Introspect/pull/169 - func introspectCollectionView(customize: @escaping (UICollectionView) -> Void) -> some View { - introspect(selector: TargetViewSelector.ancestorOrSiblingContaining, customize: customize) - } } diff --git a/RiotSwiftUI/Modules/UserSessions/Coordinator/UserSessionsFlowCoordinator.swift b/RiotSwiftUI/Modules/UserSessions/Coordinator/UserSessionsFlowCoordinator.swift index 79fd9e573..041f5a1ae 100644 --- a/RiotSwiftUI/Modules/UserSessions/Coordinator/UserSessionsFlowCoordinator.swift +++ b/RiotSwiftUI/Modules/UserSessions/Coordinator/UserSessionsFlowCoordinator.swift @@ -120,17 +120,29 @@ final class UserSessionsFlowCoordinator: NSObject, Coordinator, Presentable { case let .renameSession(sessionInfo): self.showRenameSessionScreen(for: sessionInfo) case let .logoutOfSession(sessionInfo): - if sessionInfo.isCurrent { - self.showLogoutConfirmationForCurrentSession() - } else { - self.showLogoutConfirmation(for: [sessionInfo]) - } + self.handleLogoutOfSession(sessionInfo: sessionInfo) case let .showSessionStateInfo(sessionInfo): self.showInfoSheet(parameters: .init(userSessionInfo: sessionInfo, parentSize: self.toPresentable().view.bounds.size)) } } pushScreen(with: coordinator) } + + private func handleLogoutOfSession(sessionInfo: UserSessionInfo) { + if sessionInfo.isCurrent { + self.showLogoutConfirmationForCurrentSession() + } else { + if let authentication = self.parameters.session.homeserverWellknown.authentication { + if let logoutURL = authentication.getLogoutDeviceURL(fromID: sessionInfo.id) { + self.openDeviceLogoutRedirectURL(logoutURL) + } else { + self.showDeviceLogoutRedirectError() + } + } else { + self.showLogoutConfirmation(for: [sessionInfo]) + } + } + } /// Shows the QR login screen. private func openQRLoginScreen() { @@ -182,6 +194,26 @@ final class UserSessionsFlowCoordinator: NSObject, Coordinator, Presentable { return UserOtherSessionsCoordinator(parameters: parameters) } + private func openDeviceLogoutRedirectURL(_ url: URL) { + let alert = UIAlertController(title: VectorL10n.manageSessionRedirect, message: nil, preferredStyle: .alert) + alert.addAction(UIAlertAction(title: VectorL10n.ok, style: .default) { [weak self] _ in + UIApplication.shared.open(url) { [weak self] success in + guard success else { + return + } + self?.popToSessionsOverview() + } + }) + alert.popoverPresentationController?.sourceView = toPresentable().view + navigationRouter.present(alert, animated: true) + } + + private func showDeviceLogoutRedirectError() { + let alert = UIAlertController(title: VectorL10n.manageSessionRedirectError, message: nil, preferredStyle: .alert) + alert.popoverPresentationController?.sourceView = toPresentable().view + navigationRouter.present(alert, animated: true) + } + /// Shows a confirmation dialog to the user to sign out of a session. private func showLogoutConfirmation(for sessionInfos: [UserSessionInfo]) { // Use a UIAlertController as we don't have confirmationDialog in SwiftUI on iOS 14.