Skip to content

Commit

Permalink
added local copy of net.realify.lib.androidimagecropper
Browse files Browse the repository at this point in the history
  • Loading branch information
k3b committed Apr 11, 2019
1 parent f76dde1 commit ad712c7
Show file tree
Hide file tree
Showing 54 changed files with 8,155 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
/captures
.externalNativeBuild
/.idea
/cropper/build
4 changes: 3 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,7 @@ dependencies {
// implementation project(':ucrop')
// implementation 'com.github.yalantis:ucrop:2.2.3'
// implementation 'com.edmodo:cropper:1.0.1'
implementation "com.naver.android.helloyako:imagecropview:1.2.2"
// implementation "com.naver.android.helloyako:imagecropview:1.2.2"
// implementation 'com.github.realify.Android-Image-Cropper:1.0.0'
implementation project(':cropper')
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Rect;
import android.graphics.RectF;
import android.net.Uri;
import android.os.Build;
Expand All @@ -15,7 +16,7 @@
import android.view.MenuItem;
import android.widget.Toast;

import com.naver.android.helloyako.imagecrop.view.ImageCropView;
import net.realify.lib.androidimagecropper.CropImageView;

import java.io.InputStream;
import java.io.OutputStream;
Expand Down Expand Up @@ -44,12 +45,15 @@ protected void onCreate(Bundle savedInstanceState) {
pickFromGallery();
} else {
try {
ImageCropView uCropView = findViewById(R.id.ucrop);
CropImageView uCropView = findViewById(R.id.ucrop);

/*
InputStream stream = getContentResolver().openInputStream(uri);
Bitmap bitmap = BitmapFactory.decodeStream(stream);
uCropView.setImageBitmap(bitmap);
*/
uCropView.setImageUriAsync(uri);
} catch (Exception e) {
Log.e(TAG, "setImageUri", e);
Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
Expand Down Expand Up @@ -115,6 +119,12 @@ private void saveCroppedImage() {
} else {
Uri imageUri = getIntent().getData();

CropImageView uCropView = findViewById(R.id.ucrop);

Rect crop = uCropView.getCropRect();

debug(imageUri, crop);

/**
!!!! mImageView.getCurrentCropImageState() scale must be fixed according to image with/hight/orientation
see BitmapLoadTask.resize() for new details
Expand All @@ -136,7 +146,7 @@ private void saveCroppedImage() {
}
}

private void debug(Uri imageUri, RectF currentCropImageState) {
private void debug(Uri imageUri, Object currentCropImageState) {
Log.d(TAG, imageUri.getLastPathSegment() + "(" + currentCropImageState + ")");
}

Expand Down
24 changes: 13 additions & 11 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,20 @@
/>
-->

<com.naver.android.helloyako.imagecrop.view.ImageCropView
xmlns:imagecrop="http://schemas.android.com/apk/res-auto"
<net.realify.lib.androidimagecropper.CropImageView
android:id="@+id/ucrop"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible"
imagecrop:outsideLayerColor="#99000000"
imagecrop:setInnerGridMode="on"
imagecrop:gridInnerStroke="1dp"
imagecrop:gridInnerColor="#66ffffff"
imagecrop:setOuterGridMode="on"
imagecrop:gridOuterStroke="1dp"
imagecrop:gridOuterColor="#ffffff"/>

app:cropBackgroundColor="#88AA66CC"
app:cropBorderCornerColor="@android:color/holo_blue_bright"
app:cropBorderCornerOffset="0dp"
app:cropBorderCornerThickness="5dp"
app:cropBorderLineColor="@android:color/holo_green_light"
app:cropBorderLineThickness="1dp"
app:cropGuidelines="on"
app:cropGuidelinesColor="@android:color/holo_red_dark"
app:cropInitialCropWindowPaddingRatio="0"
app:cropSnapRadius="0dp"/>
</LinearLayout>
13 changes: 12 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,21 @@ allprojects {
repositories {
google()
jcenter()
// maven { url "https://jitpack.io" }
maven { url "https://jitpack.io" }
}
}

ext {
compileSdkVersion = 28
buildToolsVersion = '28.0.3'
supportLibraryVersion = '28.0.0'

PUBLISH_GROUP_ID = 'net.realify.lib'
PUBLISH_ARTIFACT_ID = 'android-image-cropper'
PUBLISH_VERSION = '1.0.0'
// gradlew clean build generateRelease
}

task clean(type: Delete) {
delete rootProject.buildDir
}
33 changes: 33 additions & 0 deletions cropper/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apply plugin: 'com.android.library'

android {

compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion

defaultConfig {
minSdkVersion 15
targetSdkVersion rootProject.compileSdkVersion
versionCode 1
versionName PUBLISH_VERSION
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
lintOptions {
abortOnError false
}
}

repositories {
maven { url "https://jitpack.io" }
}

dependencies {
api "com.android.support:appcompat-v7:$supportLibraryVersion"
implementation "com.android.support:exifinterface:$supportLibraryVersion"

implementation 'com.github.Realify:Android-Image-Cropper:master'
}

4 changes: 4 additions & 0 deletions cropper/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<manifest
package="net.realify.lib.androidimagecropper">

</manifest>
Loading

0 comments on commit ad712c7

Please sign in to comment.