From 66b2259f7c618efef80ccbd3cb8aa2ac4a4d372d Mon Sep 17 00:00:00 2001 From: Arnfried Griesert Date: Wed, 8 Feb 2023 14:53:45 +0000 Subject: [PATCH] MESSENGER-4034 app icon name --- Config/AppIdentifiers.xcconfig | 2 +- Config/BWIBuildSettings.swift | 2 ++ Config/BuM-Beta/BWIBuildSettings+BuM-Beta.swift | 1 + Config/BuM/AppIdentifiers-bum.xcconfig | 2 +- Config/BuM/BWIBuildSettings+BuM.swift | 1 + Riot/Managers/AppInfo/AppInfo.swift | 7 ++++--- Riot/Modules/Application/LegacyAppDelegate.m | 7 ++++++- .../Camera/CameraAccessAlertPresenter.swift | 7 ++++++- Riot/Modules/Home/HomeViewController.m | 7 ++++++- .../MatrixKit/Controllers/MXKCallViewController.m | 14 ++++++++++++-- Riot/Modules/MatrixKit/Models/Account/MXKAccount.m | 7 ++++++- .../MatrixKit/Models/Contact/MXKContactManager.m | 7 ++++++- .../MediaPicker/MediaPickerViewController.m | 9 +++++++-- bwi/MatomoAnalytics/BWIAnalytics.swift | 6 +++++- bwi/UserAgent/UserAgentService.swift | 10 ++++++++-- 15 files changed, 72 insertions(+), 17 deletions(-) diff --git a/Config/AppIdentifiers.xcconfig b/Config/AppIdentifiers.xcconfig index 51a353aee..d27b76f98 100644 --- a/Config/AppIdentifiers.xcconfig +++ b/Config/AppIdentifiers.xcconfig @@ -16,7 +16,7 @@ // App identity -BUNDLE_DISPLAY_NAME = BundesMessenger +BUNDLE_DISPLAY_NAME = Messenger BASE_BUNDLE_IDENTIFIER = de.bwi.messenger APPLICATION_GROUP_IDENTIFIER = group.de.messenger APPLICATION_SCHEME = element diff --git a/Config/BWIBuildSettings.swift b/Config/BWIBuildSettings.swift index 31718fc9c..3cac8a989 100644 --- a/Config/BWIBuildSettings.swift +++ b/Config/BWIBuildSettings.swift @@ -74,6 +74,8 @@ class BWIBuildSettings: NSObject { // MARK: - + var secondaryAppName = "" + // Location Sharing // (this disables error messages when map laoding failed) var locationSharingSSLProblemWorkaround = true diff --git a/Config/BuM-Beta/BWIBuildSettings+BuM-Beta.swift b/Config/BuM-Beta/BWIBuildSettings+BuM-Beta.swift index bad0647c2..a3810f8cf 100644 --- a/Config/BuM-Beta/BWIBuildSettings+BuM-Beta.swift +++ b/Config/BuM-Beta/BWIBuildSettings+BuM-Beta.swift @@ -20,6 +20,7 @@ import Foundation extension BWIBuildSettings { func overrideTargetSpecificSettings() { + secondaryAppName = "BundesMessenger" authScreenShowRegister = true showTopBanner = false bwiShowDeveloperSettings = true diff --git a/Config/BuM/AppIdentifiers-bum.xcconfig b/Config/BuM/AppIdentifiers-bum.xcconfig index 51a353aee..d27b76f98 100644 --- a/Config/BuM/AppIdentifiers-bum.xcconfig +++ b/Config/BuM/AppIdentifiers-bum.xcconfig @@ -16,7 +16,7 @@ // App identity -BUNDLE_DISPLAY_NAME = BundesMessenger +BUNDLE_DISPLAY_NAME = Messenger BASE_BUNDLE_IDENTIFIER = de.bwi.messenger APPLICATION_GROUP_IDENTIFIER = group.de.messenger APPLICATION_SCHEME = element diff --git a/Config/BuM/BWIBuildSettings+BuM.swift b/Config/BuM/BWIBuildSettings+BuM.swift index e4165de5a..a3aea700c 100644 --- a/Config/BuM/BWIBuildSettings+BuM.swift +++ b/Config/BuM/BWIBuildSettings+BuM.swift @@ -20,6 +20,7 @@ import Foundation extension BWIBuildSettings { func overrideTargetSpecificSettings() { + secondaryAppName = "BundesMessenger" locationSharingEnabled = false bwiLocationShareButtonVisible = false } diff --git a/Riot/Managers/AppInfo/AppInfo.swift b/Riot/Managers/AppInfo/AppInfo.swift index fde62d75b..8054d040e 100644 --- a/Riot/Managers/AppInfo/AppInfo.swift +++ b/Riot/Managers/AppInfo/AppInfo.swift @@ -51,9 +51,10 @@ final class AppInfo: NSObject { } private static var bundleDisplayName: String { - guard let bundleDisplayName = Bundle.app.object(forInfoDictionaryKey: "CFBundleDisplayName") as? String else { - fatalError("CFBundleDisplayName should be defined") + if !BWIBuildSettings.shared.secondaryAppName.isEmpty { + return BWIBuildSettings.shared.secondaryAppName + } else { + return Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as? String ?? "" } - return bundleDisplayName } } diff --git a/Riot/Modules/Application/LegacyAppDelegate.m b/Riot/Modules/Application/LegacyAppDelegate.m index c95ff6020..e00b7354c 100644 --- a/Riot/Modules/Application/LegacyAppDelegate.m +++ b/Riot/Modules/Application/LegacyAppDelegate.m @@ -3506,7 +3506,12 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni callerDisplayname = event.sender; } - NSString *appDisplayName = [[NSBundle mainBundle] infoDictionary][@"CFBundleDisplayName"]; + NSString *appDisplayName; + if(![BWIBuildSettings.shared.secondaryAppName isEqualToString:@""]) { + appDisplayName = BWIBuildSettings.shared.secondaryAppName; + } else { + appDisplayName = [[NSBundle mainBundle] infoDictionary][@"CFBundleDisplayName"]; + } NSString *message = [VectorL10n noVoip:callerDisplayname :appDisplayName]; diff --git a/Riot/Modules/Camera/CameraAccessAlertPresenter.swift b/Riot/Modules/Camera/CameraAccessAlertPresenter.swift index 45c828de2..1242c35b8 100644 --- a/Riot/Modules/Camera/CameraAccessAlertPresenter.swift +++ b/Riot/Modules/Camera/CameraAccessAlertPresenter.swift @@ -25,7 +25,12 @@ final class CameraAccessAlertPresenter { return } - let appDisplayName = Bundle.main.infoDictionary?["CFBundleDisplayName"] as? String ?? "" + let appDisplayName: String + if !BWIBuildSettings.shared.secondaryAppName.isEmpty { + appDisplayName = BWIBuildSettings.shared.secondaryAppName + } else { + appDisplayName = Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as? String ?? "" + } let alert = UIAlertController(title: VectorL10n.camera, message: VectorL10n.cameraAccessNotGranted(appDisplayName), preferredStyle: .alert) diff --git a/Riot/Modules/Home/HomeViewController.m b/Riot/Modules/Home/HomeViewController.m index 72909b199..d178e9cc4 100644 --- a/Riot/Modules/Home/HomeViewController.m +++ b/Riot/Modules/Home/HomeViewController.m @@ -928,7 +928,12 @@ NSString *displayName = myUser.displayname ?: myUser.userId; displayName = displayName ?: @""; - NSString *appName = [[NSBundle mainBundle] infoDictionary][@"CFBundleDisplayName"]; + NSString *appName; + if(![BWIBuildSettings.shared.secondaryAppName isEqualToString:@""]) { + appName = BWIBuildSettings.shared.secondaryAppName; + } else { + appName = [[NSBundle mainBundle] infoDictionary][@"CFBundleDisplayName"]; + } NSString *title = [VectorL10n homeEmptyViewTitle:appName :displayName]; [self.emptyView fillWith:[self emptyViewArtwork] diff --git a/Riot/Modules/MatrixKit/Controllers/MXKCallViewController.m b/Riot/Modules/MatrixKit/Controllers/MXKCallViewController.m index 4847ffef7..bd92e520b 100644 --- a/Riot/Modules/MatrixKit/Controllers/MXKCallViewController.m +++ b/Riot/Modules/MatrixKit/Controllers/MXKCallViewController.m @@ -362,7 +362,12 @@ static const CGFloat kLocalPreviewMargin = 20; { // Access to the camera is mandatory to display the self view // Check the permission right now - NSString *appDisplayName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]; + NSString *appDisplayName; + if(![BWIBuildSettings.shared.secondaryAppName isEqualToString:@""]) { + appDisplayName = BWIBuildSettings.shared.secondaryAppName; + } else { + appDisplayName = [[NSBundle mainBundle] infoDictionary][@"CFBundleDisplayName"]; + } [MXKTools checkAccessForMediaType:AVMediaTypeVideo manualChangeMessage:[VectorL10n cameraAccessNotGrantedForCall:appDisplayName] @@ -638,7 +643,12 @@ static const CGFloat kLocalPreviewMargin = 20; { // If we are here, we have access to the camera // The following check is mainly to check microphone access permission - NSString *appDisplayName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]; + NSString *appDisplayName; + if(![BWIBuildSettings.shared.secondaryAppName isEqualToString:@""]) { + appDisplayName = BWIBuildSettings.shared.secondaryAppName; + } else { + appDisplayName = [[NSBundle mainBundle] infoDictionary][@"CFBundleDisplayName"]; + } [MXKTools checkAccessForCall:mxCall.isVideoCall manualChangeMessageForAudio:[VectorL10n microphoneAccessNotGrantedForCall:appDisplayName] diff --git a/Riot/Modules/MatrixKit/Models/Account/MXKAccount.m b/Riot/Modules/MatrixKit/Models/Account/MXKAccount.m index 862c2ba42..5e7a0dfcc 100644 --- a/Riot/Modules/MatrixKit/Models/Account/MXKAccount.m +++ b/Riot/Modules/MatrixKit/Models/Account/MXKAccount.m @@ -1515,7 +1515,12 @@ static NSArray *initialSyncSilentErrorsHTTPStatusCodes; return; } - NSString *appDisplayName = [NSString stringWithFormat:@"%@ (iOS)", [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]]; + NSString *appDisplayName; + if(![BWIBuildSettings.shared.secondaryAppName isEqualToString:@""]) { + appDisplayName = BWIBuildSettings.shared.secondaryAppName; + } else { + appDisplayName = [[NSBundle mainBundle] infoDictionary][@"CFBundleDisplayName"]; + } NSString *b64Token = [token base64EncodedStringWithOptions:0]; diff --git a/Riot/Modules/MatrixKit/Models/Contact/MXKContactManager.m b/Riot/Modules/MatrixKit/Models/Contact/MXKContactManager.m index 009a82e57..ddc72376d 100644 --- a/Riot/Modules/MatrixKit/Models/Contact/MXKContactManager.m +++ b/Riot/Modules/MatrixKit/Models/Contact/MXKContactManager.m @@ -1174,7 +1174,12 @@ NSString *const MXKContactManagerDataType = @"org.matrix.kit.MXKContactManagerDa + (void)requestUserConfirmationForLocalContactsSyncInViewController:(UIViewController *)viewController completionHandler:(void (^)(BOOL))handler { - NSString *appDisplayName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]; + NSString *appDisplayName; + if(![BWIBuildSettings.shared.secondaryAppName isEqualToString:@""]) { + appDisplayName = BWIBuildSettings.shared.secondaryAppName; + } else { + appDisplayName = [[NSBundle mainBundle] infoDictionary][@"CFBundleDisplayName"]; + } [MXKContactManager requestUserConfirmationForLocalContactsSyncWithTitle:[VectorL10n localContactsAccessDiscoveryWarningTitle] message:[VectorL10n localContactsAccessDiscoveryWarning:appDisplayName] diff --git a/Riot/Modules/MediaPicker/MediaPickerViewController.m b/Riot/Modules/MediaPicker/MediaPickerViewController.m index c7ea53317..e56715361 100644 --- a/Riot/Modules/MediaPicker/MediaPickerViewController.m +++ b/Riot/Modules/MediaPicker/MediaPickerViewController.m @@ -257,8 +257,13 @@ - (void)presentPermissionDeniedAlert { - NSString *appDisplayName = [[NSBundle mainBundle] infoDictionary][@"CFBundleDisplayName"]; - + NSString *appDisplayName; + if(![BWIBuildSettings.shared.secondaryAppName isEqualToString:@""]) { + appDisplayName = BWIBuildSettings.shared.secondaryAppName; + } else { + appDisplayName = [[NSBundle mainBundle] infoDictionary][@"CFBundleDisplayName"]; + } + NSString *message = [VectorL10n photoLibraryAccessNotGranted:appDisplayName]; UIAlertController *alert = [UIAlertController alertControllerWithTitle:[VectorL10n mediaPickerTitle] diff --git a/bwi/MatomoAnalytics/BWIAnalytics.swift b/bwi/MatomoAnalytics/BWIAnalytics.swift index 85562766e..3b3faf4a4 100644 --- a/bwi/MatomoAnalytics/BWIAnalytics.swift +++ b/bwi/MatomoAnalytics/BWIAnalytics.swift @@ -45,7 +45,11 @@ import MatomoTracker var session: MXSession? = nil private override init() { - appName = Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as! String + if !BWIBuildSettings.shared.secondaryAppName.isEmpty { + appName = BWIBuildSettings.shared.secondaryAppName + } else { + appName = Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as! String + } appVersion = AppDelegate.theDelegate().appVersion if BWIBuildSettings.shared.bwiEnableErrorTracking { diff --git a/bwi/UserAgent/UserAgentService.swift b/bwi/UserAgent/UserAgentService.swift index 539242ab3..b3dd04261 100644 --- a/bwi/UserAgent/UserAgentService.swift +++ b/bwi/UserAgent/UserAgentService.swift @@ -72,8 +72,14 @@ import WebKit flavor = ServerURLHelper.shared.flavor()! } - guard let appName = Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName"), - let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString"), + let appName: String + if !BWIBuildSettings.shared.secondaryAppName.isEmpty { + appName = BWIBuildSettings.shared.secondaryAppName + } else { + appName = Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as! String + } + + guard let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString"), let build = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion"), let network = self.networkVersion(), let darwin = self.darwinVersion()