From ddbb7d0ec240da29a376d8b90bcd095c39b4e11b Mon Sep 17 00:00:00 2001 From: Nora Trapp Date: Wed, 19 Aug 2020 20:31:20 -0700 Subject: [PATCH] Small calling design tweaks --- .../Call/CallViewController.swift | 24 ++++++++++++++----- .../ConversationViewController.m | 5 ++-- Signal/src/call/SignalCall.swift | 9 +++---- .../CallKit/CallKitCallUIAdaptee.swift | 3 ++- .../translations/en.lproj/Localizable.strings | 15 ++++++------ 5 files changed, 34 insertions(+), 22 deletions(-) diff --git a/Signal/src/ViewControllers/Call/CallViewController.swift b/Signal/src/ViewControllers/Call/CallViewController.swift index 08ff7d16cc..4645917570 100644 --- a/Signal/src/ViewControllers/Call/CallViewController.swift +++ b/Signal/src/ViewControllers/Call/CallViewController.swift @@ -37,6 +37,7 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver, let dateFormatter = DateFormatter() dateFormatter.dateFormat = "HH:mm:ss" dateFormatter.timeZone = TimeZone(identifier: "UTC")! + dateFormatter.locale = Locale(identifier: "en_US") return dateFormatter }() @@ -621,6 +622,7 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver, updateCallUI() } + private var lastLocalVideoBoundingRect: CGRect = .zero private var localVideoBoundingRect: CGRect { view.layoutIfNeeded() @@ -637,6 +639,8 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver, rect.origin.y += topInset rect.size.height -= topInset + bottomInset + lastLocalVideoBoundingRect = rect + return rect } @@ -660,18 +664,26 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver, view.bringSubviewToFront(localVideoView) + let pipSize = ReturnToCallViewController.pipSize + let lastBoundingRect = lastLocalVideoBoundingRect + let boundingRect = localVideoBoundingRect + // Prefer to start in the top right if previousOrigin == nil { previousOrigin = CGPoint( - x: localVideoBoundingRect.maxX - ReturnToCallViewController.pipSize.width, - y: localVideoBoundingRect.minY + x: boundingRect.maxX - pipSize.width, + y: boundingRect.minY ) + + // If the bounding rect has gotten bigger, and we were at the top or + // bottom edge move the pip so it stays at the top or bottom edge. + } else if boundingRect.minY < lastBoundingRect.minY && previousOrigin.y == lastBoundingRect.minY { + previousOrigin.y = boundingRect.minY + } else if boundingRect.maxY > lastBoundingRect.maxY && previousOrigin.y + pipSize.height == lastBoundingRect.maxY { + previousOrigin.y += boundingRect.maxY - lastBoundingRect.maxY } - let newFrame = CGRect( - origin: previousOrigin, - size: ReturnToCallViewController.pipSize - ).pinnedToVerticalEdge(of: localVideoBoundingRect) + let newFrame = CGRect(origin: previousOrigin, size: pipSize).pinnedToVerticalEdge(of: localVideoBoundingRect) previousOrigin = newFrame.origin UIView.animate(withDuration: 0.25) { self.localVideoView.frame = newFrame } diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index efe6278dd8..0b80ddf847 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -1300,6 +1300,7 @@ typedef enum : NSUInteger { { ConversationHeaderView *headerView = [[ConversationHeaderView alloc] initWithThread:self.thread contactsManager:self.contactsManager]; + headerView.accessibilityLabel = NSLocalizedString(@"CONVERSATION_SETTINGS", "title for conversation settings screen"); self.headerView = headerView; SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, headerView); @@ -1387,7 +1388,7 @@ typedef enum : NSUInteger { action:@selector(startAudioCall)]; audioCallButton.enabled = !OWSWindowManager.sharedManager.hasCall; audioCallButton.accessibilityLabel - = NSLocalizedString(@"CALL_LABEL", "Accessibility label for placing call button"); + = NSLocalizedString(@"AUDIO_CALL_LABEL", "Accessibility label for placing an audio call"); [barButtons addObject:audioCallButton]; UIBarButtonItem *videoCallButton = @@ -1397,7 +1398,7 @@ typedef enum : NSUInteger { action:@selector(startVideoCall)]; videoCallButton.enabled = !OWSWindowManager.sharedManager.hasCall; videoCallButton.accessibilityLabel - = NSLocalizedString(@"CALL_LABEL", "Accessibility label for placing call button"); + = NSLocalizedString(@"VIDEO_CALL_LABEL", "Accessibility label for placing a video call"); [barButtons addObject:videoCallButton]; } diff --git a/Signal/src/call/SignalCall.swift b/Signal/src/call/SignalCall.swift index a83b1757ad..3049bab163 100644 --- a/Signal/src/call/SignalCall.swift +++ b/Signal/src/call/SignalCall.swift @@ -275,13 +275,10 @@ public class SignalCall: NSObject, SignalCallNotificationInfo { } public class func incomingCall(localId: UUID, remoteAddress: SignalServiceAddress, sentAtTimestamp: UInt64, offerMediaType: TSRecentCallOfferType) -> SignalCall { - // If this is a video call, and the app is active, we want - // to use in the in app call screen because CallKit has poor - // support for video calls. We still use CallKit when the app - // is not active, because CallKit provides a much better - // background ringing experience. + // If this is a video call, we want to use in the in app call screen + // because CallKit has poor support for video calls. let callAdapterType: CallAdapterType - if offerMediaType == .video && UIApplication.shared.applicationState == .active { + if offerMediaType == .video { callAdapterType = .nonCallKit } else { callAdapterType = .default diff --git a/Signal/src/call/UserInterface/CallKit/CallKitCallUIAdaptee.swift b/Signal/src/call/UserInterface/CallKit/CallKitCallUIAdaptee.swift index f22d9db61f..2df3482de4 100644 --- a/Signal/src/call/UserInterface/CallKit/CallKitCallUIAdaptee.swift +++ b/Signal/src/call/UserInterface/CallKit/CallKitCallUIAdaptee.swift @@ -151,6 +151,8 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate { AssertIsOnMainThread() Logger.info("") + self.showCall(call) + // Construct a CXCallUpdate describing the incoming call, including the caller. let update = CXCallUpdate() @@ -337,7 +339,6 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate { } self.callService.handleAcceptCall(call) - self.showCall(call) action.fulfill() } diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index 7df0435ef6..366a58e56c 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -290,6 +290,9 @@ /* A string indicating that an audio message is playing. */ "AUDIO_ACTIVITY_PLAYBACK_NAME_AUDIO_MESSAGE" = "Audio Message"; +/* Accessibility label for placing an audio call */ +"AUDIO_CALL_LABEL" = "Audio Call"; + /* action sheet button title to enable built in speaker during a call */ "AUDIO_ROUTE_BUILT_IN_SPEAKER" = "Speaker"; @@ -461,9 +464,6 @@ /* Alert title when calling and permissions for microphone are missing */ "CALL_AUDIO_PERMISSION_TITLE" = "Microphone Access Required"; -/* Accessibility label for placing call button */ -"CALL_LABEL" = "Call"; - /* notification body */ "CALL_MISSED_BECAUSE_OF_IDENTITY_CHANGE_NOTIFICATION_BODY" = "☎️ Missed call because the caller's safety number changed."; @@ -2372,9 +2372,6 @@ /* An explanation of the consequences of muting a thread. */ "MUTE_BEHAVIOR_EXPLANATION" = "You will not receive notifications for muted conversations."; -/* Badge indicating that the user is muted. */ -"MUTED_BADGE" = "Muted"; - /* A button to skip a view. */ "NAVIGATION_ITEM_SKIP_BUTTON" = "Skip"; @@ -4259,6 +4256,9 @@ /* Label for button or row which allows users to verify the safety numbers of multiple users. */ "VERIFY_PRIVACY_MULTIPLE" = "Review Safety Numbers"; +/* Accessibility label for placing a video call */ +"VIDEO_CALL_LABEL" = "Video Call"; + /* Toast alert text shown when tapping on a view-once message that has already been viewed. */ "VIEW_ONCE_ALREADY_VIEWED_TOAST" = "You already viewed this message."; @@ -4292,5 +4292,6 @@ /* alert body shown when trying to use features in the app before completing registration-related setup. */ "YOU_MUST_COMPLETE_ONBOARDING_BEFORE_PROCEEDING" = "You must complete setup before proceeding."; -/* Info Message when you disabled disappearing messages. Embeds a {{time amount}} before messages disappear. see the *_TIME_AMOUNT strings for context. */ +/* Info Message when you disabled disappearing messages. Embeds a {{time amount}} before messages disappear. see the *_TIME_AMOUNT strings for context. + Info Message when you enabled disappearing messages. Embeds a {{time amount}} before messages disappear. see the *_TIME_AMOUNT strings for context. */ "YOU_UPDATED_DISAPPEARING_MESSAGES_CONFIGURATION" = "You set disappearing message time to %@.";