Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature][Calling][CSS] Call history #610

Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6afebc3
Css call history
pavelprystinka Jan 24, 2023
3ee664c
rename callIds to callIdList
pavelprystinka Jan 24, 2023
ae46eb7
Store callid in sqlite
pavelprystinka Jan 25, 2023
6b16f2c
rename list to plurals
pavelprystinka Jan 26, 2023
f42881a
clear call history records
pavelprystinka Jan 26, 2023
d3dda8e
update data formatter use
pavelprystinka Jan 27, 2023
41d3a1e
Merge branch 'develop' into feature/css_call_history_v1
pavelprystinka Jan 27, 2023
70c93f2
Clean old call history records async
pavelprystinka Jan 28, 2023
6f84990
Show call history in demo app
pavelprystinka Jan 30, 2023
5f08fb6
Store call history in UserDefaults
pavelprystinka Feb 7, 2023
be35c85
remove unused import
pavelprystinka Feb 7, 2023
41c703a
Inject userDefaults to history repository
pavelprystinka Feb 8, 2023
3997d0f
Fix threshold condition
pavelprystinka Feb 8, 2023
6494cd0
CallHistoryRepository to inset async and serial
pavelprystinka Feb 19, 2023
0aa3973
Make CallHistoryRepository sync, but CallHistoryService to save async
pavelprystinka Feb 23, 2023
4b7c1f8
let view model instead of var
pavelprystinka Feb 23, 2023
2efd9e1
Move callHistoryDispatchQueue to repository
pavelprystinka Feb 28, 2023
812d79b
Code format
pavelprystinka Feb 28, 2023
4a3cbd5
Use XCTestExpectation in test for call history
pavelprystinka Mar 1, 2023
84b9590
Remove not needed thread sleep
pavelprystinka Mar 1, 2023
e682109
Filter out old call history records on getAll as well.
pavelprystinka Mar 1, 2023
92cacb0
remove CallHistoryRepositoryProtocol
pavelprystinka Mar 1, 2023
5502fdb
Update cocopods SDK version
pavelprystinka Mar 1, 2023
b7f5e8c
Update pool for nightly pipeline
pavelprystinka Mar 2, 2023
1201720
Revert SDK version update
pavelprystinka Mar 7, 2023
0389a4f
Address feedback
pavelprystinka Mar 7, 2023
89f36c3
Address feedback
pavelprystinka Mar 7, 2023
f6ca66c
Fix compile error
pavelprystinka Mar 7, 2023
257c9f1
Inject userDefault to CallHistoryRepositoryMocking
pavelprystinka Mar 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
0570901C299EBAC000D7AE5F /* CallingDemoViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0570901B299EBAC000D7AE5F /* CallingDemoViewModel.swift */; };
1B0D8DC627F3B1B800F0C47A /* AzureCommunicationUIDemoAppCallTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B0D8DC527F3B1B800F0C47A /* AzureCommunicationUIDemoAppCallTests.swift */; };
1B3E3B4F285A8F690010E24E /* AzureCommunicationUIDemoAppSetupViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B3E3B4E285A8F690010E24E /* AzureCommunicationUIDemoAppSetupViewTests.swift */; };
1B5D6C0F29231B900072C66D /* CallConfigurationMocking.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B5D6C0929231B900072C66D /* CallConfigurationMocking.swift */; };
Expand Down Expand Up @@ -81,6 +82,7 @@

