Skip to content
Closed
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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Android Image Cropper
=======
[The original repository seems dead](https://github.com/ArthurHub/Android-Image-Cropper) this fork was made to continue updating this wonderful library


[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Android--Image--Cropper-green.svg?style=true)](https://android-arsenal.com/details/1/3487)
[![Build Status](https://travis-ci.org/ArthurHub/Android-Image-Cropper.svg?branch=master)](https://travis-ci.org/ArthurHub/Android-Image-Cropper)
[ ![Download](https://api.bintray.com/packages/arthurhub/maven/Android-Image-Cropper/images/download.svg) ](https://bintray.com/arthurhub/maven/Android-Image-Cropper/_latestVersion)
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.android.tools.build:gradle:3.1.4'
}
}

Expand All @@ -18,9 +18,9 @@ allprojects {
}

ext {
compileSdkVersion = 27
buildToolsVersion = '27.0.3'
supportLibraryVersion = '27.1.1'
compileSdkVersion = 28
buildToolsVersion = '28.0.2'
supportLibraryVersion = '28.0.0-rc02'

PUBLISH_GROUP_ID = 'com.theartofdev.edmodo'
PUBLISH_ARTIFACT_ID = 'android-image-cropper'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ static BitmapSampled decodeSampledBitmap(Context context, Uri uri, int reqWidth,
// First decode with inJustDecodeBounds=true to check dimensions
BitmapFactory.Options options = decodeImageForOption(resolver, uri);

if(options.outWidth == -1 && options.outHeight == -1)
throw new RuntimeException("File is not a picture");

// Calculate inSampleSize
options.inSampleSize =
Math.max(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,17 @@ private void drawBackground(Canvas canvas) {
}
mPath.addOval(mDrawRect, Path.Direction.CW);
canvas.save();
canvas.clipPath(mPath, Region.Op.XOR);
// Ops other then Region.Op.INTERSECT and Region.Op.DIFFERENCE are deprecated since API 26
// as they have the ability to expand the clip. A new method Canvas.clipOutPath(Path) has been introduce
// to solve this issue. Since Android P using any ops other than Region.Op.INTERSECT and Region.Op.DIFFERENCE
// in Canvas.clipPath(Path, Region.Op) leads to IllegalArgumentException.
// More info can be found here:
// https://developer.android.com/reference/android/graphics/Canvas#clipPath(android.graphics.Path,%20android.graphics.Region.Op)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
canvas.clipOutPath(mPath);
} else {
canvas.clipPath(mPath, Region.Op.XOR);
}
canvas.drawRect(left, top, right, bottom, mBackgroundPaint);
canvas.restore();
}
Expand Down
5 changes: 3 additions & 2 deletions test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ android {

defaultConfig {
minSdkVersion 14
targetSdkVersion 27
targetSdkVersion 28
versionCode 1
versionName '1.0'
}
Expand All @@ -16,7 +16,8 @@ android {
}

dependencies {
api "com.android.support:appcompat-v7:27.1.1"
api "com.android.support:appcompat-v7:28.0.0-rc02"
api "com.android.support:exifinterface:28.0.0-rc02"
api 'com.theartofdev.edmodo:android-image-cropper:2.7.0'

}