Skip to content

Commit

Permalink
Raise minSdk from 16 to 21.
Browse files Browse the repository at this point in the history
  • Loading branch information
vanniktech committed Oct 19, 2022
1 parent 1af36be commit f9a853e
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 416 deletions.
108 changes: 10 additions & 98 deletions cropper/lint-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,50 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 7.3.1" type="baseline" client="gradle" dependencies="false" name="AGP (7.3.1)" variant="all" version="7.3.1">

<issue
id="AnnotateVersionCheck"
message="This method should be annotated with `@ChecksSdkIntAtLeast(api=Build.VERSION_CODES.JELLY_BEAN_MR2)`"
errorLine1=" fun isAtLeastJ18() = SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2"
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/kotlin/com/canhub/cropper/common/CommonVersionCheck.kt"
line="8"
column="7"/>
</issue>

<issue
id="AnnotateVersionCheck"
message="This method should be annotated with `@ChecksSdkIntAtLeast(api=Build.VERSION_CODES.M)`"
errorLine1=" fun isAtLeastM23() = SDK_INT >= Build.VERSION_CODES.M"
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/kotlin/com/canhub/cropper/common/CommonVersionCheck.kt"
line="9"
column="7"/>
</issue>

<issue
id="AnnotateVersionCheck"
message="This method should be annotated with `@ChecksSdkIntAtLeast(api=Build.VERSION_CODES.O)`"
errorLine1=" fun isAtLeastO26() = SDK_INT >= Build.VERSION_CODES.O"
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/kotlin/com/canhub/cropper/common/CommonVersionCheck.kt"
line="10"
column="7"/>
</issue>

<issue
id="AnnotateVersionCheck"
message="This method should be annotated with `@ChecksSdkIntAtLeast(api=Build.VERSION_CODES.Q)`"
errorLine1=" fun isAtLeastQ29() = SDK_INT >= Build.VERSION_CODES.Q"
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/kotlin/com/canhub/cropper/common/CommonVersionCheck.kt"
line="11"
column="7"/>
</issue>

<issue
id="InvalidPackage"
message="Invalid package reference in org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm; not included in Android: `java.lang.instrument`. Referenced from `kotlinx.coroutines.debug.AgentPremain`.">
Expand All @@ -66,39 +22,6 @@
file="src/main/res/values-id"/>
</issue>

<issue
id="VectorRaster"
message="Resource references will not work correctly in images generated for this vector icon for API &lt; 21; check generated icon to make sure it looks acceptable"
errorLine1=" android:fillColor=&quot;@android:color/white&quot;"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/drawable/ic_flip_24.xml"
line="8"
column="28"/>
</issue>

<issue
id="VectorRaster"
message="Resource references will not work correctly in images generated for this vector icon for API &lt; 21; check generated icon to make sure it looks acceptable"
errorLine1=" android:fillColor=&quot;@android:color/white&quot;"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/drawable/ic_rotate_left_24.xml"
line="8"
column="28"/>
</issue>

<issue
id="VectorRaster"
message="Resource references will not work correctly in images generated for this vector icon for API &lt; 21; check generated icon to make sure it looks acceptable"
errorLine1=" android:fillColor=&quot;@android:color/white&quot;"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/drawable/ic_rotate_right_24.xml"
line="8"
column="28"/>
</issue>

<issue
id="PrivateResource"
message="The resource `@drawable/abc_ic_ab_back_material` is marked as private in androidx.appcompat:appcompat:1.5.1"
Expand Down Expand Up @@ -132,17 +55,6 @@
column="13"/>
</issue>

<issue
id="ObsoleteSdkInt"
message="Unnecessary; SDK_INT is always >= 11"
errorLine1=" @TargetApi(Build.VERSION_CODES.HONEYCOMB)"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/com/canhub/cropper/CropOverlayView.kt"
line="1281"
column="5"/>
</issue>

<issue
id="UnusedResources"
message="The resource `R.string.crop_image_activity_no_permissions` appears to be unused"
Expand All @@ -161,7 +73,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/com/canhub/cropper/CropImageView.kt"
line="1183"
line="1182"
column="19"/>
</issue>

Expand All @@ -172,7 +84,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/com/canhub/cropper/CropImageView.kt"
line="1184"
line="1183"
column="20"/>
</issue>

Expand All @@ -183,7 +95,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/com/canhub/cropper/CropOverlayView.kt"
line="503"
line="484"
column="20"/>
</issue>

Expand All @@ -194,7 +106,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/com/canhub/cropper/CropOverlayView.kt"
line="508"
line="489"
column="7"/>
</issue>

Expand All @@ -205,7 +117,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/com/canhub/cropper/CropOverlayView.kt"
line="509"
line="490"
column="23"/>
</issue>

