diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index a99b0ad4c..4f6c6fb31 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -17,9 +17,11 @@
+
+
diff --git a/app/build.gradle b/app/build.gradle
index aa3ec5669..7e150a6e1 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -97,6 +97,9 @@ dependencies {
// Settings Screen
implementation(project(":feature:settings"))
+
+ // PostCapture Screen
+ implementation(project(":feature:postcapture"))
}
// Allow references to generated code
diff --git a/app/src/main/java/com/google/jetpackcamera/ui/JcaApp.kt b/app/src/main/java/com/google/jetpackcamera/ui/JcaApp.kt
index 24c3d3fd1..1184a1829 100644
--- a/app/src/main/java/com/google/jetpackcamera/ui/JcaApp.kt
+++ b/app/src/main/java/com/google/jetpackcamera/ui/JcaApp.kt
@@ -27,8 +27,10 @@ import androidx.navigation.compose.rememberNavController
import com.google.accompanist.permissions.ExperimentalPermissionsApi
import com.google.accompanist.permissions.isGranted
import com.google.accompanist.permissions.rememberPermissionState
+import com.google.jetpackcamera.feature.postcapture.PostCaptureScreen
import com.google.jetpackcamera.feature.preview.PreviewScreen
import com.google.jetpackcamera.settings.SettingsScreen
+import com.google.jetpackcamera.ui.Routes.PostCaptureRoute
import com.google.jetpackcamera.ui.Routes.PreviewRoute
import com.google.jetpackcamera.ui.Routes.SettingsRoute
@@ -53,9 +55,13 @@ private fun JetpackCameraNavHost(
NavHost(navController = navController, startDestination = PreviewRoute) {
composable(PreviewRoute) {
PreviewScreen(
- onNavigateToSettings = { navController.navigate(SettingsRoute) }
+ onNavigateToSettings = { navController.navigate(SettingsRoute) },
+ onNavigateToPostCapture = { navController.navigate(PostCaptureRoute) }
)
}
composable(SettingsRoute) { SettingsScreen(navController = navController) }
+ composable(PostCaptureRoute) { PostCaptureScreen(
+ onBackPressed = { navController.navigateUp() }
+ ) }
}
}
diff --git a/app/src/main/java/com/google/jetpackcamera/ui/Routes.kt b/app/src/main/java/com/google/jetpackcamera/ui/Routes.kt
index 973e01a62..7a8db0e97 100644
--- a/app/src/main/java/com/google/jetpackcamera/ui/Routes.kt
+++ b/app/src/main/java/com/google/jetpackcamera/ui/Routes.kt
@@ -19,4 +19,5 @@ package com.google.jetpackcamera.ui
object Routes {
const val PreviewRoute = "preview"
const val SettingsRoute = "settings"
+ const val PostCaptureRoute = "postcapture"
}
\ No newline at end of file
diff --git a/data/storage/.gitignore b/data/storage/.gitignore
new file mode 100644
index 000000000..42afabfd2
--- /dev/null
+++ b/data/storage/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/data/storage/build.gradle.kts b/data/storage/build.gradle.kts
new file mode 100644
index 000000000..8991c052e
--- /dev/null
+++ b/data/storage/build.gradle.kts
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+plugins {
+ id("com.android.library")
+ id("org.jetbrains.kotlin.android")
+ id("kotlin-kapt")
+ id("com.google.dagger.hilt.android")
+}
+
+android {
+ namespace = "com.google.jetpackcamera.storage"
+ compileSdk = 33
+
+ defaultConfig {
+ minSdk = 21
+
+ testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
+ consumerProguardFiles("consumer-rules.pro")
+ }
+
+ buildTypes {
+ release {
+ isMinifyEnabled = false
+ proguardFiles(
+ getDefaultProguardFile("proguard-android-optimize.txt"),
+ "proguard-rules.pro"
+ )
+ }
+ }
+ compileOptions {
+ sourceCompatibility = JavaVersion.VERSION_17
+ targetCompatibility = JavaVersion.VERSION_17
+ }
+ kotlinOptions {
+ jvmTarget = "17"
+ }
+}
+
+dependencies {
+
+ implementation("androidx.core:core-ktx:1.9.0")
+ implementation("androidx.appcompat:appcompat:1.6.1")
+ implementation("com.google.android.material:material:1.9.0")
+ testImplementation("junit:junit:4.13.2")
+ androidTestImplementation("androidx.test.ext:junit:1.1.5")
+ androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
+
+
+ // Hilt
+ implementation("com.google.dagger:hilt-android:2.44")
+ kapt("com.google.dagger:hilt-compiler:2.44")
+}
+
+kapt {
+ correctErrorTypes = true
+}
\ No newline at end of file
diff --git a/data/storage/consumer-rules.pro b/data/storage/consumer-rules.pro
new file mode 100644
index 000000000..e69de29bb
diff --git a/data/storage/proguard-rules.pro b/data/storage/proguard-rules.pro
new file mode 100644
index 000000000..481bb4348
--- /dev/null
+++ b/data/storage/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/data/storage/src/main/AndroidManifest.xml b/data/storage/src/main/AndroidManifest.xml
new file mode 100644
index 000000000..d81265fe5
--- /dev/null
+++ b/data/storage/src/main/AndroidManifest.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/data/storage/src/main/java/com/google/jetpackcamera/storage/ImageCache.kt b/data/storage/src/main/java/com/google/jetpackcamera/storage/ImageCache.kt
new file mode 100644
index 000000000..3af514ef8
--- /dev/null
+++ b/data/storage/src/main/java/com/google/jetpackcamera/storage/ImageCache.kt
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.jetpackcamera.storage
+
+import android.graphics.Bitmap
+import android.media.Image
+
+/**
+ * Used to store a single [Image].
+ */
+interface ImageCache {
+ /**
+ * Save the image into the cache.
+ */
+ fun setImage(image: Bitmap)
+
+ /**
+ * Retrieve the saved image from cache.
+ */
+ fun getImage() : Bitmap?
+}
\ No newline at end of file
diff --git a/data/storage/src/main/java/com/google/jetpackcamera/storage/InMemoryImageCache.kt b/data/storage/src/main/java/com/google/jetpackcamera/storage/InMemoryImageCache.kt
new file mode 100644
index 000000000..c4536c96f
--- /dev/null
+++ b/data/storage/src/main/java/com/google/jetpackcamera/storage/InMemoryImageCache.kt
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.jetpackcamera.storage
+
+import android.graphics.Bitmap
+import android.media.Image
+import android.util.Log
+import javax.inject.Inject
+import javax.inject.Singleton
+
+
+private const val TAG = "InMemoryImageCache"
+
+/**
+ * In-memory implementation of [ImageCache].
+ */
+class InMemoryImageCache @Inject constructor() : ImageCache {
+
+ private var image : Bitmap? = null
+
+ override fun setImage(image: Bitmap) {
+// Log.d(TAG, "setImage $image ($this) ${image.format}")
+ this.image = image
+ }
+
+ override fun getImage(): Bitmap? {
+ Log.d(TAG, "getImage $image ($this)")
+ return image
+ }
+}
\ No newline at end of file
diff --git a/data/storage/src/main/java/com/google/jetpackcamera/storage/StorageModule.kt b/data/storage/src/main/java/com/google/jetpackcamera/storage/StorageModule.kt
new file mode 100644
index 000000000..a7d871b4a
--- /dev/null
+++ b/data/storage/src/main/java/com/google/jetpackcamera/storage/StorageModule.kt
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.jetpackcamera.storage
+
+import dagger.Module
+import dagger.Provides
+import dagger.hilt.InstallIn
+import dagger.hilt.components.SingletonComponent
+import javax.inject.Singleton
+
+@Module
+@InstallIn(SingletonComponent::class)
+class StorageModule {
+
+ @Provides
+ @Singleton
+ fun provideImageCache() : ImageCache = InMemoryImageCache()
+}
\ No newline at end of file
diff --git a/domain/camera/build.gradle b/domain/camera/build.gradle
index 890d9a3a7..246db4874 100644
--- a/domain/camera/build.gradle
+++ b/domain/camera/build.gradle
@@ -56,6 +56,7 @@ dependencies {
kapt "com.google.dagger:hilt-compiler:2.44"
implementation(project(":core:common"))
+ implementation(project(":data:storage"))
}
// Allow references to generated code
diff --git a/domain/camera/src/main/java/com/google/jetpackcamera/domain/camera/CameraXCameraUseCase.kt b/domain/camera/src/main/java/com/google/jetpackcamera/domain/camera/CameraXCameraUseCase.kt
index 10621946c..897079483 100644
--- a/domain/camera/src/main/java/com/google/jetpackcamera/domain/camera/CameraXCameraUseCase.kt
+++ b/domain/camera/src/main/java/com/google/jetpackcamera/domain/camera/CameraXCameraUseCase.kt
@@ -18,6 +18,7 @@ package com.google.jetpackcamera.domain.camera
import android.app.Application
import android.content.ContentValues
+import android.graphics.BitmapFactory
import android.provider.MediaStore
import android.util.Log
import android.util.Rational
@@ -37,13 +38,14 @@ import androidx.camera.video.VideoCapture
import androidx.concurrent.futures.await
import androidx.core.content.ContextCompat
import androidx.core.util.Consumer
-import androidx.lifecycle.LifecycleOwner
+import com.google.jetpackcamera.storage.ImageCache
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.asExecutor
-import java.util.Date
import kotlinx.coroutines.awaitCancellation
import kotlinx.coroutines.coroutineScope
+import java.nio.ByteBuffer
+import java.util.Date
import javax.inject.Inject
private const val TAG = "CameraXCameraUseCase"
@@ -54,7 +56,8 @@ private val ASPECT_RATIO_16_9 = Rational(16, 9)
*/
class CameraXCameraUseCase @Inject constructor(
private val application: Application,
- private val defaultDispatcher: CoroutineDispatcher
+ private val defaultDispatcher: CoroutineDispatcher,
+ private val imageCache: ImageCache
) : CameraUseCase {
private lateinit var cameraProvider: ProcessCameraProvider
@@ -103,8 +106,9 @@ class CameraXCameraUseCase @Inject constructor(
awaitCancellation()
}
}
-
+ @androidx.camera.core.ExperimentalGetImage
override suspend fun takePicture() {
+
val imageDeferred = CompletableDeferred()
imageCaptureUseCase.takePicture(
@@ -116,10 +120,18 @@ class CameraXCameraUseCase @Inject constructor(
}
override fun onError(exception: ImageCaptureException) {
- super.onError(exception)
Log.d(TAG, "takePicture onError: $exception")
}
})
+
+ imageDeferred.await().let {
+ val buffer: ByteBuffer = it.getPlanes().get(0).getBuffer()
+ val bytes = ByteArray(buffer.capacity())
+ buffer[bytes]
+ val bitmapImage = BitmapFactory.decodeByteArray(bytes, 0, bytes.size, null)
+ it.close()
+ imageCache.setImage(bitmapImage)
+ }
}
override suspend fun startVideoRecording() {
diff --git a/feature/postcapture/.gitignore b/feature/postcapture/.gitignore
new file mode 100644
index 000000000..42afabfd2
--- /dev/null
+++ b/feature/postcapture/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/feature/postcapture/build.gradle b/feature/postcapture/build.gradle
new file mode 100644
index 000000000..fbb2ac492
--- /dev/null
+++ b/feature/postcapture/build.gradle
@@ -0,0 +1,86 @@
+plugins {
+ id 'com.android.library'
+ id 'org.jetbrains.kotlin.android'
+ id 'kotlin-kapt'
+ id 'com.google.dagger.hilt.android'
+}
+
+android {
+ namespace 'com.google.jetpackcamera.feature.postcapture'
+ compileSdk 33
+
+ defaultConfig {
+ minSdk 21
+ targetSdk 33
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ consumerProguardFiles "consumer-rules.pro"
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled true
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_17
+ targetCompatibility JavaVersion.VERSION_17
+ }
+
+ kotlin {
+ jvmToolchain(17)
+ }
+
+ buildFeatures {
+ compose true
+ }
+
+ composeOptions {
+ kotlinCompilerExtensionVersion '1.4.0'
+ }
+
+ testOptions {
+ unitTests.returnDefaultValues = true
+ }
+}
+
+dependencies {
+ // Compose
+ def composeBom = platform('androidx.compose:compose-bom:2022.12.00')
+ implementation composeBom
+ androidTestImplementation composeBom
+
+ // Compose - Material Design 3
+ implementation 'androidx.compose.material3:material3'
+
+ // Compose - Android Studio Preview support
+ implementation 'androidx.compose.ui:ui-tooling-preview'
+ debugImplementation 'androidx.compose.ui:ui-tooling'
+
+ // Compose - Integration with ViewModels with Navigation and Hilt
+ implementation("androidx.hilt:hilt-navigation-compose:1.0.0")
+
+ // Compose - Testing
+ androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
+
+ // Testing
+ testImplementation 'junit:junit:4.13.2'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.3'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
+ testImplementation "org.mockito:mockito-core:5.2.0"
+ testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6"
+ implementation 'androidx.test:core-ktx:1.5.0'
+
+ // Hilt
+ implementation "com.google.dagger:hilt-android:2.44"
+ kapt "com.google.dagger:hilt-compiler:2.44"
+
+ implementation(project(":data:storage"))
+ implementation(project(":core:common"))
+}
+
+// Allow references to generated code
+kapt {
+ correctErrorTypes true
+}
diff --git a/feature/postcapture/proguard-rules.pro b/feature/postcapture/proguard-rules.pro
new file mode 100644
index 000000000..481bb4348
--- /dev/null
+++ b/feature/postcapture/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/feature/postcapture/src/main/AndroidManifest.xml b/feature/postcapture/src/main/AndroidManifest.xml
new file mode 100644
index 000000000..d81265fe5
--- /dev/null
+++ b/feature/postcapture/src/main/AndroidManifest.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/feature/postcapture/src/main/java/com/google/jetpackcamera/feature/postcapture/PostCaptureScreen.kt b/feature/postcapture/src/main/java/com/google/jetpackcamera/feature/postcapture/PostCaptureScreen.kt
new file mode 100644
index 000000000..1aa90b6f5
--- /dev/null
+++ b/feature/postcapture/src/main/java/com/google/jetpackcamera/feature/postcapture/PostCaptureScreen.kt
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.jetpackcamera.feature.postcapture
+
+import android.util.Log
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.activity.compose.BackHandler
+import androidx.compose.foundation.Image
+import androidx.compose.foundation.background
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.height
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.rotate
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.asImageBitmap
+import androidx.compose.ui.modifier.modifierLocalConsumer
+import androidx.hilt.navigation.compose.hiltViewModel
+
+private const val TAG = "PostCaptureScreen"
+
+/**
+ * Screen used for showing captured content.
+ */
+@Composable
+fun PostCaptureScreen(
+ onBackPressed: () -> Unit,
+ viewModel: PostCaptureViewModel = hiltViewModel()
+) {
+ Log.d(TAG, "PostCaptureScreen")
+
+ val bitmap = viewModel.getBitmap()
+
+ if (bitmap != null) {
+
+ Box(
+ modifier = Modifier.fillMaxSize().background(Color.Black)
+ ) {
+ Box(
+ modifier = Modifier.rotate(270f).background(Color.Black).fillMaxSize()
+ ) {
+ Image(bitmap = bitmap.asImageBitmap(), contentDescription = "Captured Image", modifier = Modifier.fillMaxSize())
+ }
+ }
+ } else {
+ Text("Nothing captured")
+ }
+
+ BackHandler {
+ onBackPressed()
+ }
+}
\ No newline at end of file
diff --git a/feature/postcapture/src/main/java/com/google/jetpackcamera/feature/postcapture/PostCaptureViewModel.kt b/feature/postcapture/src/main/java/com/google/jetpackcamera/feature/postcapture/PostCaptureViewModel.kt
new file mode 100644
index 000000000..2b839fb96
--- /dev/null
+++ b/feature/postcapture/src/main/java/com/google/jetpackcamera/feature/postcapture/PostCaptureViewModel.kt
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.jetpackcamera.feature.postcapture
+
+import android.app.Application
+import android.graphics.Bitmap
+import android.graphics.BitmapFactory
+import android.media.Image
+import android.util.Log
+import androidx.lifecycle.ViewModel
+import com.google.jetpackcamera.storage.ImageCache
+import dagger.hilt.android.lifecycle.HiltViewModel
+import java.nio.ByteBuffer
+import javax.inject.Inject
+
+
+private const val TAG = "PostCaptureViewModel"
+
+@HiltViewModel
+class PostCaptureViewModel @Inject constructor(
+ private val imageCache: ImageCache,
+) : ViewModel() {
+
+ fun getBitmap() : Bitmap? {
+ Log.d(TAG, "getBitmap")
+ val image = imageCache.getImage()
+
+ if (image != null) {
+ Log.d(TAG, "imageCache.getImage is not null")
+ return image
+ } else {
+ Log.d(TAG, "imageCache.getImage is null")
+ }
+
+ return null
+ }
+}
diff --git a/feature/postcapture/src/main/res/values/strings.xml b/feature/postcapture/src/main/res/values/strings.xml
new file mode 100644
index 000000000..d07d206e4
--- /dev/null
+++ b/feature/postcapture/src/main/res/values/strings.xml
@@ -0,0 +1,18 @@
+
+
+
+
\ No newline at end of file
diff --git a/feature/preview/src/main/java/com/google/jetpackcamera/feature/preview/PreviewScreen.kt b/feature/preview/src/main/java/com/google/jetpackcamera/feature/preview/PreviewScreen.kt
index 9cfccacfb..4ccab2e77 100644
--- a/feature/preview/src/main/java/com/google/jetpackcamera/feature/preview/PreviewScreen.kt
+++ b/feature/preview/src/main/java/com/google/jetpackcamera/feature/preview/PreviewScreen.kt
@@ -59,6 +59,7 @@ private const val TAG = "PreviewScreen"
@Composable
fun PreviewScreen(
onNavigateToSettings: () -> Unit,
+ onNavigateToPostCapture: () -> Unit,
viewModel: PreviewViewModel = hiltViewModel()
) {
Log.d(TAG, "PreviewScreen")
@@ -141,6 +142,11 @@ fun PreviewScreen(
}
}
}
+
+ if (previewUiState.captureState == CaptureState.COMPLETE) {
+ viewModel.clearCaptureState()
+ onNavigateToPostCapture()
+ }
}
@Composable
diff --git a/feature/preview/src/main/java/com/google/jetpackcamera/feature/preview/PreviewUiState.kt b/feature/preview/src/main/java/com/google/jetpackcamera/feature/preview/PreviewUiState.kt
index ab230e7ef..952ce35d2 100644
--- a/feature/preview/src/main/java/com/google/jetpackcamera/feature/preview/PreviewUiState.kt
+++ b/feature/preview/src/main/java/com/google/jetpackcamera/feature/preview/PreviewUiState.kt
@@ -26,6 +26,7 @@ data class PreviewUiState(
val cameraState: CameraState = CameraState.NOT_READY,
val lensFacing: Int = CameraSelector.LENS_FACING_FRONT,
val videoRecordingState: VideoRecordingState = VideoRecordingState.INACTIVE,
+ val captureState: CaptureState = CaptureState.NOT_STARTED,
)
/**
@@ -60,4 +61,19 @@ enum class CameraState {
* Camera is initialized but the preview has been stopped.
*/
PREVIEW_STOPPED
+}
+
+enum class CaptureState {
+ /**
+ * Capture hasn't started
+ */
+ NOT_STARTED,
+ /**
+ * Capture is pending
+ */
+ PENDING,
+ /**
+ * Capture complete
+ */
+ COMPLETE,
}
\ No newline at end of file
diff --git a/feature/preview/src/main/java/com/google/jetpackcamera/feature/preview/PreviewViewModel.kt b/feature/preview/src/main/java/com/google/jetpackcamera/feature/preview/PreviewViewModel.kt
index 79192e74c..bba14d8be 100644
--- a/feature/preview/src/main/java/com/google/jetpackcamera/feature/preview/PreviewViewModel.kt
+++ b/feature/preview/src/main/java/com/google/jetpackcamera/feature/preview/PreviewViewModel.kt
@@ -63,6 +63,16 @@ class PreviewViewModel @Inject constructor(
}
}
+ fun clearCaptureState() {
+ viewModelScope.launch {
+ _previewUiState.emit(
+ previewUiState.value.copy(
+ captureState = CaptureState.NOT_STARTED
+ )
+ )
+ }
+ }
+
fun runCamera(surfaceProvider: SurfaceProvider) {
Log.d(TAG, "runCamera")
stopCamera()
@@ -94,6 +104,11 @@ class PreviewViewModel @Inject constructor(
try {
cameraUseCase.takePicture()
Log.d(TAG, "cameraUseCase.takePicture success")
+ _previewUiState.emit(
+ previewUiState.value.copy(
+ captureState = CaptureState.COMPLETE
+ )
+ )
} catch (exception: ImageCaptureException) {
Log.d(TAG, "cameraUseCase.takePicture error")
Log.d(TAG, exception.toString())
diff --git a/settings.gradle b/settings.gradle
index 6509c497f..45bcea14d 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -21,3 +21,5 @@ include ':feature:settings'
include ':data:settings'
include ':core:common'
include ':feature:quicksettings'
+include ':feature:postcapture'
+include ':data:storage'