Skip to content

Commit

Permalink
Merge pull request #1844 from numbersprotocol/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
sultanmyrza committed Jul 20, 2022
2 parents 8427b98 + 484a821 commit 89b2d5c
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 18 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,13 @@ 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.2 - 2022-07-20

### Fixed

- Hide camera flash button for front camera
- Android flash light on only on capture photo or record video

## 0.61.1 - 2022-07-19

### Added
Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle
Expand Up @@ -6,8 +6,8 @@ android {
applicationId "io.numbersprotocol.capturelite"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 431
versionName "0.61.1"
versionCode 432
versionName "0.61.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildFeatures {
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "capture-lite",
"version": "0.61.1",
"version": "0.61.2",
"author": "numbersprotocol",
"homepage": "https://numbersprotocol.io/",
"scripts": {
Expand Down
6 changes: 5 additions & 1 deletion src/app/features/home/custom-camera/custom-camera.page.html
Expand Up @@ -6,7 +6,11 @@
<ng-container *ngIf="(mode$ | ngrxPush) === 'capture'">
<div id="camera-flash-placeholder"></div>

<mat-icon class="flash-camera-button" (click)="enableTorch()">
<mat-icon
*ngIf="isFlashAvailable"
class="flash-camera-button"
(click)="enableTorch()"
>
{{ isFlashOn ? 'flash_on' : 'flash_off' }}
</mat-icon>

Expand Down
22 changes: 13 additions & 9 deletions src/app/features/home/custom-camera/custom-camera.page.ts
Expand Up @@ -42,6 +42,7 @@ export class CustomCameraPage implements OnInit, OnDestroy {
curCaptureSrc?: string;

isFlashOn = false;
isFlashAvailable = false;

readonly lastConnectedGoProDevice$ =
this.goProBluetoothService.lastConnectedDevice$;
Expand Down Expand Up @@ -70,11 +71,7 @@ export class CustomCameraPage implements OnInit, OnDestroy {

this.startPreviewCamera();

this.isTorchOn().then(value => {
console.log(`isFlashOn: ${value.result}`);

return (this.isFlashOn = value.result);
});
this.syncCameraState();
}

async ionViewDidEnter() {
Expand Down Expand Up @@ -116,17 +113,24 @@ export class CustomCameraPage implements OnInit, OnDestroy {
}
}

startPreviewCamera() {
this.customCameraService.startPreviewCamera();
async startPreviewCamera() {
await this.customCameraService.startPreviewCamera();
await this.syncCameraState();
}

// eslint-disable-next-line class-methods-use-this
stopPreviewCamera() {
this.customCameraService.stopPreviewCamera();
}

flipCamera() {
this.customCameraService.flipCamera();
async flipCamera() {
await this.customCameraService.flipCamera();
await this.syncCameraState();
}

async syncCameraState() {
this.isFlashOn = (await this.isTorchOn()).result;
this.isFlashAvailable = await this.customCameraService.isTorchAvailable();
}

onPress() {
Expand Down
7 changes: 7 additions & 0 deletions src/app/features/home/custom-camera/custom-camera.service.ts
Expand Up @@ -115,6 +115,13 @@ export class CustomCameraService {
return Promise.resolve();
}

async isTorchAvailable(): Promise<boolean> {
if (this.isNativePlatform) {
return (await PreviewCamera.isTorchAvailable()).result;
}
return false;
}

private get isNativePlatform() {
return this.platform.is('ios') || this.platform.is('android');
}
Expand Down

0 comments on commit 89b2d5c

Please sign in to comment.