@@ -6,7 +6,7 @@ import android.graphics.Paint
66import android.graphics.PorterDuff
77import android.graphics.PorterDuffColorFilter
88import android.graphics.RectF
9- import android.graphics.drawable.VectorDrawable
9+ import android.graphics.drawable.Drawable
1010import androidx.appcompat.content.res.AppCompatResources
1111import androidx.compose.material3.ColorScheme
1212import androidx.compose.runtime.Composable
@@ -37,15 +37,15 @@ import kotlin.random.Random
3737
3838internal data class MaterialShapeQrState (
3939 private val context : Context ,
40- private val arrayOf1x1Shapes : List <VectorDrawable >,
41- private val arrayOf1x1SemiCircleShapes : List <VectorDrawable >,
42- private val arrayOf2x2Shapes : List <VectorDrawable >,
43- private val arrayOf3x3Shapes : List <VectorDrawable >,
44- private val arrayOf7x7Shapes : List <VectorDrawable >,
45- private val arrayOfHorizontalBarShapes : List <VectorDrawable >,
46- private val arrayOfHorizontalHalfCapsuleBarShapes : List <VectorDrawable >,
47- private val arrayOfVerticalBarShapes : List <VectorDrawable >,
48- private val arrayOfFinderPatternCenterShapes : List <VectorDrawable >,
40+ private val arrayOf1x1Shapes : List <Drawable >,
41+ private val arrayOf1x1SemiCircleShapes : List <Drawable >,
42+ private val arrayOf2x2Shapes : List <Drawable >,
43+ private val arrayOf3x3Shapes : List <Drawable >,
44+ private val arrayOf7x7Shapes : List <Drawable >,
45+ private val arrayOfHorizontalBarShapes : List <Drawable >,
46+ private val arrayOfHorizontalHalfCapsuleBarShapes : List <Drawable >,
47+ private val arrayOfVerticalBarShapes : List <Drawable >,
48+ private val arrayOfFinderPatternCenterShapes : List <Drawable >,
4949 private val foregroundColorPrimary : Int ,
5050 private val foregroundColorSecondary : Int ,
5151 private val foregroundColorAccent : Int ,
@@ -116,7 +116,7 @@ internal data class MaterialShapeQrState(
116116 }
117117 }
118118
119- fun randomSquare (shapeSize : Int ): VectorDrawable {
119+ fun randomSquare (shapeSize : Int ): Drawable {
120120 return when (shapeSize) {
121121 1 -> arrayOf1x1Shapes.random()
122122 2 -> arrayOf2x2Shapes.random()
@@ -126,23 +126,23 @@ internal data class MaterialShapeQrState(
126126 }
127127 }
128128
129- fun randomHorizontalBar (barWidth : Int ): VectorDrawable {
129+ fun randomHorizontalBar (barWidth : Int ): Drawable {
130130 return arrayOfHorizontalBarShapes[barWidth - 2 ]
131131 }
132132
133- fun randomHorizontalHalfCapsuleBar (barWidth : Int ): VectorDrawable {
133+ fun randomHorizontalHalfCapsuleBar (barWidth : Int ): Drawable {
134134 return arrayOfHorizontalHalfCapsuleBarShapes[barWidth - 2 ]
135135 }
136136
137- fun randomVerticalBar (barHeight : Int ): VectorDrawable {
137+ fun randomVerticalBar (barHeight : Int ): Drawable {
138138 return arrayOfVerticalBarShapes[barHeight - 2 ]
139139 }
140140
141- fun getSemiCircle (): VectorDrawable {
141+ fun getSemiCircle (): Drawable {
142142 return arrayOf1x1SemiCircleShapes.first()
143143 }
144144
145- fun nextFinderPatternCenter (): VectorDrawable {
145+ fun nextFinderPatternCenter (): Drawable {
146146 val vectorDrawableArr = arrayOfFinderPatternCenterShapes
147147 val index = finderPatternCenterShapeIndex
148148 finderPatternCenterShapeIndex = index + 1
@@ -307,7 +307,7 @@ internal data class MaterialShapeQrState(
307307 width : Int ,
308308 height : Int ,
309309 list : MutableList <MaterialShapeRenderer >,
310- vectorDrawable : VectorDrawable ,
310+ vectorDrawable : Drawable ,
311311 foregroundColor : Int ,
312312 rendererConfigs : (MaterialShapeRenderer ) -> Unit
313313 ) {
@@ -332,7 +332,7 @@ internal data class MaterialShapeQrState(
332332 width : Int ,
333333 height : Int ,
334334 list : MutableList <MaterialShapeRenderer >,
335- vectorDrawable : VectorDrawable ,
335+ vectorDrawable : Drawable ,
336336 rendererConfigs : (MaterialShapeRenderer ) -> Unit
337337 ) {
338338 createRendererForShape(
@@ -594,22 +594,21 @@ internal fun rememberMaterialShapeQrState(
594594 }
595595 }
596596
597- val arrayOf1x1Shapes = remember { mutableStateListOf<VectorDrawable >() }
598- val arrayOf1x1SemiCircleShapes = remember { mutableStateListOf<VectorDrawable >() }
599- val arrayOf2x2Shapes = remember { mutableStateListOf<VectorDrawable >() }
600- val arrayOf3x3Shapes = remember { mutableStateListOf<VectorDrawable >() }
601- val arrayOf7x7Shapes = remember { mutableStateListOf<VectorDrawable >() }
597+ val arrayOf1x1Shapes = remember { mutableStateListOf<Drawable >() }
598+ val arrayOf1x1SemiCircleShapes = remember { mutableStateListOf<Drawable >() }
599+ val arrayOf2x2Shapes = remember { mutableStateListOf<Drawable >() }
600+ val arrayOf3x3Shapes = remember { mutableStateListOf<Drawable >() }
601+ val arrayOf7x7Shapes = remember { mutableStateListOf<Drawable >() }
602602
603- val arrayOfHorizontalBarShapes = remember { mutableStateListOf<VectorDrawable >() }
604- val arrayOfHorizontalHalfCapsuleBarShapes = remember { mutableStateListOf<VectorDrawable >() }
605- val arrayOfVerticalBarShapes = remember { mutableStateListOf<VectorDrawable >() }
606- val arrayOfFinderPatternCenterShapes = remember { mutableStateListOf<VectorDrawable >() }
603+ val arrayOfHorizontalBarShapes = remember { mutableStateListOf<Drawable >() }
604+ val arrayOfHorizontalHalfCapsuleBarShapes = remember { mutableStateListOf<Drawable >() }
605+ val arrayOfVerticalBarShapes = remember { mutableStateListOf<Drawable >() }
606+ val arrayOfFinderPatternCenterShapes = remember { mutableStateListOf<Drawable >() }
607607
608608 val colorMap = remember { mutableStateMapOf<String , Int >() }
609609
610- fun loadVectorDrawable (resId : Int ): VectorDrawable {
611- val drawable = AppCompatResources .getDrawable(context, resId)
612- return drawable as VectorDrawable
610+ fun loadVectorDrawable (resId : Int ): Drawable {
611+ return AppCompatResources .getDrawable(context, resId)!!
613612 }
614613
615614 fun loadDrawables () {
0 commit comments