Skip to content

Commit 31b5c11

Browse files
authored
Merge pull request #7 from epegasus/master
Update sdk & fix issue
2 parents 66a5671 + 71838a3 commit 31b5c11

File tree

8 files changed

+42
-46
lines changed

8 files changed

+42
-46
lines changed

.idea/gradle.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This repository hosts the `cropView` module, a customizable view for croppingima
99
* Double tap focus
1010
* Pinch Zoom
1111
* Free Mode
12-
* Size Displayer
12+
* Size Displayed
1313
* Auto Centered
1414
* Animations
1515
* Customizable corner styles and colors

app/build.gradle.kts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ plugins {
55

66
android {
77
namespace = "com.hypersoft.cropview"
8-
compileSdk = 34
8+
compileSdk = 35
99

1010
defaultConfig {
1111
applicationId = "com.hypersoft.cropview"
1212
minSdk = 23
13-
targetSdk = 34
13+
targetSdk = 35
1414
versionCode = 1
1515
versionName = "1.0"
16-
17-
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
1816
}
1917

2018
buildTypes {
@@ -52,5 +50,5 @@ dependencies {
5250

5351
// CropView Library
5452
implementation(project(":cropView"))
55-
// implementation 'com.github.hypersoftdev:CropView:1.0.2'
53+
//implementation 'com.github.hypersoftdev:CropView:1.0.2'
5654
}

app/src/main/java/com/hypersoft/cropview/ui/crop/ActivityCrop.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class ActivityCrop : BaseActivity<ActivityCropBinding>(ActivityCropBinding::infl
138138
}
139139

140140
private fun saveImage() {
141-
bitmap = binding.cropView.getCroppedData()
141+
bitmap = binding.cropView.getCroppedImage()
142142
startActivity(Intent(this, ActivityResult::class.java))
143143
}
144144

cropView/build.gradle.kts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ plugins {
66

77
android {
88
namespace = "com.hypersoft.crop"
9-
compileSdk = 34
9+
compileSdk = 35
1010

1111
defaultConfig {
1212
minSdk = 23
13-
14-
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
1513
}
1614

1715
buildTypes {
@@ -36,12 +34,6 @@ android {
3634

3735
dependencies {
3836
implementation(libs.androidx.core.ktx)
39-
implementation(libs.androidx.appcompat)
40-
implementation(libs.material)
41-
42-
testImplementation(libs.junit)
43-
androidTestImplementation(libs.androidx.junit)
44-
androidTestImplementation(libs.androidx.espresso.core)
4537

4638
// Exif (for rotation)
4739
implementation(libs.androidx.exifinterface)
@@ -53,7 +45,7 @@ publishing {
5345
create<MavenPublication>("release") {
5446
groupId = "com.hypersoft.cropview"
5547
artifactId = "cropview"
56-
version = "1.0.1"
48+
version = "1.0.3"
5749

5850
afterEvaluate {
5951
from(components["release"])

cropView/src/main/java/com/hypersoft/crop/CropView.kt

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import android.view.MotionEvent.ACTION_UP
1717
import android.view.View
1818
import androidx.annotation.ColorInt
1919
import androidx.core.content.ContextCompat
20+
import androidx.core.graphics.createBitmap
2021
import com.hypersoft.crop.customs.AnimatableRectF
21-
import com.hypersoft.crop.dataClasses.CroppedBitmapData
2222
import com.hypersoft.crop.enums.AspectMode
2323
import com.hypersoft.crop.enums.AspectMode.ASPECT
2424
import com.hypersoft.crop.enums.AspectMode.FREE
@@ -414,7 +414,7 @@ class CropView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
414414
fun setCropRotation(angle: Float) {
415415
rotationDegrees = (rotationDegrees + angle) % 360
416416
bitmapMatrix.postRotate(angle, cropRect.centerX(), cropRect.centerY())
417-
//cropRect = rotateRect(cropRect, angle)
417+
cropRect = rotateRect(cropRect, angle)
418418
notifyCropRectChanged()
419419
invalidate()
420420
}
@@ -432,9 +432,23 @@ class CropView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
432432
)
433433
matrix.mapPoints(points)
434434

435-
val newRect = AnimatableRectF()
436-
newRect.set(points[0], points[1], points[4], points[5])
437-
return newRect
435+
var minX = Float.MAX_VALUE
436+
var minY = Float.MAX_VALUE
437+
var maxX = Float.MIN_VALUE
438+
var maxY = Float.MIN_VALUE
439+
440+
for (i in points.indices step 2) {
441+
val x = points[i]
442+
val y = points[i + 1]
443+
minX = minOf(minX, x)
444+
minY = minOf(minY, y)
445+
maxX = maxOf(maxX, x)
446+
maxY = maxOf(maxY, y)
447+
}
448+
449+
return AnimatableRectF().apply {
450+
set(minX, minY, maxX, maxY)
451+
}
438452
}
439453

440454
/**
@@ -581,7 +595,7 @@ class CropView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
581595
/**
582596
* Get cropped bitmap.
583597
*/
584-
fun getCroppedData(): Bitmap? {
598+
fun getCroppedImage(): Bitmap? {
585599
val croppedBitmapRect = getCropSizeOriginal()
586600

587601
if (bitmapRect.intersect(croppedBitmapRect).not()) {
@@ -675,7 +689,7 @@ class CropView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
675689
* Create mask bitmap
676690
*/
677691
private fun createMaskBitmap() {
678-
maskBitmap = Bitmap.createBitmap(measuredWidth, measuredHeight, Bitmap.Config.ARGB_8888)
692+
maskBitmap = createBitmap(measuredWidth, measuredHeight)
679693
maskCanvas = Canvas(maskBitmap!!)
680694
}
681695

@@ -1087,7 +1101,7 @@ class CropView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
10871101
}
10881102

10891103
/**
1090-
* Calculates minimum possibel rectangle that user can drag
1104+
* Calculates minimum possible rectangle that user can drag
10911105
* cropRect
10921106
*/
10931107
private fun calculateMinRect() {
@@ -1516,7 +1530,7 @@ class CropView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
15161530
}
15171531

15181532
/**
1519-
* If user miminize the croprect, we need to
1533+
* If user minimize the crop-rect, we need to
15201534
* calculate target centered rectangle according to
15211535
* current cropRect aspect ratio and size. With this
15221536
* target rectangle, we can animate crop rect to
@@ -1543,7 +1557,7 @@ class CropView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
15431557
* When user change cropRect size by dragging it, cropRect
15441558
* should be animated to center without changing aspect ratio,
15451559
* meanwhile bitmap matrix should be take selected crop rect to
1546-
* the center. This methods take selected crop rect to the cennter.
1560+
* the center. This methods take selected crop rect to the center.
15471561
*/
15481562
private fun animateBitmapToCenterTarget() {
15491563
val newBitmapMatrix = bitmapMatrix.clone()
@@ -1563,7 +1577,7 @@ class CropView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
15631577
}
15641578

15651579
/**
1566-
* Animates current croprect to the center position
1580+
* Animates current crop-rect to the center position
15671581
*/
15681582
private fun animateCropRectToCenterTarget() {
15691583
cropRect.animateTo(targetRect) {

gradle/libs.versions.toml

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
[versions]
2-
agp = "8.5.2"
2+
agp = "8.9.3"
33
kotlin = "1.9.0"
44

5-
coreKtx = "1.13.1"
6-
appcompat = "1.7.0"
5+
coreKtx = "1.16.0"
6+
appcompat = "1.7.1"
77
material = "1.12.0"
8-
activity = "1.9.2"
9-
constraintlayout = "2.1.4"
10-
11-
junit = "4.13.2"
12-
junitVersion = "1.2.1"
13-
espressoCore = "3.6.1"
8+
activity = "1.10.1"
9+
constraintlayout = "2.2.1"
1410

1511
# Exif Interface
16-
exifinterface = "1.3.7"
12+
exifinterface = "1.4.1"
1713

1814
# View Model Scope
19-
lifecycleViewmodelKtx = "2.8.6"
15+
lifecycleViewmodelKtx = "2.9.1"
2016

2117
[plugins]
2218
android-application = { id = "com.android.application", version.ref = "agp" }
@@ -30,10 +26,6 @@ material = { group = "com.google.android.material", name = "material", version.r
3026
androidx-activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
3127
androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
3228

33-
junit = { group = "junit", name = "junit", version.ref = "junit" }
34-
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
35-
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
36-
3729
# Exif Interface
3830
androidx-exifinterface = { group = "androidx.exifinterface", name = "exifinterface", version.ref = "exifinterface" }
3931

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Thu Sep 19 09:27:36 PKT 2024
1+
#Wed Jun 11 15:04:15 PKT 2025
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)