Expand All @@ -216,7 +128,7 @@
errorLine2=" ~~~~~~~~~~~">
<location
file="src/main/kotlin/com/canhub/cropper/CropOverlayView.kt"
line="510"
line="491"
column="24"/>
</issue>

Expand All @@ -227,7 +139,7 @@
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/kotlin/com/canhub/cropper/CropOverlayView.kt"
line="511"
line="492"
column="22"/>
</issue>

Expand All @@ -238,7 +150,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/com/canhub/cropper/CropOverlayView.kt"
line="654"
line="635"
column="26"/>
</issue>

Expand All @@ -249,7 +161,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/com/canhub/cropper/CropOverlayView.kt"
line="892"
line="869"
column="60"/>
</issue>

Expand Down Expand Up @@ -315,7 +227,7 @@
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/kotlin/com/canhub/cropper/CropOverlayView.kt"
line="1085"
line="1062"
column="16"/>
</issue>

Expand Down
5 changes: 1 addition & 4 deletions cropper/src/main/kotlin/com/canhub/cropper/CropImageView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ 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 @@ -2006,9 +2005,7 @@ 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)
}
mProgressBar.indeterminateTintList = ColorStateList.valueOf(options.progressBarColor)
setProgressBarVisibility()
}

Expand Down
28 changes: 2 additions & 26 deletions cropper/src/main/kotlin/com/canhub/cropper/CropOverlayView.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.canhub.cropper

import android.annotation.TargetApi
import android.content.Context
import android.content.res.Resources
import android.graphics.Canvas
Expand Down Expand Up @@ -262,24 +261,6 @@ class CropOverlayView
fun setCropShape(cropShape: CropShape) {
if (this.cropShape != cropShape) {
this.cropShape = cropShape
if (!CommonVersionCheck.isAtLeastJ18()) {
if (this.cropShape == CropShape.OVAL) {
mOriginalLayerType = layerType

if (mOriginalLayerType != LAYER_TYPE_SOFTWARE) {
setLayerType(
LAYER_TYPE_SOFTWARE,
null,
)
} else {
mOriginalLayerType = null
}
} else if (mOriginalLayerType != null) {
// return hardware acceleration back
setLayerType(mOriginalLayerType!!, null)
mOriginalLayerType = null
}
}
invalidate()
}
}
Expand Down Expand Up @@ -719,7 +700,7 @@ class CropOverlayView
CropShape.RECTANGLE_VERTICAL_ONLY,
CropShape.RECTANGLE_HORIZONTAL_ONLY,
->
if (!isNonStraightAngleRotated || !CommonVersionCheck.isAtLeastJ18()) {
if (!isNonStraightAngleRotated) {
canvas.drawRect(left, top, right, rect.top, mBackgroundPaint!!)
canvas.drawRect(left, rect.bottom, right, bottom, mBackgroundPaint!!)
canvas.drawRect(left, rect.top, rect.left, rect.bottom, mBackgroundPaint!!)
Expand All @@ -745,11 +726,7 @@ class CropOverlayView
}
CropShape.OVAL -> {
mPath.reset()
if (CommonVersionCheck.isAtLeastJ18()) {
mDrawRect[rect.left, rect.top, rect.right] = rect.bottom
} else {
mDrawRect[rect.left + 2, rect.top + 2, rect.right - 2] = rect.bottom - 2
}
mDrawRect[rect.left, rect.top, rect.right] = rect.bottom

mPath.addOval(mDrawRect, Path.Direction.CW)
canvas.save()
Expand Down Expand Up @@ -1278,7 +1255,6 @@ class CropOverlayView
/** Handle scaling the rectangle based on two finger input */
private inner class ScaleListener : SimpleOnScaleGestureListener() {

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
override fun onScale(detector: ScaleGestureDetector): Boolean {
val rect = mCropWindowHandler.getRect()
val x = detector.focusX
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.canhub.cropper.common

import android.os.Build
import android.os.Build.VERSION.SDK_INT
import android.os.Build.VERSION_CODES
import androidx.annotation.ChecksSdkIntAtLeast

object CommonVersionCheck {

fun isAtLeastJ18() = SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2
fun isAtLeastM23() = SDK_INT >= Build.VERSION_CODES.M
fun isAtLeastO26() = SDK_INT >= Build.VERSION_CODES.O
fun isAtLeastQ29() = SDK_INT >= Build.VERSION_CODES.Q
@ChecksSdkIntAtLeast(api = VERSION_CODES.O) fun isAtLeastO26() = SDK_INT >= VERSION_CODES.O
@ChecksSdkIntAtLeast(api = VERSION_CODES.Q) fun isAtLeastQ29() = SDK_INT >= VERSION_CODES.Q
}
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
minSdk = "16"
minSdk = "21"
compileSdk = "33"
targetSdk = "33"

Expand Down
Loading

0 comments on commit f9a853e

Please sign in to comment.