Skip to content

Commit

Permalink
Merge pull request #112 from IsseiAoki/1.1.5
Browse files Browse the repository at this point in the history
1.1.5
  • Loading branch information
igreenwood committed Jul 30, 2017
2 parents fed70e4 + 573ee8d commit 1c206b6
Show file tree
Hide file tree
Showing 46 changed files with 5,018 additions and 3,769 deletions.
25 changes: 23 additions & 2 deletions .travis.yml
@@ -1,13 +1,34 @@
language: android

install:
- ./gradlew dependencies --debug

jdk:
- oraclejdk8

cache:
directories:
— $HOME/.gradle

before_cache:
- find $HOME/.gradle -type f -not -name "*.jar" -delete
- find $HOME/.gradle -type f -not -name "*.pom" -delete
- find $HOME/.gradle -type f -not -name "*.aar" -delete

android:
components:
- tools
- platform-tools
- build-tools-23.0.2
- android-23
- tools
- build-tools-25.0.3
- android-25
- extra-android-support
- extra-android-m2repository

licenses:
- 'android-sdk-preview-license-52d11cd2'
- 'android-sdk-license-.+'
- 'google-gdk-license-.+'

script:
- ./gradlew clean build --stacktrace
8 changes: 8 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,13 @@
Change Log
=========
## Version 1.1.5
* Fix EXIF data bug
* Fix OOM in onSaveInstanceState(CropImageView does not save bitmap internally anymore.)
* Support RxJava2
* Add Builder interface(LoadRequest/CropRequest/SaveRequest)
* Support save/restore frame rect
* Support thumbnail for image loading(use blurred image for placeholder)

## Version 1.1.4
* Fix Overlay drawing is lacking when CropMode.CIRCLE

