Skip to content

Commit

Permalink
Merge pull request #967 from nextcloud/ios14-cleanup
Browse files Browse the repository at this point in the history
Remove iOS < 14 code
  • Loading branch information
Ivansss authored Nov 2, 2022
2 parents 82e2193 + 448dcdb commit 3e3b582
Show file tree
Hide file tree
Showing 21 changed files with 149 additions and 327 deletions.
4 changes: 0 additions & 4 deletions NextcloudTalk.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
1F98DF9C28E7484700E05174 /* ReferenceDeckView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F98DF9B28E7484700E05174 /* ReferenceDeckView.swift */; };
1F98DF9E28E7485000E05174 /* ReferenceDeckView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1F98DF9D28E7485000E05174 /* ReferenceDeckView.xib */; };
1FA20C8A284001D80062B4F3 /* DebounceWebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FA20C89284001D80062B4F3 /* DebounceWebView.swift */; };
1FADF2E528EAE28F0074A532 /* iOS13Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1FADF2E428EAE28F0074A532 /* iOS13Main.storyboard */; };
1FB52E762842C75E00AC741B /* QRCodeLoginController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FB52E752842C75E00AC741B /* QRCodeLoginController.swift */; };
1FB6678F28CE381300D29F8D /* SubtitleTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FB6678E28CE381300D29F8D /* SubtitleTableViewCell.swift */; };
1FD9182928C55A73009092AB /* BGTaskHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD9182828C55A73009092AB /* BGTaskHelper.swift */; };
Expand Down Expand Up @@ -393,7 +392,6 @@
1F98DF9B28E7484700E05174 /* ReferenceDeckView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReferenceDeckView.swift; sourceTree = "<group>"; };
1F98DF9D28E7485000E05174 /* ReferenceDeckView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ReferenceDeckView.xib; sourceTree = "<group>"; };
1FA20C89284001D80062B4F3 /* DebounceWebView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DebounceWebView.swift; sourceTree = "<group>"; };
1FADF2E428EAE28F0074A532 /* iOS13Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = iOS13Main.storyboard; sourceTree = "<group>"; };
1FB52E752842C75E00AC741B /* QRCodeLoginController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QRCodeLoginController.swift; sourceTree = "<group>"; };
1FB6678E28CE381300D29F8D /* SubtitleTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubtitleTableViewCell.swift; sourceTree = "<group>"; };
1FD9182828C55A73009092AB /* BGTaskHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BGTaskHelper.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -920,7 +918,6 @@
2C6085C11FB1063700B36A6E /* NextcloudTalk.entitlements */,
2CA1CCAB1F067F35002FE6A2 /* Images.xcassets */,
2C0574941EDD9E8E00D9E7F2 /* Info.plist */,
1FADF2E428EAE28F0074A532 /* iOS13Main.storyboard */,
2C05748C1EDD9E8E00D9E7F2 /* Main.storyboard */,
2C1D13A1253760EE00EC0533 /* LaunchScreen.xib */,
2C7F47AC20289B9600081CC7 /* Localizable.strings */,
Expand Down Expand Up @@ -1645,7 +1642,6 @@
2CC007BE20D8F24B0096D91F /* RoomCreation2TableViewController.xib in Resources */,
2CC32E9327F45AE000BB8C39 /* ReactionsViewCell.xib in Resources */,
2C330372255E6EBC00BDB4E4 /* InfoPlist.strings in Resources */,
1FADF2E528EAE28F0074A532 /* iOS13Main.storyboard in Resources */,
2C78EFA11F828C41008AFA74 /* CallViewController.xib in Resources */,
2C3780C5210F4A26003F9AE8 /* HeaderWithButton.xib in Resources */,
2CC007B920D8139D0096D91F /* RoomCreationTableViewController.xib in Resources */,
Expand Down
20 changes: 5 additions & 15 deletions NextcloudTalk/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,12 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(

[self registerBackgroundFetchTask];

if (@available(iOS 14.0, *)) {
[NCUserInterfaceController sharedInstance].mainSplitViewController = (NCSplitViewController *) self.window.rootViewController;
[NCUserInterfaceController sharedInstance].mainViewController = (NCSplitViewController *) self.window.rootViewController;
[NCUserInterfaceController sharedInstance].roomsTableViewController = [NCUserInterfaceController sharedInstance].mainSplitViewController.viewControllers.firstObject.childViewControllers.firstObject;

if (@available(iOS 14.5, *)) {
[NCUserInterfaceController sharedInstance].mainSplitViewController.displayModeButtonVisibility = UISplitViewControllerDisplayModeButtonVisibilityNever;
}
} else {
// We're using iOS 14 specific APIs for splitView, so fall back in case they're not supported
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"iOS13Main" bundle:[NSBundle mainBundle]];
UIViewController *vc = [storyboard instantiateInitialViewController];

self.window.rootViewController = vc;
[NCUserInterfaceController sharedInstance].mainSplitViewController = (NCSplitViewController *) self.window.rootViewController;
[NCUserInterfaceController sharedInstance].mainViewController = (NCSplitViewController *) self.window.rootViewController;
[NCUserInterfaceController sharedInstance].roomsTableViewController = [NCUserInterfaceController sharedInstance].mainSplitViewController.viewControllers.firstObject.childViewControllers.firstObject;

[NCUserInterfaceController sharedInstance].mainViewController = (NCNavigationController *) self.window.rootViewController;
if (@available(iOS 14.5, *)) {
[NCUserInterfaceController sharedInstance].mainSplitViewController.displayModeButtonVisibility = UISplitViewControllerDisplayModeButtonVisibilityNever;
}

return YES;
Expand Down
2 changes: 1 addition & 1 deletion NextcloudTalk/CallKitManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ + (BOOL)isCallKitAvailable
- (CXProvider *)provider
{
if (!_provider) {
CXProviderConfiguration *configuration = [[CXProviderConfiguration alloc] initWithLocalizedName:talkAppName];
CXProviderConfiguration *configuration = [[CXProviderConfiguration alloc] init];
configuration.supportsVideo = YES;
configuration.maximumCallGroups = 1;
configuration.maximumCallsPerCallGroup = 1;
Expand Down
10 changes: 4 additions & 6 deletions NextcloudTalk/ChatMessageTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -450,12 +450,10 @@ - (void)setUserStatus:(NSString *)userStatus
_userStatusImageView.contentMode = UIViewContentModeCenter;
_userStatusImageView.layer.cornerRadius = 6;
_userStatusImageView.clipsToBounds = YES;
_userStatusImageView.backgroundColor = self.backgroundColor;
if (@available(iOS 14.0, *)) {
// When a background color is set directly to the cell it seems that there is no background configuration.
// In this class, even when no background color is set, the background configuration is nil.
_userStatusImageView.backgroundColor = (self.backgroundColor) ? self.backgroundColor : [[self backgroundConfiguration] backgroundColor];
}

// When a background color is set directly to the cell it seems that there is no background configuration.
// In this class, even when no background color is set, the background configuration is nil.
_userStatusImageView.backgroundColor = (self.backgroundColor) ? self.backgroundColor : [[self backgroundConfiguration] backgroundColor];
}
}

Expand Down
8 changes: 3 additions & 5 deletions NextcloudTalk/ContactsTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,9 @@ - (void)setUserStatus:(NSString *)userStatus
_userStatusImageView.contentMode = UIViewContentModeCenter;
_userStatusImageView.layer.cornerRadius = 10;
_userStatusImageView.clipsToBounds = YES;
_userStatusImageView.backgroundColor = self.backgroundColor;
if (@available(iOS 14.0, *)) {
// When a background color is set directly to the cell it seems that there is no background configuration.
_userStatusImageView.backgroundColor = (self.backgroundColor) ? self.backgroundColor : [[self backgroundConfiguration] backgroundColor];
}

// When a background color is set directly to the cell it seems that there is no background configuration.
_userStatusImageView.backgroundColor = (self.backgroundColor) ? self.backgroundColor : [[self backgroundConfiguration] backgroundColor];
}
}

