diff --git a/android/app/src/main/AndroidManifest.xml.orig b/android/app/src/main/AndroidManifest.xml.orig new file mode 100644 index 000000000..66301e3a7 --- /dev/null +++ b/android/app/src/main/AndroidManifest.xml.orig @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/assets/capacitor.config.json b/android/app/src/main/assets/capacitor.config.json index 2399c4927..2b001f42e 100644 --- a/android/app/src/main/assets/capacitor.config.json +++ b/android/app/src/main/assets/capacitor.config.json @@ -16,5 +16,8 @@ "sound" ] } + }, + "server": { + "url": "http://192.168.1.8:8100" } } diff --git a/src/app/pages/chat/messages/messages.page.html b/src/app/pages/chat/messages/messages.page.html index b3676740b..011300b64 100644 --- a/src/app/pages/chat/messages/messages.page.html +++ b/src/app/pages/chat/messages/messages.page.html @@ -1,4 +1,4 @@ - +
-
-
+
+
{{msg.u.name}} {{msg.duration}} @@ -61,7 +65,8 @@
-
+
{{msg.u.name}} {{msg.duration}} @@ -74,61 +79,86 @@
-
-
- {{msg.u.name}} - {{msg.duration}} -
-
-
-
-
- image - -
-
+
+
+ {{msg.u.name}} + {{msg.duration}} +
+
+
+
+
+ image + +
+
-
+
- - - + + + + + {{file.title}}
-
- +
+
{{file.description}} - {{msg.displayType}} + {{msg.displayType}}
+
+ {{last ? scrollToBottom() : ''}}
- {{last ? scrollToBottom() : ''}}
-
-
- {{msg.u.name}} criou esta reunião
-
- De {{showDateDuration(msg.file.start_date)}} a {{showDateDuration(msg.file.end_date)}}
- {{msg.file.venue}}
-
+
+ {{msg.u.name}} criou esta reunião
+
+ + De {{showDateDuration(msg.file.start_date)}} a + {{showDateDuration(msg.file.end_date)}} +
+ + + {{msg.file.venue}} +
+
{{msg.u.name}} criou esta reunião
-
- De {{showDateDuration(msg.file.start_date)}} a {{showDateDuration(msg.file.end_date)}}
- {{msg.file.venue}}
+
+ + De {{showDateDuration(msg.file.start_date)}} a + {{showDateDuration(msg.file.end_date)}} +
+ + + {{msg.file.venue}} +
{{last ? scrollToBottom() : ''}}
@@ -168,24 +198,24 @@ -
- +
+ está a escrever ...
{{durationDisplay}} - +
- +
- - -
- + \ No newline at end of file diff --git a/src/app/pages/chat/messages/messages.page.ts b/src/app/pages/chat/messages/messages.page.ts index ec4c0deef..72e36abbc 100644 --- a/src/app/pages/chat/messages/messages.page.ts +++ b/src/app/pages/chat/messages/messages.page.ts @@ -389,11 +389,11 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { this.wsChatMethodsService.getDmRoom(roomId).send({ file: { "type": "application/audio", - /* "guid": '', */ + "guid": '', }, attachments: [{ "title": fileName , - "title_link": this.audioRecorded, + //"title_link": this.audioRecorded, "title_link_download": true, "type": "file" }], @@ -929,7 +929,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { async openPreview(msg) { console.log(msg); - if (!msg.attachments[0].image_url || msg.attachments[0].image_url === null || msg.attachments[0].image_url === '') { + if (!msg.attachments[0].image_url || msg.attachments[0].image_url === null || msg.attachments[0].image_url === '' || !msg.attachments[0].title_link || msg.attachments[0].title_link === null || msg.attachments[0].title_link === '') { this.downloadFile(msg) //this.testDownlod(msg) diff --git a/src/app/shared/chat/messages/messages.page.html b/src/app/shared/chat/messages/messages.page.html index 6abb082f5..f35ba63cb 100644 --- a/src/app/shared/chat/messages/messages.page.html +++ b/src/app/shared/chat/messages/messages.page.html @@ -106,7 +106,7 @@ {{file.title}}
-
+
diff --git a/src/app/shared/chat/messages/messages.page.ts b/src/app/shared/chat/messages/messages.page.ts index 9a45aa8fb..3cc67abe7 100644 --- a/src/app/shared/chat/messages/messages.page.ts +++ b/src/app/shared/chat/messages/messages.page.ts @@ -356,6 +356,27 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy this.wsChatMethodsService.getDmRoom(this.roomId).send({}) } + base64toBlob(base64Data, contentType) { + contentType = contentType || ''; + var sliceSize = 1024; + var byteCharacters = atob(base64Data); + var bytesLength = byteCharacters.length; + var slicesCount = Math.ceil(bytesLength / sliceSize); + var byteArrays = new Array(slicesCount); + + for (var sliceIndex = 0; sliceIndex < slicesCount; ++sliceIndex) { + var begin = sliceIndex * sliceSize; + var end = Math.min(begin + sliceSize, bytesLength); + + var bytes = new Array(end - begin); + for (var offset = begin, i = 0; offset < end; ++i, ++offset) { + bytes[i] = byteCharacters[offset].charCodeAt(0); + } + byteArrays[sliceIndex] = new Uint8Array(bytes); + } + return new Blob(byteArrays, { type: contentType }); +} + async sendAudio(fileName) { const roomId = this.roomId @@ -369,12 +390,16 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy else{ this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`; } - }); + + + console.log(this.audioRecorded) //Converting base64 to blob - const base64Response = await fetch(this.audioRecorded); - const blob = await base64Response.blob(); - + //const base64Response = await fetch(this.audioRecorded); + //console.log(base64Response) + const encodedData = btoa(this.audioRecorded); + const blob = this.base64toBlob(encodedData,'audio/webm') + console.log(blob) const formData = new FormData(); formData.append("blobFile", blob); @@ -387,12 +412,14 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy }, attachments: [{ "title": fileName , - "title_link": this.audioRecorded, + //"title_link": this.audioRecorded, "title_link_download": true, "type": "audio" }], temporaryData: formData }) + + }); this.deleteRecording(); } @@ -898,12 +925,15 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy } else if (msg.file.type === 'application/pdf') { this.downloadFile = event.body; + } else if (msg.file.type == 'application/audio') { + this.downloadFile = new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''); } msg.attachments[0] = { image_url: this.downloadFile, name: msg.attachments[0].name, title: msg.attachments[0].title, + title_link: this.downloadFile, title_link_download: msg.attachments[0].title_link_download, ts: msg.attachments[0].ts } @@ -936,6 +966,17 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy DocumentViewer.viewDocument } + async audioPreview(msg) { + console.log(msg); + if (!msg.attachments[0].title_link || msg.attachments[0].title_link === null || msg.attachments[0].title_link === '') { + this.downloadFileMsg(msg) + + } else { + + } + + } + async openPreview(msg) { console.log(msg);