Skip to content

Commit

Permalink
CropImageOptions: Option to change progress bar color. (#390)
Browse files Browse the repository at this point in the history
* CropImageOptions: Option to change progress bar color.
  • Loading branch information
vanniktech authored Jun 17, 2022
1 parent 11e14a0 commit c948413
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [x.x.x] - unreleased

- CropImageOptions: Option to change progress bar color. [#390](https://github.com/CanHub/Android-Image-Cropper/issues/390)

## [4.3.0] - 10/06/2022
### Added
- Added a helper text on top of crop overlay which moves along with it. [#381](https://github.com/CanHub/Android-Image-Cropper/issues/381)
Expand Down Expand Up @@ -128,7 +130,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

### Fixed
- ENOENT (no such file or directory) [#99](https://github.com/CanHub/Android-Image-Cropper/issues/99)
- `content://` instead of `file://` [#83](https://github.com/CanHub/Android-Image-Cropper/issues/83) [#84](https://github.com/CanHub/Android-Image-Cropper/issues/84)
- `content://` instead of `file://` [#83](https://github.com/CanHub/Android-Image-Cropper/issues/83) [#84](https://github.com/CanHub/Android-Image-Cropper/issues/84)

## [2.3.2-alpha] - 12/04/21
### Added
Expand Down
17 changes: 17 additions & 0 deletions cropper/src/main/java/com/canhub/cropper/CropImageOptions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ import android.os.Parcel
import android.os.Parcelable
import android.text.TextUtils
import android.util.TypedValue
import androidx.annotation.ColorInt
import com.canhub.cropper.CropImageView.CropShape
import com.canhub.cropper.CropImageView.Guidelines
import com.canhub.cropper.CropImageView.RequestSizeOptions

private val COLOR_PURPLE = Color.rgb(153, 51, 153)

/**
* All the possible options that can be set to customize crop image.<br></br>
* Initialized with default values.
Expand Down Expand Up @@ -96,6 +99,11 @@ open class CropImageOptions : Parcelable {
@JvmField
var showProgressBar: Boolean

/** The color of the progress bar. Only works on API level 21 and upwards. */
@JvmField
@ColorInt
var progressBarColor: Int

/**
* if auto-zoom functionality is enabled.<br></br>
* default: true.
Expand Down Expand Up @@ -140,6 +148,7 @@ open class CropImageOptions : Parcelable {

/** the color of the guidelines lines */
@JvmField
@ColorInt
var borderLineColor: Int

/** thickness of the corner line. (in pixels) */
Expand All @@ -156,6 +165,7 @@ open class CropImageOptions : Parcelable {

/** the color of the corner line */
@JvmField
@ColorInt
var borderCornerColor: Int
/**
* The fill color of circle corner
Expand All @@ -169,13 +179,15 @@ open class CropImageOptions : Parcelable {

/** the color of the guidelines lines */
@JvmField
@ColorInt
var guidelinesColor: Int

/**
* the color of the overlay background around the crop window cover the image parts not in the
* crop window.
*/
@JvmField
@ColorInt
var backgroundColor: Int

/** the min width the crop window is allowed to be. (in pixels) */
Expand Down Expand Up @@ -220,6 +232,7 @@ open class CropImageOptions : Parcelable {

/** the color to use for action bar items icons */
@JvmField
@ColorInt
var activityMenuIconColor: Int

/** the Android Uri to save the cropped image to */
Expand Down Expand Up @@ -323,6 +336,7 @@ open class CropImageOptions : Parcelable {

/** The default cropper label text color **/
@JvmField
@ColorInt
var cropperLabelTextColor: Int

/** The default cropper label text **/
Expand All @@ -344,6 +358,7 @@ open class CropImageOptions : Parcelable {
scaleType = CropImageView.ScaleType.FIT_CENTER
showCropOverlay = true
showProgressBar = true
progressBarColor = COLOR_PURPLE
autoZoomEnabled = true
multiTouchEnabled = false
centerMoveEnabled = true
Expand Down Expand Up @@ -409,6 +424,7 @@ open class CropImageOptions : Parcelable {
scaleType = CropImageView.ScaleType.values()[parcel.readInt()]
showCropOverlay = parcel.readByte().toInt() != 0
showProgressBar = parcel.readByte().toInt() != 0
progressBarColor = parcel.readInt()
autoZoomEnabled = parcel.readByte().toInt() != 0
multiTouchEnabled = parcel.readByte().toInt() != 0
centerMoveEnabled = parcel.readByte().toInt() != 0
Expand Down Expand Up @@ -474,6 +490,7 @@ open class CropImageOptions : Parcelable {
dest.writeInt(scaleType.ordinal)
dest.writeByte((if (showCropOverlay) 1 else 0).toByte())
dest.writeByte((if (showProgressBar) 1 else 0).toByte())
dest.writeInt(progressBarColor)
dest.writeByte((if (autoZoomEnabled) 1 else 0).toByte())
dest.writeByte((if (multiTouchEnabled) 1 else 0).toByte())
dest.writeByte((if (centerMoveEnabled) 1 else 0).toByte())
Expand Down
5 changes: 5 additions & 0 deletions cropper/src/main/java/com/canhub/cropper/CropImageView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.canhub.cropper

import android.app.Activity
import android.content.Context
import android.content.res.ColorStateList
import android.graphics.Bitmap
import android.graphics.Bitmap.CompressFormat
import android.graphics.BitmapFactory
Expand All @@ -10,6 +11,7 @@ import android.graphics.Matrix
import android.graphics.Rect
import android.graphics.RectF
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.os.Parcelable
import android.provider.MediaStore
Expand Down Expand Up @@ -1962,6 +1964,9 @@ class CropImageView @JvmOverloads constructor(context: Context, attrs: Attribute
mCropOverlayView.setCropWindowChangeListener(this)
mCropOverlayView.setInitialAttributeValues(options)
mProgressBar = v.findViewById(R.id.CropProgressBar)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mProgressBar.indeterminateTintList = ColorStateList.valueOf(options.progressBarColor)
}
setProgressBarVisibility()
}

Expand Down

0 comments on commit c948413

Please sign in to comment.