diff --git a/demo-angular/app/app.component.html b/demo-angular/app/app.component.html
index b13e6a9..7c4bd42 100644
--- a/demo-angular/app/app.component.html
+++ b/demo-angular/app/app.component.html
@@ -4,8 +4,5 @@
-
-
-
-
+
\ No newline at end of file
diff --git a/demo-angular/app/app.component.ts b/demo-angular/app/app.component.ts
index 62f616e..df5a244 100644
--- a/demo-angular/app/app.component.ts
+++ b/demo-angular/app/app.component.ts
@@ -2,6 +2,8 @@ import { Component } from '@angular/core';
import { takePicture, requestPermissions } from 'nativescript-camera';
import { ImageSource } from 'tns-core-modules/image-source';
import { ImageAsset } from 'tns-core-modules/image-asset';
+import { layout } from 'tns-core-modules/utils/utils';
+import * as app from "tns-core-modules/application";
@Component({
selector: 'my-app',
@@ -12,22 +14,30 @@ export class AppComponent {
public cameraImage: ImageAsset;
onTakePictureTap(args) {
- takePicture({ width: 180, height: 180, keepAspectRatio: true, saveToGallery: this.saveToGallery })
- .then((imageAsset) => {
- let source = new ImageSource();
- source.fromAsset(imageAsset).then((source) => {
- console.log(`Size: ${source.width}x${source.height}`);
- });
- this.cameraImage = imageAsset;
- }, (error) => {
- console.log("Error: " + error);
- });
- }
-
- onRequestPermissionsTap() {
requestPermissions().then(
- () => console.log('got permissions'),
- () => console.log('permissions rejected')
+ () => {
+ takePicture({ width: 180, height: 180, keepAspectRatio: true, saveToGallery: this.saveToGallery })
+ .then((imageAsset: any) => {
+ this.cameraImage = imageAsset;
+
+ // if you need image source
+ let source = new ImageSource();
+ source.fromAsset(imageAsset).then((source) => {
+ let width = source.width;
+ let height = source.height;
+ if (app.android) {
+ // the android dimensions are in device pixels
+ width = layout.toDeviceIndependentPixels(width);
+ height = layout.toDeviceIndependentPixels(height);
+ }
+
+ console.log(`Size: ${width}x${height}`);
+ });
+ }, (error) => {
+ console.log("Error: " + error);
+ });
+ },
+ () => alert('permissions rejected')
);
}
}
diff --git a/demo/app/main-page.ts b/demo/app/main-page.ts
index 4afa9fd..fb46ca3 100644
--- a/demo/app/main-page.ts
+++ b/demo/app/main-page.ts
@@ -4,6 +4,8 @@ import { View } from 'tns-core-modules/ui/core/view';
import { takePicture, requestPermissions } from "nativescript-camera";
import * as appModule from "tns-core-modules/application";
import * as imageSourceModule from "tns-core-modules/image-source";
+import { layout } from 'tns-core-modules/utils/utils';
+import * as app from "tns-core-modules/application";
import * as trace from "tns-core-modules/trace";
trace.addCategories(trace.categories.Debug);
@@ -13,28 +15,36 @@ export function navigatingTo(args: EventData) {
let page = args.object;
let picturePath = null;
- page.bindingContext = fromObject({cameraImage: picturePath, saveToGallery: true});
-}
-
-export function onRequestPermissionsTap(args: EventData) {
- requestPermissions().then(
- () => console.log('got permissions'),
- () => console.log('permissions rejected')
- );
+ page.bindingContext = fromObject({ cameraImage: picturePath, saveToGallery: true });
}
export function onTakePictureTap(args: EventData) {
let page = (args.object).page;
let saveToGallery = page.bindingContext.get("saveToGallery");
- takePicture({width: 180, height: 180, keepAspectRatio: true, saveToGallery: saveToGallery}).
- then((imageAsset) => {
- let source = new imageSourceModule.ImageSource();
- source.fromAsset(imageAsset).then((source) => {
- console.log(`Size: ${source.width}x${source.height}`);
- });
- page.bindingContext.set("cameraImage", imageAsset);
+ requestPermissions().then(
+ () => {
+ takePicture({ width: 180, height: 180, keepAspectRatio: true, saveToGallery: saveToGallery }).
+ then((imageAsset) => {
+ page.bindingContext.set("cameraImage", imageAsset);
+
+ // if you need image source
+ let source = new imageSourceModule.ImageSource();
+ source.fromAsset(imageAsset).then((source) => {
+ let width = source.width;
+ let height = source.height;
+ if (app.android) {
+ // the android dimensions are in device pixels
+ width = layout.toDeviceIndependentPixels(width);
+ height = layout.toDeviceIndependentPixels(height);
+ }
+
+ console.log(`Size: ${width}x${height}`);
+ });
+ },
+ (err) => {
+ console.log("Error -> " + err.message);
+ });
},
- (err) => {
- console.log("Error -> " + err.message);
- });
+ () => alert('permissions rejected')
+ );
}
\ No newline at end of file
diff --git a/demo/app/main-page.xml b/demo/app/main-page.xml
index 9779999..a99150d 100644
--- a/demo/app/main-page.xml
+++ b/demo/app/main-page.xml
@@ -5,9 +5,6 @@
-
-
-
-
+
\ No newline at end of file
diff --git a/src/camera.ios.ts b/src/camera.ios.ts
index 7b7e86a..87447bd 100644
--- a/src/camera.ios.ts
+++ b/src/camera.ios.ts
@@ -37,19 +37,6 @@ class UIImagePickerControllerDelegateImpl extends NSObject implements UIImagePic
return this;
}
- // create date from a string with format yyyy:MM:dd HH:mm:ss (like the format used in image description)
- private createDateFromString(value: string): Date {
- let year = parseInt(value.substr(0, 4));
- let month = parseInt(value.substr(5, 2));
- let date = parseInt(value.substr(8, 2));
-
- let hour = parseInt(value.substr(11, 2));
- let minutes = parseInt(value.substr(14, 2));
- let seconds = parseInt(value.substr(17, 2));
-
- return new Date(year, month - 1, date, hour, minutes, seconds);
- }
-
imagePickerControllerDidFinishPickingMediaWithInfo(picker, info): void {
if (info) {
let currentDate: Date = new Date();
diff --git a/src/package.json b/src/package.json
index a3fe754..428a1d4 100644
--- a/src/package.json
+++ b/src/package.json
@@ -1,6 +1,6 @@
{
"name": "nativescript-camera",
- "version": "3.1.4",
+ "version": "3.2.0",
"description": "Provides API for using device camera",
"repository": {
"type": "git",
@@ -21,7 +21,7 @@
"test.android": "npm i && npm run tsc && npm run tslint && cd ../demo && tns build android && tns test android --justlaunch",
"test.ios": "npm i && npm run tsc && npm run tslint && cd ../demo && tns build ios && tns test ios --justlaunch",
"tslint": "cd .. && tslint \"**/*.ts\" --config tslint.json --exclude \"**/node_modules/**\"",
- "plugin.link": "npm link && cd ../demo && npm link nativescript-camera && cd ../src",
+ "plugin.link": "npm link && cd ../demo && npm link nativescript-camera",
"plugin.tscwatch": "npm run tsc -- -w",
"demo.ios": "npm i && npm run tsc && cd ../demo && tns run ios --syncAllFiles",
"demo.android": "npm i && npm run tsc && cd ../demo && tns run android --syncAllFiles",