Expand Down
154 changes: 110 additions & 44 deletions README.md
Expand Up @@ -19,6 +19,7 @@ Supported on API Level 10 and above.
* [Image Cropping](#image-cropping)
* [Image Rotation](#image-rotation)
* [Load Image](#load-image)
* [Apply Thumbnail](#apply-thumbnail)
* [Crop and Save Image](#crop-and-save-image)
* [Compress Format](#compress-format)
* [Compress Quality](#compress-quality)
Expand All @@ -28,6 +29,7 @@ Supported on API Level 10 and above.
* [CropMode](#cropmode)
* [MinimumFrameSize](#minimumframesize)
* [InitialFrameScale](#initialframescale)
* [Save and Restore FrameRect](#save-and-restoreframerect)
* [Color](#color)
* [Stroke Weight and Handle Size](#stroke-weight-and-handle-size)
* [Handle Touch Padding](#handle-touch-padding)
Expand All @@ -49,7 +51,7 @@ repositories {
jcenter()
}
dependencies {
compile 'com.isseiaoki:simplecropview:1.1.4'
compile 'com.isseiaoki:simplecropview:1.1.5'
}
```

Expand Down Expand Up @@ -96,54 +98,61 @@ Add the `com.isseiaoki.simplecropview.CropImageView` to your layout XML file.

```


Load image from sourceUri.


```java

mCropView = (CropImageView) findViewById(R.id.cropImageView);

mCropView.startLoad(

sourceUri,

new LoadCallback() {
@Override
public void onSuccess() {}
mCropView.load(sourceUri).execute(mLoadCallback);
```

@Override
public void onError() {}
});
with RxJava,

```
mCropView.load(sourceUri).executeAsCompletable();
```

Crop image and save cropped bitmap in saveUri.

```java
mCropView.crop(sourceUri)
.execute(new CropCallback() {
@Override public void onSuccess(Bitmap cropped) {
mCropView.save(cropped)
.execute(saveUri, mSaveCallback);
}

@Override public void onError(Throwable e) {
}
});
```

mCropView.startCrop(

saveUri,

new CropCallback() {
@Override
public void onSuccess(Bitmap cropped) {}

@Override
public void onError() {}
},

new SaveCallback() {
@Override
public void onSuccess(Uri outputUri) {}

@Override
public void onError() {}
}
);
with RxJava,

```
mCropView.crop(sourceUri)
.executeAsSingle()
.flatMap(new Function<Bitmap, SingleSource<Uri>>() {
@Override public SingleSource<Uri> apply(@io.reactivex.annotations.NonNull Bitmap bitmap)
throws Exception {
return mCropView.save(bitmap)
.executeAsSingle(saveUri);
}
})
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<Uri>() {
@Override public void accept(@io.reactivex.annotations.NonNull Uri uri) throws Exception {
// on success
}
}, new Consumer<Throwable>() {
@Override public void accept(@io.reactivex.annotations.NonNull Throwable throwable)
throws Exception {
// on error
}
});
```

### Image Rotation

Expand All @@ -162,28 +171,68 @@ cropImageView.rotateImage(CropImageView.RotateDegrees.ROTATE_M90D); // rotate co

## Load Image

* `setImageXXX()`(Sync method)
* `load(sourceUri).execute(mLoadCallback);`

This method loads the given Bitmap. If the bitmap size is too large, Exception occurs.
with RxJava,

* `startLoad(Uri sourceUri, LoadCallback callback)`(Async method, **RECOMMENDED**)
* `load(sourceUri).executeAsCompletable();`

This method loads Bitmap in efficient size from sourceUri.
These method load Bitmap in efficient size from sourceUri.
You don't have to care for filePath and image size.
You can also use `Picasso` or `Glide`.

**REMEMBER** : `sourceUri` parameter will be used in `startCrop(Uri saveUri, CropCallback cropCallback, SaveCallback saveCallback)`.
### Apply Thumbnail
You can use blurred image for placeholder.

```
mCropView.load(result.getData())
.useThumbnail(true)
.execute(mLoadCallback);
```

## Crop and Save Image

* `getCroppedBitmap()`(Sync method)
```java
mCropView.crop(sourceUri)
.execute(new CropCallback() {
@Override public void onSuccess(Bitmap cropped) {
mCropView.save(cropped)
.execute(saveUri, mSaveCallback);
}

@Override public void onError(Throwable e) {
}
});
```

This method always use thumbnail bitmap set by `setImageXXX()` for cropping.
It does not save cropped bitmap.
with RxJava,

* `startCrop(Uri saveUri, CropCallback cropCallback, SaveCallback saveCallback)`(Async Method, **RECOMMENDED**)
```
mCropView.crop(sourceUri)
.executeAsSingle()
.flatMap(new Function<Bitmap, SingleSource<Uri>>() {
@Override public SingleSource<Uri> apply(@io.reactivex.annotations.NonNull Bitmap bitmap)
throws Exception {
return mCropView.save(bitmap)
.executeAsSingle(saveUri);
}
})
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<Uri>() {
@Override public void accept(@io.reactivex.annotations.NonNull Uri uri) throws Exception {
// on success
}
}, new Consumer<Throwable>() {
@Override public void accept(@io.reactivex.annotations.NonNull Throwable throwable)
throws Exception {
// on error
}
});
```

This method uses full size bitmap taken from `sourceUri` for cropping.
If `sourceUri` is not set, it uses thumbnail bitmap.
These cropping method use full size bitmap taken from `sourceUri` for cropping.
If `sourceUri` is null, the Uri set in load(Uri) is used.
After cropping, it saves cropped image in `saveUri`.

### Compress Format
Expand Down Expand Up @@ -284,6 +333,23 @@ cropImageView.setInitialFrameScale(1.0f);
| 0.75| <img src="https://raw.github.com/wiki/IsseiAoki/SimpleCropView/images/1.0.8/initial_frame_scale_0.75.jpg" width="100%"> |
| 1.0 (default)| <img src="https://raw.github.com/wiki/IsseiAoki/SimpleCropView/images/1.0.8/initial_frame_scale_1.0.jpg" width="100%"> |

### Save and Restore FrameRect
You can save and restore frame rect as follows. See [sample project](https://github.com/IsseiAoki/SimpleCropView/tree/master/simplecropview-sample) for more details.

* Save FrameRect

```
mCropView.getActualCropRect()
```

* Restore FrameRect

```
mCropView.load(result.getData())
.initialFrameRect(mFrameRect)
.execute(mLoadCallback);
```

### Color

```java
Expand Down
28 changes: 14 additions & 14 deletions build.gradle
@@ -1,21 +1,21 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
jcenter()
}
repositories {
jcenter()
}
}
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
#Wed Apr 10 15:27:10 PDT 2013
#Wed May 10 22:46:03 JST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.11-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
64 changes: 32 additions & 32 deletions simplecropview-sample/build.gradle
Expand Up @@ -2,45 +2,45 @@ apply plugin: 'com.android.application'
apply plugin: 'android-apt'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
compileSdkVersion 25
buildToolsVersion '25.0.3'

defaultConfig {
applicationId "com.example.simplecropviewsample"
minSdkVersion 13
targetSdkVersion 23
versionCode 1
versionName "1.0.0"
defaultConfig {
applicationId "com.example.simplecropviewsample"
minSdkVersion 13
targetSdkVersion 25
versionCode 1
versionName "1.0.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
res.srcDirs = ['src/main/res', 'src/main/res/raw']
assets.srcDirs = ['src/main/assets', 'src/main/assets/']
}
}
lintOptions {
abortOnError false
}
sourceSets {
main {
res.srcDirs = ['src/main/res', 'src/main/res/raw']
assets.srcDirs = ['src/main/assets', 'src/main/assets/']
}
}
lintOptions {
abortOnError false
}
}

ext {
permissionsDispatcherVersion = '2.1.2'
permissionsDispatcherVersion = '2.1.2'
supportLibraryVersion = '25.3.1'
}

dependencies {
compile "com.android.support:appcompat-v7:23.3.0"
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':simplecropview')
compile "com.github.hotchemi:permissionsdispatcher:${permissionsDispatcherVersion}"
apt "com.github.hotchemi:permissionsdispatcher-processor:${permissionsDispatcherVersion}"
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':simplecropview')
compile "com.github.hotchemi:permissionsdispatcher:$permissionsDispatcherVersion"
apt "com.github.hotchemi:permissionsdispatcher-processor:$permissionsDispatcherVersion"
compile "com.android.support:appcompat-v7:$supportLibraryVersion"
compile 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.4@aar'
compile 'io.reactivex.rxjava2:rxjava:2.1.0'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
}

0 comments on commit 1c206b6

Please sign in to comment.