diff --git a/Riot/Assets/en.lproj/Vector.strings b/Riot/Assets/en.lproj/Vector.strings index 697d08884..b44c54519 100644 --- a/Riot/Assets/en.lproj/Vector.strings +++ b/Riot/Assets/en.lproj/Vector.strings @@ -673,6 +673,7 @@ Tap the + to start adding people."; "settings_labs_enable_threads" = "Threaded messaging"; "settings_labs_enable_auto_report_decryption_errors" = "Auto Report Decryption Errors"; "settings_labs_use_only_latest_user_avatar_and_name" = "Show latest avatar and name for users in message history"; +"settings_labs_enable_live_location_sharing" = "Live location sharing - share current location (active development, and temporarily, locations persist in room history)"; "settings_version" = "Version %@"; "settings_olm_version" = "Olm Version %@"; diff --git a/Riot/Generated/Strings.swift b/Riot/Generated/Strings.swift index 4130a3cc1..f1985bb8e 100644 --- a/Riot/Generated/Strings.swift +++ b/Riot/Generated/Strings.swift @@ -6883,6 +6883,10 @@ public class VectorL10n: NSObject { public static var settingsLabsEnableAutoReportDecryptionErrors: String { return VectorL10n.tr("Vector", "settings_labs_enable_auto_report_decryption_errors") } + /// Live location sharing - share current location (active development, and temporarily, locations persist in room history) + public static var settingsLabsEnableLiveLocationSharing: String { + return VectorL10n.tr("Vector", "settings_labs_enable_live_location_sharing") + } /// Ring for group calls public static var settingsLabsEnableRingingForGroupCalls: String { return VectorL10n.tr("Vector", "settings_labs_enable_ringing_for_group_calls") diff --git a/Riot/Managers/Settings/RiotSettings.swift b/Riot/Managers/Settings/RiotSettings.swift index 49516ddf9..d2cabfcfa 100644 --- a/Riot/Managers/Settings/RiotSettings.swift +++ b/Riot/Managers/Settings/RiotSettings.swift @@ -31,6 +31,7 @@ final class RiotSettings: NSObject { static let pinRoomsWithUnreadMessagesOnHome = "pinRoomsWithUnread" static let showAllRoomsInHomeSpace = "showAllRoomsInHomeSpace" static let enableUISIAutoReporting = "enableUISIAutoReporting" + static let enableLiveLocationSharing = "enableLiveLocationSharing" } static let shared = RiotSettings() @@ -151,6 +152,10 @@ final class RiotSettings: NSObject { @UserDefault(key: UserDefaultsKeys.enableUISIAutoReporting, defaultValue: BuildSettings.cryptoUISIAutoReportingEnabled, storage: defaults) var enableUISIAutoReporting + /// Indicates if live location sharing is enabled + @UserDefault(key: UserDefaultsKeys.enableLiveLocationSharing, defaultValue: BuildSettings.liveLocationSharingEnabled, storage: defaults) + var enableLiveLocationSharing + // MARK: Calls /// Indicate if `allowStunServerFallback` settings has been set once. diff --git a/Riot/Modules/LocationSharing/UserLocationServiceProvider.swift b/Riot/Modules/LocationSharing/UserLocationServiceProvider.swift index 007e745e2..a9230b181 100644 --- a/Riot/Modules/LocationSharing/UserLocationServiceProvider.swift +++ b/Riot/Modules/LocationSharing/UserLocationServiceProvider.swift @@ -31,7 +31,7 @@ class UserLocationServiceProvider { // MARK: - Setup private init() { - guard BuildSettings.liveLocationSharingEnabled else { + guard RiotSettings.shared.enableLiveLocationSharing else { return } diff --git a/Riot/Modules/Room/DataSources/RoomDataSource.m b/Riot/Modules/Room/DataSources/RoomDataSource.m index b2ac6499c..8fed2858c 100644 --- a/Riot/Modules/Room/DataSources/RoomDataSource.m +++ b/Riot/Modules/Room/DataSources/RoomDataSource.m @@ -238,7 +238,7 @@ const CGFloat kTypingCellHeight = 24; - (void)roomSummaryDidChange:(NSNotification*)notification { - if (BuildSettings.liveLocationSharingEnabled) + if (RiotSettings.shared.enableLiveLocationSharing) { [self updateCurrentUserLocationSharingStatus]; } diff --git a/Riot/Modules/Settings/SettingsViewController.m b/Riot/Modules/Settings/SettingsViewController.m index 4e0730bb2..a55366233 100644 --- a/Riot/Modules/Settings/SettingsViewController.m +++ b/Riot/Modules/Settings/SettingsViewController.m @@ -167,7 +167,8 @@ typedef NS_ENUM(NSUInteger, LABS_ENABLE) LABS_ENABLE_THREADS_INDEX, LABS_ENABLE_MESSAGE_BUBBLES_INDEX, LABS_ENABLE_AUTO_REPORT_DECRYPTION_ERRORS, - LABS_USE_ONLY_LATEST_USER_AVATAR_AND_NAME_INDEX + LABS_USE_ONLY_LATEST_USER_AVATAR_AND_NAME_INDEX, + LABS_ENABLE_LIVE_LOCATION_SHARING }; typedef NS_ENUM(NSUInteger, SECURITY) @@ -595,6 +596,11 @@ ThreadsBetaCoordinatorBridgePresenterDelegate> [sectionLabs addRowWithTag:LABS_ENABLE_MESSAGE_BUBBLES_INDEX]; [sectionLabs addRowWithTag:LABS_ENABLE_AUTO_REPORT_DECRYPTION_ERRORS]; [sectionLabs addRowWithTag:LABS_USE_ONLY_LATEST_USER_AVATAR_AND_NAME_INDEX]; + if (BuildSettings.liveLocationSharingEnabled) + { + // Hide live location lab setting until it's ready to be release + [sectionLabs addRowWithTag:LABS_ENABLE_LIVE_LOCATION_SHARING]; + } sectionLabs.headerTitle = [VectorL10n settingsLabs]; if (sectionLabs.hasAnyRows) { @@ -1522,6 +1528,21 @@ ThreadsBetaCoordinatorBridgePresenterDelegate> return labelAndSwitchCell; } +- (UITableViewCell *)buildLiveLocationSharingCellForTableView:(UITableView*)tableView + atIndexPath:(NSIndexPath*)indexPath +{ + MXKTableViewCellWithLabelAndSwitch* labelAndSwitchCell = [self getLabelAndSwitchCell:tableView forIndexPath:indexPath]; + + labelAndSwitchCell.mxkLabel.text = [VectorL10n settingsLabsEnableLiveLocationSharing]; + + labelAndSwitchCell.mxkSwitch.on = RiotSettings.shared.enableLiveLocationSharing; + labelAndSwitchCell.mxkSwitch.onTintColor = ThemeService.shared.theme.tintColor; + labelAndSwitchCell.mxkSwitch.enabled = YES; + [labelAndSwitchCell.mxkSwitch addTarget:self action:@selector(toggleEnableLiveLocationSharing:) forControlEvents:UIControlEventTouchUpInside]; + + return labelAndSwitchCell; +} + #pragma mark - 3Pid Add - (void)showAuthenticationIfNeededForAdding:(MX3PIDMedium)medium withSession:(MXSession*)session completion:(void (^)(NSDictionary* authParams))completion @@ -2528,6 +2549,10 @@ ThreadsBetaCoordinatorBridgePresenterDelegate> cell = labelAndSwitchCell; } + else if (row == LABS_ENABLE_LIVE_LOCATION_SHARING) + { + cell = [self buildLiveLocationSharingCellForTableView:tableView atIndexPath:indexPath]; + } } else if (section == SECTION_TAG_FLAIR) { @@ -4003,6 +4028,11 @@ ThreadsBetaCoordinatorBridgePresenterDelegate> RiotSettings.shared.enableUISIAutoReporting = sender.isOn; } +- (void)toggleEnableLiveLocationSharing:(UISwitch *)sender +{ + RiotSettings.shared.enableLiveLocationSharing = sender.isOn; +} + #pragma mark - TextField listener - (IBAction)textFieldDidChange:(id)sender diff --git a/RiotSwiftUI/Modules/Room/LocationSharing/Coordinator/LocationSharingCoordinator.swift b/RiotSwiftUI/Modules/Room/LocationSharing/Coordinator/LocationSharingCoordinator.swift index 1abb36aa8..b4e11f34e 100644 --- a/RiotSwiftUI/Modules/Room/LocationSharing/Coordinator/LocationSharingCoordinator.swift +++ b/RiotSwiftUI/Modules/Room/LocationSharing/Coordinator/LocationSharingCoordinator.swift @@ -82,7 +82,7 @@ final class LocationSharingCoordinator: Coordinator, Presentable { let viewModel = LocationSharingViewModel(mapStyleURL: BuildSettings.tileServerMapStyleURL, avatarData: parameters.avatarData, - isLiveLocationSharingEnabled: BuildSettings.liveLocationSharingEnabled, service: locationSharingService) + isLiveLocationSharingEnabled: RiotSettings.shared.enableLiveLocationSharing, service: locationSharingService) let view = LocationSharingView(context: viewModel.context) .addDependency(AvatarService.instantiate(mediaManager: parameters.mediaManager)) diff --git a/changelog.d/6195.change b/changelog.d/6195.change new file mode 100644 index 000000000..0cdb3a521 --- /dev/null +++ b/changelog.d/6195.change @@ -0,0 +1 @@ +Location sharing: Add labs flag for live location sharing