diff --git a/src/app/pages/chat/group-messages/group-messages.page.ts b/src/app/pages/chat/group-messages/group-messages.page.ts index b53e1b254..67151d38a 100644 --- a/src/app/pages/chat/group-messages/group-messages.page.ts +++ b/src/app/pages/chat/group-messages/group-messages.page.ts @@ -300,15 +300,25 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy { } - startRecording() { - console.log('Recording'); - - if (this.recording) { - return; + async startRecording() { + if(await VoiceRecorder.canDeviceVoiceRecord().then((result: GenericResponse) =>{return result.value})){ + if(await VoiceRecorder.requestAudioRecordingPermission().then((result: GenericResponse) => {return result.value})){ + //if(await this.hasAudioRecordingPermission()){ + if (this.recording) { + return; + } + this.recording = true; + VoiceRecorder.startRecording(); + this.calculateDuration(); + //} + } + else{ + this.toastService._badRequest('Para gravar uma mensagem de voz, permita o acesso do Gabinete Digital ao seu microfone.'); + } + } + else{ + this.toastService._badRequest('Este dispositivo não tem capacidade para gravação de áudio!'); } - this.recording = true; - VoiceRecorder.startRecording(); - this.calculateDuration(); } @@ -1076,14 +1086,14 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy { } else { if (!msg.attachments[0].image_url || msg.attachments[0].image_url === null || msg.attachments[0].image_url === '') { this.downloadFileMsg(msg) - + } else { - + var str = msg.attachments[0].image_url; str = str.substring(1, ((str.length) - 1)); - + if (this.platform.is('desktop') || this.platform.is('mobileweb')) { - + this.downloadFileFromBrowser(msg.attachments[0].name, str) /* const modal = await this.modalController.create({ component: ViewMediaPage, @@ -1096,7 +1106,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy { } }); modal.present(); */ - + } else { this.openFile(str, msg.attachments[0].name); } diff --git a/src/app/pages/chat/messages/messages.page.ts b/src/app/pages/chat/messages/messages.page.ts index 66fcc1b30..99a72a53a 100644 --- a/src/app/pages/chat/messages/messages.page.ts +++ b/src/app/pages/chat/messages/messages.page.ts @@ -237,17 +237,25 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { } - startRecording() { - console.log('Recording'); - - if (this.recording) { - return; + async startRecording() { + if(await VoiceRecorder.canDeviceVoiceRecord().then((result: GenericResponse) =>{return result.value})){ + if(await VoiceRecorder.requestAudioRecordingPermission().then((result: GenericResponse) => {return result.value})){ + //if(await this.hasAudioRecordingPermission()){ + if (this.recording) { + return; + } + this.recording = true; + VoiceRecorder.startRecording(); + this.calculateDuration(); + //} + } + else{ + this.toastService._badRequest('Para gravar uma mensagem de voz, permita o acesso do Gabinete Digital ao seu microfone.'); + } + } + else{ + this.toastService._badRequest('Este dispositivo não tem capacidade para gravação de áudio!'); } - this.recording = true; - VoiceRecorder.startRecording() - .then((result: GenericResponse) => console.log(result.value)) - .catch(error => console.log(error)); - this.calculateDuration(); } stopRecording() { @@ -990,13 +998,13 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { if (!msg.attachments[0].image_url || msg.attachments[0].image_url === null || msg.attachments[0].image_url === '') { this.downloadFileMsg(msg) //this.testDownlod(msg) - + } else { var str = msg.attachments[0].image_url; str = str.substring(1, ((str.length) - 1)); - + if (this.platform.is('desktop') || this.platform.is('mobileweb')) { - + this.downloadFileFromBrowser(msg.attachments[0].name, str) /* const modal = await this.modalController.create({ component: ViewMediaPage, @@ -1009,11 +1017,11 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { } }); modal.present(); */ - + } else { this.openFile(str, msg.attachments[0].name, msg.file.type); } - + } } diff --git a/src/app/shared/chat/messages/messages.page.ts b/src/app/shared/chat/messages/messages.page.ts index 5343eb941..8c071f9f4 100644 --- a/src/app/shared/chat/messages/messages.page.ts +++ b/src/app/shared/chat/messages/messages.page.ts @@ -282,14 +282,25 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy }); } - startRecording() { - - if (this.recording) { - return; + async startRecording() { + if(await VoiceRecorder.canDeviceVoiceRecord().then((result: GenericResponse) =>{return result.value})){ + if(await VoiceRecorder.requestAudioRecordingPermission().then((result: GenericResponse) => {return result.value})){ + //if(await this.hasAudioRecordingPermission()){ + if (this.recording) { + return; + } + this.recording = true; + VoiceRecorder.startRecording(); + this.calculateDuration(); + //} + } + else{ + this.toastService._badRequest('Para gravar uma mensagem de voz, permita o acesso do Gabinete Digital ao seu microfone.'); + } + } + else{ + this.toastService._badRequest('Este dispositivo não tem capacidade para gravação de áudio!'); } - this.recording = true; - VoiceRecorder.startRecording(); - this.calculateDuration(); } stopRecording() { @@ -1021,42 +1032,42 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy if (!msg.attachments[0].image_url || msg.attachments[0].image_url === null || msg.attachments[0].image_url === '') { this.downloadFileMsg(msg) - - + + /* } else if (msg.file.type === "application/pdf") { - - + + console.log(str); const win = window.open("", "_blank"); let html = ''; - + html += ''; html += '
'; html += ''; html += ''; html += ''; - + setTimeout(() => { win.document.write(html); }, 0); */ - - - + + + //this.viewDocument(msg, msg.attachments.image_url) } else { - + var str = msg.attachments[0].image_url; str = str.substring(1, ((str.length) - 1)); - + if (this.platform.is('desktop') || this.platform.is('mobileweb')) { this.downloadFileFromBrowser(msg.attachments[0].name, str) } else if (this.platform.is('tablet')) { this.openFile(str, msg.attachments[0].name, msg.file.type); } - - - + + + } }