diff --git a/README.md b/README.md index f74ed4ad..87af73dc 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/build.gradle b/build.gradle index b31e2b7f..fc1ee2eb 100644 --- a/build.gradle +++ b/build.gradle @@ -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' } } @@ -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' diff --git a/cropper/src/main/java/com/theartofdev/edmodo/cropper/BitmapUtils.java b/cropper/src/main/java/com/theartofdev/edmodo/cropper/BitmapUtils.java index 92c87b58..c96788c1 100644 --- a/cropper/src/main/java/com/theartofdev/edmodo/cropper/BitmapUtils.java +++ b/cropper/src/main/java/com/theartofdev/edmodo/cropper/BitmapUtils.java @@ -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( diff --git a/cropper/src/main/java/com/theartofdev/edmodo/cropper/CropOverlayView.java b/cropper/src/main/java/com/theartofdev/edmodo/cropper/CropOverlayView.java index 51abac43..d0338ca2 100644 --- a/cropper/src/main/java/com/theartofdev/edmodo/cropper/CropOverlayView.java +++ b/cropper/src/main/java/com/theartofdev/edmodo/cropper/CropOverlayView.java @@ -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(); } diff --git a/test/build.gradle b/test/build.gradle index 626df4f7..ef89cc42 100644 --- a/test/build.gradle +++ b/test/build.gradle @@ -6,7 +6,7 @@ android { defaultConfig { minSdkVersion 14 - targetSdkVersion 27 + targetSdkVersion 28 versionCode 1 versionName '1.0' } @@ -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' }