Skip to content

Commit

Permalink
Proximity meter fixes
Browse files Browse the repository at this point in the history
There was the issue when Proximity meter is kept on after having audio/video call. The problem was that `isProximityMonitoringEnabled` was not toggled back.
The Proximity meter blocks user interactions and turns screen brightness off/on itself. So some redundant part of ProximityManager class was removed.

MOB-2771
  • Loading branch information
Egor Egorov authored and github-review-helper committed Oct 26, 2023
1 parent 1945b78 commit 77298bb
Show file tree
Hide file tree
Showing 46 changed files with 214 additions and 163 deletions.
16 changes: 16 additions & 0 deletions GliaWidgets.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@
845E2F98283FC9A900C04D56 /* Theme.Survey.OptionButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845E2F97283FC9A900C04D56 /* Theme.Survey.OptionButton.swift */; };
845E2F9B283FCA9000C04D56 /* Theme.Survey.Checkbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845E2F9A283FCA9000C04D56 /* Theme.Survey.Checkbox.swift */; };
845E2F9D283FCB1400C04D56 /* Theme.Survey.Checkbox.Accessibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845E2F9C283FCB1400C04D56 /* Theme.Survey.Checkbox.Accessibility.swift */; };
84602A742AE94DE50031E606 /* ProximityManager.Mock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84602A732AE94DE50031E606 /* ProximityManager.Mock.swift */; };
84602A772AEA5BEA0031E606 /* ProximityManager.Failing.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84602A762AEA5BEA0031E606 /* ProximityManager.Failing.swift */; };
8464297A2A44937600943BD6 /* AlertViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 846429792A44937600943BD6 /* AlertViewControllerTests.swift */; };
8464297D2A459E7D00943BD6 /* UIViewController+Replaceble.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8464297C2A459E7D00943BD6 /* UIViewController+Replaceble.swift */; };
846429802A45A1F200943BD6 /* OfferPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8464297F2A45A1F200943BD6 /* OfferPresenter.swift */; };
Expand Down Expand Up @@ -1089,6 +1091,8 @@
845E2F97283FC9A900C04D56 /* Theme.Survey.OptionButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Theme.Survey.OptionButton.swift; sourceTree = "<group>"; };
845E2F9A283FCA9000C04D56 /* Theme.Survey.Checkbox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Theme.Survey.Checkbox.swift; sourceTree = "<group>"; };
845E2F9C283FCB1400C04D56 /* Theme.Survey.Checkbox.Accessibility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Theme.Survey.Checkbox.Accessibility.swift; sourceTree = "<group>"; };
84602A732AE94DE50031E606 /* ProximityManager.Mock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProximityManager.Mock.swift; sourceTree = "<group>"; };
84602A762AEA5BEA0031E606 /* ProximityManager.Failing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProximityManager.Failing.swift; sourceTree = "<group>"; };
846429792A44937600943BD6 /* AlertViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertViewControllerTests.swift; sourceTree = "<group>"; };
8464297C2A459E7D00943BD6 /* UIViewController+Replaceble.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+Replaceble.swift"; sourceTree = "<group>"; };
8464297F2A45A1F200943BD6 /* OfferPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OfferPresenter.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2670,6 +2674,7 @@
7512A57827BF9FB800319DF1 /* Sources */ = {
isa = PBXGroup;
children = (
84602A752AEA5BDE0031E606 /* ProximityManager */,
84681A932A61840700DD7406 /* ChatViewModel */,
846429812A45DA5900943BD6 /* AlertViewController */,
846A5C4329F6BEB60049B29F /* Glia */,
Expand Down Expand Up @@ -3117,6 +3122,14 @@
path = URLScheme;
sourceTree = "<group>";
};
84602A752AEA5BDE0031E606 /* ProximityManager */ = {
isa = PBXGroup;
children = (
84602A762AEA5BEA0031E606 /* ProximityManager.Failing.swift */,
);
path = ProximityManager;
sourceTree = "<group>";
};
8464297B2A459E3500943BD6 /* Replaceble */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -3524,6 +3537,7 @@
isa = PBXGroup;
children = (
C05E3EDD29C99E070013BC81 /* ProximityManager.swift */,
84602A732AE94DE50031E606 /* ProximityManager.Mock.swift */,
);
path = ProximityManager;
sourceTree = "<group>";
Expand Down Expand Up @@ -4631,6 +4645,7 @@
755D187129A6A6400009F5E8 /* WelcomeStyle+MessageTextViewNormalStyle.swift in Sources */,
845A28FC28AFF092008558EA /* URLScheme.swift in Sources */,
75F58EE127E7D5300065BA2D /* Survey.ViewController.Props.swift in Sources */,
84602A742AE94DE50031E606 /* ProximityManager.Mock.swift in Sources */,
754CC61527E27C42005676E9 /* Survey.Checkbox.swift in Sources */,
84681AA72A681EF900DD7406 /* QuickReplyButtonStyle.swift in Sources */,
1A4AD3CA256E864800468BFB /* ThemeColorStyle.swift in Sources */,
Expand Down Expand Up @@ -4857,6 +4872,7 @@
8491AF502A9CBB0400CC3E72 /* TranscriptModelTests+GVA.swift in Sources */,
C03A8049292BC8DB00DDECA6 /* CallViewControllerTests.swift in Sources */,
84D5B9662A15204400807F92 /* QuickLookBased.Failing.swift in Sources */,
84602A772AEA5BEA0031E606 /* ProximityManager.Failing.swift in Sources */,
84681A982A61853300DD7406 /* GvaOption.Mock.swift in Sources */,
AF6AB34B2989517100003645 /* FileUploader.Failing.swift in Sources */,
EB03B00E27FFF6DD0058F6B1 /* CallViewTests.swift in Sources */,
Expand Down
4 changes: 2 additions & 2 deletions GliaWidgets/Public/Glia/Glia+StartEngagement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ extension Glia {
submitSurveyAnswer: environment.coreSdk.submitSurveyAnswer,
uiApplication: environment.uiApplication,
uiScreen: environment.uiScreen,
uiDevice: environment.uiDevice,
notificationCenter: environment.notificationCenter,
fetchChatHistory: environment.coreSdk.fetchChatHistory,
listQueues: environment.coreSdk.listQueues,
Expand All @@ -161,7 +160,8 @@ extension Glia {
stopSocketObservation: environment.coreSdk.stopSocketObservation,
pushNotifications: environment.coreSdk.pushNotifications,
createSendMessagePayload: environment.coreSdk.createSendMessagePayload,
orientationManager: environment.orientationManager
orientationManager: environment.orientationManager,
proximityManager: environment.proximityManager
)
)
rootCoordinator?.delegate = { [weak self] event in
Expand Down
3 changes: 2 additions & 1 deletion GliaWidgets/Public/Glia/Glia.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ public class Glia {
assetsBuilder: { [weak self] in self?.assetsBuilder ?? .standard },
getCurrentEngagement: environment.coreSdk.getCurrentEngagement,
eventHandler: onEvent,
orientationManager: environment.orientationManager
orientationManager: environment.orientationManager,
proximityManager: environment.proximityManager
)
)
var rootCoordinator: EngagementCoordinator?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ extension SecureConversations.Coordinator {
interactor: environment.interactor,
startSocketObservation: environment.startSocketObservation,
stopSocketObservation: environment.stopSocketObservation,
createSendMessagePayload: environment.createSendMessagePayload
createSendMessagePayload: environment.createSendMessagePayload,
proximityManager: environment.proximityManager
),
startWithSecureTranscriptFlow: true
)
Expand Down Expand Up @@ -321,7 +322,6 @@ extension SecureConversations.Coordinator {
var uuid: () -> UUID
var uiApplication: UIKitBased.UIApplication
var uiScreen: UIKitBased.UIScreen
var uiDevice: UIKitBased.UIDevice
var notificationCenter: FoundationBased.NotificationCenter
var createFileUploadListModel: SecureConversations.FileUploadListViewModel.Create
var viewFactory: ViewFactory
Expand All @@ -348,6 +348,7 @@ extension SecureConversations.Coordinator {
var stopSocketObservation: CoreSdkClient.StopSocketObservation
var createSendMessagePayload: CoreSdkClient.CreateSendMessagePayload
var orientationManager: OrientationManager
var proximityManager: ProximityManager
}

enum DelegateEvent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ extension CallVisualizer {
var getCurrentEngagement: CoreSdkClient.GetCurrentEngagement
var eventHandler: ((GliaEvent) -> Void)?
var orientationManager: OrientationManager
var proximityManager: ProximityManager
}
}
3 changes: 2 additions & 1 deletion GliaWidgets/Sources/CallVisualizer/CallVisualizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public final class CallVisualizer {
self?.environment.eventHandler?(.maximized)
}
},
orientationManager: environment.orientationManager
orientationManager: environment.orientationManager,
proximityManager: environment.proximityManager
)
)
}()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ extension CallVisualizer.Coordinator {
var engagedOperator: () -> CoreSdkClient.Operator?
var eventHandler: (DelegateEvent) -> Void
var orientationManager: OrientationManager
var proximityManager: ProximityManager
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ extension CallVisualizer {
notificationCenter: environment.notificationCenter,
date: environment.date,
engagedOperator: environment.engagedOperator,
screenShareHandler: environment.screenShareHandler
screenShareHandler: environment.screenShareHandler,
proximityManager: environment.proximityManager
),
theme: environment.viewFactory.theme,
call: .init(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ extension CallVisualizer.VideoCallCoordinator {
var date: () -> Date
var engagedOperator: () -> CoreSdkClient.Operator?
var screenShareHandler: ScreenShareHandler
var proximityManager: ProximityManager
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ extension CallVisualizer {
notificationCenter: environment.notificationCenter,
date: environment.date,
engagedOperator: environment.engagedOperator,
screenShareHandler: environment.screenShareHandler
screenShareHandler: environment.screenShareHandler,
proximityManager: environment.proximityManager
),
call: call
)
Expand All @@ -57,9 +58,6 @@ extension CallVisualizer {
gcd: environment.gcd,
uiScreen: environment.uiScreen
),
uiApplication: environment.uiApplication,
uiScreen: environment.uiScreen,
uiDevice: environment.uiDevice,
notificationCenter: environment.notificationCenter
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ extension CallVisualizer {
final class VideoCallViewController: UIViewController {
private let videoCallView: VideoCallView
private let environment: Environment
private var proximityManager: ProximityManager?

var props: Props {
didSet {
Expand All @@ -24,10 +23,6 @@ extension CallVisualizer {
super.init(nibName: nil, bundle: nil)
}

deinit {
proximityManager?.stop()
}

// MARK: - Required

required init?(coder: NSCoder) {
Expand All @@ -42,16 +37,7 @@ extension CallVisualizer {

override func viewDidLoad() {
super.viewDidLoad()
proximityManager = .init(
view: self.view,
environment: .init(
uiApplication: environment.uiApplication,
uiDevice: environment.uiDevice,
uiScreen: environment.uiScreen,
notificationCenter: environment.notificationCenter
)
)
proximityManager?.start()
props.viewDidLoad()
}
}
}
Expand All @@ -61,6 +47,7 @@ extension CallVisualizer {
extension CallVisualizer.VideoCallViewController {
struct Props: Equatable {
let videoCallViewProps: CallVisualizer.VideoCallView.Props
let viewDidLoad: Cmd
}
}

Expand All @@ -69,9 +56,6 @@ extension CallVisualizer.VideoCallViewController {
extension CallVisualizer.VideoCallViewController {
struct Environment {
var videoCallView: CallVisualizer.VideoCallView.Environment
var uiApplication: UIKitBased.UIApplication
var uiScreen: UIKitBased.UIScreen
var uiDevice: UIKitBased.UIDevice
var notificationCenter: FoundationBased.NotificationCenter
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ extension CallVisualizer.VideoCallViewModel {
var date: () -> Date
var engagedOperator: () -> CoreSdkClient.Operator?
var screenShareHandler: ScreenShareHandler
var proximityManager: ProximityManager
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ extension CallVisualizer {
object: nil
)
}

deinit {
environment.proximityManager.stop()
}
}
}

Expand Down Expand Up @@ -180,7 +184,10 @@ extension CallVisualizer.VideoCallViewModel {
),
style: style.header
)
)
),
viewDidLoad: .init { [weak self] in
self?.environment.proximityManager.start()
}
)
}

Expand Down
8 changes: 3 additions & 5 deletions GliaWidgets/Sources/Coordinators/Call/CallCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ private extension CallCoordinator {
fetchChatHistory: environment.fetchChatHistory,
fileUploadListStyle: viewFactory.theme.chatStyle.messageEntry.uploadList,
createFileUploadListModel: environment.createFileUploadListModel,
createSendMessagePayload: environment.createSendMessagePayload
createSendMessagePayload: environment.createSendMessagePayload,
proximityManager: environment.proximityManager
),
call: call,
unreadMessages: unreadMessages,
Expand All @@ -97,9 +98,6 @@ private extension CallCoordinator {
viewModel: viewModel,
viewFactory: viewFactory,
environment: .init(
uiApplication: environment.uiApplication,
uiScreen: environment.uiScreen,
uiDevice: environment.uiDevice,
notificationCenter: environment.notificationCenter
)
)
Expand Down Expand Up @@ -147,10 +145,10 @@ extension CallCoordinator {
var uuid: () -> UUID
var uiApplication: UIKitBased.UIApplication
var uiScreen: UIKitBased.UIScreen
var uiDevice: UIKitBased.UIDevice
var notificationCenter: FoundationBased.NotificationCenter
var fetchChatHistory: CoreSdkClient.FetchChatHistory
var createFileUploadListModel: SecureConversations.FileUploadListViewModel.Create
var createSendMessagePayload: CoreSdkClient.CreateSendMessagePayload
var proximityManager: ProximityManager
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ extension ChatCoordinator {
var startSocketObservation: CoreSdkClient.StartSocketObservation
var stopSocketObservation: CoreSdkClient.StopSocketObservation
var createSendMessagePayload: CoreSdkClient.CreateSendMessagePayload
var proximityManager: ProximityManager
}
}
3 changes: 2 additions & 1 deletion GliaWidgets/Sources/Coordinators/Chat/ChatCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ extension ChatCoordinator {
fetchChatHistory: environment.fetchChatHistory,
fileUploadListStyle: viewFactory.theme.chatStyle.messageEntry.uploadList,
createFileUploadListModel: environment.createFileUploadListModel,
createSendMessagePayload: environment.createSendMessagePayload
createSendMessagePayload: environment.createSendMessagePayload,
proximityManager: environment.proximityManager
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ extension EngagementCoordinator.Environment {
submitSurveyAnswer: { _, _, _, _ in },
uiApplication: .mock,
uiScreen: .mock,
uiDevice: .mock,
notificationCenter: .mock,
fetchChatHistory: { _ in },
listQueues: { _ in },
Expand All @@ -35,7 +34,8 @@ extension EngagementCoordinator.Environment {
stopSocketObservation: {},
pushNotifications: .mock,
createSendMessagePayload: { _, _ in .mock() },
orientationManager: .mock()
orientationManager: .mock(),
proximityManager: .mock
)
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ extension EngagementCoordinator {
var submitSurveyAnswer: CoreSdkClient.SubmitSurveyAnswer
var uiApplication: UIKitBased.UIApplication
var uiScreen: UIKitBased.UIScreen
var uiDevice: UIKitBased.UIDevice
var notificationCenter: FoundationBased.NotificationCenter
var fetchChatHistory: CoreSdkClient.FetchChatHistory
var listQueues: CoreSdkClient.ListQueues
Expand All @@ -37,5 +36,6 @@ extension EngagementCoordinator {
var pushNotifications: CoreSdkClient.PushNotifications
var createSendMessagePayload: CoreSdkClient.CreateSendMessagePayload
var orientationManager: OrientationManager
var proximityManager: ProximityManager
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ extension EngagementCoordinator {
interactor: interactor,
startSocketObservation: environment.startSocketObservation,
stopSocketObservation: environment.stopSocketObservation,
createSendMessagePayload: environment.createSendMessagePayload
createSendMessagePayload: environment.createSendMessagePayload,
proximityManager: environment.proximityManager
),
startWithSecureTranscriptFlow: false
)
Expand Down Expand Up @@ -343,11 +344,11 @@ extension EngagementCoordinator {
uuid: environment.uuid,
uiApplication: environment.uiApplication,
uiScreen: environment.uiScreen,
uiDevice: environment.uiDevice,
notificationCenter: environment.notificationCenter,
fetchChatHistory: environment.fetchChatHistory,
createFileUploadListModel: environment.createFileUploadListModel,
createSendMessagePayload: environment.createSendMessagePayload
createSendMessagePayload: environment.createSendMessagePayload,
proximityManager: environment.proximityManager
)
)
coordinator.delegate = { [weak self] event in
Expand Down Expand Up @@ -453,7 +454,6 @@ extension EngagementCoordinator {
uuid: environment.uuid,
uiApplication: environment.uiApplication,
uiScreen: environment.uiScreen,
uiDevice: environment.uiDevice,
notificationCenter: environment.notificationCenter,
createFileUploadListModel: environment.createFileUploadListModel,
viewFactory: viewFactory,
Expand All @@ -479,7 +479,8 @@ extension EngagementCoordinator {
startSocketObservation: environment.startSocketObservation,
stopSocketObservation: environment.stopSocketObservation,
createSendMessagePayload: environment.createSendMessagePayload,
orientationManager: environment.orientationManager
orientationManager: environment.orientationManager,
proximityManager: environment.proximityManager
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ extension Glia {
var messagesWithUnreadCountLoaderScheduler: CoreSdkClient.ReactiveSwift.DateScheduler
var orientationManager: OrientationManager
var coreSDKConfigurator: CoreSDKConfigurator
var proximityManager: ProximityManager
}
}

Expand Down
Loading

0 comments on commit 77298bb

Please sign in to comment.