diff --git a/Application/Resources/Apps/Play RSI/ApplicationConfiguration.json b/Application/Resources/Apps/Play RSI/ApplicationConfiguration.json index 0fdfc645b..de137b026 100755 --- a/Application/Resources/Apps/Play RSI/ApplicationConfiguration.json +++ b/Application/Resources/Apps/Play RSI/ApplicationConfiguration.json @@ -5,7 +5,6 @@ "tvSiteName": "rsi-player-tvos-apple", "voiceOverLanguageCode": "it", "appStoreProductIdentifier": 920753497, - "serviceURL": "https://il.srf.ch", "playURLs": "{\"rsi\":\"https://www.rsi.ch/play/\",\"rtr\":\"https://www.rtr.ch/play/\",\"rts\":\"https://www.rts.ch/play/\",\"srf\":\"https://www.srf.ch/play/\",\"swi\":\"https://play.swissinfo.ch/play/\"}", "playServiceURL": "https://www.rsi.ch/play/", "middlewareURL": "https://playfff.herokuapp.com", diff --git a/Application/Resources/Apps/Play RTR/ApplicationConfiguration.json b/Application/Resources/Apps/Play RTR/ApplicationConfiguration.json index 84863b498..5637b118e 100755 --- a/Application/Resources/Apps/Play RTR/ApplicationConfiguration.json +++ b/Application/Resources/Apps/Play RTR/ApplicationConfiguration.json @@ -4,7 +4,6 @@ "siteName": "rtr-player-ios-v", "tvSiteName": "rtr-player-tvos-apple", "appStoreProductIdentifier": 920754925, - "serviceURL": "https://il.srf.ch", "playURLs": "{\"rsi\":\"https://www.rsi.ch/play/\",\"rtr\":\"https://www.rtr.ch/play/\",\"rts\":\"https://www.rts.ch/play/\",\"srf\":\"https://www.srf.ch/play/\",\"swi\":\"https://play.swissinfo.ch/play/\"}", "playServiceURL": "https://www.rtr.ch/play/", "middlewareURL": "https://playfff.herokuapp.com", diff --git a/Application/Resources/Apps/Play RTS/ApplicationConfiguration.json b/Application/Resources/Apps/Play RTS/ApplicationConfiguration.json index 7c3964337..e9f68bb0f 100755 --- a/Application/Resources/Apps/Play RTS/ApplicationConfiguration.json +++ b/Application/Resources/Apps/Play RTS/ApplicationConfiguration.json @@ -5,7 +5,6 @@ "tvSiteName": "rts-player-tvos-apple", "voiceOverLanguageCode": "fr", "appStoreProductIdentifier": 920754415, - "serviceURL": "https://il.srf.ch", "playURLs": "{\"rsi\":\"https://www.rsi.ch/play/\",\"rtr\":\"https://www.rtr.ch/play/\",\"rts\":\"https://www.rts.ch/play/\",\"srf\":\"https://www.srf.ch/play/\",\"swi\":\"https://play.swissinfo.ch/play/\"}", "playServiceURL": "https://www.rts.ch/play/", "middlewareURL": "https://playfff.herokuapp.com", diff --git a/Application/Resources/Apps/Play SRF/ApplicationConfiguration.json b/Application/Resources/Apps/Play SRF/ApplicationConfiguration.json index 59be87314..099b90644 100755 --- a/Application/Resources/Apps/Play SRF/ApplicationConfiguration.json +++ b/Application/Resources/Apps/Play SRF/ApplicationConfiguration.json @@ -5,7 +5,6 @@ "tvSiteName": "srf-player-tvos-apple", "voiceOverLanguageCode": "de", "appStoreProductIdentifier": 638194352, - "serviceURL": "https://il.srf.ch", "playURLs": "{\"rsi\":\"https://www.rsi.ch/play/\",\"rtr\":\"https://www.rtr.ch/play/\",\"rts\":\"https://www.rts.ch/play/\",\"srf\":\"https://www.srf.ch/play/\",\"swi\":\"https://play.swissinfo.ch/play/\"}", "playServiceURL": "https://www.srf.ch/play/", "middlewareURL": "https://playfff.herokuapp.com", diff --git a/Application/Resources/Apps/Play SWI/ApplicationConfiguration.json b/Application/Resources/Apps/Play SWI/ApplicationConfiguration.json index 4338c212a..5612d9e11 100755 --- a/Application/Resources/Apps/Play SWI/ApplicationConfiguration.json +++ b/Application/Resources/Apps/Play SWI/ApplicationConfiguration.json @@ -5,7 +5,6 @@ "tvSiteName": "swi-player-tvos-apple", "voiceOverLanguageCode": "en", "appStoreProductIdentifier": 920785201, - "serviceURL": "https://il.srf.ch", "playURLs": "{\"rsi\":\"https://www.rsi.ch/play/\",\"rtr\":\"https://www.rtr.ch/play/\",\"rts\":\"https://www.rts.ch/play/\",\"srf\":\"https://www.srf.ch/play/\",\"swi\":\"https://play.swissinfo.ch/play/\"}", "playServiceURL": "https://play.swissinfo.ch/play/", "middlewareURL": "https://playfff.herokuapp.com", diff --git a/Application/Sources/Application/AppDelegate.m b/Application/Sources/Application/AppDelegate.m index 281e86dec..26116ef9e 100755 --- a/Application/Sources/Application/AppDelegate.m +++ b/Application/Sources/Application/AppDelegate.m @@ -110,7 +110,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( PlayApplicationRunOnce(^(void (^completionHandler)(BOOL success)) { NSUserDefaults *userDefaults = NSUserDefaults.standardUserDefaults; - [userDefaults removeObjectForKey:PlaySRGSettingServiceIdentifier]; + [userDefaults removeObjectForKey:PlaySRGSettingServiceEnvironment]; [userDefaults synchronize]; completionHandler(YES); }, @"DataProviderServiceURLChange"); @@ -122,7 +122,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( #if defined(DEBUG) || defined(NIGHTLY) || defined(BETA) NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults; - [defaults addObserver:self forKeyPath:PlaySRGSettingServiceIdentifier options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:s_kvoContext]; + [defaults addObserver:self forKeyPath:PlaySRGSettingServiceEnvironment options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:s_kvoContext]; [defaults addObserver:self forKeyPath:PlaySRGSettingUserLocation options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:s_kvoContext]; #endif @@ -379,7 +379,7 @@ - (void)userDidLogout:(NSNotification *)notification - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { if (s_kvoContext == context) { - if ([keyPath isEqualToString:PlaySRGSettingServiceIdentifier] || [keyPath isEqualToString:PlaySRGSettingUserLocation]) { + if ([keyPath isEqualToString:PlaySRGSettingServiceEnvironment] || [keyPath isEqualToString:PlaySRGSettingUserLocation]) { id oldValue = change[NSKeyValueChangeOldKey]; id newValue = change[NSKeyValueChangeNewKey]; diff --git a/Application/Sources/Application/SceneDelegate.m b/Application/Sources/Application/SceneDelegate.m index e0590a6c5..09ab543f0 100644 --- a/Application/Sources/Application/SceneDelegate.m +++ b/Application/Sources/Application/SceneDelegate.m @@ -58,7 +58,7 @@ - (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session op #if defined(DEBUG) || defined(NIGHTLY) || defined(BETA) NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults; - [defaults addObserver:self forKeyPath:PlaySRGSettingServiceIdentifier options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:s_kvoContext]; + [defaults addObserver:self forKeyPath:PlaySRGSettingServiceEnvironment options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:s_kvoContext]; [defaults addObserver:self forKeyPath:PlaySRGSettingUserLocation options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:s_kvoContext]; [defaults addObserver:self forKeyPath:PlaySRGSettingPosterImages options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:s_kvoContext]; [defaults addObserver:self forKeyPath:PlaySRGSettingSquareImages options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:s_kvoContext]; @@ -70,7 +70,7 @@ - (void)sceneDidDisconnect:(UIScene *)scene { #if defined(DEBUG) || defined(NIGHTLY) || defined(BETA) NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults; - [defaults removeObserver:self forKeyPath:PlaySRGSettingServiceIdentifier]; + [defaults removeObserver:self forKeyPath:PlaySRGSettingServiceEnvironment]; [defaults removeObserver:self forKeyPath:PlaySRGSettingUserLocation]; [defaults removeObserver:self forKeyPath:PlaySRGSettingPosterImages]; [defaults removeObserver:self forKeyPath:PlaySRGSettingSquareImages]; @@ -110,7 +110,7 @@ - (void)handleDeepLinkAction:(DeepLinkAction *)action if (! [serviceIdentifier isEqual:ApplicationSettingServiceIdentifier()]) { ApplicationSettingSetServiceIdentifier(serviceIdentifier); - NSString *serviceName = [ServiceObjC nameForServiceId:serviceIdentifier]; + NSString *serviceName = [ServiceObjC nameForEnvironment:serviceIdentifier]; [Banner showWith:BannerStyleInfo message:[NSString stringWithFormat:NSLocalizedString(@"Server changed to '%@'", @"Notification message when the server URL changed due to a custom URL."), serviceName] image:[UIImage imageNamed:@"settings"] @@ -560,7 +560,7 @@ - (void)openSectionUid:(NSString *)sectionUid - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { if (s_kvoContext == context) { - if ([keyPath isEqualToString:PlaySRGSettingServiceIdentifier] || [keyPath isEqualToString:PlaySRGSettingUserLocation] || [keyPath isEqualToString:PlaySRGSettingPosterImages] || [keyPath isEqualToString:PlaySRGSettingSquareImages] || [keyPath isEqualToString:PlaySRGSettingAudioHomepageOption]) { + if ([keyPath isEqualToString:PlaySRGSettingServiceEnvironment] || [keyPath isEqualToString:PlaySRGSettingUserLocation] || [keyPath isEqualToString:PlaySRGSettingPosterImages] || [keyPath isEqualToString:PlaySRGSettingSquareImages] || [keyPath isEqualToString:PlaySRGSettingAudioHomepageOption]) { // Entirely reload the view controller hierarchy to ensure all configuration changes are reflected in the // user interface. Scheduled for the next run loop to have the same code in the app delegate (updating the // data provider) executed first. diff --git a/Application/Sources/Configuration/ApplicationConfiguration.h b/Application/Sources/Configuration/ApplicationConfiguration.h index 41460af0d..d791cf2f9 100755 --- a/Application/Sources/Configuration/ApplicationConfiguration.h +++ b/Application/Sources/Configuration/ApplicationConfiguration.h @@ -38,8 +38,10 @@ OBJC_EXPORT NSString * const ApplicationConfigurationDidChangeNotification; @property (nonatomic, readonly, copy) NSNumber *appStoreProductIdentifier; -@property (nonatomic, readonly, nullable) NSURL *serviceURL; @property (nonatomic, readonly) NSURL *playServiceURL; +@property (nonatomic, readonly) NSURL *dataProviderProductionServiceURL; +@property (nonatomic, readonly) NSURL *dataProviderStageServiceURL; +@property (nonatomic, readonly) NSURL *dataProviderTestServiceURL; @property (nonatomic, readonly) NSURL *middlewareURL; @property (nonatomic, readonly, nullable) NSURL *identityWebserviceURL; @property (nonatomic, readonly, nullable) NSURL *identityWebsiteURL; diff --git a/Application/Sources/Configuration/ApplicationConfiguration.m b/Application/Sources/Configuration/ApplicationConfiguration.m index 376923e79..68e7dde31 100755 --- a/Application/Sources/Configuration/ApplicationConfiguration.m +++ b/Application/Sources/Configuration/ApplicationConfiguration.m @@ -122,9 +122,11 @@ @interface ApplicationConfiguration () @property (nonatomic, copy) NSNumber *appStoreProductIdentifier; -@property (nonatomic) NSURL *serviceURL; @property (nonatomic) NSDictionary *playURLs; @property (nonatomic) NSURL *playServiceURL; +@property (nonatomic) NSURL *dataProviderProductionServiceURL; +@property (nonatomic) NSURL *dataProviderStageServiceURL; +@property (nonatomic) NSURL *dataProviderTestServiceURL; @property (nonatomic) NSURL *middlewareURL; @property (nonatomic) NSURL *identityWebserviceURL; @property (nonatomic) NSURL *identityWebsiteURL; @@ -237,6 +239,21 @@ - (instancetype)init #pragma mark Getters and setters +- (NSURL *)dataProviderProductionServiceURL +{ + return _dataProviderProductionServiceURL ?: SRGIntegrationLayerProductionServiceURL(); +} + +- (NSURL *)dataProviderStageServiceURL +{ + return _dataProviderStageServiceURL ?: SRGIntegrationLayerStagingServiceURL(); +} + +- (NSURL *)dataProviderTestServiceURL +{ + return _dataProviderTestServiceURL ?: SRGIntegrationLayerTestServiceURL(); +} + - (BOOL)isContinuousPlaybackAvailable { #if TARGET_OS_IOS @@ -449,10 +466,16 @@ - (BOOL)synchronizeWithFirebaseConfiguration:(PlayFirebaseConfiguration *)fireba // self.voiceOverLanguageCode = [firebaseConfiguration stringForKey:@"voiceOverLanguageCode"]; - - NSString *serviceURLString = [firebaseConfiguration stringForKey:@"serviceURL"]; - self.serviceURL = serviceURLString ? [NSURL URLWithString:serviceURLString] : nil; - + + NSString *dataProviderProductionServiceURLString = [firebaseConfiguration stringForKey:@"dataProviderProductionServiceURL"]; + self.dataProviderProductionServiceURL = dataProviderProductionServiceURLString ? [NSURL URLWithString:dataProviderProductionServiceURLString] : nil; + + NSString *dataProviderStageServiceURLString = [firebaseConfiguration stringForKey:@"dataProviderStageServiceURL"]; + self.dataProviderStageServiceURL = dataProviderStageServiceURLString ? [NSURL URLWithString:dataProviderStageServiceURLString] : nil; + + NSString *dataProviderTestServiceURLString = [firebaseConfiguration stringForKey:@"dataProviderTestServiceURL"]; + self.dataProviderTestServiceURL = dataProviderTestServiceURLString ? [NSURL URLWithString:dataProviderTestServiceURLString] : nil; + NSString *identityWebserviceURLString = [firebaseConfiguration stringForKey:@"identityWebserviceURL"]; self.identityWebserviceURL = identityWebserviceURLString ? [NSURL URLWithString:identityWebserviceURLString] : nil; diff --git a/Application/Sources/Settings/ApplicationSettings+Common.m b/Application/Sources/Settings/ApplicationSettings+Common.m index a626b478d..6c9d6770b 100755 --- a/Application/Sources/Settings/ApplicationSettings+Common.m +++ b/Application/Sources/Settings/ApplicationSettings+Common.m @@ -197,19 +197,19 @@ void ApplicationSettingSetLastSelectedAudioLanguageCode(NSString *languageCode) NSString *ApplicationSettingServiceIdentifier(void) { - return [NSUserDefaults.standardUserDefaults stringForKey:PlaySRGSettingServiceIdentifier]; + return [NSUserDefaults.standardUserDefaults stringForKey:PlaySRGSettingServiceEnvironment]; } void ApplicationSettingSetServiceIdentifier(NSString *identifier) { NSUserDefaults *userDefaults = NSUserDefaults.standardUserDefaults; - [userDefaults setObject:identifier forKey:PlaySRGSettingServiceIdentifier]; + [userDefaults setObject:identifier forKey:PlaySRGSettingServiceEnvironment]; [userDefaults synchronize]; } NSURL *ApplicationSettingServiceURL(void) { - return [ServiceObjC urlForServiceId:ApplicationSettingServiceIdentifier()]; + return [ServiceObjC urlForEnvironment:ApplicationSettingServiceIdentifier()]; } BOOL ApplicationSettingAutoplayEnabled(void) diff --git a/Application/Sources/Settings/ApplicationSettingsConstants.h b/Application/Sources/Settings/ApplicationSettingsConstants.h index 7e7d35d68..b29a2bcf6 100644 --- a/Application/Sources/Settings/ApplicationSettingsConstants.h +++ b/Application/Sources/Settings/ApplicationSettingsConstants.h @@ -22,7 +22,7 @@ OBJC_EXPORT NSString * const PlaySRGSettingAudioDescriptionAvailabilityDisplayed OBJC_EXPORT NSString * const PlaySRGSettingDiscoverySubtitleOptionLanguageRunOnce; OBJC_EXPORT NSString * const PlaySRGSettingLastLoggedInEmailAddress; OBJC_EXPORT NSString * const PlaySRGSettingSelectedLivestreamURNForChannels; -OBJC_EXPORT NSString * const PlaySRGSettingServiceIdentifier; +OBJC_EXPORT NSString * const PlaySRGSettingServiceEnvironment; OBJC_EXPORT NSString * const PlaySRGSettingUserLocation; OBJC_EXPORT NSString * const PlaySRGSettingUserConsentAcceptedServiceIds; #if defined(DEBUG) || defined(NIGHTLY) || defined(BETA) diff --git a/Application/Sources/Settings/ApplicationSettingsConstants.m b/Application/Sources/Settings/ApplicationSettingsConstants.m index 0d3e37216..2a5fd8aec 100644 --- a/Application/Sources/Settings/ApplicationSettingsConstants.m +++ b/Application/Sources/Settings/ApplicationSettingsConstants.m @@ -20,7 +20,7 @@ NSString * const PlaySRGSettingDiscoverySubtitleOptionLanguageRunOnce = @"PlaySRGSettingDiscoverySubtitleOptionLanguageRunOnce"; NSString * const PlaySRGSettingLastLoggedInEmailAddress = @"PlaySRGSettingLastLoggedInEmailAddress"; NSString * const PlaySRGSettingSelectedLivestreamURNForChannels = @"PlaySRGSettingSelectedLivestreamURNForChannels"; -NSString * const PlaySRGSettingServiceIdentifier = @"PlaySRGSettingServiceIdentifier"; +NSString * const PlaySRGSettingServiceEnvironment = @"PlaySRGSettingServiceEnvironment"; NSString * const PlaySRGSettingUserLocation = @"PlaySRGSettingUserLocation"; NSString * const PlaySRGSettingUserConsentAcceptedServiceIds = @"PlaySRGSettingUserConsentAcceptedServiceIds"; #if defined(DEBUG) || defined(NIGHTLY) || defined(BETA) diff --git a/Application/Sources/Settings/Service.swift b/Application/Sources/Settings/Service.swift index 7947a1d5f..fd42e8116 100644 --- a/Application/Sources/Settings/Service.swift +++ b/Application/Sources/Settings/Service.swift @@ -5,72 +5,77 @@ // import Foundation -import SRGDataProvider -struct Service: Identifiable, Equatable { - let id: String - let name: String - let url: URL +enum Service: String, Identifiable, CaseIterable { + case production + case stage + case test + case mmf = "play mmf" + case samProduction = "sam production" + case samStage = "sam stage" + case samTest = "sam test" - static var production = Self( - id: "production", - name: NSLocalizedString("Production", comment: "Server setting name"), - url: SRGIntegrationLayerProductionServiceURL() - ) - - static var stage = Self( - id: "stage", - name: NSLocalizedString("Stage", comment: "Server setting name"), - url: SRGIntegrationLayerStagingServiceURL() - ) - - static var test = Self( - id: "test", - name: NSLocalizedString("Test", comment: "Server setting name"), - url: SRGIntegrationLayerTestServiceURL() - ) - - static var mmf = Self( - id: "play mmf", - name: "Play MMF", - url: mmfUrl - ) - - private static var mmfUrl: URL = { + private static var mmfUrl: URL { guard let mmfUrlString = Bundle.main.object(forInfoDictionaryKey: "PlayMMFServiceURL") as? String, !mmfUrlString.isEmpty else { return URL(string: "https://play-mmf.herokuapp.com")! } return URL(string: mmfUrlString)! - }() + } - static var samProduction = Self( - id: "sam production", - name: "SAM \(NSLocalizedString("Production", comment: "Server setting name"))", - url: SRGIntegrationLayerProductionServiceURL().appendingPathComponent("sam") - ) + var id: Self { + self + } - static var samStage = Self( - id: "sam stage", - name: "SAM \(NSLocalizedString("Stage", comment: "Server setting name"))", - url: SRGIntegrationLayerStagingServiceURL().appendingPathComponent("sam") - ) + var environment: String { + rawValue + } - static var samTest = Self( - id: "sam test", - name: "SAM \(NSLocalizedString("Test", comment: "Server setting name"))", - url: SRGIntegrationLayerTestServiceURL().appendingPathComponent("sam") - ) + var name: String { + switch self { + case .production: + NSLocalizedString("Production", comment: "Server setting name") + case .stage: + NSLocalizedString("Stage", comment: "Server setting name") + case .test: + NSLocalizedString("Test", comment: "Server setting name") + case .mmf: + "Play MMF" + case .samProduction: + "SAM \(NSLocalizedString("Production", comment: "Server setting name"))" + case .samStage: + "SAM \(NSLocalizedString("Stage", comment: "Server setting name"))" + case .samTest: + "SAM \(NSLocalizedString("Test", comment: "Server setting name"))" + } + } - static var services: [Self] = [production, stage, test, mmf, samProduction, samStage, samTest] + var url: URL { + switch self { + case .production: + ApplicationConfiguration().dataProviderProductionServiceURL + case .stage: + ApplicationConfiguration().dataProviderStageServiceURL + case .test: + ApplicationConfiguration().dataProviderTestServiceURL + case .mmf: + Self.mmfUrl + case .samProduction: + ApplicationConfiguration().dataProviderProductionServiceURL.appendingPathComponent("sam") + case .samStage: + ApplicationConfiguration().dataProviderStageServiceURL.appendingPathComponent("sam") + case .samTest: + ApplicationConfiguration().dataProviderTestServiceURL.appendingPathComponent("sam") + } + } - static func service(forId id: String?) -> Self { + static func service(for environment: String?) -> Self { #if DEBUG || NIGHTLY || BETA - guard let id, let server = services.first(where: { $0.id == id }) else { + guard let environment, let service = Self(rawValue: environment) else { return .production } - return server + return service #else return .production #endif @@ -78,11 +83,13 @@ struct Service: Identifiable, Equatable { } @objc class ServiceObjC: NSObject { - @objc static func name(forServiceId serviceId: String) -> String { - Service.service(forId: serviceId).name + @objc static var environments = Service.allCases.map(\.environment) + + @objc static func name(forEnvironment environment: String) -> String { + Service.service(for: environment).name } - @objc static func url(forServiceId serviceId: String) -> URL { - ApplicationConfiguration().serviceURL ?? Service.service(forId: serviceId).url + @objc static func url(forEnvironment environment: String) -> URL { + Service.service(for: environment).url } } diff --git a/Application/Sources/Settings/SettingsView.swift b/Application/Sources/Settings/SettingsView.swift index 1a5f2e61a..6ab7b58b0 100644 --- a/Application/Sources/Settings/SettingsView.swift +++ b/Application/Sources/Settings/SettingsView.swift @@ -562,10 +562,10 @@ struct SettingsView: View { } private struct ServiceSelectionCell: View { - @AppStorage(PlaySRGSettingServiceIdentifier) private var selectedServiceId: String? + @AppStorage(PlaySRGSettingServiceEnvironment) private var selectedServiceId: String? private var selectedService: Service { - Service.service(forId: selectedServiceId) + Service.service(for: selectedServiceId) } var body: some View { @@ -643,7 +643,7 @@ struct SettingsView: View { private struct ServiceSelectionView: View { var body: some View { List { - ForEach(Service.services) { service in + ForEach(Service.allCases) { service in ServiceCell(service: service) } } @@ -660,7 +660,7 @@ struct SettingsView: View { private struct ServiceCell: View { let service: Service - @AppStorage(PlaySRGSettingServiceIdentifier) var selectedServiceId: String? + @AppStorage(PlaySRGSettingServiceEnvironment) var selectedServiceIdentifier: String? var body: some View { Button(action: select) { @@ -676,15 +676,11 @@ struct SettingsView: View { } private func isSelected() -> Bool { - if let selectedServiceId { - service.id == selectedServiceId - } else { - service == .production - } + service == Service.service(for: selectedServiceIdentifier) } private func select() { - selectedServiceId = service.id + selectedServiceIdentifier = service.rawValue } } diff --git a/Application/Sources/Settings/UserDefaults+ApplicationSettings.swift b/Application/Sources/Settings/UserDefaults+ApplicationSettings.swift index 2246fd574..084585220 100644 --- a/Application/Sources/Settings/UserDefaults+ApplicationSettings.swift +++ b/Application/Sources/Settings/UserDefaults+ApplicationSettings.swift @@ -25,8 +25,8 @@ extension UserDefaults { string(forKey: PlaySRG.PlaySRGSettingAudioHomepageOption) } - @objc dynamic var PlaySRGSettingServiceIdentifier: String? { - string(forKey: PlaySRG.PlaySRGSettingServiceIdentifier) + @objc dynamic var PlaySRGSettingServiceEnvironment: String? { + string(forKey: PlaySRG.PlaySRGSettingServiceEnvironment) } @objc dynamic var PlaySRGSettingUserLocation: String? { diff --git a/Scripts/check-quality.sh b/Scripts/check-quality.sh index db6d49012..b7e50f3fb 100755 --- a/Scripts/check-quality.sh +++ b/Scripts/check-quality.sh @@ -2,12 +2,13 @@ set -e -echo "... checking Swift code..." +echo "... checking Swift code with SwiftLint..." if [ $# -eq 0 ]; then swiftlint --quiet --strict elif [[ "$1" == "only-changes" ]]; then git diff --staged --name-only | grep ".swift$" | xargs -I FILE swiftlint lint --quiet --strict "FILE" fi +echo "... checking Swift code with SwiftFormat..." if [ $# -eq 0 ]; then swiftformat --lint --quiet . elif [[ "$1" == "only-changes" ]]; then diff --git a/TV Application/Sources/AppDelegate.swift b/TV Application/Sources/AppDelegate.swift index 00c60e237..ce78cfdce 100644 --- a/TV Application/Sources/AppDelegate.swift +++ b/TV Application/Sources/AppDelegate.swift @@ -38,7 +38,7 @@ extension AppDelegate: UIApplicationDelegate { PlayApplicationRunOnce({ completionHandler in let userDefaults = UserDefaults.standard - userDefaults.removeObject(forKey: PlaySRGSettingServiceIdentifier) + userDefaults.removeObject(forKey: PlaySRGSettingServiceEnvironment) userDefaults.synchronize() completionHandler(true) }, "DataProviderServiceURLChange") @@ -97,7 +97,7 @@ extension AppDelegate: UIApplicationDelegate { #if DEBUG || NIGHTLY || BETA Publishers.Merge( - ApplicationSignal.settingUpdates(at: \.PlaySRGSettingServiceIdentifier), + ApplicationSignal.settingUpdates(at: \.PlaySRGSettingServiceEnvironment), ApplicationSignal.settingUpdates(at: \.PlaySRGSettingUserLocation) ) .receive(on: DispatchQueue.main) diff --git a/TV Application/Sources/SceneDelegate.swift b/TV Application/Sources/SceneDelegate.swift index 22eb0638a..abd8d8d93 100644 --- a/TV Application/Sources/SceneDelegate.swift +++ b/TV Application/Sources/SceneDelegate.swift @@ -187,7 +187,7 @@ extension SceneDelegate: UIWindowSceneDelegate { ApplicationSignal.settingUpdates(at: \.PlaySRGSettingPosterImages), ApplicationSignal.settingUpdates(at: \.PlaySRGSettingSquareImages), ApplicationSignal.settingUpdates(at: \.PlaySRGSettingAudioHomepageOption), - ApplicationSignal.settingUpdates(at: \.PlaySRGSettingServiceIdentifier), + ApplicationSignal.settingUpdates(at: \.PlaySRGSettingServiceEnvironment), ApplicationSignal.settingUpdates(at: \.PlaySRGSettingUserLocation) ) .debounce(for: 0.7, scheduler: DispatchQueue.main) diff --git a/docs/REMOTE_CONFIGURATION.md b/docs/REMOTE_CONFIGURATION.md index 3d7f7ca91..0fcd37abb 100755 --- a/docs/REMOTE_CONFIGURATION.md +++ b/docs/REMOTE_CONFIGURATION.md @@ -26,7 +26,9 @@ If a remote configuration is found to be invalid (usually a mandatory parameter * `faqURL` (optional, string): The URL of the FAQs. * `dataProtectionURL` (optional, string): The URL of the data protection information page. * `impressumURL` (optional, string): The URL of the impressum page. If none is provided, the corresponding menu entry will not be displayed. -* `serviceURL` (optional, string): The URL of the Content service (DataProvider). If set, it overrides the local server option available in beta builds only. +* `dataProviderProductionServiceURL (optional, string): The URL of the production DataProvider service. If omitted, the default Integration Layer production URL is used. +* `dataProviderStageServiceURL (optional, string): The URL of the stage/int DataProvider service. If omitted, the default Integration Layer stage URL is used. +* `dataProviderTestServiceURL (optional, string): The URL of the test/dev DataProvider service. If omitted, the default Integration Layer test URL is used. * `identityWebserviceURL` (optional, string): The URL of the identity webservices. * `identityWebsiteURL` (optional, string): The URL of the identity web portal. * `userDataServiceURL` (optional, string): The URL of the service with which user data can be synchronized (history, preferences, playlists).