Skip to content

Commit bf799aa

Browse files
committed
Replace CameraScreen workaround with proper fix
The issue being worked around with PR#4 was fixed in CameraX in https://android-review.googlesource.com/c/platform/frameworks/support/+/3630671 This fixes some of the instability with rotation, as well as with tabletop mode, allowing us to remove the workaround.
1 parent 8542006 commit bf799aa

File tree

2 files changed

+2
-20
lines changed

2 files changed

+2
-20
lines changed

feature/camera/src/main/java/com/android/developers/androidify/camera/CameraScreen.kt

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ import androidx.compose.runtime.mutableFloatStateOf
4747
import androidx.compose.runtime.remember
4848
import androidx.compose.runtime.rememberCoroutineScope
4949
import androidx.compose.runtime.setValue
50-
import androidx.compose.runtime.snapshotFlow
5150
import androidx.compose.ui.Alignment
5251
import androidx.compose.ui.Modifier
5352
import androidx.compose.ui.geometry.Offset
@@ -71,7 +70,6 @@ import com.google.accompanist.permissions.ExperimentalPermissionsApi
7170
import com.google.accompanist.permissions.isGranted
7271
import com.google.accompanist.permissions.rememberPermissionState
7372
import com.google.accompanist.permissions.shouldShowRationale
74-
import kotlinx.coroutines.flow.takeWhile
7573
import kotlinx.coroutines.launch
7674

7775
@OptIn(
@@ -131,22 +129,6 @@ fun CameraPreviewScreen(
131129
}
132130

133131
uiState.surfaceRequest?.let { surface ->
134-
// Workaround for https://issuetracker.google.com/275157240
135-
// When switching to/from tabletop posture, the underlying SurfaceView
136-
// destroys its Surface. Invalidate the SurfaceRequest when this happens
137-
// so CameraX can retrieve the new Surface.
138-
LaunchedEffect(surface) {
139-
val oldIsTableTop = isTableTopPosture(foldingFeature)
140-
141-
snapshotFlow { foldingFeature }
142-
.takeWhile {
143-
val newIsTableTop = isTableTopPosture(it)
144-
val shouldInvalidate = oldIsTableTop != newIsTableTop
145-
if (shouldInvalidate) surface.invalidate()
146-
!shouldInvalidate
147-
}.collect {}
148-
}
149-
150132
CameraPreviewContent(
151133
surfaceRequest = surface,
152134
autofocusUiState = uiState.autofocusUiState,

settings.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pluginManagement {
1212
maven {
1313
// You can find the maven URL for other artifacts (e.g. KMP, METALAVA) on their
1414
// build pages.
15-
url = uri("https://androidx.dev/snapshots/builds/13496591/artifacts/repository")
15+
url = uri("https://androidx.dev/snapshots/builds/13511472/artifacts/repository")
1616
}
1717

1818
}
@@ -23,7 +23,7 @@ dependencyResolutionManagement {
2323
google()
2424
mavenCentral()
2525
maven {
26-
url = uri("https://androidx.dev/snapshots/builds/13496591/artifacts/repository")
26+
url = uri("https://androidx.dev/snapshots/builds/13511472/artifacts/repository")
2727
}
2828
}
2929
}

0 commit comments

Comments
 (0)