diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m index c073052b8..6eefb6759 100644 --- a/Classes/ChatConversationView.m +++ b/Classes/ChatConversationView.m @@ -370,8 +370,6 @@ static UICompositeViewDescription *compositeDescription = nil; } } - - - (void)configureForRoom:(BOOL)editing { if (!_chatRoom) { _chatView.hidden = YES; diff --git a/Classes/ChatsListView.m b/Classes/ChatsListView.m index 142618c35..b6f9316cb 100644 --- a/Classes/ChatsListView.m +++ b/Classes/ChatsListView.m @@ -39,6 +39,10 @@ selector:@selector(ephemeralDeleted:) name:kLinphoneEphemeralMessageDeletedInRoom object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(displayModeChanged) + name:kDisplayModeChanged + object:nil]; [_backToCallButton update]; self.tableController.waitView = _waitView; [self setEditing:NO]; @@ -68,6 +72,9 @@ } +- (void)displayModeChanged{ + [self.tableController.tableView reloadData]; +} - (void)ephemeralDeleted:(NSNotification *)notif { //LinphoneChatRoom *r =[[notif.userInfo objectForKey:@"room"] intValue]; diff --git a/Classes/ContactsListView.m b/Classes/ContactsListView.m index 2093bcb7a..2b791f148 100644 --- a/Classes/ContactsListView.m +++ b/Classes/ContactsListView.m @@ -147,6 +147,10 @@ static UICompositeViewDescription *compositeDescription = nil; selector:@selector(onMagicSearchMoreAvailable:) name:kLinphoneMagicSearchMoreAvailable object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(displayModeChanged) + name:kDisplayModeChanged + object:nil]; } - (void)onMagicSearchStarted:(NSNotification *)k { @@ -258,6 +262,10 @@ static UICompositeViewDescription *compositeDescription = nil; } } +- (void)displayModeChanged{ + [self.tableController.tableView reloadData]; +} + - (IBAction)onDeleteClick:(id)sender { NSString *msg = [NSString stringWithFormat:NSLocalizedString(@"Do you want to delete selected contacts?\nThey will also be deleted from your phone's address book.", nil)]; [LinphoneManager.instance setContactsUpdated:TRUE]; diff --git a/Classes/HistoryListView.m b/Classes/HistoryListView.m index 7c3e96de6..58e0333f8 100644 --- a/Classes/HistoryListView.m +++ b/Classes/HistoryListView.m @@ -67,10 +67,15 @@ static UICompositeViewDescription *compositeDescription = nil; // Fake event [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneCallUpdate object:self]; [_toggleSelectionButton setImage:[UIImage imageNamed:@"select_all_default.png"] forState:UIControlStateSelected]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(displayModeChanged) + name:kDisplayModeChanged + object:nil]; } - (void) viewWillDisappear:(BOOL)animated { self.view = NULL; + [NSNotificationCenter.defaultCenter removeObserver:self]; } #pragma mark - @@ -100,6 +105,10 @@ static UICompositeViewDescription *compositeDescription = nil; _selectedButtonImage.frame = frame; } +- (void)displayModeChanged{ + [self.tableController.tableView reloadData]; +} + #pragma m ~ark - Action Functions - (IBAction)onAllClick:(id)event { diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index 197720713..62406a221 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -85,6 +85,7 @@ [LinphoneManager.instance.fastAddressBook reloadFriends]; [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneMessageReceived object:nil]; + } - (void)applicationWillResignActive:(UIApplication *)application { @@ -183,6 +184,11 @@ }]; + if ([UIDeviceBridge switchedDisplayMode]) { + [AvatarBridge prepareIt]; + [NSNotificationCenter.defaultCenter postNotificationName:kDisplayModeChanged object:nil]; + } + } #pragma deploymate push "ignored-api-availability" diff --git a/Classes/LinphoneManager.h b/Classes/LinphoneManager.h index 82dd9b91f..f83fd9611 100644 --- a/Classes/LinphoneManager.h +++ b/Classes/LinphoneManager.h @@ -66,6 +66,7 @@ extern NSString *const kLinphoneConfStateChanged; extern NSString *const kLinphoneMagicSearchStarted; extern NSString *const kLinphoneMagicSearchFinished; extern NSString *const kLinphoneMagicSearchMoreAvailable; +extern NSString *const kDisplayModeChanged; extern NSString *const kLinphoneMsgNotificationAppGroupId; diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index d481ad6d4..bf2f3ea23 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -82,6 +82,7 @@ NSString *const kLinphoneConfStateParticipantListChanged = @"kLinphoneConfStateP NSString *const kLinphoneMagicSearchStarted = @"LinphoneMagicSearchStarted"; NSString *const kLinphoneMagicSearchFinished = @"LinphoneMagicSearchFinished"; NSString *const kLinphoneMagicSearchMoreAvailable = @"LinphoneMagicSearchMoreAvailable"; +NSString *const kDisplayModeChanged = @"DisplayModeChanged"; NSString *const kLinphoneMsgNotificationAppGroupId = @"group.org.linphone.phone.msgNotification"; diff --git a/Classes/Swift/Extensions/IOS/UIDeviceExtensions.swift b/Classes/Swift/Extensions/IOS/UIDeviceExtensions.swift index 3690dc81d..212a7793e 100644 --- a/Classes/Swift/Extensions/IOS/UIDeviceExtensions.swift +++ b/Classes/Swift/Extensions/IOS/UIDeviceExtensions.swift @@ -54,4 +54,24 @@ extension UIDevice { return [.landscapeRight,.landscapeLeft].contains(UIDevice.current.orientation) ? sidePadding : topPadding } + static func switchedDisplayMode() -> Bool { + let displayMode = UserDefaults.standard.string(forKey: "displayMode") + if #available(iOS 13.0, *) { + if UITraitCollection.current.userInterfaceStyle == .light { + UserDefaults.standard.set("light", forKey: "displayMode") + } else { + UserDefaults.standard.set("dark", forKey: "displayMode") + } + } + return displayMode != nil && displayMode != UserDefaults.standard.string(forKey: "displayMode") + } + +} + +@objc class UIDeviceBridge : NSObject { + @available(iOS 12.0, *) + static let displayMode = MutableLiveData() + @objc static func switchedDisplayMode() -> Bool { + return UIDevice.switchedDisplayMode() + } } diff --git a/Classes/Swift/Voip/Theme/VoipTheme.swift b/Classes/Swift/Voip/Theme/VoipTheme.swift index 6a12d881e..4c36f4d66 100644 --- a/Classes/Swift/Voip/Theme/VoipTheme.swift +++ b/Classes/Swift/Voip/Theme/VoipTheme.swift @@ -88,7 +88,7 @@ import UIKit static let call_header_subtitle = TextStyle(fgColor: LightDarkColor(.white,.white), bgColor: LightDarkColor(.clear,.clear), allCaps: false, align: .center, font: fontName+"-Regular", size: 14.0) static let call_generated_avatar_large = TextStyle(fgColor: LightDarkColor(.white,.white), bgColor: LightDarkColor(.clear,.clear), allCaps: true, align: .center, font: fontName+"-Regular", size: 53.0) static let call_generated_avatar_medium = TextStyle(fgColor: LightDarkColor(.white,.white), bgColor: LightDarkColor(.clear,.clear), allCaps: true, align: .center, font: fontName+"-Regular", size: 27.0) - static let call_generated_avatar_small = TextStyle(fgColor: LightDarkColor(.white,.white), bgColor: LightDarkColor(.clear,.clear), allCaps: true, align: .center, font: fontName+"-Bold", size: 25.0) + static let call_generated_avatar_small = TextStyle(fgColor: LightDarkColor(.white,voip_dark_gray), bgColor: LightDarkColor(.clear,.clear), allCaps: true, align: .center, font: fontName+"-Bold", size: 25.0) static let dtmf_label = TextStyle(fgColor: LightDarkColor(.white,.white), bgColor: LightDarkColor(.clear,.clear), allCaps: false, align: .center, font: fontName+"-Regular", size: 30.0) static let call_remote_name = TextStyle(fgColor: LightDarkColor(.white,.white), bgColor: LightDarkColor(.clear,.clear), allCaps: false, align: .left, font: fontName+"-Regular", size: 18.0) diff --git a/Classes/Swift/Voip/Widgets/Avatar.swift b/Classes/Swift/Voip/Widgets/Avatar.swift index 66611fa01..6e63fd2a9 100644 --- a/Classes/Swift/Voip/Widgets/Avatar.swift +++ b/Classes/Swift/Voip/Widgets/Avatar.swift @@ -87,13 +87,20 @@ class Avatar : UIView { @objc class AvatarBridge : NSObject { // Ugly work around to tap into the swift Avatars, until rest of the app is reworked in Swift. static var shared : Avatar? = nil - static let size = 50.0 + static let size = 50.0 + @objc static func prepareIt() { + if (shared != nil) { + shared?.removeFromSuperview() + } + shared = Avatar(color:VoipTheme.primaryTextColor, textStyle: VoipTheme.call_generated_avatar_small) + PhoneMainView.instance().mainViewController.view.addSubview(shared!) + PhoneMainView.instance().mainViewController.view.sendSubviewToBack(shared!) + shared?.bounds.size = CGSize(width: size, height: size) + } + @objc static func imageForAddress(address:OpaquePointer) -> UIImage? { if (shared == nil) { - shared = Avatar(color:VoipTheme.primaryTextColor, textStyle: VoipTheme.call_generated_avatar_small) - PhoneMainView.instance().mainViewController.view.addSubview(shared!) - PhoneMainView.instance().mainViewController.view.sendSubviewToBack(shared!) - shared?.bounds.size = CGSize(width: size, height: size) + prepareIt() } let sAddr = Address.getSwiftObject(cObject: address) shared?.fillFromAddress(address: sAddr) @@ -102,10 +109,7 @@ class Avatar : UIView { @objc static func imageForInitials(displayName:String) -> UIImage? { if (shared == nil) { - shared = Avatar(color:VoipTheme.primaryTextColor, textStyle: VoipTheme.call_generated_avatar_small) - PhoneMainView.instance().mainViewController.view.addSubview(shared!) - PhoneMainView.instance().mainViewController.view.sendSubviewToBack(shared!) - shared?.bounds.size = CGSize(width: size, height: size) + prepareIt() } shared?.initialsLabel.text = Address.initials(displayName: displayName) shared?.initialsLabel.isHidden = false