Skip to content

Commit 90cad4d

Browse files
committed
Update Android Gradle
Fix #1. Bump Version.
1 parent 9e4dbbe commit 90cad4d

File tree

4 files changed

+54
-46
lines changed

4 files changed

+54
-46
lines changed

README.md

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
<!--
22
@Author: Brian Thurlow <bthurlow>
33
@Date: 03/29/2016 03:41:05 PM
4-
@Last modified by: bthurlow
5-
@Last modified time: 03/29/2016 04:24:04 PM
4+
@Last modified by: Brian Thurlow
5+
@Last modified time: 04/01/2016 11:52:29 AM
66
-->
77

8-
9-
108
# A {N} Image Cropping Plugin
11-
[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat)](http://choosealicense.com/licenses/mit/)
12-
[![npm](https://img.shields.io/npm/v/nativescript-imagecropper.svg)](https://www.npmjs.com/package/nativescript-imagecropper)
13-
[![npm](https://img.shields.io/npm/dt/nativescript-imagecropper.svg?label=npm%20downloads)](https://www.npmjs.com/package/nativescript-imagecropper)
14-
[![GitHub release](https://img.shields.io/github/release/bthurlow/nativescript-imagecropper.svg)](https://github.com/bthurlow/nativescript-imagecropper)
9+
10+
[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat)](http://choosealicense.com/licenses/mit/) [![npm](https://img.shields.io/npm/v/nativescript-imagecropper.svg)](https://www.npmjs.com/package/nativescript-imagecropper) [![npm](https://img.shields.io/npm/dt/nativescript-imagecropper.svg?label=npm%20downloads)](https://www.npmjs.com/package/nativescript-imagecropper) [![GitHub release](https://img.shields.io/github/release/bthurlow/nativescript-imagecropper.svg)](https://github.com/bthurlow/nativescript-imagecropper)
1511

1612
## Notes
1713

1814
iOS 8+
1915

2016
Android 17+
2117

22-
###Based on
18+
### Based on
19+
2320
[TOCropViewController](https://github.com/TimOliver/TOCropViewController) for iOS
2421

2522
[uCrop](https://github.com/Yalantis/uCrop) for Android
@@ -28,11 +25,12 @@ Android 17+
2825

2926
Run `tns plugin add nativescript-imagecropper`
3027

31-
## Android Install Notes
28+
### Android Install Notes
3229

3330
This plugin is designed according to {N} 2.0 Specs. For Android, you will need to modify the AndroidManifest.xml file.
3431

3532
Add the following to the AndroidManifest.xml
33+
3634
```xml
3735
<manifest>
3836
<application>
@@ -44,12 +42,15 @@ Add the following to the AndroidManifest.xml
4442
### Usage
4543

4644
To use the image cropping module you must first require it.
45+
4746
```js
4847
var icModule = require("nativescript-imagecropper");
4948
```
49+
5050
### Methods
5151

52-
show(ImageSource): Returns a cropped ImageSource
52+
`show(ImageSource)`: Returns a cropped ImageSource
53+
5354
```js
5455
var cropper = new icModule.ImageCropper();
5556
cropper.show(picture).then(function(args){
@@ -60,7 +61,8 @@ cropper.show(picture).then(function(args){
6061
});
6162
```
6263

63-
show(ImageSource,Options): Returns a cropped and resized ImageSource
64+
`show(ImageSource,Options)`: Returns a cropped and resized ImageSource
65+
6466
```js
6567
var cropper = new icModule.ImageCropper();
6668
cropper.show(picture,{width:300,height:300}).then(function(args){
@@ -72,13 +74,15 @@ cropper.show(picture,{width:300,height:300}).then(function(args){
7274
```
7375

7476
### Options
75-
* width:<number> The width of the image you would like returned.
76-
* height:<number> The height of the image you would like returned.
77+
78+
Option | Type | Description
79+
------ | ------ | ------------------------------------------------
80+
width | number | The width of the image you would like returned.
81+
height | number | The height of the image you would like returned.
7782

7883
### Returned Result Arguments
79-
* response: string;
80-
* Success
81-
* Cancelled
82-
* Error
83-
* image: ImageSource;
84-
* Returns null if there was an error or was cancelled.
84+
85+
Argument | Type | Result(s)
86+
-------- | ----------- | --------------------------------------------------------------------------
87+
response | string | Success<br/>Cancelled<br/>Error
88+
image | ImageSource | `null` if there was an error or was cancelled<br/>`ImageSource` on success

imagecropper.android.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,11 @@ export class ImageCropper{
4949
var sourcePath:android.net.Uri = android.net.Uri.parse("file://"+sourcePathTemp); //Fix our path that comes from {N} file-system.
5050
var destinationPath:android.net.Uri = android.net.Uri.parse("file://"+destinationPathTemp); //Fix our path that comes from {N} file-system.
5151

52-
application.android.on(application.AndroidApplication.activityResultEvent,onResult);
53-
5452
function onResult(args){
5553
var requestCode = args.requestCode;
5654
var resultCode = args.resultCode;
5755
var data = args.intent;
56+
// var _that = this;
5857

5958
if(resultCode == android.app.Activity.RESULT_OK && requestCode == UCrop.REQUEST_CROP){
6059
var resultUri:android.net.Uri = UCrop.getOutput(data);
@@ -90,6 +89,8 @@ export class ImageCropper{
9089
}
9190
};
9291

92+
application.android.on(application.AndroidApplication.activityResultEvent,onResult);
93+
9394
if(_options && _options.width && _options.height){
9495
var gcd = this._gcd(_options.width,_options.height);
9596
// console.log("gcd:" + gcd.toString());
@@ -106,14 +107,14 @@ export class ImageCropper{
106107
}
107108
}
108109
else{
109-
application.android.off(application.AndroidApplication.activityResultEvent, onResult);
110+
// application.android.off(application.AndroidApplication.activityResultEvent, this.onResult);
110111
reject({
111112
response:"Error",
112113
image:null
113114
});
114115
}
115116
} catch(e){
116-
application.android.off(application.AndroidApplication.activityResultEvent, onResult);
117+
// application.android.off(application.AndroidApplication.activityResultEvent, this.onResult);
117118
reject({
118119
response:"Error",
119120
image:null
@@ -129,6 +130,7 @@ export class ImageCropper{
129130
return this._gcd(height, width % height);
130131
}
131132
}
133+
132134
private _storeImageSource(image:imageSource.ImageSource):string{
133135
var folder:fs.Folder = fs.knownFolders.temp();
134136
var path = fs.path.join(folder.path,"temp.jpg");
@@ -140,11 +142,13 @@ export class ImageCropper{
140142
return null;
141143
}
142144
}
145+
143146
private _cleanFiles():void{
144147
//Clear Temp
145148
var folder:fs.Folder = fs.knownFolders.temp();
146149
folder.clear();
147150
}
151+
148152
private _getContext():android.app.Activity{
149153
return application.android.foregroundActivity;
150154
}

package.json

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
{
2-
"name":"nativescript-imagecropper",
3-
"version":"0.0.4",
4-
"description":"A image cropper based on TOCropViewController for iOS and uCrop for Android",
5-
"main":"imagecropper.js",
6-
"nativescript":{
7-
"platforms":{
8-
"android":"1.4.0",
9-
"ios":"1.4.0"
2+
"name": "nativescript-imagecropper",
3+
"version": "0.0.5",
4+
"description": "A image cropper based on TOCropViewController for iOS and uCrop for Android",
5+
"main": "imagecropper.js",
6+
"nativescript": {
7+
"platforms": {
8+
"android": "1.4.0",
9+
"ios": "1.4.0"
1010
}
1111
},
12-
"scripts":{
12+
"scripts": {
1313
"build": "tsc",
1414
"preparedemo": "npm run build && cd demo && tns plugin remove nativescript-imagecropper && tns plugin add .. && tns install",
1515
"setup": "cd demo && npm install && cd .. && npm run build && cd demo && tns plugin add .. && cd ..",
1616
"demo.ios": "npm run preparedemo; cd demo; tns deploy ios --emulator --justlaunch",
17-
"demo.android": "npm run preparedemo && cd demo && tns run android"
17+
"demo.android": "npm run preparedemo && cd demo && tns run android"
1818
},
19-
"repository":{
20-
"type":"git",
21-
"url":"https://github.com/bthurlow/nativescript-imagecropper"
19+
"repository": {
20+
"type": "git",
21+
"url": "https://github.com/bthurlow/nativescript-imagecropper"
2222
},
23-
"keywords":[
23+
"keywords": [
2424
"NativeScript",
2525
"image",
2626
"crop",
@@ -29,14 +29,14 @@
2929
"TOCropViewController",
3030
"uCrop"
3131
],
32-
"author":"bthurlow",
33-
"bugs":{
34-
"url":"https://github.com/bthurlow/nativescript-imagecropper/issues"
32+
"author": "bthurlow",
33+
"bugs": {
34+
"url": "https://github.com/bthurlow/nativescript-imagecropper/issues"
3535
},
3636
"license": "MIT",
37-
"homepage":"https://github.com/bthurlow/nativescript-imagecropper",
38-
"readmeFilename":"README.md",
39-
"devDependencies":{
40-
"typescript":"^1.8.7"
37+
"homepage": "https://github.com/bthurlow/nativescript-imagecropper",
38+
"readmeFilename": "README.md",
39+
"devDependencies": {
40+
"typescript": "^1.8.7"
4141
}
4242
}

platforms/android/include.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ repositories {
22
jcenter()
33
}
44
dependencies {
5-
compile 'com.yalantis:ucrop:1.3.+'
5+
compile 'com.yalantis:ucrop:1.3.2'
66
}

0 commit comments

Comments
 (0)