mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
sharesd and video bug ios
This commit is contained in:
Generated
+474
-394
File diff suppressed because it is too large
Load Diff
@@ -79,7 +79,6 @@
|
||||
"@ionic-native/file": "^5.36.0",
|
||||
"@ionic-native/file-opener": "^5.36.0",
|
||||
"@ionic-native/file-path": "^5.30.0",
|
||||
"@ionic-native/fingerprint-aio": "^4.20.0",
|
||||
"@ionic-native/http": "^5.36.0",
|
||||
"@ionic-native/image-picker": "^5.36.0",
|
||||
"@ionic-native/in-app-browser": "^5.28.0",
|
||||
|
||||
+15
-32
@@ -106,8 +106,8 @@ export class HomePage implements OnInit {
|
||||
private modalController: ModalController,
|
||||
private zone: NgZone
|
||||
|
||||
// private ChunkService: ChunkService,
|
||||
// private StreamService: StreamService
|
||||
// private ChunkService: ChunkService,
|
||||
// private StreamService: StreamService
|
||||
) {
|
||||
if (SessionStore.exist) {
|
||||
this.user = SessionStore.user;
|
||||
@@ -143,7 +143,6 @@ export class HomePage implements OnInit {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sendIntent.setRouteService(this.router)
|
||||
|
||||
}
|
||||
@@ -166,43 +165,22 @@ export class HomePage implements OnInit {
|
||||
console.log(JSON.stringify(result));
|
||||
}
|
||||
if (result.url) {
|
||||
let resultUrl = decodeURIComponent(result.url);
|
||||
Filesystem.readFile({path: resultUrl})
|
||||
|
||||
.then(async (content) => {
|
||||
|
||||
const modal = await this.modalController.create({
|
||||
component: PublicationsPage,
|
||||
componentProps: {
|
||||
item: "item",
|
||||
intent: content.data
|
||||
},
|
||||
cssClass: 'new-action modal modal-desktop',
|
||||
backdropDismiss: false
|
||||
});
|
||||
|
||||
modal.onDidDismiss().then(() => {
|
||||
SendIntent.finish();
|
||||
});
|
||||
await modal.present();
|
||||
|
||||
|
||||
console.log(content.data);
|
||||
})
|
||||
.catch((err) => console.error(err));
|
||||
window["sharedContent"] = result;
|
||||
this.zone.run(() => this.router.navigateByUrl("/home/publications"));
|
||||
}
|
||||
}).catch(err => console.error(err));
|
||||
|
||||
}
|
||||
ngOnInit() {
|
||||
|
||||
if(window["sharedintend"]) {
|
||||
/* if (window["sharedintend"]) {
|
||||
this.router.navigateByUrl("/home/publication");
|
||||
}
|
||||
} */
|
||||
|
||||
window["this.router"] = this.router
|
||||
|
||||
/* this.checkSendIntentReceived() */
|
||||
if (this.platform.is('ios'))
|
||||
this.checkSendIntentReceived()
|
||||
|
||||
if ("serviceWorker" in navigator) {
|
||||
navigator.serviceWorker.onmessage = (event) => {
|
||||
@@ -298,10 +276,15 @@ export class HomePage implements OnInit {
|
||||
if (!this.platform.is('desktop')) {
|
||||
App.addListener('appStateChange', ({ isActive }) => {
|
||||
if (isActive) {
|
||||
sendIntent.setRouteService(this.router)
|
||||
if (this.platform.is('ios')) {
|
||||
this.checkSendIntentReceived();
|
||||
} else if (this.platform.is('android')) {
|
||||
sendIntent.setRouteService(this.router)
|
||||
} else {
|
||||
}
|
||||
|
||||
console.log('App is in the foreground');
|
||||
this.checkSendIntentReceived()
|
||||
/* this.checkSendIntentReceived() */
|
||||
} else {
|
||||
// The app is in the background.
|
||||
console.log('App is in the background');
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
</div> -->
|
||||
|
||||
<div class="ion-item-container-no-border pt-10">
|
||||
<ion-label (click)="chossePhotoOrVideo()">
|
||||
<ion-label (click)="takePicture()">
|
||||
<div class="attach-icon">
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' "
|
||||
src="assets/images/icons-add-photo.svg"></ion-icon>
|
||||
@@ -92,14 +92,29 @@
|
||||
|
||||
</div>
|
||||
<div class="attach-document">
|
||||
<ion-label>Câmera</ion-label>
|
||||
<ion-label>Tirar Fotografia</ion-label>
|
||||
</div>
|
||||
</ion-label>
|
||||
</div>
|
||||
<div *ngIf="photoOrVideo" class="container-multiselect pt-10">
|
||||
|
||||
<div class="ion-item-container-no-border pt-10">
|
||||
<ion-label (click)="startVideoRecording()">
|
||||
<div class="attach-icon">
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' "
|
||||
src="assets/images/icons-add-photo.svg"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' "
|
||||
src="assets/images/theme/gov/icons-add-photo.svg"></ion-icon>
|
||||
|
||||
</div>
|
||||
<div class="attach-document">
|
||||
<ion-label>Fazer Vídeo</ion-label>
|
||||
</div>
|
||||
</ion-label>
|
||||
</div>
|
||||
<!-- <div *ngIf="photoOrVideo" class="container-multiselect pt-10">
|
||||
<button id="container-multiselect" class="multiselect-button" (click)="takePicture()">Fotografia</button>
|
||||
<button id="container-multiselect" class="multiselect-button" (click)="startVideoRecording()">Video</button>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<!-- <div *ngIf="photoOrVideo" class="ion-item-container-no-border">
|
||||
<ion-label (click)="takePicture()">
|
||||
|
||||
@@ -16,7 +16,7 @@ import { formatDate } from 'src/plugin/momentG.js'
|
||||
import { ThemeService } from 'src/app/services/theme.service';
|
||||
import { Camera, CameraResultType, CameraSource, Photo } from '@capacitor/camera';
|
||||
|
||||
import { Filesystem, Directory, Encoding, FilesystemDirectory } from '@capacitor/filesystem';
|
||||
import { Filesystem, Directory, Encoding, FilesystemDirectory, FilesystemEncoding } from '@capacitor/filesystem';
|
||||
import { NgxImageCompressService } from "ngx-image-compress";
|
||||
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
|
||||
import { PublicationFolderService } from 'src/app/store/publication-folder.service';
|
||||
@@ -34,6 +34,7 @@ import { FileValidatorService } from "src/app/services/file/file-validator.servi
|
||||
import { App } from '@capacitor/app';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
|
||||
const config = {
|
||||
quality: 0.5,
|
||||
maxWidth: 800,
|
||||
@@ -165,12 +166,16 @@ export class NewPublicationPage implements OnInit {
|
||||
recursive: true
|
||||
});
|
||||
|
||||
/* try {
|
||||
document.addEventListener("click", clickOutside, false);
|
||||
function clickOutside(e) {
|
||||
const inside = document.getElementById('container-multiselect').contains(e.target);
|
||||
this.photoOrVideo = false;
|
||||
console.log(this.photoOrVideo)
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('click butto', error)
|
||||
} */
|
||||
}
|
||||
|
||||
// in use
|
||||
@@ -241,12 +246,53 @@ export class NewPublicationPage implements OnInit {
|
||||
let options: CaptureImageOptions = { limit: 1 }
|
||||
const data: any = await this.mediaCapture.captureVideo(options)
|
||||
this.video = data[0];
|
||||
console.log(data)
|
||||
console.log('video record', data)
|
||||
data.forEach(async element => {
|
||||
Capacitor.convertFileSrc(element.fullPath);
|
||||
console.log('convert url', (Capacitor.convertFileSrc(element.fullPath)));
|
||||
this.filesSizeSum = this.filesSizeSum + element.size
|
||||
if (this.fileSizeToMB(this.filesSizeSum) <= 20) {
|
||||
|
||||
const reader = new FileReader();
|
||||
|
||||
// Define a função de callback para ser executada quando a leitura estiver completa
|
||||
reader.onload = async () => {
|
||||
// O resultado contém os dados do arquivo em formato de array de bytes (buffer)
|
||||
const byteArray = new Uint8Array(reader.result as ArrayBuffer);
|
||||
|
||||
// Agora você pode trabalhar com o array de bytes conforme necessário
|
||||
console.log('BYTE ARRAY', byteArray);
|
||||
};
|
||||
|
||||
// Inicia a leitura do arquivo como um array de bytes (buffer)
|
||||
reader.readAsArrayBuffer(data[0]);
|
||||
|
||||
try {
|
||||
if (this.platform.is('ios')) {
|
||||
const result = await Filesystem.writeFile({
|
||||
path: 'video.mov',
|
||||
data: element.fullPath,
|
||||
directory: FilesystemDirectory.Data,
|
||||
encoding: FilesystemEncoding.UTF8
|
||||
})
|
||||
console.log('Wrote file', result);
|
||||
|
||||
Filesystem.readFile({ path: result.uri })
|
||||
|
||||
.then(async (content) => {
|
||||
console.log(content.data)
|
||||
this.filecontent = true;
|
||||
let fileObject = {
|
||||
FileBase64: 'data:video/mp4;base64,' + content.data,
|
||||
FileExtension: 'mp4',
|
||||
OriginalFileName: 'video'
|
||||
}
|
||||
this.seletedContent.push(fileObject)
|
||||
})
|
||||
.catch((err) => console.error(err));
|
||||
} else {
|
||||
const savedFile = await Filesystem.copy({
|
||||
from: element.fullPath, // directory prop removed, Capacitor parses filename for us
|
||||
from: Capacitor.convertFileSrc(element.fullPath), // directory prop removed, Capacitor parses filename for us
|
||||
to: "video.mp4",
|
||||
toDirectory: FilesystemDirectory.Data
|
||||
});
|
||||
@@ -263,6 +309,12 @@ export class NewPublicationPage implements OnInit {
|
||||
this.seletedContent.push(fileObject)
|
||||
})
|
||||
.catch((err) => console.error(err));
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.error('Unable to write file', e);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (this.seletedContent.length === 0)
|
||||
this.filesSizeSum = 0
|
||||
@@ -513,7 +565,7 @@ export class NewPublicationPage implements OnInit {
|
||||
this.publication = {
|
||||
DateIndex: date,
|
||||
DocumentId: null,
|
||||
ProcessId: this.folderId,
|
||||
ProcessId: JSON.stringify(this.folderId),
|
||||
Title: this.pub.Title,
|
||||
Message: this.pub.Message,
|
||||
DatePublication: date,
|
||||
@@ -544,7 +596,7 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
await this.publications.CreatePublication(this.folderId, this.publication).toPromise();
|
||||
this.httpErrorHandle.httpsSucessMessagge('Criar publicação')
|
||||
if(window["sharedContent"]) {
|
||||
if (window["sharedContent"]) {
|
||||
this.router.navigate(['/home/publications', this.folderId]);
|
||||
return
|
||||
}
|
||||
@@ -571,7 +623,7 @@ export class NewPublicationPage implements OnInit {
|
||||
this.showLoader = true;
|
||||
});
|
||||
|
||||
if(window["sharedContent"]) {
|
||||
if (window["sharedContent"]) {
|
||||
this.closeApp();
|
||||
}
|
||||
}
|
||||
@@ -757,6 +809,7 @@ export class NewPublicationPage implements OnInit {
|
||||
let resultUrl = decodeURIComponent(element.url);
|
||||
Filesystem.readFile({ path: resultUrl }).then(async (content) => {
|
||||
let fileObject;
|
||||
try {
|
||||
if (this.checkFileType.checkFileType(FileExtension) == 'image') {
|
||||
fileObject = {
|
||||
FileBase64: this.removeTextBeforeSlash(content.data, ','),
|
||||
@@ -775,6 +828,10 @@ export class NewPublicationPage implements OnInit {
|
||||
console.log('shared base', content.data)
|
||||
|
||||
this.seletedContent.push(fileObject)
|
||||
} catch (error) {
|
||||
console.log('error shared filesystem', error)
|
||||
}
|
||||
|
||||
})
|
||||
} else {
|
||||
this.httpErrorHandle.validationMessagge('filetype');
|
||||
@@ -795,6 +852,7 @@ export class NewPublicationPage implements OnInit {
|
||||
}
|
||||
|
||||
closeApp() {
|
||||
if (this.platform.is('android'))
|
||||
App.exitApp()
|
||||
}
|
||||
|
||||
|
||||
@@ -82,6 +82,7 @@ export class PublicationsPage implements OnInit {
|
||||
this.months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"];
|
||||
this.days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"];
|
||||
this.intent = window["sharedContent"]
|
||||
console.log('shared recived', this.intent)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ export class checkFileTypeService {
|
||||
const imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp','tiff','tif',
|
||||
'image/jpg', 'image/jpeg', 'image/png', 'image/gif', 'image/bmp','image/tiff','image/tif', 'image/*']; // Add more if needed
|
||||
const videoExtensions = ['mp4', 'webm', 'mpg', 'mpeg', 'ogg',
|
||||
'video/mp4', 'video/webm', 'video/mpg', 'video/mpeg', 'video/ogg','video/quicktime', 'video/*']; // Add more if needed
|
||||
'video/mp4', 'video/webm', 'video/mpg', 'video/mpeg', 'video/ogg','video/quicktime','video/mov', 'video/*']; // Add more if needed
|
||||
|
||||
// Check if it's an image
|
||||
if (imageExtensions.includes(lowerCaseType)) {
|
||||
|
||||
Reference in New Issue
Block a user