Add front camera preview and camera switch UI
This commit is contained in:
parent
5be04b0217
commit
9deeb40217
5 changed files with 594 additions and 21 deletions
|
|
@ -57,6 +57,7 @@ class MainActivity : ComponentActivity() {
|
|||
@Inject lateinit var authSessionStore: AuthSessionStore
|
||||
|
||||
@Volatile private var isAuthenticated = false
|
||||
private var frontPreviewOpened = false
|
||||
|
||||
companion object {
|
||||
private const val TAG = "MainActivity"
|
||||
|
|
@ -97,7 +98,16 @@ class MainActivity : ComponentActivity() {
|
|||
})
|
||||
|
||||
lifecycleScope.launch {
|
||||
authSessionStore.token.collect { token -> isAuthenticated = !token.isNullOrBlank() }
|
||||
authSessionStore.token.collect { token ->
|
||||
isAuthenticated = !token.isNullOrBlank()
|
||||
|
||||
if (isAuthenticated && !frontPreviewOpened) {
|
||||
frontPreviewOpened = true
|
||||
runOnUiThread {
|
||||
openFrontPreview()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
registerHardwareReceiver()
|
||||
|
|
@ -222,6 +232,20 @@ class MainActivity : ComponentActivity() {
|
|||
}
|
||||
|
||||
|
||||
|
||||
private fun openFrontPreview() {
|
||||
if (!isAuthenticated) return
|
||||
|
||||
startActivity(
|
||||
android.content.Intent(
|
||||
this,
|
||||
com.bodycamera.twentyfoulabs.camera.M530CameraActivity::class.java
|
||||
).putExtra(
|
||||
com.bodycamera.twentyfoulabs.camera.M530CameraActivity.EXTRA_MODE,
|
||||
com.bodycamera.twentyfoulabs.camera.M530CameraActivity.MODE_FRONT_PREVIEW
|
||||
).addFlags(android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
||||
)
|
||||
}
|
||||
private fun handlePhotoButton() {
|
||||
startActivity(
|
||||
android.content.Intent(
|
||||
|
|
@ -374,3 +398,4 @@ fun AppNavigation(viewModel: MainViewModel, onOpenPhotoCamera: () -> Unit, onOpe
|
|||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue