File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
app/shared/src/main/kotlin/dev/aaa1115910/m3qrcode Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -5,9 +5,10 @@ import android.graphics.Paint
55import android.graphics.Rect
66import android.graphics.RectF
77import android.graphics.drawable.VectorDrawable
8- import kotlin.math.cos
8+ import android.os.Build
99import androidx.core.graphics.withRotation
1010import androidx.core.graphics.withSave
11+ import kotlin.math.cos
1112
1213class MaterialShapeRenderer {
1314 var animationStyle: EntryAnimationStyle
@@ -60,12 +61,15 @@ class MaterialShapeRenderer {
6061
6162 private fun draw (canvas : Canvas , rectF : RectF , paint : Paint ) {
6263 canvas.withRotation(initialRotation * 90.0f , rectF.centerX(), rectF.centerY()) {
63- val vectorDrawable = srcImgSvg
64+ val vectorDrawable = if (Build .VERSION .SDK_INT <= Build .VERSION_CODES .P ) {
65+ runCatching { srcImgSvg.constantState!! .newDrawable().mutate() }
66+ .getOrDefault(srcImgSvg)
67+ } else srcImgSvg
6468 val rect = Rect ()
6569 rectF.round(rect)
6670 vectorDrawable.bounds = rect
67- srcImgSvg.setColorFilter( paint.colorFilter)
68- srcImgSvg .draw(this )
71+ vectorDrawable.colorFilter = paint.colorFilter
72+ vectorDrawable .draw(this )
6973 }
7074 }
7175
You can’t perform that action at this time.
0 commit comments