diff --git a/package-lock.json b/package-lock.json index 40dacf83c..97ba4a125 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2031,9 +2031,9 @@ "dev": true }, "@capacitor/android": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/@capacitor/android/-/android-3.3.0.tgz", - "integrity": "sha512-dzbzdN7KjjwpUbg7mZKVkgAVytEwGyXUL4Z1t9c12UhViJaNjU7/nSlTXjb+IiauwVg9oI2LHtSVrp1NIjUycw==" + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/@capacitor/android/-/android-3.3.1.tgz", + "integrity": "sha512-TB9UJh6/e6CV6KDpu/lNHKhgVvnDL2d3crNYtfKzp64CzeZhttQGIQShXSdMb3DG4kk7Zi/qBlfSaWBBD95NhQ==" }, "@capacitor/app": { "version": "1.0.5", diff --git a/package.json b/package.json index ee8d66bc4..deaa84b33 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "@angular/platform-browser": "~12.1.2", "@angular/platform-browser-dynamic": "~12.1.2", "@angular/router": "~12.1.2", - "@capacitor/android": "^3.3.0", + "@capacitor/android": "^3.3.1", "@capacitor/app": "^1.0.5", "@capacitor/camera": "^1.2.0", "@capacitor/core": "^3.3.0", diff --git a/src/app/pages/publications/new-publication/new-publication.page.ts b/src/app/pages/publications/new-publication/new-publication.page.ts index 10cf13580..a82247f04 100644 --- a/src/app/pages/publications/new-publication/new-publication.page.ts +++ b/src/app/pages/publications/new-publication/new-publication.page.ts @@ -118,7 +118,28 @@ async takePicture() { }); - laodPicture() { + async laodPicture() { + const capturedImage = await Camera.getPhoto({ + resultType: CameraResultType.Uri, + source: CameraSource.Photos, + quality: 90, + width: 1080, + height: 720, + }); + + const response = await fetch(capturedImage.webPath!); + const blob = await response.blob(); + + this.photos.unshift({ + filepath: "soon...", + webviewPath: capturedImage.webPath + }); + + this.capturedImage = await this.convertBlobToBase64(blob); + this.capturedImageTitle = new Date().getTime() + '.jpeg'; + } + + /* laodPicture() { const input = this.fileLoaderService.createInput({ accept: ['image/apng', 'image/jpeg', 'image/png'] }) @@ -133,30 +154,10 @@ async takePicture() { console.log(this.capturedImage) }; - } - - /* getPicture() { - const options: CameraOptions = { - quality: 90, - sourceType: this.camera.PictureSourceType.PHOTOLIBRARY, - destinationType: this.camera.DestinationType.DATA_URL, - encodingType: this.camera.EncodingType.JPEG, - mediaType: this.camera.MediaType.PICTURE, - targetWidth: 720, - targetHeight: 720, - } - - this.camera.getPicture(options).then((imageData) => { - // imageData is either a base64 encoded string or a file URI - // If it's base64 (DATA_URL): - let base64Image = 'data:image/jpeg;base64,' + imageData; - this.capturedImage = imageData; - this.capturedImageTitle = new Date().getTime() + '.jpeg'; - }, (err) => { - console.log(err); - }); } */ + + runValidation() { this.validateFrom = true } diff --git a/src/app/shared/publication/new-publication/new-publication.page.ts b/src/app/shared/publication/new-publication/new-publication.page.ts index e55bc3cad..50c3a3d32 100644 --- a/src/app/shared/publication/new-publication/new-publication.page.ts +++ b/src/app/shared/publication/new-publication/new-publication.page.ts @@ -94,7 +94,6 @@ export class NewPublicationPage implements OnInit { // allowEditing: true, resultType: CameraResultType.Uri, source: CameraSource.Camera - }); const response = await fetch(capturedImage.webPath!); const blob = await response.blob(); @@ -103,12 +102,9 @@ export class NewPublicationPage implements OnInit { filepath: "soon...", webviewPath: capturedImage.webPath }); - this.capturedImage = await this.convertBlobToBase64(blob); this.capturedImageTitle = new Date().getTime() + '.jpeg'; - //console.log(this.capturedImage); - } convertBlobToBase64 = (blob: Blob) => new Promise((resolve, reject) => { @@ -120,7 +116,28 @@ export class NewPublicationPage implements OnInit { reader.readAsDataURL(blob); }); - laodPicture() { + async laodPicture() { + const capturedImage = await Camera.getPhoto({ + resultType: CameraResultType.Uri, + source: CameraSource.Photos, + quality: 90, + width: 1080, + height: 720, + }); + + const response = await fetch(capturedImage.webPath!); + const blob = await response.blob(); + + this.photos.unshift({ + filepath: "soon...", + webviewPath: capturedImage.webPath + }); + + this.capturedImage = await this.convertBlobToBase64(blob); + this.capturedImageTitle = new Date().getTime() + '.jpeg'; + } + + /* laodPicture() { const input = this.fileLoaderService.createInput({ accept: ['image/apng', 'image/jpeg', 'image/png'] }) @@ -132,8 +149,7 @@ export class NewPublicationPage implements OnInit { this.capturedImage = imageData; this.capturedImageTitle = file.name }; - - } + } */ runValidation() {