Skip to content

Commit 1ac9eef

Browse files
author
vakrilov
committed
Version updates
1 parent acef3c8 commit 1ac9eef

File tree

7 files changed

+54
-43
lines changed

7 files changed

+54
-43
lines changed

compile.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
set -x
23

34
SOURCE_DIR=src;
45
PACK_DIR=dist/package/;
@@ -18,5 +19,5 @@ rm -rf $DIST_DIR
1819
mkdir -p $PACK_DIR
1920

2021
#compile package and copy file required by npm
21-
node_modules/.bin/tsc -p $SOURCE_DIR --outDir $PACK_DIR
22+
$SOURCE_DIR/node_modules/.bin/tsc -p $SOURCE_DIR --outDir $PACK_DIR
2223
copy_package_files

package.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/nativescript-camera.android.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export var takePicture = function (options?): Promise<any> {
1919

2020
let types: typeof typesModule = require("utils/types");
2121
let utils: typeof utilsModule = require("utils/utils");
22-
22+
2323
let saveToGallery;
2424
let reqWidth;
2525
let reqHeight;
@@ -39,7 +39,7 @@ export var takePicture = function (options?): Promise<any> {
3939

4040
let takePictureIntent = new android.content.Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
4141
let dateStamp = createDateTimeStamp();
42-
42+
4343
let picturePath: string;
4444
let nativeFile;
4545
let tempPictureUri;
@@ -52,38 +52,38 @@ export var takePicture = function (options?): Promise<any> {
5252
picturePath = utils.ad.getApplicationContext().getExternalFilesDir(null).getAbsolutePath() + "/" + "NSIMG_" + dateStamp + ".jpg";
5353
nativeFile = new java.io.File(picturePath);
5454
}
55-
55+
5656
let sdkVersionInt = parseInt(platform.device.sdkVersion);
5757
if (sdkVersionInt >= 21) {
5858
tempPictureUri = (<any>android.support.v4.content).FileProvider.getUriForFile(applicationModule.android.currentContext, applicationModule.android.nativeApp.getPackageName() + ".provider", nativeFile);
5959
}
6060
else {
6161
tempPictureUri = android.net.Uri.fromFile(nativeFile);
6262
}
63-
63+
6464
takePictureIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, tempPictureUri);
6565

6666
if (takePictureIntent.resolveActivity(utils.ad.getApplicationContext().getPackageManager()) != null) {
6767

6868
let appModule: typeof applicationModule = require("application");
6969

70-
let previousResult = appModule.android.onActivityResult;
71-
appModule.android.onActivityResult = (requestCode: number, resultCode: number, data: android.content.Intent) => {
72-
appModule.android.onActivityResult = previousResult;
70+
appModule.android.on("activityResult", (args) => {
71+
const requestCode = args.requestCode;
72+
const resultCode = args.resultCode;
7373

7474
if (requestCode === REQUEST_IMAGE_CAPTURE && resultCode === android.app.Activity.RESULT_OK) {
7575
if (saveToGallery) {
7676
try {
7777
let callback = new android.media.MediaScannerConnection.OnScanCompletedListener({
78-
onScanCompleted: function(path, uri) {
79-
if (trace.enabled) {
78+
onScanCompleted: function (path, uri) {
79+
if (trace.isEnabled()) {
8080
trace.write(`image from path ${path} has been successfully scanned!`, trace.categories.Debug);
8181
}
8282
}
8383
});
8484
android.media.MediaScannerConnection.scanFile(appModule.android.context, [picturePath], null, callback);
8585
} catch (ex) {
86-
if (trace.enabled) {
86+
if (trace.isEnabled()) {
8787
trace.write(`An error occurred while scanning file ${picturePath}: ${ex.message}!`, trace.categories.Debug);
8888
}
8989
}
@@ -97,7 +97,7 @@ export var takePicture = function (options?): Promise<any> {
9797
};
9898
resolve(asset);
9999
}
100-
};
100+
});
101101

102102
appModule.android.foregroundActivity.startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
103103

@@ -112,7 +112,7 @@ export var takePicture = function (options?): Promise<any> {
112112

113113
export var isAvailable = function () {
114114
var utils: typeof utilsModule = require("utils/utils");
115-
115+
116116
return utils.ad.getApplicationContext().getPackageManager().hasSystemFeature(android.content.pm.PackageManager.FEATURE_CAMERA)
117117
}
118118

@@ -126,11 +126,11 @@ export var requestPermissions = function () {
126126
var createDateTimeStamp = function () {
127127
let result = "";
128128
let date = new Date();
129-
result = date.getFullYear().toString() +
130-
((date.getMonth() + 1) < 10 ? "0" + (date.getMonth() + 1).toString() : (date.getMonth() + 1).toString()) +
131-
(date.getDate() < 10 ? "0" + date.getDate().toString() : date.getDate().toString()) + "_" +
132-
date.getHours().toString() +
133-
date.getMinutes().toString() +
134-
date.getSeconds().toString();
129+
result = date.getFullYear().toString() +
130+
((date.getMonth() + 1) < 10 ? "0" + (date.getMonth() + 1).toString() : (date.getMonth() + 1).toString()) +
131+
(date.getDate() < 10 ? "0" + date.getDate().toString() : date.getDate().toString()) + "_" +
132+
date.getHours().toString() +
133+
date.getMinutes().toString() +
134+
date.getSeconds().toString();
135135
return result;
136136
}

src/nativescript-camera.ios.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,14 @@ export var requestPermissions = function () {
178178
if (authStatus === PHAuthorizationStatus.NotDetermined) {
179179
PHPhotoLibrary.requestAuthorization((auth) => {
180180
if (auth === PHAuthorizationStatus.Authorized) {
181-
if (trace.enabled) {
181+
if (trace.isEnabled()) {
182182
trace.write("Application can access photo library assets.", trace.categories.Debug);
183183
}
184184
return;
185185
}
186186
})
187187
} else if (authStatus !== PHAuthorizationStatus.Authorized) {
188-
if (trace.enabled) {
188+
if (trace.isEnabled()) {
189189
trace.write("Application can not access photo library assets.", trace.categories.Debug);
190190
}
191191
}

src/package.json

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-camera",
3-
"version": "0.0.8",
3+
"version": "3.0.0",
44
"description": "Provides API for using device camera",
55
"main": "nativescript-camera",
66
"nativescript": {
@@ -10,7 +10,18 @@
1010
}
1111
},
1212
"keywords": [
13-
"NativeScript", "camera", "gallery", "images"
13+
"NativeScript",
14+
"camera",
15+
"gallery",
16+
"images"
1417
],
15-
"author": "NativeScript team"
16-
}
18+
"author": "NativeScript team",
19+
"devDependencies": {
20+
"tns-core-modules": "^3.0.0 || ^3.0.0-rc.1",
21+
"tns-platform-declarations": "^3.0.0 || ^3.0.0-rc.1",
22+
"typescript": "^2.2.2"
23+
},
24+
"peerDependencies": {
25+
"tns-core-modules": "^3.0.0 || ^3.0.0-rc.1"
26+
}
27+
}

src/references.d.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
/// <reference path="../node_modules/tns-core-modules/tns-core-modules.es2016.d.ts" />
2-
/// <reference path="../node_modules/tns-platform-declarations/ios.d.ts" />
3-
/// <reference path="../node_modules/tns-platform-declarations/android.d.ts" />
1+
/// <reference path="./node_modules/tns-platform-declarations/ios.d.ts" />
2+
/// <reference path="./node_modules/tns-platform-declarations/android.d.ts" />

src/tsconfig.json

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,19 @@
1111
"noEmitHelpers": true,
1212
"experimentalDecorators": true,
1313
"lib": [
14-
"es2016"
15-
]
14+
"es6",
15+
"dom"
16+
],
17+
"baseUrl": ".",
18+
"paths": {
19+
"*": [
20+
"./node_modules/tns-core-modules/*",
21+
"./node_modules/*"
22+
]
23+
}
1624
},
17-
"filesGlob": [
18-
"./**/*.ts",
19-
"!./node_modules/**/*.ts"
20-
],
21-
"exclude": []
22-
}
25+
"exclude": [
26+
"node_modules",
27+
"platforms"
28+
]
29+
}

0 commit comments

Comments
 (0)