diff --git a/README.md b/README.md
index 5f39b07b9..294d254c7 100644
--- a/README.md
+++ b/README.md
@@ -93,6 +93,14 @@ Currently you can change:
# Changelog
+### Version: 2.2.5
+* Fixed [#584](https://github.com/Yalantis/uCrop/issues/584)
+* Fixed [#598](https://github.com/Yalantis/uCrop/issues/598)
+* Fixed [#543](https://github.com/Yalantis/uCrop/issues/543)
+* Fixed [#602](https://github.com/Yalantis/uCrop/issues/602)
+* And other improvements
+
+
### Version: 2.2.4
* **AndroidX migration**
diff --git a/gradle.properties b/gradle.properties
index 0296aefbb..86372fda7 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -17,8 +17,8 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
-VERSION_NAME=2.2.4-native
-VERSION_CODE=25
+VERSION_NAME=2.2.5-native
+VERSION_CODE=26
GROUP=com.yalantis
POM_DESCRIPTION=Android Library for cropping images
diff --git a/sample/build.gradle b/sample/build.gradle
index 233cd2063..06f3e1bc7 100644
--- a/sample/build.gradle
+++ b/sample/build.gradle
@@ -1,12 +1,12 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 28
+ compileSdkVersion 29
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.yalantis.ucrop.sample"
minSdkVersion 14
- targetSdkVersion 28
+ targetSdkVersion 29
versionCode 13
versionName "1.2.4"
}
diff --git a/sample/src/main/java/com/yalantis/ucrop/sample/SampleActivity.java b/sample/src/main/java/com/yalantis/ucrop/sample/SampleActivity.java
index 3f8f919b0..153937f8d 100644
--- a/sample/src/main/java/com/yalantis/ucrop/sample/SampleActivity.java
+++ b/sample/src/main/java/com/yalantis/ucrop/sample/SampleActivity.java
@@ -1,9 +1,7 @@
package com.yalantis.ucrop.sample;
-import android.Manifest;
import android.annotation.TargetApi;
import android.content.Intent;
-import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.PorterDuff;
import android.graphics.drawable.Animatable;
@@ -41,7 +39,6 @@
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.widget.Toolbar;
-import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
/**
@@ -106,23 +103,6 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
}
}
- /**
- * Callback received when a permissions request has been completed.
- */
- @Override
- public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
- switch (requestCode) {
- case REQUEST_STORAGE_READ_ACCESS_PERMISSION:
- if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
- pickFromGallery();
- }
- break;
- default:
- super.onRequestPermissionsResult(requestCode, permissions, grantResults);
- }
- }
-
-
private TextWatcher mAspectRatioTextWatcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@@ -227,24 +207,16 @@ public void onStopTrackingTouch(SeekBar seekBar) {
}
private void pickFromGallery() {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
- && ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)
- != PackageManager.PERMISSION_GRANTED) {
- requestPermission(Manifest.permission.READ_EXTERNAL_STORAGE,
- getString(R.string.permission_read_storage_rationale),
- REQUEST_STORAGE_READ_ACCESS_PERMISSION);
- } else {
- Intent intent = new Intent(Intent.ACTION_GET_CONTENT)
- .setType("image/*")
- .addCategory(Intent.CATEGORY_OPENABLE);
+ Intent intent = new Intent(Intent.ACTION_GET_CONTENT)
+ .setType("image/*")
+ .addCategory(Intent.CATEGORY_OPENABLE);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
- String[] mimeTypes = {"image/jpeg", "image/png"};
- intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
- }
-
- startActivityForResult(Intent.createChooser(intent, getString(R.string.label_select_picture)), requestMode);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
+ String[] mimeTypes = {"image/jpeg", "image/png"};
+ intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
}
+
+ startActivityForResult(Intent.createChooser(intent, getString(R.string.label_select_picture)), requestMode);
}
private void startCrop(@NonNull Uri uri) {
@@ -372,9 +344,9 @@ Tune everything (ノ◕ヮ◕)ノ*:・゚✧
// Color palette
options.setToolbarColor(ContextCompat.getColor(this, R.color.your_color_res));
options.setStatusBarColor(ContextCompat.getColor(this, R.color.your_color_res));
- options.setActiveWidgetColor(ContextCompat.getColor(this, R.color.your_color_res));
options.setToolbarWidgetColor(ContextCompat.getColor(this, R.color.your_color_res));
options.setRootViewBackgroundColor(ContextCompat.getColor(this, R.color.your_color_res));
+ options.setActiveControlsWidgetColor(ContextCompat.getColor(this, R.color.your_color_res));
// Aspect ratio options
options.setAspectRatioOptions(1,
diff --git a/sample/src/main/res/values/colors.xml b/sample/src/main/res/values/colors.xml
index 6531d5c07..4f44e31ee 100644
--- a/sample/src/main/res/values/colors.xml
+++ b/sample/src/main/res/values/colors.xml
@@ -3,4 +3,6 @@
#FF6E40
#CC5833
#FF6E40
+
+ #03A9F4
diff --git a/ucrop/build.gradle b/ucrop/build.gradle
index f6490e585..e1289e889 100644
--- a/ucrop/build.gradle
+++ b/ucrop/build.gradle
@@ -8,8 +8,8 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 28
- versionCode 25
- versionName "2.2.4-native"
+ versionCode 26
+ versionName "2.2.5-native"
vectorDrawables.useSupportLibrary = true
}
diff --git a/ucrop/src/main/java/com/yalantis/ucrop/UCrop.java b/ucrop/src/main/java/com/yalantis/ucrop/UCrop.java
index 357ace2d9..e28fd5bc9 100644
--- a/ucrop/src/main/java/com/yalantis/ucrop/UCrop.java
+++ b/ucrop/src/main/java/com/yalantis/ucrop/UCrop.java
@@ -279,11 +279,11 @@ public static class Options {
public static final String EXTRA_CROP_GRID_ROW_COUNT = EXTRA_PREFIX + ".CropGridRowCount";
public static final String EXTRA_CROP_GRID_COLUMN_COUNT = EXTRA_PREFIX + ".CropGridColumnCount";
public static final String EXTRA_CROP_GRID_COLOR = EXTRA_PREFIX + ".CropGridColor";
+ public static final String EXTRA_CROP_GRID_CORNER_COLOR = EXTRA_PREFIX + ".CropGridCornerColor";
public static final String EXTRA_CROP_GRID_STROKE_WIDTH = EXTRA_PREFIX + ".CropGridStrokeWidth";
public static final String EXTRA_TOOL_BAR_COLOR = EXTRA_PREFIX + ".ToolbarColor";
public static final String EXTRA_STATUS_BAR_COLOR = EXTRA_PREFIX + ".StatusBarColor";
- public static final String EXTRA_UCROP_COLOR_WIDGET_ACTIVE = EXTRA_PREFIX + ".UcropColorWidgetActive";
public static final String EXTRA_UCROP_COLOR_CONTROLS_WIDGET_ACTIVE = EXTRA_PREFIX + ".UcropColorControlsWidgetActive";
public static final String EXTRA_UCROP_WIDGET_COLOR_TOOLBAR = EXTRA_PREFIX + ".UcropToolbarWidgetColor";
@@ -426,6 +426,13 @@ public void setCropGridColor(@ColorInt int color) {
mOptionBundle.putInt(EXTRA_CROP_GRID_COLOR, color);
}
+ /**
+ * @param color - desired color of crop grid/guidelines corner
+ */
+ public void setCropGridCornerColor(@ColorInt int color) {
+ mOptionBundle.putInt(EXTRA_CROP_GRID_CORNER_COLOR, color);
+ }
+
/**
* @param width - desired width of crop grid lines in pixels
*/
@@ -448,14 +455,7 @@ public void setStatusBarColor(@ColorInt int color) {
}
/**
- * @param color - desired resolved color of the progress wheel middle line (default is violet)
- */
- public void setActiveWidgetColor(@ColorInt int color) {
- mOptionBundle.putInt(EXTRA_UCROP_COLOR_WIDGET_ACTIVE, color);
- }
-
- /**
- * @param color - desired resolved color of the active and selected widget (default is white)
+ * @param color - desired resolved color of the active and selected widget and progress wheel middle line (default is white)
*/
public void setActiveControlsWidgetColor(@ColorInt int color) {
mOptionBundle.putInt(EXTRA_UCROP_COLOR_CONTROLS_WIDGET_ACTIVE, color);
diff --git a/ucrop/src/main/java/com/yalantis/ucrop/UCropActivity.java b/ucrop/src/main/java/com/yalantis/ucrop/UCropActivity.java
index a48969fcc..0b32aafe8 100644
--- a/ucrop/src/main/java/com/yalantis/ucrop/UCropActivity.java
+++ b/ucrop/src/main/java/com/yalantis/ucrop/UCropActivity.java
@@ -49,6 +49,7 @@
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.transition.AutoTransition;
@@ -87,7 +88,6 @@ public class UCropActivity extends AppCompatActivity {
// Enables dynamic coloring
private int mToolbarColor;
private int mStatusBarColor;
- private int mActiveWidgetColor;
private int mActiveControlsWidgetColor;
private int mToolbarWidgetColor;
@ColorInt
@@ -116,6 +116,10 @@ public class UCropActivity extends AppCompatActivity {
private int mCompressQuality = DEFAULT_COMPRESS_QUALITY;
private int[] mAllowedGestures = new int[]{SCALE, ROTATE, ALL};
+ static {
+ AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
+ }
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -248,6 +252,7 @@ private void processOptions(@NonNull Intent intent) {
mOverlayView.setCropGridRowCount(intent.getIntExtra(UCrop.Options.EXTRA_CROP_GRID_ROW_COUNT, OverlayView.DEFAULT_CROP_GRID_ROW_COUNT));
mOverlayView.setCropGridColumnCount(intent.getIntExtra(UCrop.Options.EXTRA_CROP_GRID_COLUMN_COUNT, OverlayView.DEFAULT_CROP_GRID_COLUMN_COUNT));
mOverlayView.setCropGridColor(intent.getIntExtra(UCrop.Options.EXTRA_CROP_GRID_COLOR, getResources().getColor(R.color.ucrop_color_default_crop_grid)));
+ mOverlayView.setCropGridCornerColor(intent.getIntExtra(UCrop.Options.EXTRA_CROP_GRID_CORNER_COLOR, getResources().getColor(R.color.ucrop_color_default_crop_grid)));
mOverlayView.setCropGridStrokeWidth(intent.getIntExtra(UCrop.Options.EXTRA_CROP_GRID_STROKE_WIDTH, getResources().getDimensionPixelSize(R.dimen.ucrop_default_crop_grid_stoke_width)));
// Aspect ratio options
@@ -282,7 +287,6 @@ private void processOptions(@NonNull Intent intent) {
private void setupViews(@NonNull Intent intent) {
mStatusBarColor = intent.getIntExtra(UCrop.Options.EXTRA_STATUS_BAR_COLOR, ContextCompat.getColor(this, R.color.ucrop_color_statusbar));
mToolbarColor = intent.getIntExtra(UCrop.Options.EXTRA_TOOL_BAR_COLOR, ContextCompat.getColor(this, R.color.ucrop_color_toolbar));
- mActiveWidgetColor = intent.getIntExtra(UCrop.Options.EXTRA_UCROP_COLOR_WIDGET_ACTIVE, ContextCompat.getColor(this, R.color.ucrop_color_widget_background));
mActiveControlsWidgetColor = intent.getIntExtra(UCrop.Options.EXTRA_UCROP_COLOR_CONTROLS_WIDGET_ACTIVE, ContextCompat.getColor(this, R.color.ucrop_color_active_controls_color));
mToolbarWidgetColor = intent.getIntExtra(UCrop.Options.EXTRA_UCROP_WIDGET_COLOR_TOOLBAR, ContextCompat.getColor(this, R.color.ucrop_color_toolbar_widget));
@@ -302,7 +306,6 @@ private void setupViews(@NonNull Intent intent) {
ViewGroup viewGroup = findViewById(R.id.ucrop_photobox);
ViewGroup wrapper = viewGroup.findViewById(R.id.controls_wrapper);
wrapper.setVisibility(View.VISIBLE);
- wrapper.setBackgroundColor(mRootViewBackgroundColor);
LayoutInflater.from(this).inflate(R.layout.ucrop_controls, wrapper, true);
mControlsTransition = new AutoTransition();
@@ -364,6 +367,11 @@ private void initiateRootViews() {
((ImageView) findViewById(R.id.image_view_logo)).setColorFilter(mLogoColor, PorterDuff.Mode.SRC_ATOP);
findViewById(R.id.ucrop_frame).setBackgroundColor(mRootViewBackgroundColor);
+ if (!mShowBottomControls) {
+ RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) findViewById(R.id.ucrop_frame).getLayoutParams();
+ params.bottomMargin = 0;
+ findViewById(R.id.ucrop_frame).requestLayout();
+ }
}
private TransformImageView.TransformImageListener mImageListener = new TransformImageView.TransformImageListener() {
@@ -394,7 +402,7 @@ public void onLoadFailure(@NonNull Exception e) {
};
/**
- * Use {@link #mActiveWidgetColor} for color filter
+ * Use {@link #mActiveControlsWidgetColor} for color filter
*/
private void setupStatesWrapper() {
ImageView stateScaleImageView = findViewById(R.id.image_view_state_scale);
@@ -496,7 +504,7 @@ public void onScrollStart() {
}
});
- ((HorizontalProgressWheelView) findViewById(R.id.rotate_scroll_wheel)).setMiddleLineColor(mActiveWidgetColor);
+ ((HorizontalProgressWheelView) findViewById(R.id.rotate_scroll_wheel)).setMiddleLineColor(mActiveControlsWidgetColor);
findViewById(R.id.wrapper_reset_rotate).setOnClickListener(new View.OnClickListener() {
@@ -511,6 +519,7 @@ public void onClick(View v) {
rotateByAngle(90);
}
});
+ setAngleTextColor(mActiveControlsWidgetColor);
}
private void setupScaleWidget() {
@@ -538,7 +547,9 @@ public void onScrollStart() {
mGestureCropImageView.cancelAllAnimations();
}
});
- ((HorizontalProgressWheelView) findViewById(R.id.scale_scroll_wheel)).setMiddleLineColor(mActiveWidgetColor);
+ ((HorizontalProgressWheelView) findViewById(R.id.scale_scroll_wheel)).setMiddleLineColor(mActiveControlsWidgetColor);
+
+ setScaleTextColor(mActiveControlsWidgetColor);
}
private void setAngleText(float angle) {
@@ -547,12 +558,24 @@ private void setAngleText(float angle) {
}
}
+ private void setAngleTextColor(int textColor) {
+ if (mTextViewRotateAngle != null) {
+ mTextViewRotateAngle.setTextColor(textColor);
+ }
+ }
+
private void setScaleText(float scale) {
if (mTextViewScalePercent != null) {
mTextViewScalePercent.setText(String.format(Locale.getDefault(), "%d%%", (int) (scale * 100)));
}
}
+ private void setScaleTextColor(int textColor) {
+ if (mTextViewScalePercent != null) {
+ mTextViewScalePercent.setTextColor(textColor);
+ }
+ }
+
private void resetRotation() {
mGestureCropImageView.postRotate(-mGestureCropImageView.getCurrentAngle());
mGestureCropImageView.setImageToWrapCropBounds();
diff --git a/ucrop/src/main/java/com/yalantis/ucrop/UCropFragment.java b/ucrop/src/main/java/com/yalantis/ucrop/UCropFragment.java
index 9d33f8089..8ceea611b 100644
--- a/ucrop/src/main/java/com/yalantis/ucrop/UCropFragment.java
+++ b/ucrop/src/main/java/com/yalantis/ucrop/UCropFragment.java
@@ -39,6 +39,7 @@
import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatDelegate;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.transition.AutoTransition;
@@ -72,7 +73,7 @@ public class UCropFragment extends Fragment {
private UCropFragmentCallback callback;
private int mActiveControlsWidgetColor;
- private int mActiveWidgetColor;
+
@ColorInt
private int mRootViewBackgroundColor;
private int mLogoColor;
@@ -94,6 +95,10 @@ public class UCropFragment extends Fragment {
private int mCompressQuality = DEFAULT_COMPRESS_QUALITY;
private int[] mAllowedGestures = new int[]{SCALE, ROTATE, ALL};
+ static {
+ AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
+ }
+
public static UCropFragment newInstance(Bundle uCrop) {
UCropFragment fragment = new UCropFragment();
fragment.setArguments(uCrop);
@@ -133,8 +138,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
public void setupViews(View view, Bundle args) {
- mActiveWidgetColor = args.getInt(UCrop.Options.EXTRA_UCROP_COLOR_WIDGET_ACTIVE, ContextCompat.getColor(getContext(), R.color.ucrop_color_widget_background));
- mActiveControlsWidgetColor = args.getInt(UCrop.Options.EXTRA_UCROP_COLOR_WIDGET_ACTIVE, ContextCompat.getColor(getContext(), R.color.ucrop_color_widget_active));
+ mActiveControlsWidgetColor = args.getInt(UCrop.Options.EXTRA_UCROP_COLOR_CONTROLS_WIDGET_ACTIVE, ContextCompat.getColor(getContext(), R.color.ucrop_color_widget_active));
mLogoColor = args.getInt(UCrop.Options.EXTRA_UCROP_LOGO_COLOR, ContextCompat.getColor(getContext(), R.color.ucrop_color_default_logo));
mShowBottomControls = !args.getBoolean(UCrop.Options.EXTRA_HIDE_BOTTOM_CONTROLS, false);
mRootViewBackgroundColor = args.getInt(UCrop.Options.EXTRA_UCROP_ROOT_VIEW_BACKGROUND_COLOR, ContextCompat.getColor(getContext(), R.color.ucrop_color_crop_background));
@@ -146,7 +150,6 @@ public void setupViews(View view, Bundle args) {
ViewGroup wrapper = view.findViewById(R.id.controls_wrapper);
wrapper.setVisibility(View.VISIBLE);
- wrapper.setBackgroundColor(mRootViewBackgroundColor);
LayoutInflater.from(getContext()).inflate(R.layout.ucrop_controls, wrapper, true);
mControlsTransition = new AutoTransition();
@@ -167,6 +170,10 @@ public void setupViews(View view, Bundle args) {
setupRotateWidget(view);
setupScaleWidget(view);
setupStatesWrapper(view);
+ } else {
+ RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) view.findViewById(R.id.ucrop_frame).getLayoutParams();
+ params.bottomMargin = 0;
+ view.findViewById(R.id.ucrop_frame).requestLayout();
}
}
@@ -334,7 +341,7 @@ private void setupAspectRatioWidget(@NonNull Bundle bundle, View view) {
wrapperAspectRatio = (FrameLayout) getLayoutInflater().inflate(R.layout.ucrop_aspect_ratio, null);
wrapperAspectRatio.setLayoutParams(lp);
aspectRatioTextView = ((AspectRatioTextView) wrapperAspectRatio.getChildAt(0));
- aspectRatioTextView.setActiveColor(mActiveWidgetColor);
+ aspectRatioTextView.setActiveColor(mActiveControlsWidgetColor);
aspectRatioTextView.setAspectRatio(aspectRatio);
wrapperAspectRatioList.addView(wrapperAspectRatio);
@@ -380,7 +387,7 @@ public void onScrollStart() {
}
});
- ((HorizontalProgressWheelView) view.findViewById(R.id.rotate_scroll_wheel)).setMiddleLineColor(mActiveWidgetColor);
+ ((HorizontalProgressWheelView) view.findViewById(R.id.rotate_scroll_wheel)).setMiddleLineColor(mActiveControlsWidgetColor);
view.findViewById(R.id.wrapper_reset_rotate).setOnClickListener(new View.OnClickListener() {
@@ -395,6 +402,7 @@ public void onClick(View v) {
rotateByAngle(90);
}
});
+ setAngleTextColor(mActiveControlsWidgetColor);
}
private void setupScaleWidget(View view) {
@@ -422,7 +430,9 @@ public void onScrollStart() {
mGestureCropImageView.cancelAllAnimations();
}
});
- ((HorizontalProgressWheelView) view.findViewById(R.id.scale_scroll_wheel)).setMiddleLineColor(mActiveWidgetColor);
+ ((HorizontalProgressWheelView) view.findViewById(R.id.scale_scroll_wheel)).setMiddleLineColor(mActiveControlsWidgetColor);
+
+ setScaleTextColor(mActiveControlsWidgetColor);
}
private void setAngleText(float angle) {
@@ -431,12 +441,24 @@ private void setAngleText(float angle) {
}
}
+ private void setAngleTextColor(int textColor) {
+ if (mTextViewRotateAngle != null) {
+ mTextViewRotateAngle.setTextColor(textColor);
+ }
+ }
+
private void setScaleText(float scale) {
if (mTextViewScalePercent != null) {
mTextViewScalePercent.setText(String.format(Locale.getDefault(), "%d%%", (int) (scale * 100)));
}
}
+ private void setScaleTextColor(int textColor) {
+ if (mTextViewScalePercent != null) {
+ mTextViewScalePercent.setTextColor(textColor);
+ }
+ }
+
private void resetRotation() {
mGestureCropImageView.postRotate(-mGestureCropImageView.getCurrentAngle());
mGestureCropImageView.setImageToWrapCropBounds();
diff --git a/ucrop/src/main/java/com/yalantis/ucrop/task/BitmapLoadTask.java b/ucrop/src/main/java/com/yalantis/ucrop/task/BitmapLoadTask.java
index c836fdd11..61235a158 100755
--- a/ucrop/src/main/java/com/yalantis/ucrop/task/BitmapLoadTask.java
+++ b/ucrop/src/main/java/com/yalantis/ucrop/task/BitmapLoadTask.java
@@ -1,34 +1,26 @@
package com.yalantis.ucrop.task;
-import android.Manifest.permission;
import android.content.Context;
-import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.net.Uri;
import android.os.AsyncTask;
-import android.os.Build;
-import android.os.ParcelFileDescriptor;
-import android.text.TextUtils;
import android.util.Log;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
import com.yalantis.ucrop.callback.BitmapLoadCallback;
import com.yalantis.ucrop.model.ExifInfo;
import com.yalantis.ucrop.util.BitmapLoadUtils;
-import com.yalantis.ucrop.util.FileUtils;
import java.io.File;
-import java.io.FileDescriptor;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.core.content.ContextCompat;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
@@ -95,27 +87,8 @@ protected BitmapWorkerResult doInBackground(Void... params) {
return new BitmapWorkerResult(e);
}
- final ParcelFileDescriptor parcelFileDescriptor;
- try {
- parcelFileDescriptor = mContext.getContentResolver().openFileDescriptor(mInputUri, "r");
- } catch (FileNotFoundException e) {
- return new BitmapWorkerResult(e);
- }
-
- final FileDescriptor fileDescriptor;
- if (parcelFileDescriptor != null) {
- fileDescriptor = parcelFileDescriptor.getFileDescriptor();
- } else {
- return new BitmapWorkerResult(new NullPointerException("ParcelFileDescriptor was null for given Uri: [" + mInputUri + "]"));
- }
-
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
- BitmapFactory.decodeFileDescriptor(fileDescriptor, null, options);
- if (options.outWidth == -1 || options.outHeight == -1) {
- return new BitmapWorkerResult(new IllegalArgumentException("Bounds for bitmap could not be retrieved from the Uri: [" + mInputUri + "]"));
- }
-
options.inSampleSize = BitmapLoadUtils.calculateInSampleSize(options, mRequiredWidth, mRequiredHeight);
options.inJustDecodeBounds = false;
@@ -124,11 +97,22 @@ protected BitmapWorkerResult doInBackground(Void... params) {
boolean decodeAttemptSuccess = false;
while (!decodeAttemptSuccess) {
try {
- decodeSampledBitmap = BitmapFactory.decodeFileDescriptor(fileDescriptor, null, options);
+ InputStream stream = mContext.getContentResolver().openInputStream(mInputUri);
+ try {
+ decodeSampledBitmap = BitmapFactory.decodeStream(stream, null, options);
+ if (options.outWidth == -1 || options.outHeight == -1) {
+ return new BitmapWorkerResult(new IllegalArgumentException("Bounds for bitmap could not be retrieved from the Uri: [" + mInputUri + "]"));
+ }
+ } finally {
+ BitmapLoadUtils.close(stream);
+ }
decodeAttemptSuccess = true;
} catch (OutOfMemoryError error) {
Log.e(TAG, "doInBackground: BitmapFactory.decodeFileDescriptor: ", error);
options.inSampleSize *= 2;
+ } catch (IOException e) {
+ Log.e(TAG, "doInBackground: ImageDecoder.createSource: ", e);
+ return new BitmapWorkerResult(new IllegalArgumentException("Bitmap could not be decoded from the Uri: [" + mInputUri + "]", e));
}
}
@@ -136,10 +120,6 @@ protected BitmapWorkerResult doInBackground(Void... params) {
return new BitmapWorkerResult(new IllegalArgumentException("Bitmap could not be decoded from the Uri: [" + mInputUri + "]"));
}
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
- BitmapLoadUtils.close(parcelFileDescriptor);
- }
-
int exifOrientation = BitmapLoadUtils.getExifOrientation(mContext, mInputUri);
int exifDegrees = BitmapLoadUtils.exifToDegrees(exifOrientation);
int exifTranslation = BitmapLoadUtils.exifToTranslation(exifOrientation);
@@ -171,16 +151,11 @@ private void processInputUri() throws NullPointerException, IOException {
throw e;
}
} else if ("content".equals(inputUriScheme)) {
- String path = getFilePath();
- if (!TextUtils.isEmpty(path) && new File(path).exists()) {
- mInputUri = Uri.fromFile(new File(path));
- } else {
- try {
- copyFile(mInputUri, mOutputUri);
- } catch (NullPointerException | IOException e) {
- Log.e(TAG, "Copying failed", e);
- throw e;
- }
+ try {
+ copyFile(mInputUri, mOutputUri);
+ } catch (NullPointerException | IOException e) {
+ Log.e(TAG, "Copying failed", e);
+ throw e;
}
} else if (!"file".equals(inputUriScheme)) {
Log.e(TAG, "Invalid Uri scheme " + inputUriScheme);
@@ -188,15 +163,6 @@ private void processInputUri() throws NullPointerException, IOException {
}
}
- private String getFilePath() {
- if (ContextCompat.checkSelfPermission(mContext, permission.READ_EXTERNAL_STORAGE)
- == PackageManager.PERMISSION_GRANTED) {
- return FileUtils.getPath(mContext, mInputUri);
- } else {
- return null;
- }
- }
-
private void copyFile(@NonNull Uri inputUri, @Nullable Uri outputUri) throws NullPointerException, IOException {
Log.d(TAG, "copyFile");
diff --git a/ucrop/src/main/java/com/yalantis/ucrop/view/OverlayView.java b/ucrop/src/main/java/com/yalantis/ucrop/view/OverlayView.java
index eb5397015..203888291 100644
--- a/ucrop/src/main/java/com/yalantis/ucrop/view/OverlayView.java
+++ b/ucrop/src/main/java/com/yalantis/ucrop/view/OverlayView.java
@@ -213,6 +213,13 @@ public void setCropGridColor(@ColorInt int color) {
mCropGridPaint.setColor(color);
}
+ /**
+ * Setter for crop grid corner color
+ */
+ public void setCropGridCornerColor(@ColorInt int color) {
+ mCropFrameCornersPaint.setColor(color);
+ }
+
/**
* This method sets aspect ratio for crop bounds.
*
@@ -545,6 +552,7 @@ private void initCropFrameStyle(@NonNull TypedArray a) {
getResources().getDimensionPixelSize(R.dimen.ucrop_default_crop_frame_stoke_width));
int cropFrameColor = a.getColor(R.styleable.ucrop_UCropView_ucrop_frame_color,
getResources().getColor(R.color.ucrop_color_default_crop_frame));
+
mCropFramePaint.setStrokeWidth(cropFrameStrokeSize);
mCropFramePaint.setColor(cropFrameColor);
mCropFramePaint.setStyle(Paint.Style.STROKE);
diff --git a/ucrop/src/main/java/com/yalantis/ucrop/view/widget/HorizontalProgressWheelView.java b/ucrop/src/main/java/com/yalantis/ucrop/view/widget/HorizontalProgressWheelView.java
index fc7d9b3d8..756765841 100644
--- a/ucrop/src/main/java/com/yalantis/ucrop/view/widget/HorizontalProgressWheelView.java
+++ b/ucrop/src/main/java/com/yalantis/ucrop/view/widget/HorizontalProgressWheelView.java
@@ -59,6 +59,7 @@ public void setScrollingListener(ScrollingListener scrollingListener) {
public void setMiddleLineColor(@ColorInt int middleLineColor) {
mMiddleLineColor = middleLineColor;
+ mProgressMiddleLinePaint.setColor(mMiddleLineColor);
invalidate();
}
diff --git a/ucrop/src/main/res/layout/ucrop_activity_photobox.xml b/ucrop/src/main/res/layout/ucrop_activity_photobox.xml
index 0ed5f6d82..57a5a3b13 100644
--- a/ucrop/src/main/res/layout/ucrop_activity_photobox.xml
+++ b/ucrop/src/main/res/layout/ucrop_activity_photobox.xml
@@ -28,7 +28,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/controls_wrapper"
- android:layout_below="@+id/toolbar">
+ android:layout_below="@+id/toolbar"
+ android:layout_marginBottom="-12dp">
@@ -52,7 +53,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
- android:background="@android:color/black"
android:visibility="gone" />
diff --git a/ucrop/src/main/res/layout/ucrop_fragment_photobox.xml b/ucrop/src/main/res/layout/ucrop_fragment_photobox.xml
index a2ff0467a..34594546c 100644
--- a/ucrop/src/main/res/layout/ucrop_fragment_photobox.xml
+++ b/ucrop/src/main/res/layout/ucrop_fragment_photobox.xml
@@ -10,6 +10,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/controls_wrapper"
+ android:layout_marginBottom="-12dp"
android:background="@color/ucrop_color_crop_background">
diff --git a/ucrop/src/main/res/values-es/strings.xml b/ucrop/src/main/res/values-es/strings.xml
new file mode 100644
index 000000000..a8993ed1b
--- /dev/null
+++ b/ucrop/src/main/res/values-es/strings.xml
@@ -0,0 +1,12 @@
+
+
+ Original
+ Editar Foto
+
+ Cortar
+
+ Rotar
+ Escalar
+ Cortar
+
+
diff --git a/ucrop/src/main/res/values-ja/strings.xml b/ucrop/src/main/res/values-ja/strings.xml
new file mode 100644
index 000000000..bb13d357e
--- /dev/null
+++ b/ucrop/src/main/res/values-ja/strings.xml
@@ -0,0 +1,11 @@
+
+
+ オリジナル
+ 画像編集
+
+ 切り抜き
+
+ 拡大
+ 回転
+ 比率
+
\ No newline at end of file
diff --git a/ucrop/src/main/res/values-pt-br b/ucrop/src/main/res/values-pt-br
new file mode 100644
index 000000000..9fea3b042
--- /dev/null
+++ b/ucrop/src/main/res/values-pt-br
@@ -0,0 +1,14 @@
+
+
+ Original
+ Editar Foto
+
+ Cortar
+
+ Uri de entrada e saída deve ser especificado
+ Portanto, substitua o recurso de cores (ucrop_color_toolbar_widget) no seu aplicativo para fazê-lo funcionar em dispositivos pré-L
+ Girar
+ Tamanho
+ Cortar
+
+