Skip to content

Commit

Permalink
Merge branch 'release/v1.2.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
helloyako committed Jul 23, 2019
2 parents 14820e0 + 118db57 commit 127da92
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 23 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@

An Android library that lets you implement image crop.
ImageCropView crops image by moving image under fixed crop area like instagram and iOS.
Image zoom in/out is base on [sephiroth74's imageViewZoom](https://github.com/sephiroth74/ImageViewZoom).
Image zoom in/out is base on [sephiroth74's ImageViewZoom](https://github.com/sephiroth74/ImageViewZoom).

## Screenshot
| Screenshot | in [PHOLAR](https://play.google.com/store/apps/details?id=com.naver.android.pholar) |
|:---------------------------------------:|:-------------------------------------:|
| ![screenshot](doc/img/screenshot.png) | ![screenshot](doc/img/pholar.gif) |

> Screenshot image source
> http://bts.ibighit.com/photo.php
## Installation
[Android Studio](http://developer.android.com/sdk/index.html)
Android SDK 28
Expand All @@ -20,7 +23,7 @@ Android SDK Build-tools 28.0.3
##### Gradle
```gradle
dependencies {
implementation "com.naver.android.helloyako:imagecropview:1.2.2
implementation "com.naver.android.helloyako:imagecropview:1.2.3"
}
```

Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import android.view.View;
import android.widget.Toast;

import com.naver.android.helloyako.imagecrop.model.ViewState;
import com.naver.android.helloyako.imagecrop.view.ImageCropView;

import java.io.File;
Expand All @@ -39,6 +40,7 @@ public class CropActivity extends Activity {
public static final String TAG = "CropActivity";

private ImageCropView imageCropView;
private ViewState viewState;

@Override
public void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -171,14 +173,17 @@ public void onScanCompleted(String path, Uri uri) {
}

public void onClickSaveButton(View v) {
imageCropView.saveState();
viewState = imageCropView.saveState();
View restoreButton = findViewById(R.id.restore_btn);
if (!restoreButton.isEnabled()) {
restoreButton.setEnabled(true);
}
}

public void onClickRestoreButton(View v) {
imageCropView.restoreState();
if (viewState == null) {
return;
}
imageCropView.restoreState(viewState);
}
}
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.21'
ext.kotlin_version = '1.3.31'
ext {
appcompat_version = '1.1.0-alpha01'
appcompat_version = '1.1.0-rc01'
legacy_version = '1.0.0'
easying_version = '1.0.3'
}
Expand All @@ -12,7 +12,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.android.tools.build:gradle:3.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VERSION_NAME=1.2.2
VERSION_CODE=10
VERSION_NAME=1.2.3
VERSION_CODE=11
GROUP=com.naver.android.helloyako

POM_DESCRIPTION=Android Image Crop View
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Mar 05 19:10:39 KST 2019
#Wed Jul 17 10:15:09 JST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.naver.android.helloyako.imagecrop.model;

import android.graphics.Matrix;

public class ViewState {
private Matrix matrix;
private float[] suppMatrixValues;

public ViewState(Matrix matrix, float[] suppMatrixValues) {
this.matrix = matrix;
this.suppMatrixValues = suppMatrixValues;
}

public Matrix getMatrix() {
return matrix;
}

public float[] getSuppMatrixValues() {
return suppMatrixValues;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

import com.naver.android.helloyako.imagecrop.R;
import com.naver.android.helloyako.imagecrop.model.CropInfo;
import com.naver.android.helloyako.imagecrop.model.ViewState;
import com.naver.android.helloyako.imagecrop.util.BitmapLoadUtils;
import com.naver.android.helloyako.imagecrop.view.graphics.FastBitmapDrawable;

Expand Down Expand Up @@ -129,8 +130,6 @@ public class ImageCropView extends ImageView {

private boolean isChangingScale = false;

private int savedAspectRatioWidth;
private int savedAspectRatioHeight;
private float[] suppMatrixValues = new float[9];

public ImageCropView(Context context) {
Expand Down Expand Up @@ -981,23 +980,20 @@ private int dpToPixel(int dp) {
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, getResources().getDisplayMetrics());
}

public void saveState() {
savedAspectRatioWidth = mAspectRatioWidth;
savedAspectRatioHeight = mAspectRatioHeight;
public ViewState saveState() {
mSuppMatrix.getValues(suppMatrixValues);

return new ViewState(getImageViewMatrix(), suppMatrixValues);
}

public void restoreState() {
public void restoreState(ViewState viewState) {
mBitmapChanged = true;
mRestoreRequest = true;
mAspectRatioWidth = savedAspectRatioWidth;
mAspectRatioHeight = savedAspectRatioHeight;
mTargetAspectRatio = (float) mAspectRatioHeight / (float) mAspectRatioWidth;

mSuppMatrix = new Matrix();
mSuppMatrix.setValues(suppMatrixValues);
mSuppMatrix.setValues(viewState.getSuppMatrixValues());

setImageMatrix(getImageViewMatrix());
setImageMatrix(viewState.getMatrix());
postInvalidate();
requestLayout();
}
Expand Down

0 comments on commit 127da92

Please sign in to comment.