diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f9f3b900..a8b38a66b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.61.1 - 2022-07-19 + +### Added + +- Camera flash light + +### Fixed + +- Capture flow, confirm button work smoothly +- Use high resolution as default camera settings + ## 0.60.2 - 2022-07-07 ### Changed diff --git a/android/app/build.gradle b/android/app/build.gradle index f0e663a23..dedafb6f7 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -6,8 +6,8 @@ android { applicationId "io.numbersprotocol.capturelite" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 430 - versionName "0.61.0" + versionCode 431 + versionName "0.61.1" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildFeatures { diff --git a/package-lock.json b/package-lock.json index 87527e8f4..41c99a1a0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "capture-lite", - "version": "0.61.0", + "version": "0.61.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "capture-lite", - "version": "0.61.0", + "version": "0.61.1", "dependencies": { "@angular/animations": "^12.2.4", "@angular/cdk": "^12.2.4", @@ -48,7 +48,7 @@ "@ngx-formly/core": "^5.10.22", "@ngx-formly/material": "^5.10.22", "@ngx-formly/schematics": "^5.10.22", - "@numbersprotocol/preview-camera": "github:numbersprotocol/preview-camera#release-0.0.2-auto-rotate-fix", + "@numbersprotocol/preview-camera": "github:numbersprotocol/preview-camera", "@numbersprotocol/preview-video": "github:numbersprotocol/preview-video", "@techiediaries/ngx-qrcode": "^9.1.0", "async-mutex": "^0.3.2", @@ -4157,8 +4157,8 @@ } }, "node_modules/@numbersprotocol/preview-camera": { - "version": "0.0.2", - "resolved": "git+ssh://git@github.com/numbersprotocol/preview-camera.git#2ce3dc63f83780c4c8e7afe8291238b9c838eb5c", + "version": "0.0.3", + "resolved": "git+ssh://git@github.com/numbersprotocol/preview-camera.git#cc4a7d544220040e4fad9730dbdd2251458390c3", "license": "MIT", "peerDependencies": { "@capacitor/core": "^3.0.0" @@ -28525,8 +28525,8 @@ } }, "@numbersprotocol/preview-camera": { - "version": "git+ssh://git@github.com/numbersprotocol/preview-camera.git#2ce3dc63f83780c4c8e7afe8291238b9c838eb5c", - "from": "@numbersprotocol/preview-camera@github:numbersprotocol/preview-camera#release-0.0.2-auto-rotate-fix", + "version": "git+ssh://git@github.com/numbersprotocol/preview-camera.git#cc4a7d544220040e4fad9730dbdd2251458390c3", + "from": "@numbersprotocol/preview-camera@github:numbersprotocol/preview-camera", "requires": {} }, "@numbersprotocol/preview-video": { diff --git a/package.json b/package.json index 825908e70..e74d7901b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "capture-lite", - "version": "0.61.0", + "version": "0.61.1", "author": "numbersprotocol", "homepage": "https://numbersprotocol.io/", "scripts": { @@ -59,7 +59,7 @@ "@ngx-formly/core": "^5.10.22", "@ngx-formly/material": "^5.10.22", "@ngx-formly/schematics": "^5.10.22", - "@numbersprotocol/preview-camera": "github:numbersprotocol/preview-camera#release-0.0.2-auto-rotate-fix", + "@numbersprotocol/preview-camera": "github:numbersprotocol/preview-camera", "@numbersprotocol/preview-video": "github:numbersprotocol/preview-video", "@techiediaries/ngx-qrcode": "^9.1.0", "async-mutex": "^0.3.2", diff --git a/src/app/features/home/custom-camera/custom-camera.page.html b/src/app/features/home/custom-camera/custom-camera.page.html index 0e7d2a6ed..aa169603f 100644 --- a/src/app/features/home/custom-camera/custom-camera.page.html +++ b/src/app/features/home/custom-camera/custom-camera.page.html @@ -5,6 +5,11 @@ >
+ + + {{ isFlashOn ? 'flash_on' : 'flash_off' }} + +
(this.captureVideoFinishedListener = listener)); this.startPreviewCamera(); + + this.isTorchOn().then(value => { + console.log(`isFlashOn: ${value.result}`); + + return (this.isFlashOn = value.result); + }); } async ionViewDidEnter() { @@ -158,13 +166,21 @@ export class CustomCameraPage implements OnInit, OnDestroy { async confirmCurrentCapture() { if (this.curCaptureFilePath && this.curCaptureType) { - await this.customCameraService.uploadToCapture( + this.customCameraService.uploadToCapture( this.curCaptureFilePath, this.curCaptureType ); - this.removeCurrentCapture(); + this.leaveCustomCamera(); } - this.leaveCustomCamera(); + } + + async isTorchOn() { + return this.customCameraService.isTorchOn(); + } + + async enableTorch() { + await this.customCameraService.enableTorch(!this.isFlashOn); + this.isFlashOn = (await this.customCameraService.isTorchOn()).result; } async leaveCustomCamera() { diff --git a/src/app/features/home/custom-camera/custom-camera.service.spec.ts b/src/app/features/home/custom-camera/custom-camera.service.spec.ts index 288da8ca1..383e6e88c 100644 --- a/src/app/features/home/custom-camera/custom-camera.service.spec.ts +++ b/src/app/features/home/custom-camera/custom-camera.service.spec.ts @@ -1,14 +1,30 @@ -import { TestBed } from '@angular/core/testing'; +import { TestBed, waitForAsync } from '@angular/core/testing'; +import { Platform } from '@ionic/angular'; import { SharedTestingModule } from '../../../shared/shared-testing.module'; import { CustomCameraService } from './custom-camera.service'; describe('CustomCameraService', () => { let service: CustomCameraService; + let platformReadySpy: Promise; + let platformIsSpy: boolean | undefined; + let platformSpy: Platform; - beforeEach(() => { - TestBed.configureTestingModule({ imports: [SharedTestingModule] }); - service = TestBed.inject(CustomCameraService); - }); + beforeEach( + waitForAsync(() => { + platformReadySpy = Promise.resolve(); + platformIsSpy = false; + platformSpy = jasmine.createSpyObj('Platform', { + ready: platformReadySpy, + is: platformIsSpy, + }); + + TestBed.configureTestingModule({ + imports: [SharedTestingModule], + providers: [{ provide: Platform, useValue: platformSpy }], + }).compileComponents(); + service = TestBed.inject(CustomCameraService); + }) + ); it('should be created', () => { expect(service).toBeTruthy(); diff --git a/src/app/features/home/custom-camera/custom-camera.service.ts b/src/app/features/home/custom-camera/custom-camera.service.ts index 2bce4eebe..ceab9dbc5 100644 --- a/src/app/features/home/custom-camera/custom-camera.service.ts +++ b/src/app/features/home/custom-camera/custom-camera.service.ts @@ -3,6 +3,7 @@ import { Inject, Injectable } from '@angular/core'; import { DomSanitizer } from '@angular/platform-browser'; import { Capacitor } from '@capacitor/core'; import { FilesystemPlugin } from '@capacitor/filesystem'; +import { Platform } from '@ionic/angular'; import { TranslocoService } from '@ngneat/transloco'; import { PreviewCamera } from '@numbersprotocol/preview-camera'; import { BehaviorSubject } from 'rxjs'; @@ -31,7 +32,8 @@ export class CustomCameraService { private readonly errorService: ErrorService, private readonly translocoService: TranslocoService, @Inject(FILESYSTEM_PLUGIN) - private readonly filesystemPlugin: FilesystemPlugin + private readonly filesystemPlugin: FilesystemPlugin, + private readonly platform: Platform ) {} private mediaItemFromFilePath( @@ -56,6 +58,7 @@ export class CustomCameraService { const base64 = await blobToBase64(itemBlob); const mimeType = itemToUpload.mimeType; await this.captureService.capture({ base64, mimeType }); + await this.removeFile(filePath); } catch (error) { const errMsg = this.translocoService.translate(`error.internetError`); await this.errorService.toastError$(errMsg).toPromise(); @@ -98,6 +101,24 @@ export class CustomCameraService { await this.filesystemPlugin.deleteFile({ path: filePath }); } + async isTorchOn() { + if (this.isNativePlatform) { + return await PreviewCamera.isTorchOn(); + } + return { result: false }; + } + + async enableTorch(enable: boolean): Promise { + if (this.isNativePlatform) { + return await PreviewCamera.enableTorch({ enable }); + } + return Promise.resolve(); + } + + private get isNativePlatform() { + return this.platform.is('ios') || this.platform.is('android'); + } + private changeGlobalCSSBackgroundToTransparent() { document.querySelector('body')?.classList.add(this.globalCSSClass); document.querySelector('ion-app')?.classList.add(this.globalCSSClass);