From f59dcfdde1a85920c57b6c5908bac78cd7cd1200 Mon Sep 17 00:00:00 2001 From: Yang Wang <yang.wang@savoirfairelinux.com> Date: Thu, 24 Oct 2019 16:49:09 -0400 Subject: [PATCH] chatview: add audio widget button - audio button is added to text area - signal will be triggered by this button to record audio in native code Change-Id: Id73b9a9cdc6b46bceb5a48f07d02810f3aa949a8 --- src/web-chatview/chatview.html | 6 ++++++ src/web-chatview/chatview.js | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/web-chatview/chatview.html b/src/web-chatview/chatview.html index d592f32c..1701e130 100644 --- a/src/web-chatview/chatview.html +++ b/src/web-chatview/chatview.html @@ -97,6 +97,12 @@ <path d="M0 0h24v24H0z" fill="none" /> </svg> </div> + <div id="audioRecordButton" class="action-button nav-button" onclick="audioRecord()"> + <svg class="svgicon" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"> + <path d="M12 14c1.66 0 2.99-1.34 2.99-3L15 5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm5.3-3c0 3-2.54 5.1-5.3 5.1S6.7 14 6.7 11H5c0 3.41 2.72 6.23 6 6.72V21h2v-3.28c3.28-.48 6-3.3 6-6.72h-1.7z" /> + <path d="M0 0h24v24H0z" fill="none" /> + </svg> + </div> <div id="videoRecordButton" class="nav-button action-button nav-right" onclick="videoRecord()"> <svg class="svgicon" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"> <path fill="none" d="M0 0h24v24H0V0z" /> diff --git a/src/web-chatview/chatview.js b/src/web-chatview/chatview.js index e8deb8c7..5b696ab2 100644 --- a/src/web-chatview/chatview.js +++ b/src/web-chatview/chatview.js @@ -45,6 +45,7 @@ const backToBottomBtn = document.getElementById("back_to_bottom_button") const backToBottomBtnContainer = document.getElementById("back_to_bottom_button_container") const sendFileButton = document.getElementById("sendFileButton") const videoRecordButton = document.getElementById("videoRecordButton") +const audioRecordButton = document.getElementById("audioRecordButton") const aliasField = document.getElementById("nav-contactid-alias") const bestIdField = document.getElementById("nav-contactid-bestId") const idField = document.getElementById("nav-contactid") @@ -359,8 +360,10 @@ function displayNavbar(isVisible) { /* exported displayRecordControls */ function displayRecordControls(isVisible) { if (isVisible) { + audioRecordButton.classList.remove("hiddenState") videoRecordButton.classList.remove("hiddenState") } else { + audioRecordButton.classList.add("hiddenState") videoRecordButton.classList.add("hiddenState") } } @@ -647,13 +650,24 @@ function selectFileToSend() { /* exported sendFile */ function videoRecord() { if (use_qt) { - window.jsbridge.videoRecord() + var rect = videoRecordButton.getBoundingClientRect() + window.jsbridge.openVideoRecorder(rect.left + rect.width / 2, rect.top) } else { var rect = videoRecordButton.getBoundingClientRect() window.prompt(`VIDEO_RECORD:${rect.left + rect.width / 2}x${rect.top}`) } } +function audioRecord() { + if (use_qt) { + var rect = audioRecordButton.getBoundingClientRect() + window.jsbridge.openAudioRecorder(rect.left + rect.width / 2, rect.top) + } else { + var rect = audioRecordButton.getBoundingClientRect() + window.prompt(`AUDIO_RECORD:${rect.left + rect.width / 2}x${rect.top}`) + } +} + /** * Clear all messages. */ -- GitLab