Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/local.properties
/.idea/workspace.xml
/.idea/libraries
/.idea/*
.DS_Store
/build
/captures
26 changes: 13 additions & 13 deletions cookie-cutter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ android {

dependencies {
}

apply from: 'https://raw.githubusercontent.com/blundell/release-android-library/master/android-release-aar.gradle'

publishing {
publications {
maven(MavenPublication) {
artifactId = PUBLISH_ARTIFACT_ID
groupId = PUBLISH_GROUP_ID
version = PUBLISH_VERSION
artifact "${buildDir}/outputs/aar/${project.name}-release.aar"
}
}
}
//
//apply from: 'https://raw.githubusercontent.com/blundell/release-android-library/master/android-release-aar.gradle'
//
//publishing {
// publications {
// maven(MavenPublication) {
// artifactId = PUBLISH_ARTIFACT_ID
// groupId = PUBLISH_GROUP_ID
// version = PUBLISH_VERSION
// artifact "${buildDir}/outputs/aar/${project.name}-release.aar"
// }
// }
//}
Original file line number Diff line number Diff line change
Expand Up @@ -129,31 +129,23 @@ private void onImageDragged(MotionEvent event, ImageView view) {
float translationX = event.getX() - firstTouchPoint.x;
float translationY = event.getY() - firstTouchPoint.y;

float[] matrixValues = new float[9];
savedMatrix.getValues(matrixValues);

float scaleWidth = matrixValues[0];
float scaleHeight = matrixValues[4];
float x = matrixValues[2];
float y = matrixValues[5];

int circleCenterX = view.getWidth() / 2;
int circleCenterY = view.getHeight() / 2;
int circleRadius = cookieCutterParams.getCircleRadius();
MatrixParams matrixParams = MatrixParams.fromMatrix(savedMatrix);

float width = view.getDrawable().getIntrinsicWidth() * scaleWidth;
float height = view.getDrawable().getIntrinsicHeight() * scaleHeight;
float width = view.getDrawable().getIntrinsicWidth() * matrixParams.getScaleWidth();
float height = view.getDrawable().getIntrinsicHeight() * matrixParams.getScaleHeight();
float x = matrixParams.getX();
float y = matrixParams.getY();

if (translationX + x > circleCenterX - circleRadius) {
translationX = circleCenterX - circleRadius - x;
} else if (translationX + x + width < circleCenterX + circleRadius) {
translationX = circleCenterX + circleRadius - x - width;
if (translationX + x > circle.getLeftBound()) {
translationX = circle.getLeftBound() - x;
} else if (translationX + x + width < circle.getRightBound()) {
translationX = circle.getRightBound() - x - width;
}

if (translationY + y > circleCenterY - circleRadius) {
translationY = circleCenterY - circleRadius - y;
} else if (translationY + y + height < circleCenterY + circleRadius) {
translationY = circleCenterY + circleRadius - y - height;
if (translationY + y > circle.getTopBound()) {
translationY = circle.getTopBound() - y;
} else if (translationY + y + height < circle.getBottomBound()) {
translationY = circle.getBottomBound() - y - height;
}

matrix.postTranslate(translationX, translationY);
Expand Down
6 changes: 4 additions & 2 deletions example/src/main/java/com/adamstyrc/example/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Point;
import android.net.Uri;
import android.os.Bundle;
Expand Down Expand Up @@ -76,8 +77,9 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Uri imageUri = data.getData();
// ivCrop.setImageURI(imageUri);

Point screenSize = ImageUtils.getScreenSize(this);
Bitmap scaledBitmap = ImageUtils.decodeUriToScaledBitmap(this, imageUri, screenSize.x, screenSize.y);
// Point screenSize = new Point(ivCrop.getWidth(), ivCrop.getHeight());
// Bitmap scaledBitmap = ImageUtils.decodeUriToScaledBitmap(this, imageUri, screenSize.x, screenSize.y);
Bitmap scaledBitmap = BitmapFactory.decodeStream(this.getContentResolver().openInputStream(imageUri));
ivCrop.setImageBitmap(scaledBitmap);

} catch (Exception e) {
Expand Down
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists