From f102c4284cb0c6cd52119cb45eff89601417ec2a Mon Sep 17 00:00:00 2001 From: Stoyan Stratev Date: Tue, 27 Nov 2018 13:53:39 +0200 Subject: [PATCH] fix: demo crash when camera does not return image - reproduced with monkey testing - remove unneeded code in package.json and android source - add markingMode:none to demo --- demo-angular/app/app.component.ts | 8 ++++++- demo-angular/app/package.json | 39 +------------------------------ src/camera.android.ts | 2 -- 3 files changed, 8 insertions(+), 41 deletions(-) diff --git a/demo-angular/app/app.component.ts b/demo-angular/app/app.component.ts index 48b2698..333e436 100644 --- a/demo-angular/app/app.component.ts +++ b/demo-angular/app/app.component.ts @@ -24,7 +24,13 @@ export class AppComponent { .then((imageAsset: any) => { this.cameraImage = imageAsset; let that = this; - imageAsset.getImageAsync(function (nativeImage) { + imageAsset.getImageAsync(function (nativeImage, ex) { + if (ex instanceof Error) { + throw ex; + } else if (typeof ex === "string") { + throw new Error(ex); + } + if (imageAsset.android) { // get the current density of the screen (dpi) and divide it by the default one to get the scale that.scale = nativeImage.getDensity() / android.util.DisplayMetrics.DENSITY_DEFAULT; diff --git a/demo-angular/app/package.json b/demo-angular/app/package.json index c0a3699..ab9a34d 100644 --- a/demo-angular/app/package.json +++ b/demo-angular/app/package.json @@ -1,47 +1,10 @@ { - "private": false, - "nativescript": { - "id": "org.nativescript.helloworldng" - }, "name": "tns-template-hello-world-ng", "main": "main.js", "version": "2.3.3", - "author": "Telerik ", - "description": "Nativescript Angular Hello World template", - "license": "BSD", - "keywords": [ - "telerik", - "mobile", - "angular", - "nativescript", - "{N}", - "tns", - "appbuilder", - "template" - ], - "repository": { - "type": "git", - "url": "git://github.com/NativeScript/template-hello-world-ng" - }, - "homepage": "https://github.com/NativeScript/template-hello-world-ng", "android": { "v8Flags": "--expose_gc", + "markingMode": "none", "requireModules": ["nativescript-camera"] - }, - "dependencies": { - "nativescript-angular": "1.1.0", - "@angular/core": "2.1.0", - "@angular/common": "2.1.0", - "@angular/compiler": "2.1.0", - "@angular/http": "2.1.0", - "@angular/platform-browser": "2.1.0", - "@angular/platform-browser-dynamic": "2.1.0", - "@angular/forms": "2.1.0", - "@angular/router": "3.1.0", - "reflect-metadata": "~0.1.8" - }, - "devDependencies": { - "zone.js": "~0.6.21", - "nativescript-dev-typescript": "^0.3.2" } } \ No newline at end of file diff --git a/src/camera.android.ts b/src/camera.android.ts index 90c6980..2a252a1 100644 --- a/src/camera.android.ts +++ b/src/camera.android.ts @@ -1,14 +1,12 @@ import * as typesModule from "tns-core-modules/utils/types"; import * as utilsModule from "tns-core-modules/utils/utils"; import * as applicationModule from "tns-core-modules/application/application"; -import * as imageSourceModule from "tns-core-modules/image-source/image-source"; import * as imageAssetModule from "tns-core-modules/image-asset/image-asset"; import * as trace from "tns-core-modules/trace/trace"; import * as platform from "tns-core-modules/platform/platform"; import * as permissions from "nativescript-permissions"; let REQUEST_IMAGE_CAPTURE = 3453; -let REQUEST_REQUIRED_PERMISSIONS = 1234; export let takePicture = function (options?): Promise { return new Promise((resolve, reject) => {