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 acd0d13cf..0eca122f4 100644 --- a/sample/src/main/java/com/yalantis/ucrop/sample/SampleActivity.java +++ b/sample/src/main/java/com/yalantis/ucrop/sample/SampleActivity.java @@ -373,9 +373,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/src/main/java/com/yalantis/ucrop/UCrop.java b/ucrop/src/main/java/com/yalantis/ucrop/UCrop.java index e0d423634..878191c1b 100644 --- a/ucrop/src/main/java/com/yalantis/ucrop/UCrop.java +++ b/ucrop/src/main/java/com/yalantis/ucrop/UCrop.java @@ -261,7 +261,6 @@ public static class Options { 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,14 +425,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 8ba5bf48c..fae5dc9ea 100644 --- a/ucrop/src/main/java/com/yalantis/ucrop/UCropActivity.java +++ b/ucrop/src/main/java/com/yalantis/ucrop/UCropActivity.java @@ -88,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 @@ -287,7 +286,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)); @@ -399,7 +397,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); @@ -501,7 +499,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() { @@ -516,6 +514,8 @@ public void onClick(View v) { rotateByAngle(90); } }); + + setAngleTextColor(mActiveControlsWidgetColor); } private void setupScaleWidget() { @@ -543,7 +543,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) { @@ -552,12 +554,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 2c39f17af..44545b609 100644 --- a/ucrop/src/main/java/com/yalantis/ucrop/UCropFragment.java +++ b/ucrop/src/main/java/com/yalantis/ucrop/UCropFragment.java @@ -73,7 +73,6 @@ public class UCropFragment extends Fragment { private UCropFragmentCallback callback; private int mActiveControlsWidgetColor; - private int mActiveWidgetColor; @ColorInt private int mRootViewBackgroundColor; private int mLogoColor; @@ -138,8 +137,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)); @@ -301,7 +299,7 @@ public void onLoadFailure(@NonNull Exception e) { }; /** - * Use {@link #mActiveWidgetColor} for color filter + * Use {@link #mActiveControlsWidgetColor} for color filter */ private void setupStatesWrapper(View view) { ImageView stateScaleImageView = view.findViewById(R.id.image_view_state_scale); @@ -339,7 +337,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); @@ -385,7 +383,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() { @@ -400,6 +398,8 @@ public void onClick(View v) { rotateByAngle(90); } }); + + setAngleTextColor(mActiveControlsWidgetColor); } private void setupScaleWidget(View view) { @@ -427,7 +427,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) { @@ -436,12 +438,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/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(); }