diff options
author | Matt Porter <mporter@konsulko.com> | 2017-05-20 09:43:18 -0400 |
---|---|---|
committer | Matt Porter <mporter@konsulko.com> | 2017-05-20 09:49:39 -0400 |
commit | 1f5cd7758161271e7e7c38e5a7dc78396f5c56b8 (patch) | |
tree | eb46ced90b3dfa48b428381df94969fb94badedb /app | |
parent | 3a208ed9a418f02b4938f447af04666593cda410 (diff) |
Add support for UI display of phone call duration
Adds support to the telephony binding for generating events when
a call's state changes to active or disconnected states (when a
remote/local party answers or disconnects the call). These events
are used to drive a call duration display in the phone app UI.
AGL-Bug: SPEC-599
Change-Id: Ib4b0b115ca1d0573a7ae046082627f561f0d8d8a
Signed-off-by: Matt Porter <mporter@konsulko.com>
Diffstat (limited to 'app')
-rw-r--r-- | app/Dialer.qml | 30 | ||||
-rw-r--r-- | app/api/Telephony.qml | 4 |
2 files changed, 30 insertions, 4 deletions
diff --git a/app/Dialer.qml b/app/Dialer.qml index 99610fd..51f6a53 100644 --- a/app/Dialer.qml +++ b/app/Dialer.qml @@ -25,10 +25,30 @@ import 'api' as API Item { id: root + function getTime() { + return new Date().getTime() + } + + // Elapsed time in hh:mm:ss format + function getElapsedTimeString(startTime) { + var seconds = Math.floor((getTime() - startTime) / 1000); + var time = new Date(null); + time.setSeconds(seconds); + return time.toISOString().substr(11, 8); + } + + Timer { + id: callTimer + interval: 1000 + repeat: true + property var startTime + onTriggered: callStatusLabel.text = getElapsedTimeString(startTime) + } + API.Telephony { id: telephony url: bindingAddress - property string callStatus: "idle" + property string callStatus: "disconnected" property string callClipColp: "" onCallStatusChanged: { @@ -36,9 +56,13 @@ Item { ringtone.active = true callStatusLabel.text = "Incoming call from " + callClipColp } else if (callStatus == "dialing") { - callStatusLabel.text = "Calling " + callClipColp - } else if (callStatus == "idle") { + callStatusLabel.text = "Dialing " + callClipColp + } else if (callStatus == "active") { + callTimer.startTime = getTime() + callTimer.restart() + } else if (callStatus == "disconnected") { ringtone.active = false + callTimer.stop() callStatusLabel.text = "" } } diff --git a/app/api/Telephony.qml b/app/api/Telephony.qml index b42af4f..c7d9218 100644 --- a/app/api/Telephony.qml +++ b/app/api/Telephony.qml @@ -65,7 +65,9 @@ WebSocket { callClipColp = data.colp callStatus = "dialing" } else if (event == "telephony/terminatedCall") { - callStatus = "idle" + callStatus = "disconnected" + } else if (event == "telephony/callStateChanged") { + callStatus = data.state } break } |