Expand Down
2 changes: 1 addition & 1 deletion NextcloudTalk/DebounceWebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DebounceWebView: WKWebView {

previousPasteTimestamp = currentPasteTimestamp
}

super.paste(sender)
}
}
2 changes: 1 addition & 1 deletion NextcloudTalk/DiagnosticsTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ class DiagnosticsTableViewController: UITableViewController {
cell.textLabel?.text = NSLocalizedString("Location access", comment: "")

if CLLocationManager.locationServicesEnabled() {
switch CLLocationManager.authorizationStatus() {
switch CLLocationManager().authorizationStatus {
case .authorizedAlways, .authorizedWhenInUse:
cell.detailTextLabel?.text = allowedString

Expand Down
2 changes: 1 addition & 1 deletion NextcloudTalk/NCNotificationController.m
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNot
{
// Called when a notification is delivered to a foreground app.
[[NSNotificationCenter defaultCenter] postNotificationName:NCNotificationControllerWillPresentNotification object:self userInfo:nil];
completionHandler(UNNotificationPresentationOptionAlert);
completionHandler(UNNotificationPresentationOptionList | UNNotificationPresentationOptionBanner);

// Remove the notification from Notification Center if it is from the active account
NSString *notificationAccountId = [notification.request.content.userInfo objectForKey:@"accountId"];
Expand Down
88 changes: 39 additions & 49 deletions NextcloudTalk/NCSplitViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
override func viewDidLoad() {
super.viewDidLoad()
self.delegate = self
self.preferredDisplayMode = .allVisible
self.preferredDisplayMode = .oneBesideSecondary

// As we always show the columns on iPads, we don't need gesture support
self.presentsWithGesture = false
Expand All @@ -46,48 +46,44 @@
return
}

if #available(iOS 14.0, *) {
if let navController = self.viewController(for: .secondary) as? UINavigationController,
viewController is RoomsTableViewController {

// MovingFromParentViewController is always false in case of a rootViewController,
// because of this, the chat will never be left in NCChatViewController
// (see viewDidDisappear). So we have to leave the chat here, if collapsed
if let chatViewController = getActiveChatViewController() {
chatViewController.leaveChat()
}
if let navController = self.viewController(for: .secondary) as? UINavigationController,
viewController is RoomsTableViewController {

// Make sure the chatViewController gets properly deallocated
setViewController(placeholderViewController, for: .secondary)
navController.setViewControllers([placeholderViewController], animated: false)
// MovingFromParentViewController is always false in case of a rootViewController,
// because of this, the chat will never be left in NCChatViewController
// (see viewDidDisappear). So we have to leave the chat here, if collapsed
if let chatViewController = getActiveChatViewController() {
chatViewController.leaveChat()
}

// Make sure the chatViewController gets properly deallocated
setViewController(placeholderViewController, for: .secondary)
navController.setViewControllers([placeholderViewController], animated: false)
}
}

override func showDetailViewController(_ vc: UIViewController, sender: Any?) {
if #available(iOS 14.0, *) {
if !isCollapsed {
// When another room is selected while there's still an active chatViewController
// we need to make sure the active one is removed (applies to expanded mode only)
if let navController = self.viewController(for: .secondary) as? UINavigationController {
navController.popToRootViewController(animated: false)
}
if !isCollapsed {
// When another room is selected while there's still an active chatViewController
// we need to make sure the active one is removed (applies to expanded mode only)
if let navController = self.viewController(for: .secondary) as? UINavigationController {
navController.popToRootViewController(animated: false)
}
}

super.showDetailViewController(vc, sender: sender)
super.showDetailViewController(vc, sender: sender)

if isCollapsed {
// Make sure we don't have accidentally a placeholderView in our navigation
// while in collapsed mode
if let navController = self.viewController(for: .secondary) as? UINavigationController,
vc is NCChatViewController {
if isCollapsed {
// Make sure we don't have accidentally a placeholderView in our navigation
// while in collapsed mode
if let navController = self.viewController(for: .secondary) as? UINavigationController,
vc is NCChatViewController {

// Only set the viewController if there's actually an active one shown by showDetailViewController
// Otherwise UI might break or crash (view not loaded correctly)
// This might happen if a chatViewController is shown by a push notification
if self.hasActiveChatViewController() {
navController.setViewControllers([vc], animated: false)
}
// Only set the viewController if there's actually an active one shown by showDetailViewController
// Otherwise UI might break or crash (view not loaded correctly)
// This might happen if a chatViewController is shown by a push notification
if self.hasActiveChatViewController() {
navController.setViewControllers([vc], animated: false)
}
}
}
Expand All @@ -102,29 +98,26 @@
}

func getActiveViewController<T: UIViewController>() -> T? {
if #available(iOS 14.0, *) {
// In case we have a collapsed view, we need to retrieve the viewController this way
if let navController = self.viewController(for: .secondary) as? UINavigationController {
for secondaryViewController in navController.viewControllers {
if let activeViewController = secondaryViewController as? T {
return activeViewController
}
// In case we have a collapsed view, we need to retrieve the viewController this way
if let navController = self.viewController(for: .secondary) as? UINavigationController {
for secondaryViewController in navController.viewControllers {
if let activeViewController = secondaryViewController as? T {
return activeViewController
}
}
}

if let navController = self.viewController(for: .primary) as? UINavigationController {
for primaryViewController in navController.viewControllers {
if let activeViewController = primaryViewController as? T {
return activeViewController
}
if let navController = self.viewController(for: .primary) as? UINavigationController {
for primaryViewController in navController.viewControllers {
if let activeViewController = primaryViewController as? T {
return activeViewController
}
}
}

return nil
}

@available(iOS 14.0, *)
func splitViewController(_ svc: UISplitViewController, topColumnForCollapsingToProposedTopColumn proposedTopColumn: UISplitViewController.Column) -> UISplitViewController.Column {
// When we rotate the device and the splitViewController gets collapsed
// we need to determine if we're still in a chat or not.
Expand All @@ -136,7 +129,6 @@
return .primary
}

@available(iOS 14.0, *)
func splitViewControllerDidExpand(_ svc: UISplitViewController) {
if let navController = self.viewController(for: .secondary) as? UINavigationController {
if hasActiveChatViewController() {
Expand All @@ -151,7 +143,6 @@
}
}

@available(iOS 14.0, *)
func splitViewControllerDidCollapse(_ svc: UISplitViewController) {
if hasActiveChatViewController() {
// If we collapse (only show one column) and there's a active chatViewController
Expand All @@ -162,7 +153,6 @@
}
}

@available(iOS 14.0, *)
func popSecondaryColumnToRootViewController() {
if let navController = self.viewController(for: .secondary) as? UINavigationController {
if let chatViewController = getActiveChatViewController() {
Expand Down
38 changes: 16 additions & 22 deletions NextcloudTalk/NCUserInterfaceController.m
Original file line number Diff line number Diff line change
Expand Up @@ -325,36 +325,30 @@ - (void)presentConversationsList
{
[_mainViewController dismissViewControllerAnimated:YES completion:nil];

if (@available(iOS 14.0, *)) {
[_mainSplitViewController popSecondaryColumnToRootViewController];
[_mainSplitViewController showColumn:UISplitViewControllerColumnPrimary];
}
[_mainSplitViewController popSecondaryColumnToRootViewController];
[_mainSplitViewController showColumn:UISplitViewControllerColumnPrimary];
}


- (void)presentChatViewController:(NCChatViewController *)chatViewController
{
[self presentConversationsList];

if (@available(iOS 14.0, *)) {
if (_mainSplitViewController.transitionCoordinator == nil) {
// No ongoing animations -> show chatViewController directly
[_mainSplitViewController showDetailViewController:chatViewController sender:self];
} else {
// Wait until the splitViewController finished all it's animations.
// Otherwise the chatViewController might end up in the wrong column.
// This mainly happens when being in a conversation and tapping a push notification
// of another conversation.
[_mainSplitViewController.transitionCoordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
// Nothing to do here, we are only interested in the completion block
} completion:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
dispatch_async(dispatch_get_main_queue(), ^{
[self->_mainSplitViewController showDetailViewController:chatViewController sender:self];
});
}];
}
if (_mainSplitViewController.transitionCoordinator == nil) {
// No ongoing animations -> show chatViewController directly
[_mainSplitViewController showDetailViewController:chatViewController sender:self];
} else {
[(UINavigationController *)_mainViewController pushViewController:chatViewController animated:YES];
// Wait until the splitViewController finished all it's animations.
// Otherwise the chatViewController might end up in the wrong column.
// This mainly happens when being in a conversation and tapping a push notification
// of another conversation.
[_mainSplitViewController.transitionCoordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
// Nothing to do here, we are only interested in the completion block
} completion:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
dispatch_async(dispatch_get_main_queue(), ^{
[self->_mainSplitViewController showDetailViewController:chatViewController sender:self];
});
}];
}

[_roomsTableViewController setSelectedRoomToken:chatViewController.room.token];
Expand Down
6 changes: 1 addition & 5 deletions NextcloudTalk/NCUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,7 @@ + (void)log:(NSString *)message

+ (BOOL)isiOSAppOnMac
{
if (@available(iOS 14.0, *)) {
return [NSProcessInfo processInfo].isiOSAppOnMac;
}

return false;
return [NSProcessInfo processInfo].isiOSAppOnMac;
}

+ (NSString *)removeHTMLFromString:(NSString *)string
Expand Down
Loading

0 comments on commit 3e3b582

Please sign in to comment.