From 11dff385cc8fdf03f59b835a209ddc0b73b4cd1c Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Mon, 2 Aug 2021 15:36:56 +1000 Subject: [PATCH] Add in Dependencies type --- Session/Calls/UserInterface/CallButton.swift | 10 +++---- Session/Calls/UserInterface/CallHeader.swift | 8 ++--- .../Group/GroupCallSwipeToastView.swift | 4 +-- .../Group/GroupCallViewController.swift | 4 +-- .../Individual/CallUIAdapter.swift | 13 +++++---- .../IndividualCallViewController.swift | 4 +-- Session/Meta/Dependencies+MainApp.swift | 29 +++++++++++++++++++ Session/Meta/Signal-Bridging-Header.h | 1 + 8 files changed, 52 insertions(+), 21 deletions(-) diff --git a/Session/Calls/UserInterface/CallButton.swift b/Session/Calls/UserInterface/CallButton.swift index 2e6c2bd58..4b59f3413 100644 --- a/Session/Calls/UserInterface/CallButton.swift +++ b/Session/Calls/UserInterface/CallButton.swift @@ -19,8 +19,8 @@ class CallButton: UIButton { var selectedIconColor: UIColor = .ows_gray75 { didSet { updateAppearance() } } var currentIconColor: UIColor { isSelected ? selectedIconColor : iconColor } - var unselectedBackgroundColor = UIColor.ows_whiteAlpha40 { didSet { updateAppearance() } } - var selectedBackgroundColor = UIColor.ows_white { didSet { updateAppearance() } } + var unselectedBackgroundColor = UIColor.white.withAlphaComponent(0.4) { didSet { updateAppearance() } } + var selectedBackgroundColor = UIColor.white { didSet { updateAppearance() } } var currentBackgroundColor: UIColor { return isSelected ? selectedBackgroundColor : unselectedBackgroundColor @@ -119,9 +119,9 @@ class CallButton: UIButton { NSLayoutConstraint.deactivate(currentConstraints) currentConstraints.removeAll() - currentConstraints += circleView.autoSetDimensions(to: CGSize(square: currentIconSize)) + currentConstraints += circleView.autoSetDimensions(to: CGSize(width: currentIconSize, height: currentIconSize)) circleView.layer.shadowPath = UIBezierPath( - ovalIn: CGRect(origin: .zero, size: .square(currentIconSize)) + ovalIn: CGRect(origin: .zero, size: CGSize(width: currentIconSize, height: currentIconSize)) ).cgPath currentConstraints += iconView.autoPinEdgesToSuperviewEdges(with: currentIconInsets) if let dropdownIconView = dropdownIconView { @@ -136,7 +136,7 @@ class CallButton: UIButton { self.dropdownIconView = dropdownIconView circleView.addSubview(dropdownIconView) - dropdownIconView.autoSetDimensions(to: CGSize(square: 12)) + dropdownIconView.autoSetDimensions(to: CGSize(width: 12, height: 12)) dropdownIconView.autoVCenterInSuperview() updateSizing() diff --git a/Session/Calls/UserInterface/CallHeader.swift b/Session/Calls/UserInterface/CallHeader.swift index 042147053..536a3a3f4 100644 --- a/Session/Calls/UserInterface/CallHeader.swift +++ b/Session/Calls/UserInterface/CallHeader.swift @@ -39,7 +39,7 @@ class CallHeader: UIView { let gradientLayer = CAGradientLayer() gradientLayer.colors = [ - UIColor.ows_blackAlpha60.cgColor, + UIColor.black.withAlphaComponent(0.6).cgColor, UIColor.black.withAlphaComponent(0).cgColor ] let gradientView = OWSLayerView(frame: .zero) { view in @@ -64,7 +64,7 @@ class CallHeader: UIView { let backButton = UIButton() let backButtonImage = CurrentAppContext().isRTL ? #imageLiteral(resourceName: "NavBarBackRTL") : #imageLiteral(resourceName: "NavBarBack") - backButton.setTemplateImage(backButtonImage, tintColor: .ows_white) + backButton.setTemplateImage(backButtonImage, tintColor: .white) backButton.autoSetDimensions(to: CGSize(square: 40)) backButton.imageEdgeInsets = UIEdgeInsets(top: -12, leading: -18, bottom: 0, trailing: 0) backButton.addTarget(delegate, action: #selector(CallHeaderDelegate.didTapBackButton), for: .touchUpInside) @@ -91,7 +91,7 @@ class CallHeader: UIView { // Add trailing space after the name scrolls before it wraps around and scrolls back in. callTitleLabel.trailingBuffer = ScaleFromIPhone5(80.0) - callTitleLabel.font = UIFont.ows_dynamicTypeHeadlineClamped.ows_semibold + callTitleLabel.font = .boldSystemFont(ofSize: Values.mediumFontSize) callTitleLabel.textAlignment = .center callTitleLabel.textColor = UIColor.white addShadow(to: callTitleLabel) @@ -317,7 +317,7 @@ private class GroupMembersButton: UIButton { iconImageView.autoSetDimensions(to: CGSize(square: 22)) iconImageView.autoPinEdge(toSuperviewEdge: .top, withInset: 2) - countLabel.font = UIFont.ows_dynamicTypeFootnoteClamped.ows_monospaced + countLabel.font = .systemFont(ofSize: Values.mediumFontSize) countLabel.textColor = .ows_white addSubview(countLabel) countLabel.autoPinEdge(.leading, to: .trailing, of: iconImageView, withOffset: 5) diff --git a/Session/Calls/UserInterface/Group/GroupCallSwipeToastView.swift b/Session/Calls/UserInterface/Group/GroupCallSwipeToastView.swift index 26ab76f05..00a1e25cd 100644 --- a/Session/Calls/UserInterface/Group/GroupCallSwipeToastView.swift +++ b/Session/Calls/UserInterface/Group/GroupCallSwipeToastView.swift @@ -8,13 +8,13 @@ class GroupCallSwipeToastView: UIView { private let imageView: UIImageView = { let view = UIImageView() - view.setTemplateImageName("arrow-up-20", tintColor: .ows_white) + view.setTemplateImageName("arrow-up-20", tintColor: .white) return view }() private let label: UILabel = { let label = UILabel() - label.font = UIFont.ows_dynamicTypeBody2 + label.font = .systemFont(ofSize: Values.mediumFontSize) label.textColor = .ows_gray05 label.numberOfLines = 0 label.lineBreakMode = .byWordWrapping diff --git a/Session/Calls/UserInterface/Group/GroupCallViewController.swift b/Session/Calls/UserInterface/Group/GroupCallViewController.swift index fe481a44d..f18a19048 100644 --- a/Session/Calls/UserInterface/Group/GroupCallViewController.swift +++ b/Session/Calls/UserInterface/Group/GroupCallViewController.swift @@ -829,7 +829,7 @@ extension GroupCallViewController: GroupCallMemberViewDelegate { let titleFormat = NSLocalizedString( "GROUP_CALL_BLOCKED_ALERT_TITLE_FORMAT", comment: "Title for alert explaining that a group call participant is blocked. Embeds {{ user's name }}") - let displayName = contactsManager.displayName(for: address) + let displayName = Storage.shared.getContact(with: address)?.displayName(for: .regular) ?? address title = String(format: titleFormat, displayName) case let .noMediaKeys(address): @@ -840,7 +840,7 @@ extension GroupCallViewController: GroupCallMemberViewDelegate { let titleFormat = NSLocalizedString( "GROUP_CALL_NO_KEYS_ALERT_TITLE_FORMAT", comment: "Title for alert explaining that a group call participant cannot be displayed because of missing keys. Embeds {{ user's name }}") - let displayName = contactsManager.displayName(for: address) + let displayName = Storage.shared.getContact(with: address)?.displayName(for: .regular) ?? address title = String(format: titleFormat, displayName) } diff --git a/Session/Calls/UserInterface/Individual/CallUIAdapter.swift b/Session/Calls/UserInterface/Individual/CallUIAdapter.swift index b96a5f963..671c7575d 100644 --- a/Session/Calls/UserInterface/Individual/CallUIAdapter.swift +++ b/Session/Calls/UserInterface/Individual/CallUIAdapter.swift @@ -27,7 +27,7 @@ protocol CallUIAdaptee { func failCall(_ call: SignalCall, error: SignalCall.CallError) func setIsMuted(call: SignalCall, isMuted: Bool) func setHasLocalVideo(call: SignalCall, hasLocalVideo: Bool) - func startAndShowOutgoingCall(address: String, hasLocalVideo: Bool) + func startAndShowOutgoingCall(publicKey: String, hasLocalVideo: Bool) } // Shared default implementations @@ -48,17 +48,17 @@ extension CallUIAdaptee { notificationPresenter.presentMissedCall(call.individualCall, callerName: callerName) } - internal func startAndShowOutgoingCall(address: String, hasLocalVideo: Bool) { + internal func startAndShowOutgoingCall(publicKey: String, hasLocalVideo: Bool) { AssertIsOnMainThread() guard let call = self.callService.buildOutgoingIndividualCallIfPossible( - publicKey: address, + publicKey: publicKey, hasVideo: hasLocalVideo ) else { // @integration This is not unexpected, it could happen if Bob tries // to start an outgoing call at the same moment Alice has already // sent him an Offer that is being processed. - Logger.info("found an existing call when trying to start outgoing call: \(address)") + Logger.info("found an existing call when trying to start outgoing call: \(publicKey)") return } @@ -91,6 +91,7 @@ public class CallUIAdapter: NSObject, CallServiceObserver { return nil } else { Logger.info("using callkit adaptee for iOS11+") + let preferences = Environment.shared.preferences! let showNames = preferences.notificationPreviewType() != .noNameNoPreview let useSystemCallLog = preferences.isSystemCallLogEnabled() @@ -215,10 +216,10 @@ public class CallUIAdapter: NSObject, CallServiceObserver { adaptee(for: call).answerCall(call) } - @objc public func startAndShowOutgoingCall(address: String, hasLocalVideo: Bool) { + @objc public func startAndShowOutgoingCall(publicKey: String, hasLocalVideo: Bool) { AssertIsOnMainThread() - defaultAdaptee.startAndShowOutgoingCall(address: address, hasLocalVideo: hasLocalVideo) + defaultAdaptee.startAndShowOutgoingCall(publicKey: publicKey, hasLocalVideo: hasLocalVideo) } internal func recipientAcceptedCall(_ call: SignalCall) { diff --git a/Session/Calls/UserInterface/Individual/IndividualCallViewController.swift b/Session/Calls/UserInterface/Individual/IndividualCallViewController.swift index afbe6213d..b38d36947 100644 --- a/Session/Calls/UserInterface/Individual/IndividualCallViewController.swift +++ b/Session/Calls/UserInterface/Individual/IndividualCallViewController.swift @@ -36,7 +36,7 @@ class IndividualCallViewController: OWSViewController, CallObserver, CallAudioSe private lazy var topGradientView: UIView = { let gradientLayer = CAGradientLayer() gradientLayer.colors = [ - UIColor.ows_blackAlpha60.cgColor, + UIColor.black.withAlphaComponent(0.6).cgColor, UIColor.black.withAlphaComponent(0).cgColor ] let view = OWSLayerView(frame: .zero) { view in @@ -52,7 +52,7 @@ class IndividualCallViewController: OWSViewController, CallObserver, CallAudioSe let gradientLayer = CAGradientLayer() gradientLayer.colors = [ UIColor.black.withAlphaComponent(0).cgColor, - UIColor.ows_blackAlpha60.cgColor + UIColor.black.withAlphaComponent(0.6).cgColor ] let view = OWSLayerView(frame: .zero) { view in gradientLayer.frame = view.bounds diff --git a/Session/Meta/Dependencies+MainApp.swift b/Session/Meta/Dependencies+MainApp.swift index fdc5e05f7..ee5e28011 100644 --- a/Session/Meta/Dependencies+MainApp.swift +++ b/Session/Meta/Dependencies+MainApp.swift @@ -33,3 +33,32 @@ public extension NSObject { AppEnvironment.shared.outboundIndividualCallInitiatorRef } } + +public protocol Dependencies { } + +public extension Dependencies { + + var individualCallUIAdapter: CallUIAdapter { + AppEnvironment.shared.callServiceRef.individualCallService.callUIAdapter + } + + static var individualCallUIAdapter: CallUIAdapter { + AppEnvironment.shared.callServiceRef.individualCallService.callUIAdapter + } + + var callService: CallService { + AppEnvironment.shared.callServiceRef + } + + static var callService: CallService { + AppEnvironment.shared.callServiceRef + } + + var outboundIndividualCallInitiator: OutboundIndividualCallInitiator { + AppEnvironment.shared.outboundIndividualCallInitiatorRef + } + + static var outboundIndividualCallInitiator: OutboundIndividualCallInitiator { + AppEnvironment.shared.outboundIndividualCallInitiatorRef + } +} diff --git a/Session/Meta/Signal-Bridging-Header.h b/Session/Meta/Signal-Bridging-Header.h index 956c13505..e0a2802f0 100644 --- a/Session/Meta/Signal-Bridging-Header.h +++ b/Session/Meta/Signal-Bridging-Header.h @@ -30,6 +30,7 @@ #import "OWSWindowManager.h" #import "PrivacySettingsTableViewController.h" #import "OWSQRCodeScanningViewController.h" +#import "RemoteVideoView.h" #import "SignalApp.h" #import "UIViewController+Permissions.h" #import