@@ -3,6 +3,7 @@ package co.stonephone.stonecamera.plugins
33import android.content.ContentResolver
44import android.graphics.Bitmap
55import android.graphics.BitmapFactory
6+ import android.graphics.Matrix
67import android.media.ExifInterface
78import android.net.Uri
89import androidx.camera.core.ImageCapture
@@ -120,7 +121,7 @@ class PortraitModePlugin : IPlugin {
120121 if (rotation == 0 ) {
121122 return image;
122123 }
123- val matrix = android.graphics. Matrix ().apply { postRotate(rotation.toFloat()) }
124+ val matrix = Matrix ().apply { postRotate(rotation.toFloat()) }
124125 return Bitmap .createBitmap(
125126 image,
126127 0 ,
@@ -264,35 +265,38 @@ class PortraitModePlugin : IPlugin {
264265 return img
265266 }
266267
267- override val settings: List <PluginSetting > = listOf (
268- PluginSetting .EnumSetting (
269- key = " portraitMode" ,
270- defaultValue = " OFF" ,
271- options = listOf (" OFF" , " ON" ),
272- render = { isEnabled ->
273- Icon (
274- imageVector = when (isEnabled) {
275- " OFF" -> Icons .Default .PersonOff
276- " ON" -> Icons .Default .Portrait
277- else -> {
278- Icons .Default .PersonOff
279- }
280- },
281- contentDescription = when (isEnabled) {
282- " OFF" -> " Portrait Mode Off"
283- " ON" -> " Portrait Mode On"
284- else -> {
285- " Portrait Mode Off"
286- }
287- },
288- tint = Color .White
289- )
290-
291- },
292- onChange = { viewModel, value ->
293- viewModel.recreateUseCases()
294- },
295- renderLocation = SettingLocation .TOP
268+ override val settings: (StoneCameraViewModel ) -> List <PluginSetting > = { viewModel ->
269+ listOf (
270+ PluginSetting .EnumSetting (
271+ key = " portraitMode" ,
272+ defaultValue = " OFF" ,
273+ options = listOf (" OFF" , " ON" ),
274+ render = { isEnabled, isSelected ->
275+ Icon (
276+ imageVector = when (isEnabled) {
277+ " OFF" -> Icons .Default .PersonOff
278+ " ON" -> Icons .Default .Portrait
279+ else -> {
280+ Icons .Default .PersonOff
281+ }
282+ },
283+ contentDescription = when (isEnabled) {
284+ " OFF" -> " Portrait Mode Off"
285+ " ON" -> " Portrait Mode On"
286+ else -> {
287+ " Portrait Mode Off"
288+ }
289+ },
290+ tint = if (isSelected) Color (0xFFFFCC00 ) else Color .White
291+ )
292+
293+ },
294+ onChange = { viewModel, value ->
295+ viewModel.recreateUseCases()
296+ },
297+ renderLocation = SettingLocation .TOP ,
298+ label = " Portrait Mode"
299+ )
296300 )
297- )
301+ }
298302}
0 commit comments