/* Begin PBXFileReference section */
026F091CB7F97EBA5A39610B /* Pods_AzureCommunicationUIDemoApp_AzureCommunicationUIDemoAppUITests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AzureCommunicationUIDemoApp_AzureCommunicationUIDemoAppUITests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
0570901B299EBAC000D7AE5F /* CallingDemoViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CallingDemoViewModel.swift; sourceTree = "<group>"; };
1AA61EC7BE9A4B43EEC5DBCC /* Pods-AzureCommunicationUIDemoApp-AzureCommunicationUIDemoAppUITests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AzureCommunicationUIDemoApp-AzureCommunicationUIDemoAppUITests.release.xcconfig"; path = "Target Support Files/Pods-AzureCommunicationUIDemoApp-AzureCommunicationUIDemoAppUITests/Pods-AzureCommunicationUIDemoApp-AzureCommunicationUIDemoAppUITests.release.xcconfig"; sourceTree = "<group>"; };
1B0D8DC527F3B1B800F0C47A /* AzureCommunicationUIDemoAppCallTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AzureCommunicationUIDemoAppCallTests.swift; sourceTree = "<group>"; };
1B3E3B4E285A8F690010E24E /* AzureCommunicationUIDemoAppSetupViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AzureCommunicationUIDemoAppSetupViewTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -291,6 +293,7 @@
A87CEABB2729ECA600F3AE16 /* EntryViewController.swift */,
A85DDCB52728B23B001297B4 /* CallingDemoView.swift */,
A85DDCB42728B23A001297B4 /* CallingDemoViewController.swift */,
0570901B299EBAC000D7AE5F /* CallingDemoViewModel.swift */,
50D8EE9E2926C0C6003C3A95 /* ChatDemoView.swift */,
50D8EEA02926C0DD003C3A95 /* ChatDemoViewController.swift */,
50B390CE27D2996E0010A2ED /* SettingsView.swift */,
Expand Down Expand Up @@ -580,6 +583,7 @@
A85DDCB82728B23B001297B4 /* CallingDemoViewController.swift in Sources */,
50D8EE9F2926C0C6003C3A95 /* ChatDemoView.swift in Sources */,
50D8EEA12926C0DD003C3A95 /* ChatDemoViewController.swift in Sources */,
0570901C299EBAC000D7AE5F /* CallingDemoViewModel.swift in Sources */,
A8C69FB62728AE1A00143DB7 /* SceneDelegate.swift in Sources */,
1B981B0429480DA8002EB167 /* FloatingUITestWindow.swift in Sources */,
A87CEABC2729ECA600F3AE16 /* EntryViewController.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ struct CallingDemoView: View {
@State var isSettingsDisplayed: Bool = false
@State var isStartExperienceLoading: Bool = false
@State var errorMessage: String = ""
@State var isShowingCallHistory: Bool = false
@ObservedObject var envConfigSubject: EnvConfigSubject
@ObservedObject var callingViewModel: CallingDemoViewModel

let verticalPadding: CGFloat = 5
let horizontalPadding: CGFloat = 10
Expand All @@ -30,6 +32,7 @@ struct CallingDemoView: View {
displayNameTextField
meetingSelector
settingButton
showCallHistoryButton
startExperienceButton
Spacer()
}
Expand All @@ -43,6 +46,15 @@ struct CallingDemoView: View {
isErrorDisplayed = false
}))
}
.alert(isPresented: $isShowingCallHistory) {
Alert(
title: Text(callingViewModel.callHistoryTitle),
message: Text(callingViewModel.callHistoryMessage),
dismissButton:
.default(Text("Dismiss"), action: {
isShowingCallHistory = false
}))
}
.sheet(isPresented: $isSettingsDisplayed) {
SettingsView(envConfigSubject: envConfigSubject)
}
Expand Down Expand Up @@ -130,6 +142,13 @@ struct CallingDemoView: View {
.accessibility(identifier: AccessibilityId.startExperienceAccessibilityID.rawValue)
}

var showCallHistoryButton: some View {
Button("Show call history") {
isShowingCallHistory = true
}
.buttonStyle(DemoButtonStyle())
}

var isStartExperienceDisabled: Bool {
let acsToken = envConfigSubject.useExpiredToken ? envConfigSubject.expiredAcsToken : envConfigSubject.acsToken
if (envConfigSubject.selectedAcsTokenType == .token && acsToken.isEmpty)
Expand Down Expand Up @@ -282,7 +301,7 @@ extension CallingDemoView {
private func onError(_ error: CallCompositeError, callComposite: CallComposite) {
print("::::CallingDemoView::getEventsHandler::onError \(error)")
print("::::CallingDemoView error.code \(error.code)")
print("::::CallingDemoView debug info \(callComposite.debugInfo.currentOrLastCallId ?? "Unknown")")
callingViewModel.callHistory.last?.callIds.forEach { print("::::CallingDemoView call id \($0)") }
showError(for: error.code)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class CallingDemoViewController: UIViewController {
static let buttonHorizontalInset: CGFloat = 20.0
static let buttonVerticalInset: CGFloat = 10.0
}
var callingViewModel: CallingDemoViewModel

private var selectedAcsTokenType: ACSTokenType = .token
private var acsTokenUrlTextField: UITextField!
Expand All @@ -32,6 +33,7 @@ class CallingDemoViewController: UIViewController {
private var groupCallTextField: UITextField!
private var teamsMeetingTextField: UITextField!
private var settingsButton: UIButton!
private var showCallHistoryButton: UIButton!
private var startExperienceButton: UIButton!
private var acsTokenTypeSegmentedControl: UISegmentedControl!
private var meetingTypeSegmentedControl: UISegmentedControl!
Expand Down Expand Up @@ -79,15 +81,19 @@ class CallingDemoViewController: UIViewController {

#if DEBUG
init(envConfigSubject: EnvConfigSubject,
callingViewModel: CallingDemoViewModel,
callingSDKHandlerMock: UITestCallingSDKWrapper? = nil) {
self.envConfigSubject = envConfigSubject
self.callingViewModel = callingViewModel
self.callingSDKWrapperMock = callingSDKHandlerMock
super.init(nibName: nil, bundle: nil)
self.combineEnvConfigSubject()
}
#else
init(envConfigSubject: EnvConfigSubject) {
init(envConfigSubject: EnvConfigSubject,
callingViewModel: CallingDemoViewModel) {
self.envConfigSubject = envConfigSubject
self.callingViewModel = callingViewModel
super.init(nibName: nil, bundle: nil)
self.combineEnvConfigSubject()
}
Expand Down Expand Up @@ -158,7 +164,7 @@ class CallingDemoViewController: UIViewController {
private func onError(_ error: CallCompositeError, callComposite: CallComposite) {
print("::::UIKitDemoView::getEventsHandler::onError \(error)")
print("::::UIKitDemoView error.code \(error.code)")
print("::::SwiftUIDemoView debug info \(callComposite.debugInfo.currentOrLastCallId ?? "Unknown")")
callingViewModel.callHistory.last?.callIds.forEach { print("::::UIKitDemoView call id \($0)") }
}

private func onRemoteParticipantJoined(to callComposite: CallComposite, identifiers: [CommunicationIdentifier]) {
Expand Down Expand Up @@ -354,6 +360,16 @@ class CallingDemoViewController: UIViewController {
present(settingsViewHostingController, animated: true, completion: nil)
}

@objc func onShowHistoryBtnPressed() {
let errorAlert = UIAlertController(title: callingViewModel.callHistoryTitle,
message: callingViewModel.callHistoryMessage,
preferredStyle: .alert)
errorAlert.addAction(UIAlertAction(title: "Dismiss", style: .cancel, handler: nil))
present(errorAlert,
animated: true,
completion: nil)
}

@objc func onStartExperienceBtnPressed() {
startExperienceButton.isEnabled = false
startExperienceButton.backgroundColor = .systemGray3
Expand Down Expand Up @@ -494,6 +510,16 @@ class CallingDemoViewController: UIViewController {
right: LayoutConstants.buttonHorizontalInset)
settingsButton.accessibilityIdentifier = AccessibilityId.settingsButtonAccessibilityID.rawValue

showCallHistoryButton = UIButton()
showCallHistoryButton.setTitle("Show call history", for: .normal)
showCallHistoryButton.backgroundColor = .systemBlue
showCallHistoryButton.contentEdgeInsets = UIEdgeInsets.init(top: LayoutConstants.buttonVerticalInset,
left: LayoutConstants.buttonHorizontalInset,
bottom: LayoutConstants.buttonVerticalInset,
right: LayoutConstants.buttonHorizontalInset)
showCallHistoryButton.layer.cornerRadius = 8
pavelprystinka marked this conversation as resolved.
Show resolved Hide resolved
showCallHistoryButton.addTarget(self, action: #selector(onShowHistoryBtnPressed), for: .touchUpInside)

startExperienceButton = UIButton()
startExperienceButton.backgroundColor = .systemBlue
startExperienceButton.setTitleColor(UIColor.white, for: .normal)
Expand Down Expand Up @@ -527,6 +553,22 @@ class CallingDemoViewController: UIViewController {
settingsButtonHStack.distribution = .fill
settingsButtonHStack.translatesAutoresizingMaskIntoConstraints = false

let showHistoryButtonHSpacer1 = UIView()
showHistoryButtonHSpacer1.translatesAutoresizingMaskIntoConstraints = false
showHistoryButtonHSpacer1.setContentHuggingPriority(.defaultLow, for: .horizontal)

let showHistoryButtonHSpacer2 = UIView()
showHistoryButtonHSpacer2.translatesAutoresizingMaskIntoConstraints = false
showHistoryButtonHSpacer2.setContentHuggingPriority(.defaultLow, for: .horizontal)

let showHistoryButtonHStack = UIStackView(arrangedSubviews: [showHistoryButtonHSpacer1,
showCallHistoryButton,
showHistoryButtonHSpacer2])
showHistoryButtonHStack.axis = .horizontal
showHistoryButtonHStack.alignment = .fill
showHistoryButtonHStack.distribution = .fill
showHistoryButtonHStack.translatesAutoresizingMaskIntoConstraints = false

let startButtonHSpacer1 = UIView()
emlynmac marked this conversation as resolved.
Show resolved Hide resolved
startButtonHSpacer1.translatesAutoresizingMaskIntoConstraints = false
startButtonHSpacer1.setContentHuggingPriority(.defaultLow, for: .horizontal)
Expand Down Expand Up @@ -555,6 +597,7 @@ class CallingDemoViewController: UIViewController {
groupCallTextField,
teamsMeetingTextField,
settingsButtonHStack,
showHistoryButtonHStack,
startButtonHStack])
stackView.spacing = LayoutConstants.stackViewSpacingPortrait
stackView.axis = .vertical
Expand Down Expand Up @@ -586,6 +629,7 @@ class CallingDemoViewController: UIViewController {
stackView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor).isActive = true

settingButtonHSpacer2.widthAnchor.constraint(equalTo: settingButtonHSpacer1.widthAnchor).isActive = true
showHistoryButtonHSpacer2.widthAnchor.constraint(equalTo: showHistoryButtonHSpacer1.widthAnchor).isActive = true
startButtonHSpacer2.widthAnchor.constraint(equalTo: startButtonHSpacer1.widthAnchor).isActive = true

updateAcsTokenTypeFields()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//

import Foundation
#if DEBUG
@testable import AzureCommunicationUICalling
#else
import AzureCommunicationUICalling
#endif

class CallingDemoViewModel: ObservableObject {
vhuseinova-msft marked this conversation as resolved.
Show resolved Hide resolved
lazy var dateFormatter: DateFormatter = {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
return dateFormatter
}()

var callHistoryTitle: String {
return "Total calls: \(callHistory.count)"
}

var callHistoryMessage: String {
var callHistoryMessage = "Last Call: none"
if let lastHistoryRecord = callHistory.last {
let formattedDate = dateFormatter.string(from: lastHistoryRecord.callStartedOn)
callHistoryMessage = "Last Call: \(formattedDate)\n"
callHistoryMessage += "Call Ids:\n"
callHistoryMessage += lastHistoryRecord.callIds.joined(separator: "\n")
}
return callHistoryMessage
}

var callHistory: [CallHistoryRecord] {
let callComposite = CallComposite()
let debugInfo = callComposite.debugInfo
let callHistory = debugInfo.callHistoryRecords
return callHistory
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class EntryViewController: UIViewController {
private var callingSDKWrapperMock: UITestCallingSDKWrapper?
#endif
private var cancellables = Set<AnyCancellable>()
private let callingViewModel = CallingDemoViewModel()

override func viewDidLoad() {
super.viewDidLoad()
Expand Down Expand Up @@ -151,9 +152,10 @@ class EntryViewController: UIViewController {
@objc func onCallingSwiftUIPressed() {
#if DEBUG
let swiftUIDemoView = CallingDemoView(envConfigSubject: envConfigSubject,
callingViewModel: callingViewModel,
callingSDKWrapperMock: callingSDKWrapperMock)
#else
let swiftUIDemoView = CallingDemoView(envConfigSubject: envConfigSubject)
let swiftUIDemoView = CallingDemoView(envConfigSubject: envConfigSubject, callingViewModel: callingViewModel)
#endif
let swiftUIDemoViewHostingController = UIHostingController(rootView: swiftUIDemoView)
swiftUIDemoViewHostingController.modalPresentationStyle = .fullScreen
Expand All @@ -163,9 +165,11 @@ class EntryViewController: UIViewController {
@objc func onCallingUIKitPressed() {
#if DEBUG
let uiKitDemoViewController = CallingDemoViewController(envConfigSubject: envConfigSubject,
callingViewModel: callingViewModel,
callingSDKHandlerMock: callingSDKWrapperMock)
#else
let uiKitDemoViewController = CallingDemoViewController(envConfigSubject: envConfigSubject)
let uiKitDemoViewController = CallingDemoViewController(envConfigSubject: envConfigSubject,
callingViewModel: callingViewModel)
#endif
uiKitDemoViewController.modalPresentationStyle = .fullScreen
present(uiKitDemoViewController, animated: true, completion: nil)
Expand Down
2 changes: 1 addition & 1 deletion AzureCommunicationUI/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: dba06e7567902f624b6be4dac963332e701eb372

COCOAPODS: 1.11.3
COCOAPODS: 1.12.0
Loading