Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add the method of setter for crop corners color #558

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
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 @@ -272,6 +272,7 @@ public static class Options {

public static final String EXTRA_SHOW_CROP_FRAME = EXTRA_PREFIX + ".ShowCropFrame";
public static final String EXTRA_CROP_FRAME_COLOR = EXTRA_PREFIX + ".CropFrameColor";
public static final String EXTRA_CROP_FRAME_CORNERS_COLOR = EXTRA_PREFIX + ".CropFrameCornersColor";
public static final String EXTRA_CROP_FRAME_STROKE_WIDTH = EXTRA_PREFIX + ".CropFrameStrokeWidth";

public static final String EXTRA_SHOW_CROP_GRID = EXTRA_PREFIX + ".ShowCropGrid";
Expand Down Expand Up @@ -390,6 +391,13 @@ public void setCropFrameColor(@ColorInt int color) {
mOptionBundle.putInt(EXTRA_CROP_FRAME_COLOR, color);
}

/**
* @param color - desired color of crop frame corners
*/
public void setCropFrameCornersColor(@ColorInt int color) {
mOptionBundle.putInt(EXTRA_CROP_FRAME_CORNERS_COLOR, color);
}

/**
* @param width - desired width of crop frame line 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 @@ -241,6 +241,7 @@ private void processOptions(@NonNull Intent intent) {

mOverlayView.setShowCropFrame(intent.getBooleanExtra(UCrop.Options.EXTRA_SHOW_CROP_FRAME, OverlayView.DEFAULT_SHOW_CROP_FRAME));
mOverlayView.setCropFrameColor(intent.getIntExtra(UCrop.Options.EXTRA_CROP_FRAME_COLOR, getResources().getColor(R.color.ucrop_color_default_crop_frame)));
mOverlayView.setCropFrameCornersColor(intent.getIntExtra(UCrop.Options.EXTRA_CROP_FRAME_CORNERS_COLOR, getResources().getColor(R.color.ucrop_color_default_crop_frame_corners)));
mOverlayView.setCropFrameStrokeWidth(intent.getIntExtra(UCrop.Options.EXTRA_CROP_FRAME_STROKE_WIDTH, getResources().getDimensionPixelSize(R.dimen.ucrop_default_crop_frame_stoke_width)));

mOverlayView.setShowCropGrid(intent.getBooleanExtra(UCrop.Options.EXTRA_SHOW_CROP_GRID, OverlayView.DEFAULT_SHOW_CROP_GRID));
Expand Down
1 change: 1 addition & 0 deletions ucrop/src/main/java/com/yalantis/ucrop/UCropFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ private void processOptions(@NonNull Bundle bundle) {

mOverlayView.setShowCropFrame(bundle.getBoolean(UCrop.Options.EXTRA_SHOW_CROP_FRAME, OverlayView.DEFAULT_SHOW_CROP_FRAME));
mOverlayView.setCropFrameColor(bundle.getInt(UCrop.Options.EXTRA_CROP_FRAME_COLOR, getResources().getColor(R.color.ucrop_color_default_crop_frame)));
mOverlayView.setCropFrameCornersColor(bundle.getInt(UCrop.Options.EXTRA_CROP_FRAME_CORNERS_COLOR, getResources().getColor(R.color.ucrop_color_default_crop_frame_corners)));
mOverlayView.setCropFrameStrokeWidth(bundle.getInt(UCrop.Options.EXTRA_CROP_FRAME_STROKE_WIDTH, getResources().getDimensionPixelSize(R.dimen.ucrop_default_crop_frame_stoke_width)));

mOverlayView.setShowCropGrid(bundle.getBoolean(UCrop.Options.EXTRA_SHOW_CROP_GRID, OverlayView.DEFAULT_SHOW_CROP_GRID));
Expand Down
12 changes: 11 additions & 1 deletion ucrop/src/main/java/com/yalantis/ucrop/view/OverlayView.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,14 @@ public void setCropGridColor(@ColorInt int color) {
mCropGridPaint.setColor(color);
}

/**
* Setter for crop corners color
* @param color
*/
public void setCropFrameCornersColor(@ColorInt int color) {
mCropFrameCornersPaint.setColor(color);
}

/**
* This method sets aspect ratio for crop bounds.
*
Expand Down Expand Up @@ -548,8 +556,10 @@ private void initCropFrameStyle(@NonNull TypedArray a) {
mCropFramePaint.setColor(cropFrameColor);
mCropFramePaint.setStyle(Paint.Style.STROKE);

int cropFrameCornersColor = a.getColor(R.styleable.ucrop_UCropView_ucrop_frame_corners_color,
getResources().getColor(R.color.ucrop_color_default_crop_frame_corners));
mCropFrameCornersPaint.setStrokeWidth(cropFrameStrokeSize * 3);
mCropFrameCornersPaint.setColor(cropFrameColor);
mCropFrameCornersPaint.setColor(cropFrameCornersColor);
mCropFrameCornersPaint.setStyle(Paint.Style.STROKE);
}

Expand Down
1 change: 1 addition & 0 deletions ucrop/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

<attr name="ucrop_frame_stroke_size" format="dimension"/>
<attr name="ucrop_frame_color" format="color"/>
<attr name="ucrop_frame_corners_color" format="color"/>
<attr name="ucrop_show_frame" format="boolean"/>

</declare-styleable>
Expand Down
1 change: 1 addition & 0 deletions ucrop/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<!--Crop View-->
<color name="ucrop_color_default_crop_grid">#80ffffff</color>
<color name="ucrop_color_default_crop_frame">#ffffff</color>
<color name="ucrop_color_default_crop_frame_corners">#ffffff</color>
<color name="ucrop_color_default_dimmed">#8c000000</color>
<color name="ucrop_color_default_logo">#4f212121</color>

Expand Down