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": "^5.36.0",
|
||||||
"@ionic-native/file-opener": "^5.36.0",
|
"@ionic-native/file-opener": "^5.36.0",
|
||||||
"@ionic-native/file-path": "^5.30.0",
|
"@ionic-native/file-path": "^5.30.0",
|
||||||
"@ionic-native/fingerprint-aio": "^4.20.0",
|
|
||||||
"@ionic-native/http": "^5.36.0",
|
"@ionic-native/http": "^5.36.0",
|
||||||
"@ionic-native/image-picker": "^5.36.0",
|
"@ionic-native/image-picker": "^5.36.0",
|
||||||
"@ionic-native/in-app-browser": "^5.28.0",
|
"@ionic-native/in-app-browser": "^5.28.0",
|
||||||
|
|||||||
+13
-30
@@ -143,7 +143,6 @@ export class HomePage implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sendIntent.setRouteService(this.router)
|
sendIntent.setRouteService(this.router)
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -166,43 +165,22 @@ export class HomePage implements OnInit {
|
|||||||
console.log(JSON.stringify(result));
|
console.log(JSON.stringify(result));
|
||||||
}
|
}
|
||||||
if (result.url) {
|
if (result.url) {
|
||||||
let resultUrl = decodeURIComponent(result.url);
|
window["sharedContent"] = result;
|
||||||
Filesystem.readFile({path: resultUrl})
|
this.zone.run(() => this.router.navigateByUrl("/home/publications"));
|
||||||
|
|
||||||
.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));
|
|
||||||
}
|
}
|
||||||
}).catch(err => console.error(err));
|
}).catch(err => console.error(err));
|
||||||
|
|
||||||
}
|
}
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
if(window["sharedintend"]) {
|
/* if (window["sharedintend"]) {
|
||||||
this.router.navigateByUrl("/home/publication");
|
this.router.navigateByUrl("/home/publication");
|
||||||
}
|
} */
|
||||||
|
|
||||||
window["this.router"] = this.router
|
window["this.router"] = this.router
|
||||||
|
|
||||||
/* this.checkSendIntentReceived() */
|
if (this.platform.is('ios'))
|
||||||
|
this.checkSendIntentReceived()
|
||||||
|
|
||||||
if ("serviceWorker" in navigator) {
|
if ("serviceWorker" in navigator) {
|
||||||
navigator.serviceWorker.onmessage = (event) => {
|
navigator.serviceWorker.onmessage = (event) => {
|
||||||
@@ -298,10 +276,15 @@ export class HomePage implements OnInit {
|
|||||||
if (!this.platform.is('desktop')) {
|
if (!this.platform.is('desktop')) {
|
||||||
App.addListener('appStateChange', ({ isActive }) => {
|
App.addListener('appStateChange', ({ isActive }) => {
|
||||||
if (isActive) {
|
if (isActive) {
|
||||||
sendIntent.setRouteService(this.router)
|
if (this.platform.is('ios')) {
|
||||||
this.checkSendIntentReceived();
|
this.checkSendIntentReceived();
|
||||||
|
} else if (this.platform.is('android')) {
|
||||||
|
sendIntent.setRouteService(this.router)
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
|
||||||
console.log('App is in the foreground');
|
console.log('App is in the foreground');
|
||||||
this.checkSendIntentReceived()
|
/* this.checkSendIntentReceived() */
|
||||||
} else {
|
} else {
|
||||||
// The app is in the background.
|
// The app is in the background.
|
||||||
console.log('App is in the background');
|
console.log('App is in the background');
|
||||||
|
|||||||
@@ -83,7 +83,7 @@
|
|||||||
</div> -->
|
</div> -->
|
||||||
|
|
||||||
<div class="ion-item-container-no-border pt-10">
|
<div class="ion-item-container-no-border pt-10">
|
||||||
<ion-label (click)="chossePhotoOrVideo()">
|
<ion-label (click)="takePicture()">
|
||||||
<div class="attach-icon">
|
<div class="attach-icon">
|
||||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' "
|
<ion-icon *ngIf="ThemeService.currentTheme == 'default' "
|
||||||
src="assets/images/icons-add-photo.svg"></ion-icon>
|
src="assets/images/icons-add-photo.svg"></ion-icon>
|
||||||
@@ -92,14 +92,29 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="attach-document">
|
<div class="attach-document">
|
||||||
<ion-label>Câmera</ion-label>
|
<ion-label>Tirar Fotografia</ion-label>
|
||||||
</div>
|
</div>
|
||||||
</ion-label>
|
</ion-label>
|
||||||
</div>
|
</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)="takePicture()">Fotografia</button>
|
||||||
<button id="container-multiselect" class="multiselect-button" (click)="startVideoRecording()">Video</button>
|
<button id="container-multiselect" class="multiselect-button" (click)="startVideoRecording()">Video</button>
|
||||||
</div>
|
</div> -->
|
||||||
|
|
||||||
<!-- <div *ngIf="photoOrVideo" class="ion-item-container-no-border">
|
<!-- <div *ngIf="photoOrVideo" class="ion-item-container-no-border">
|
||||||
<ion-label (click)="takePicture()">
|
<ion-label (click)="takePicture()">
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import { formatDate } from 'src/plugin/momentG.js'
|
|||||||
import { ThemeService } from 'src/app/services/theme.service';
|
import { ThemeService } from 'src/app/services/theme.service';
|
||||||
import { Camera, CameraResultType, CameraSource, Photo } from '@capacitor/camera';
|
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 { NgxImageCompressService } from "ngx-image-compress";
|
||||||
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
|
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
|
||||||
import { PublicationFolderService } from 'src/app/store/publication-folder.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 { App } from '@capacitor/app';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
quality: 0.5,
|
quality: 0.5,
|
||||||
maxWidth: 800,
|
maxWidth: 800,
|
||||||
@@ -165,12 +166,16 @@ export class NewPublicationPage implements OnInit {
|
|||||||
recursive: true
|
recursive: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* try {
|
||||||
document.addEventListener("click", clickOutside, false);
|
document.addEventListener("click", clickOutside, false);
|
||||||
function clickOutside(e) {
|
function clickOutside(e) {
|
||||||
const inside = document.getElementById('container-multiselect').contains(e.target);
|
const inside = document.getElementById('container-multiselect').contains(e.target);
|
||||||
this.photoOrVideo = false;
|
this.photoOrVideo = false;
|
||||||
console.log(this.photoOrVideo)
|
console.log(this.photoOrVideo)
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log('click butto', error)
|
||||||
|
} */
|
||||||
}
|
}
|
||||||
|
|
||||||
// in use
|
// in use
|
||||||
@@ -241,12 +246,53 @@ export class NewPublicationPage implements OnInit {
|
|||||||
let options: CaptureImageOptions = { limit: 1 }
|
let options: CaptureImageOptions = { limit: 1 }
|
||||||
const data: any = await this.mediaCapture.captureVideo(options)
|
const data: any = await this.mediaCapture.captureVideo(options)
|
||||||
this.video = data[0];
|
this.video = data[0];
|
||||||
console.log(data)
|
console.log('video record', data)
|
||||||
data.forEach(async element => {
|
data.forEach(async element => {
|
||||||
|
Capacitor.convertFileSrc(element.fullPath);
|
||||||
|
console.log('convert url', (Capacitor.convertFileSrc(element.fullPath)));
|
||||||
this.filesSizeSum = this.filesSizeSum + element.size
|
this.filesSizeSum = this.filesSizeSum + element.size
|
||||||
if (this.fileSizeToMB(this.filesSizeSum) <= 20) {
|
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({
|
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",
|
to: "video.mp4",
|
||||||
toDirectory: FilesystemDirectory.Data
|
toDirectory: FilesystemDirectory.Data
|
||||||
});
|
});
|
||||||
@@ -263,6 +309,12 @@ export class NewPublicationPage implements OnInit {
|
|||||||
this.seletedContent.push(fileObject)
|
this.seletedContent.push(fileObject)
|
||||||
})
|
})
|
||||||
.catch((err) => console.error(err));
|
.catch((err) => console.error(err));
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Unable to write file', e);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (this.seletedContent.length === 0)
|
if (this.seletedContent.length === 0)
|
||||||
this.filesSizeSum = 0
|
this.filesSizeSum = 0
|
||||||
@@ -513,7 +565,7 @@ export class NewPublicationPage implements OnInit {
|
|||||||
this.publication = {
|
this.publication = {
|
||||||
DateIndex: date,
|
DateIndex: date,
|
||||||
DocumentId: null,
|
DocumentId: null,
|
||||||
ProcessId: this.folderId,
|
ProcessId: JSON.stringify(this.folderId),
|
||||||
Title: this.pub.Title,
|
Title: this.pub.Title,
|
||||||
Message: this.pub.Message,
|
Message: this.pub.Message,
|
||||||
DatePublication: date,
|
DatePublication: date,
|
||||||
@@ -757,6 +809,7 @@ export class NewPublicationPage implements OnInit {
|
|||||||
let resultUrl = decodeURIComponent(element.url);
|
let resultUrl = decodeURIComponent(element.url);
|
||||||
Filesystem.readFile({ path: resultUrl }).then(async (content) => {
|
Filesystem.readFile({ path: resultUrl }).then(async (content) => {
|
||||||
let fileObject;
|
let fileObject;
|
||||||
|
try {
|
||||||
if (this.checkFileType.checkFileType(FileExtension) == 'image') {
|
if (this.checkFileType.checkFileType(FileExtension) == 'image') {
|
||||||
fileObject = {
|
fileObject = {
|
||||||
FileBase64: this.removeTextBeforeSlash(content.data, ','),
|
FileBase64: this.removeTextBeforeSlash(content.data, ','),
|
||||||
@@ -775,6 +828,10 @@ export class NewPublicationPage implements OnInit {
|
|||||||
console.log('shared base', content.data)
|
console.log('shared base', content.data)
|
||||||
|
|
||||||
this.seletedContent.push(fileObject)
|
this.seletedContent.push(fileObject)
|
||||||
|
} catch (error) {
|
||||||
|
console.log('error shared filesystem', error)
|
||||||
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.httpErrorHandle.validationMessagge('filetype');
|
this.httpErrorHandle.validationMessagge('filetype');
|
||||||
@@ -795,6 +852,7 @@ export class NewPublicationPage implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
closeApp() {
|
closeApp() {
|
||||||
|
if (this.platform.is('android'))
|
||||||
App.exitApp()
|
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.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.days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"];
|
||||||
this.intent = window["sharedContent"]
|
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',
|
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
|
'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',
|
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
|
// Check if it's an image
|
||||||
if (imageExtensions.includes(lowerCaseType)) {
|
if (imageExtensions.includes(lowerCaseType)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user