Skip to content

Commit

Permalink
Merge pull request #643 from Yalantis/develop
Browse files Browse the repository at this point in the history
merged develop into master
  • Loading branch information
ukevgen authored Apr 29, 2020
2 parents 76a9f06 + 39da556 commit c120968
Show file tree
Hide file tree
Showing 17 changed files with 162 additions and 123 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -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"
}
Expand Down
46 changes: 9 additions & 37 deletions sample/src/main/java/com/yalantis/ucrop/sample/SampleActivity.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions sample/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
<color name="colorPrimary">#FF6E40</color>
<color name="colorPrimaryDark">#CC5833</color>
<color name="colorAccent">#FF6E40</color>

<color name="your_color_res">#03A9F4</color>
</resources>
4 changes: 2 additions & 2 deletions ucrop/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
18 changes: 9 additions & 9 deletions ucrop/src/main/java/com/yalantis/ucrop/UCrop.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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
*/
Expand All @@ -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);
Expand Down
35 changes: 29 additions & 6 deletions ucrop/src/main/java/com/yalantis/ucrop/UCropActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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));
Expand All @@ -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();
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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() {
Expand All @@ -511,6 +519,7 @@ public void onClick(View v) {
rotateByAngle(90);
}
});
setAngleTextColor(mActiveControlsWidgetColor);
}

private void setupScaleWidget() {
Expand Down Expand Up @@ -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) {
Expand All @@ -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();
Expand Down
Loading

0 comments on commit c120968

Please sign in to comment.