Skip to content

Commit

Permalink
Merge pull request Yalantis#235 from uDevel/feature/crop_grid_corner
Browse files Browse the repository at this point in the history
Feature: Add option to change grid corner color.
  • Loading branch information
Kirill authored Mar 19, 2020
2 parents f885182 + 97fc0a9 commit db9b50b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ucrop/src/main/java/com/yalantis/ucrop/UCrop.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ 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";
Expand Down Expand Up @@ -425,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 Down
1 change: 1 addition & 0 deletions ucrop/src/main/java/com/yalantis/ucrop/UCropActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -252,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
8 changes: 8 additions & 0 deletions ucrop/src/main/java/com/yalantis/ucrop/view/OverlayView.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit db9b50b

Please sign in to comment.