Modern Apps git

← Modern-Apps.git

camera: new app

Commit
17583f7e25d9074c9a0f90756c3e650957b8c39e
Author
Vayun Mathur <[email protected]>
When
2026-06-11 04:28 UTC (5 months ago)
Parents
6db1673

Diff

.idea/deploymentTargetSelector.xml
diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xmlindex deeeb0dec3..82b58028a6 100644--- a/.idea/deploymentTargetSelector.xml+++ b/.idea/deploymentTargetSelector.xml@@ -98,6 +98,10 @@         <option name="selectionMode" value="DROPDOWN" />         <DialogSelection />       </SelectionState>+      <SelectionState runConfigName="camera">+        <option name="selectionMode" value="DROPDOWN" />+        <DialogSelection />+      </SelectionState>     </selectionStates>   </component> </project>\ No newline at end of file
.idea/gradle.xml
diff --git a/.idea/gradle.xml b/.idea/gradle.xmlindex 5393f7e6e6..f2e4abb121 100644--- a/.idea/gradle.xml+++ b/.idea/gradle.xml@@ -23,6 +23,7 @@             <option value="$PROJECT_DIR$" />             <option value="$PROJECT_DIR$/build-logic" />             <option value="$PROJECT_DIR$/calendar" />+            <option value="$PROJECT_DIR$/camera" />             <option value="$PROJECT_DIR$/clock" />             <option value="$PROJECT_DIR$/contacts" />             <option value="$PROJECT_DIR$/email" />
camera/build.gradle.kts
diff --git a/camera/build.gradle.kts b/camera/build.gradle.ktsnew file mode 100644index 0000000000..10d905c0c4--- /dev/null+++ b/camera/build.gradle.kts@@ -0,0 +1,19 @@+plugins {+    id("common-conventions-app")+}++android {+    defaultConfig {+        applicationId = "com.vayunmathur.camera"+    }+}++dependencies {+    implementation(libs.androidx.camera.core)+    implementation(libs.androidx.camera.camera2)+    implementation(libs.androidx.camera.lifecycle)+    implementation(libs.androidx.camera.view)+    implementation(libs.zxing.core)+    implementation("com.google.mediapipe:tasks-vision:0.10.14")+    implementation("org.opencv:opencv:4.10.0")+}
camera/src/main/AndroidManifest.xml
diff --git a/camera/src/main/AndroidManifest.xml b/camera/src/main/AndroidManifest.xmlnew file mode 100644index 0000000000..112543c8dd--- /dev/null+++ b/camera/src/main/AndroidManifest.xml@@ -0,0 +1,40 @@+<?xml version="1.0" encoding="utf-8"?>+<manifest xmlns:android="http://schemas.android.com/apk/res/android">++    <uses-permission android:name="android.permission.CAMERA" />+    <uses-permission android:name="android.permission.RECORD_AUDIO" />+    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />+    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />++    <uses-feature android:name="android.hardware.camera" android:required="true" />+    <uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />++    <application+        android:allowBackup="true"+        android:dataExtractionRules="@xml/data_extraction_rules"+        android:icon="@mipmap/ic_launcher"+        android:label="@string/app_name"+        android:roundIcon="@mipmap/ic_launcher"+        android:supportsRtl="true"+        android:theme="@style/Theme.General">+        <activity+            android:name=".MainActivity"+            android:exported="true"+            android:screenOrientation="portrait"+            android:theme="@style/Theme.General">+            <intent-filter>+                <action android:name="android.intent.action.MAIN" />+                <category android:name="android.intent.category.LAUNCHER" />+            </intent-filter>+            <intent-filter>+                <action android:name="android.media.action.IMAGE_CAPTURE" />+                <category android:name="android.intent.category.DEFAULT" />+            </intent-filter>+            <intent-filter>+                <action android:name="android.media.action.VIDEO_CAPTURE" />+                <category android:name="android.intent.category.DEFAULT" />+            </intent-filter>+        </activity>+    </application>++</manifest>
camera/src/main/assets/selfie_segmenter.tflite
diff --git a/camera/src/main/assets/selfie_segmenter.tflite b/camera/src/main/assets/selfie_segmenter.tflitenew file mode 100644index 0000000000..a4ebd4777eBinary files /dev/null and b/camera/src/main/assets/selfie_segmenter.tflite differ
camera/src/main/ic_launcher-playstore.png
diff --git a/camera/src/main/ic_launcher-playstore.png b/camera/src/main/ic_launcher-playstore.pngnew file mode 100644index 0000000000..1592ad914bBinary files /dev/null and b/camera/src/main/ic_launcher-playstore.png differ
camera/src/main/java/com/vayunmathur/camera/MainActivity.kt
diff --git a/camera/src/main/java/com/vayunmathur/camera/MainActivity.kt b/camera/src/main/java/com/vayunmathur/camera/MainActivity.ktnew file mode 100644index 0000000000..7d7e53aea1--- /dev/null+++ b/camera/src/main/java/com/vayunmathur/camera/MainActivity.kt@@ -0,0 +1,54 @@+package com.vayunmathur.camera++import android.Manifest+import android.os.Bundle+import androidx.activity.ComponentActivity+import androidx.activity.compose.setContent+import androidx.activity.enableEdgeToEdge+import androidx.activity.viewModels+import com.vayunmathur.camera.ui.CameraScreen+import com.vayunmathur.camera.ui.SettingsPage+import com.vayunmathur.camera.util.CameraViewModel+import com.vayunmathur.library.ui.DynamicTheme+import com.vayunmathur.library.ui.PermissionsChecker+import com.vayunmathur.library.util.DialogPage+import com.vayunmathur.library.util.MainNavigation+import com.vayunmathur.library.util.NavKey+import com.vayunmathur.library.util.rememberNavBackStack+import kotlinx.serialization.Serializable++@Serializable+sealed interface Route : NavKey {+    @Serializable+    data object Camera : Route+    @Serializable+    data object Settings : Route+}++class MainActivity : ComponentActivity() {+    private val viewModel: CameraViewModel by viewModels()++    override fun onCreate(savedInstanceState: Bundle?) {+        super.onCreate(savedInstanceState)+        enableEdgeToEdge()++        setContent {+            DynamicTheme {+                PermissionsChecker(+                    permissions = arrayOf(Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO),+                    text = getString(R.string.grant_camera_permission)+                ) {+                    val backStack = rememberNavBackStack<Route>(Route.Camera)+                    MainNavigation(backStack) {+                        entry<Route.Camera> {+                            CameraScreen(backStack, viewModel)+                        }+                        entry<Route.Settings>(metadata = DialogPage()) {+                            SettingsPage(backStack, viewModel)+                        }+                    }+                }+            }+        }+    }+}
camera/src/main/java/com/vayunmathur/camera/ui/CameraScreen.kt
diff --git a/camera/src/main/java/com/vayunmathur/camera/ui/CameraScreen.kt b/camera/src/main/java/com/vayunmathur/camera/ui/CameraScreen.ktnew file mode 100644index 0000000000..8dbdbb4c0b--- /dev/null+++ b/camera/src/main/java/com/vayunmathur/camera/ui/CameraScreen.kt@@ -0,0 +1,777 @@+package com.vayunmathur.camera.ui++import android.content.ClipData+import android.content.ClipboardManager+import android.content.Context+import android.content.Intent+import android.net.Uri+import android.provider.MediaStore+import android.util.Patterns+import android.view.MotionEvent+import android.graphics.BitmapShader+import android.graphics.Matrix+import android.graphics.RenderEffect+import android.graphics.RuntimeShader+import android.graphics.Shader+import androidx.camera.core.CameraSelector+import androidx.camera.core.FocusMeteringAction+import androidx.camera.core.SurfaceOrientedMeteringPointFactory+import androidx.camera.view.CameraController+import androidx.camera.view.LifecycleCameraController+import androidx.camera.view.PreviewView+import androidx.compose.animation.core.animateFloatAsState+import androidx.compose.animation.core.spring+import androidx.compose.animation.core.tween+import androidx.compose.foundation.background+import androidx.compose.foundation.border+import androidx.compose.foundation.clickable+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.Spacer+import androidx.compose.foundation.layout.aspectRatio+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.size+import androidx.compose.foundation.shape.CircleShape+import androidx.compose.foundation.shape.RoundedCornerShape+import androidx.compose.material3.Button+import androidx.compose.material3.FilledTonalButton+import androidx.compose.material3.Icon+import androidx.compose.material3.IconButton+import androidx.compose.material3.MaterialTheme+import androidx.compose.material3.Scaffold+import androidx.compose.material3.Text+import androidx.compose.material3.TextButton+import androidx.compose.runtime.Composable+import androidx.compose.runtime.DisposableEffect+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.collectAsState+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.Alignment+import androidx.compose.ui.ExperimentalComposeUiApi+import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.clip+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.asComposeRenderEffect+import androidx.compose.ui.graphics.graphicsLayer+import androidx.compose.ui.input.pointer.pointerInteropFilter+import androidx.compose.ui.platform.LocalContext+import androidx.compose.ui.res.painterResource+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.text.font.FontWeight+import androidx.compose.ui.text.style.TextAlign+import androidx.compose.ui.unit.dp+import androidx.compose.ui.unit.sp+import androidx.compose.ui.viewinterop.AndroidView+import androidx.core.content.ContextCompat+import androidx.lifecycle.compose.LocalLifecycleOwner+import com.vayunmathur.camera.R+import com.vayunmathur.camera.Route+import com.vayunmathur.camera.util.AspectRatioOption+import com.vayunmathur.camera.util.BokehAnalyzer+import com.vayunmathur.camera.util.CameraMode+import com.vayunmathur.camera.util.CameraViewModel+import com.vayunmathur.camera.util.FlashMode+import com.vayunmathur.camera.util.QrAnalyzer+import com.vayunmathur.camera.util.TimerDuration+import com.vayunmathur.library.util.NavBackStack++private val ZOOM_LEVELS = listOf(".5" to 0.5f, "1x" to 1f, "2" to 2f, "5" to 5f)++private const val BOKEH_SHADER = """+    uniform shader cameraInput;+    uniform shader alphaMask;+    +    half4 main(float2 fragCoord) {+        float maskAlpha = alphaMask.eval(fragCoord).a;+        +        if (maskAlpha > 0.5) {+            return cameraInput.eval(fragCoord);+        }+        +        half4 blur = half4(0.0);+        float samples = 0.0;+        +        for (float x = -16.0; x <= 16.0; x += 2.0) {+            for (float y = -16.0; y <= 16.0; y += 2.0) {+                blur += cameraInput.eval(fragCoord + float2(x, y));+                samples += 1.0;+            }+        }+        +        half4 sharp = cameraInput.eval(fragCoord);+        half4 blurred = blur / samples;+        return mix(blurred, sharp, maskAlpha);+    }+"""++@Composable+fun CameraScreen(backStack: NavBackStack<Route>, viewModel: CameraViewModel) {+    val context = LocalContext.current+    val lifecycleOwner = LocalLifecycleOwner.current++    val cameraMode by viewModel.cameraMode.collectAsState()+    val lensFacing by viewModel.lensFacing.collectAsState()+    val flashMode by viewModel.flashMode.collectAsState()+    val isRecording by viewModel.isRecording.collectAsState()+    val timerCountdown by viewModel.timerCountdown.collectAsState()+    val qrResult by viewModel.qrResult.collectAsState()+    val aspectRatio by viewModel.aspectRatio.collectAsState()+    val zoomRatio by viewModel.zoomRatio.collectAsState()+    val timerDuration by viewModel.timerDuration.collectAsState()+    val isCapturing by viewModel.isCapturing.collectAsState()++    var maskBitmap by remember { mutableStateOf<android.graphics.Bitmap?>(null) }+    val isPhotoType = cameraMode in listOf(CameraMode.PHOTO, CameraMode.PORTRAIT, CameraMode.PANORAMA)+    val bokehShader = remember { lazy { RuntimeShader(BOKEH_SHADER) } }++    val panoSweeping by viewModel.panoramaEngine.isSweeping.collectAsState()+    val panoStitching by viewModel.panoramaEngine.isStitching.collectAsState()+    val panoFrameCount by viewModel.panoramaEngine.frameCount.collectAsState()+    val panoAngle by viewModel.panoramaEngine.sweepAngle.collectAsState()++    val animatedZoom by animateFloatAsState(+        targetValue = zoomRatio,+        animationSpec = tween(durationMillis = 300)+    )++    val controller = remember { LifecycleCameraController(context) }++    LaunchedEffect(lensFacing) {+        controller.cameraSelector = CameraSelector.Builder()+            .requireLensFacing(lensFacing)+            .build()+    }++    LaunchedEffect(Unit) {+        viewModel.updateLocation()+    }++    LaunchedEffect(flashMode) {+        controller.imageCaptureFlashMode = viewModel.getImageCaptureFlashMode()+    }++    LaunchedEffect(animatedZoom) {+        val zoomState = controller.zoomState.value+        if (zoomState != null) {+            val clamped = animatedZoom.coerceIn(zoomState.minZoomRatio, zoomState.maxZoomRatio)+            controller.setZoomRatio(clamped)+        } else {+            controller.setZoomRatio(animatedZoom)+        }+    }++    LaunchedEffect(cameraMode) {+        if (cameraMode == CameraMode.PHOTO || cameraMode == CameraMode.PORTRAIT || cameraMode == CameraMode.PANORAMA) {+            controller.setEnabledUseCases(CameraController.IMAGE_CAPTURE or CameraController.IMAGE_ANALYSIS)+            when (cameraMode) {+                CameraMode.PORTRAIT -> {+                    controller.setImageAnalysisAnalyzer(+                        ContextCompat.getMainExecutor(context),+                        BokehAnalyzer(context) { mask -> maskBitmap = mask }+                    )+                }+                CameraMode.PANORAMA -> {+                    maskBitmap = null+                    controller.setImageAnalysisAnalyzer(+                        ContextCompat.getMainExecutor(context)+                    ) @androidx.annotation.OptIn(androidx.camera.core.ExperimentalGetImage::class) { imageProxy ->+                        viewModel.panoramaEngine.latestFrame = imageProxy.toBitmap()+                        imageProxy.close()+                    }+                }+                else -> {+                    maskBitmap = null+                    controller.setImageAnalysisAnalyzer(+                        ContextCompat.getMainExecutor(context),+                        QrAnalyzer { text -> viewModel.setQrResult(text) }+                    )+                }+            }+        } else {+            maskBitmap = null+            controller.setEnabledUseCases(CameraController.VIDEO_CAPTURE)+            controller.clearImageAnalysisAnalyzer()+            viewModel.setQrResult(null)+        }+    }++    DisposableEffect(Unit) {+        controller.bindToLifecycle(lifecycleOwner)+        onDispose { }+    }++    val previewAspectRatio = when (aspectRatio) {+        AspectRatioOption.RATIO_16_9 -> 9f / 16f+        AspectRatioOption.RATIO_4_3 -> 3f / 4f+        AspectRatioOption.RATIO_1_1 -> 1f+    }++    Scaffold(+        containerColor = Color.Black+    ) { padding ->+        Box(modifier = Modifier.fillMaxSize().padding(padding)) {+            Column(modifier = Modifier.fillMaxSize()) {+                TopBar(+                    flashMode = flashMode,+                    onFlashToggle = {+                        val next = when (flashMode) {+                            FlashMode.OFF -> FlashMode.ON+                            FlashMode.ON -> FlashMode.AUTO+                            FlashMode.AUTO -> FlashMode.OFF+                        }+                        viewModel.setFlashMode(next)+                    }+                )++                Box(+                    modifier = Modifier+                        .fillMaxWidth()+                        .weight(1f),+                    contentAlignment = Alignment.Center+                ) {+                    @OptIn(ExperimentalComposeUiApi::class)+                    AndroidView(+                        factory = { ctx ->+                            PreviewView(ctx).apply {+                                this.controller = controller+                                scaleType = PreviewView.ScaleType.FIT_CENTER+                                implementationMode = PreviewView.ImplementationMode.COMPATIBLE+                            }+                        },+                        modifier = Modifier+                            .fillMaxWidth()+                            .aspectRatio(previewAspectRatio)+                            .clip(RoundedCornerShape(12.dp))+                            .then(+                                if (cameraMode == CameraMode.PORTRAIT && maskBitmap != null) {+                                    Modifier.graphicsLayer {+                                        val mask = maskBitmap!!+                                        val shader = bokehShader.value+                                        val maskShader = BitmapShader(mask, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP)+                                        val matrix = Matrix()+                                        matrix.setScale(size.width / mask.width, size.height / mask.height)+                                        maskShader.setLocalMatrix(matrix)+                                        shader.setInputShader("alphaMask", maskShader)+                                        renderEffect = RenderEffect+                                            .createRuntimeShaderEffect(shader, "cameraInput")+                                            .asComposeRenderEffect()+                                    }+                                } else {+                                    Modifier.graphicsLayer { renderEffect = null }+                                }+                            )+                            .pointerInteropFilter { event ->+                                if (event.action == MotionEvent.ACTION_UP) {+                                    val factory = SurfaceOrientedMeteringPointFactory(+                                        event.x, event.y+                                    )+                                    val point = factory.createPoint(event.x, event.y)+                                    val action = FocusMeteringAction.Builder(point).build()+                                    controller.cameraControl?.startFocusAndMetering(action)+                                }+                                false+                            }+                    )++                    if (timerCountdown > 0) {+                        Text(+                            text = "$timerCountdown",+                            fontSize = 96.sp,+                            color = Color.White,+                            textAlign = TextAlign.Center+                        )+                    }++                    ZoomBar(+                        currentZoom = zoomRatio,+                        onZoomSelected = { viewModel.setZoomRatio(it) },+                        modifier = Modifier.align(Alignment.BottomCenter).padding(bottom = 16.dp)+                    )+                }++                ShutterRow(+                    cameraMode = cameraMode,+                    isRecording = isRecording,+                    isCapturing = isCapturing,+                    onCapture = {+                        when {+                            cameraMode == CameraMode.PANORAMA -> {+                                if (panoSweeping) viewModel.stopPanorama()+                                else viewModel.startPanorama()+                            }+                            isPhotoType -> viewModel.takePhoto(controller)+                            else -> viewModel.toggleRecording(controller)+                        }+                    },+                    onFlipCamera = { viewModel.flipCamera() },+                    onGallery = {+                        context.startActivity(+                            Intent(Intent.ACTION_VIEW, MediaStore.Images.Media.EXTERNAL_CONTENT_URI)+                        )+                    }+                )++                ModeSelector(+                    cameraMode = cameraMode,+                    isPhotoType = isPhotoType,+                    onModeSelected = { viewModel.setCameraMode(it) }+                )++                BottomBar(+                    cameraMode = cameraMode,+                    isPhotoType = isPhotoType,+                    timerDuration = timerDuration,+                    onPickerChanged = { photo ->+                        if (photo) {+                            viewModel.setCameraMode(CameraMode.PHOTO)+                        } else {+                            viewModel.setCameraMode(CameraMode.VIDEO)+                        }+                    },+                    onSettingsClick = { backStack.add(Route.Settings) },+                    onTimerCycle = {+                        val next = when (timerDuration) {+                            TimerDuration.NONE -> TimerDuration.THREE+                            TimerDuration.THREE -> TimerDuration.FIVE+                            TimerDuration.FIVE -> TimerDuration.TEN+                            TimerDuration.TEN -> TimerDuration.NONE+                        }+                        viewModel.setTimerDuration(next)+                    }+                )+            }++            if (qrResult != null) {+                QrResultOverlay(+                    text = qrResult!!,+                    onDismiss = { viewModel.setQrResult(null) },+                    context = context,+                    modifier = Modifier+                        .align(Alignment.BottomCenter)+                        .padding(bottom = 280.dp)+                )+            }++            if (cameraMode == CameraMode.PANORAMA && (panoSweeping || panoStitching)) {+                PanoramaOverlay(+                    isSweeping = panoSweeping,+                    isStitching = panoStitching,+                    frameCount = panoFrameCount,+                    sweepAngle = panoAngle,+                    modifier = Modifier.align(Alignment.TopCenter).padding(top = 60.dp)+                )+            }+        }+    }+}++@Composable+private fun TopBar(+    flashMode: FlashMode,+    onFlashToggle: () -> Unit+) {+    Row(+        modifier = Modifier+            .fillMaxWidth()+            .padding(horizontal = 8.dp, vertical = 8.dp),+        verticalAlignment = Alignment.CenterVertically+    ) {+        val flashBg = when (flashMode) {+            FlashMode.ON -> Color(0xFF3C3C3C)+            FlashMode.OFF -> Color.Transparent+            FlashMode.AUTO -> Color(0xFF3C3C3C)+        }+        IconButton(+            onClick = onFlashToggle,+            modifier = Modifier+                .size(40.dp)+                .background(flashBg, CircleShape)+        ) {+            Icon(+                painterResource(+                    when (flashMode) {+                        FlashMode.ON -> R.drawable.flash_on_24px+                        FlashMode.OFF -> R.drawable.flash_off_24px+                        FlashMode.AUTO -> R.drawable.flash_auto_24px+                    }+                ),+                contentDescription = null,+                tint = Color.White,+                modifier = Modifier.size(22.dp)+            )+        }+    }+}++@Composable+private fun ZoomBar(currentZoom: Float, onZoomSelected: (Float) -> Unit, modifier: Modifier = Modifier) {+    Row(+        modifier = modifier+            .background(Color(0x99000000), RoundedCornerShape(24.dp))+            .padding(horizontal = 6.dp, vertical = 4.dp),+        horizontalArrangement = Arrangement.spacedBy(2.dp),+        verticalAlignment = Alignment.CenterVertically+    ) {+        ZOOM_LEVELS.forEach { (label, ratio) ->+            val isSelected = currentZoom == ratio+            Box(+                modifier = Modifier+                    .size(36.dp)+                    .then(+                        if (isSelected) Modifier.background(Color(0xFF3C3C3C), CircleShape)+                        else Modifier+                    )+                    .clip(CircleShape)+                    .clickable { onZoomSelected(ratio) },+                contentAlignment = Alignment.Center+            ) {+                Text(+                    label,+                    color = if (isSelected) Color.White else Color(0xFFBBBBBB),+                    fontSize = 13.sp,+                    fontWeight = if (isSelected) FontWeight.Bold else FontWeight.Normal+                )+            }+        }+    }+}++@Composable+private fun ShutterRow(+    cameraMode: CameraMode,+    isRecording: Boolean,+    isCapturing: Boolean,+    onCapture: () -> Unit,+    onFlipCamera: () -> Unit,+    onGallery: () -> Unit+) {+    val shutterScale by animateFloatAsState(+        targetValue = if (isCapturing) 0.8f else 1f,+        animationSpec = spring(dampingRatio = 0.4f, stiffness = 800f)+    )++    Row(+        modifier = Modifier+            .fillMaxWidth()+            .padding(horizontal = 32.dp, vertical = 16.dp),+        horizontalArrangement = Arrangement.SpaceBetween,+        verticalAlignment = Alignment.CenterVertically+    ) {+        Box(+            modifier = Modifier+                .size(48.dp)+                .clip(RoundedCornerShape(8.dp))+                .background(Color(0xFF3C3C3C))+                .clickable(onClick = onGallery),+            contentAlignment = Alignment.Center+        ) {+            Icon(+                painterResource(R.drawable.ic_photo_library),+                contentDescription = stringResource(R.string.open_gallery),+                tint = Color.White,+                modifier = Modifier.size(24.dp)+            )+        }++        Box(+            modifier = Modifier+                .size((76 * shutterScale).dp)+                .border(3.dp, Color.White, CircleShape)+                .padding(5.dp)+                .clip(CircleShape)+                .background(+                    if (isRecording) Color.Red+                    else if (cameraMode in listOf(CameraMode.VIDEO, CameraMode.SLOW_MO, CameraMode.TIMELAPSE)) Color.Red+                    else Color.White+                )+                .clickable(onClick = onCapture)+        )++        Box(+            modifier = Modifier+                .size(48.dp)+                .background(Color(0xFF3C3C3C), CircleShape)+                .clickable(onClick = onFlipCamera),+            contentAlignment = Alignment.Center+        ) {+            Icon(+                painterResource(R.drawable.flip_camera_android_24px),+                contentDescription = stringResource(R.string.flip_camera),+                tint = Color.White,+                modifier = Modifier.size(24.dp)+            )+        }+    }+}++@Composable+private fun ModeSelector(+    cameraMode: CameraMode,+    isPhotoType: Boolean,+    onModeSelected: (CameraMode) -> Unit+) {+    Row(+        modifier = Modifier.fillMaxWidth(),+        horizontalArrangement = Arrangement.Center,+        verticalAlignment = Alignment.CenterVertically+    ) {+        val modes = if (isPhotoType) {+            listOf(+                CameraMode.PORTRAIT to "Portrait",+                CameraMode.PHOTO to "Photo",+                CameraMode.PANORAMA to "Pano"+            )+        } else {+            listOf(+                CameraMode.SLOW_MO to "Slo-Mo",+                CameraMode.VIDEO to "Video",+                CameraMode.TIMELAPSE to "Timelapse"+            )+        }+        modes.forEach { (mode, label) ->+            val isSelected = cameraMode == mode+            Text(+                text = label,+                color = Color.White,+                fontSize = 14.sp,+                fontWeight = if (isSelected) FontWeight.Bold else FontWeight.Normal,+                modifier = Modifier+                    .then(+                        if (isSelected) Modifier.background(Color(0xFF3C3C3C), RoundedCornerShape(20.dp))+                        else Modifier+                    )+                    .clickable { if (!isSelected) onModeSelected(mode) }+                    .padding(horizontal = 16.dp, vertical = 6.dp)+            )+        }+    }+}++@Composable+private fun BottomBar(+    cameraMode: CameraMode,+    isPhotoType: Boolean,+    timerDuration: TimerDuration,+    onPickerChanged: (Boolean) -> Unit,+    onSettingsClick: () -> Unit,+    onTimerCycle: () -> Unit+) {+    Row(+        modifier = Modifier+            .fillMaxWidth()+            .padding(horizontal = 16.dp, vertical = 8.dp),+        horizontalArrangement = Arrangement.SpaceBetween,+        verticalAlignment = Alignment.CenterVertically+    ) {+        Box(+            modifier = Modifier+                .size(44.dp)+                .background(Color(0xFF3C3C3C), CircleShape)+                .clickable(onClick = onSettingsClick),+            contentAlignment = Alignment.Center+        ) {+            Icon(+                painterResource(com.vayunmathur.library.R.drawable.settings_24px),+                contentDescription = stringResource(R.string.settings),+                tint = Color.White,+                modifier = Modifier.size(22.dp)+            )+        }++        Row(+            modifier = Modifier+                .background(Color(0xFF3C3C3C), RoundedCornerShape(20.dp))+                .padding(4.dp),+            verticalAlignment = Alignment.CenterVertically+        ) {+            Box(+                modifier = Modifier+                    .size(36.dp)+                    .then(+                        if (isPhotoType) Modifier.background(Color(0xFF5C5C5C), CircleShape)+                        else Modifier+                    )+                    .clickable { if (!isPhotoType) onPickerChanged(true) },+                contentAlignment = Alignment.Center+            ) {+                Icon(+                    painterResource(R.drawable.photo_camera_24px),+                    contentDescription = stringResource(R.string.mode_photo),+                    tint = Color.White,+                    modifier = Modifier.size(20.dp)+                )+            }+            Box(+                modifier = Modifier+                    .size(36.dp)+                    .then(+                        if (!isPhotoType) Modifier.background(Color(0xFF5C5C5C), CircleShape)+                        else Modifier+                    )+                    .clickable { if (isPhotoType) onPickerChanged(false) },+                contentAlignment = Alignment.Center+            ) {+                Icon(+                    painterResource(R.drawable.video_camera_back_24px),+                    contentDescription = stringResource(R.string.mode_video),+                    tint = Color.White,+                    modifier = Modifier.size(20.dp)+                )+            }+        }++        if (isPhotoType) {+            val timerLabel = when (timerDuration) {+                TimerDuration.NONE -> ""+                TimerDuration.THREE -> "3"+                TimerDuration.FIVE -> "5"+                TimerDuration.TEN -> "10"+            }+            val timerBg = if (timerDuration != TimerDuration.NONE) MaterialTheme.colorScheme.primary else Color(0xFF3C3C3C)+            Box(+                modifier = Modifier+                    .size(44.dp)+                    .background(timerBg, CircleShape)+                    .clickable(onClick = onTimerCycle),+                contentAlignment = Alignment.Center+            ) {+                if (timerDuration == TimerDuration.NONE) {+                    Icon(+                        painterResource(R.drawable.ic_timer),+                        contentDescription = stringResource(R.string.settings_timer),+                        tint = Color.White,+                        modifier = Modifier.size(22.dp)+                    )+                } else {+                    Column(horizontalAlignment = Alignment.CenterHorizontally) {+                        Icon(+                            painterResource(R.drawable.ic_timer),+                            contentDescription = null,+                            tint = Color.White,+                            modifier = Modifier.size(14.dp)+                        )+                        Text(timerLabel, color = Color.White, fontSize = 10.sp, fontWeight = FontWeight.Bold, lineHeight = 10.sp)+                    }+                }+            }+        } else {+            // Invisible spacer to maintain layout+            Spacer(Modifier.size(44.dp))+        }+    }+}++@Composable+private fun QrResultOverlay(text: String, onDismiss: () -> Unit, context: Context, modifier: Modifier = Modifier) {+    Column(+        modifier = modifier+            .padding(16.dp)+            .background(+                MaterialTheme.colorScheme.surfaceContainer,+                RoundedCornerShape(16.dp)+            )+            .padding(16.dp),+        horizontalAlignment = Alignment.CenterHorizontally+    ) {+        Text(+            stringResource(R.string.qr_result),+            style = MaterialTheme.typography.titleSmall,+            color = MaterialTheme.colorScheme.onSurface+        )+        Text(+            text,+            style = MaterialTheme.typography.bodyMedium,+            color = MaterialTheme.colorScheme.onSurfaceVariant,+            modifier = Modifier.padding(vertical = 8.dp)+        )+        Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {+            if (Patterns.WEB_URL.matcher(text).matches()) {+                Button(onClick = {+                    val url = if (!text.startsWith("http")) "https://$text" else text+                    context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)))+                }) {+                    Text(stringResource(R.string.open_url))+                }+            }+            FilledTonalButton(onClick = {+                val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager+                clipboard.setPrimaryClip(ClipData.newPlainText("QR", text))+            }) {+                Text(stringResource(R.string.copy_text))+            }+            TextButton(onClick = onDismiss) {+                Text(stringResource(android.R.string.cancel))+            }+        }+    }+}++@Composable+private fun PanoramaOverlay(+    isSweeping: Boolean,+    isStitching: Boolean,+    frameCount: Int,+    sweepAngle: Float,+    modifier: Modifier = Modifier+) {+    Column(+        modifier = modifier+            .background(Color(0xCC000000), RoundedCornerShape(16.dp))+            .padding(horizontal = 24.dp, vertical = 12.dp),+        horizontalAlignment = Alignment.CenterHorizontally+    ) {+        if (isStitching) {+            Text(+                "Processing panoramaโ€ฆ",+                color = Color.White,+                fontSize = 16.sp,+                fontWeight = FontWeight.Bold+            )+        } else if (isSweeping) {+            Text(+                "โ† Sweep slowly โ†’",+                color = Color.White,+                fontSize = 16.sp,+                fontWeight = FontWeight.Bold+            )+            Spacer(Modifier.size(4.dp))+            Row(+                horizontalArrangement = Arrangement.spacedBy(8.dp),+                verticalAlignment = Alignment.CenterVertically+            ) {+                Text(+                    "$frameCount frames",+                    color = Color(0xFFBBBBBB),+                    fontSize = 13.sp+                )+                Text("โ€ข", color = Color(0xFF888888), fontSize = 13.sp)+                Text(+                    "${sweepAngle.toInt()}ยฐ",+                    color = Color(0xFFBBBBBB),+                    fontSize = 13.sp+                )+            }++            Spacer(Modifier.size(8.dp))+            Box(+                modifier = Modifier+                    .fillMaxWidth(0.6f)+                    .background(Color(0xFF444444), RoundedCornerShape(4.dp))+            ) {+                Box(+                    modifier = Modifier+                        .fillMaxWidth((sweepAngle / 180f).coerceIn(0f, 1f))+                        .background(Color.White, RoundedCornerShape(4.dp))+                        .size(4.dp)+                )+            }+        }+    }+}
camera/src/main/java/com/vayunmathur/camera/ui/SettingsPage.kt
diff --git a/camera/src/main/java/com/vayunmathur/camera/ui/SettingsPage.kt b/camera/src/main/java/com/vayunmathur/camera/ui/SettingsPage.ktnew file mode 100644index 0000000000..2ebad6f8b6--- /dev/null+++ b/camera/src/main/java/com/vayunmathur/camera/ui/SettingsPage.kt@@ -0,0 +1,150 @@+package com.vayunmathur.camera.ui++import android.Manifest+import android.content.pm.PackageManager+import androidx.activity.compose.rememberLauncherForActivityResult+import androidx.activity.result.contract.ActivityResultContracts+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.Spacer+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.height+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.rememberScrollState+import androidx.compose.foundation.selection.selectable+import androidx.compose.foundation.selection.selectableGroup+import androidx.compose.foundation.verticalScroll+import androidx.compose.material3.ExperimentalMaterial3Api+import androidx.compose.material3.MaterialTheme+import androidx.compose.material3.RadioButton+import androidx.compose.material3.Scaffold+import androidx.compose.material3.Switch+import androidx.compose.material3.Text+import androidx.compose.material3.TopAppBar+import androidx.compose.runtime.Composable+import androidx.compose.runtime.collectAsState+import androidx.compose.runtime.getValue+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.platform.LocalContext+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.semantics.Role+import androidx.compose.ui.unit.dp+import androidx.core.content.ContextCompat+import com.vayunmathur.camera.R+import com.vayunmathur.camera.util.AspectRatioOption+import com.vayunmathur.camera.util.CameraViewModel+import com.vayunmathur.library.ui.IconNavigation+import com.vayunmathur.library.util.NavBackStack+import com.vayunmathur.library.util.NavKey++@OptIn(ExperimentalMaterial3Api::class)+@Composable+fun <T : NavKey> SettingsPage(backStack: NavBackStack<T>, viewModel: CameraViewModel) {+    val aspectRatio by viewModel.aspectRatio.collectAsState()+    val locationEnabled by viewModel.locationEnabled.collectAsState()+    val context = LocalContext.current++    val locationPermissionLauncher = rememberLauncherForActivityResult(+        ActivityResultContracts.RequestPermission()+    ) { granted ->+        viewModel.setLocationEnabled(granted)+        if (granted) viewModel.updateLocation()+    }++    Scaffold(+        topBar = {+            TopAppBar(+                title = { Text(stringResource(R.string.settings)) },+                navigationIcon = { IconNavigation(backStack) }+            )+        }+    ) { padding ->+        Column(+            modifier = Modifier+                .fillMaxSize()+                .padding(padding)+                .verticalScroll(rememberScrollState())+                .padding(16.dp)+        ) {+            SettingsSection(stringResource(R.string.settings_aspect_ratio)) {+                RadioGroup(+                    options = AspectRatioOption.entries.map { it to it.label },+                    selected = aspectRatio,+                    onSelect = { viewModel.setAspectRatio(it) }+                )+            }++            SettingsSection(stringResource(R.string.settings_location)) {+                Row(+                    modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp),+                    verticalAlignment = Alignment.CenterVertically+                ) {+                    Text(+                        stringResource(R.string.settings_location_description),+                        style = MaterialTheme.typography.bodyLarge,+                        modifier = Modifier.weight(1f)+                    )+                    Switch(+                        checked = locationEnabled,+                        onCheckedChange = { enabled ->+                            if (enabled) {+                                val hasPermission = ContextCompat.checkSelfPermission(+                                    context, Manifest.permission.ACCESS_FINE_LOCATION+                                ) == PackageManager.PERMISSION_GRANTED+                                if (hasPermission) {+                                    viewModel.setLocationEnabled(true)+                                    viewModel.updateLocation()+                                } else {+                                    locationPermissionLauncher.launch(Manifest.permission.ACCESS_FINE_LOCATION)+                                }+                            } else {+                                viewModel.setLocationEnabled(false)+                            }+                        }+                    )+                }+            }+        }+    }+}++@Composable+private fun SettingsSection(title: String, content: @Composable () -> Unit) {+    Text(+        text = title,+        style = MaterialTheme.typography.titleMedium,+        color = MaterialTheme.colorScheme.primary+    )+    Spacer(modifier = Modifier.height(4.dp))+    content()+    Spacer(modifier = Modifier.height(16.dp))+}++@Composable+private fun <T> RadioGroup(options: List<Pair<T, String>>, selected: T, onSelect: (T) -> Unit) {+    Column(Modifier.selectableGroup()) {+        options.forEach { (value, label) ->+            Row(+                Modifier+                    .fillMaxWidth()+                    .height(40.dp)+                    .selectable(+                        selected = value == selected,+                        onClick = { onSelect(value) },+                        role = Role.RadioButton+                    )+                    .padding(horizontal = 8.dp),+                verticalAlignment = Alignment.CenterVertically+            ) {+                RadioButton(selected = value == selected, onClick = null)+                Text(+                    text = label,+                    style = MaterialTheme.typography.bodyLarge,+                    modifier = Modifier.padding(start = 12.dp)+                )+            }+        }+    }+}
camera/src/main/java/com/vayunmathur/camera/util/BokehAnalyzer.kt
diff --git a/camera/src/main/java/com/vayunmathur/camera/util/BokehAnalyzer.kt b/camera/src/main/java/com/vayunmathur/camera/util/BokehAnalyzer.ktnew file mode 100644index 0000000000..5971c91b2a--- /dev/null+++ b/camera/src/main/java/com/vayunmathur/camera/util/BokehAnalyzer.kt@@ -0,0 +1,64 @@+package com.vayunmathur.camera.util++import android.content.Context+import android.graphics.Bitmap+import android.graphics.Color+import androidx.camera.core.ImageAnalysis+import androidx.camera.core.ImageProxy+import com.google.mediapipe.framework.image.BitmapImageBuilder+import com.google.mediapipe.framework.image.ByteBufferExtractor+import com.google.mediapipe.tasks.core.BaseOptions+import com.google.mediapipe.tasks.vision.core.RunningMode+import com.google.mediapipe.tasks.vision.imagesegmenter.ImageSegmenter++class BokehAnalyzer(+    context: Context,+    private val onMaskGenerated: (Bitmap) -> Unit+) : ImageAnalysis.Analyzer {++    private val imageSegmenter: ImageSegmenter++    init {+        val baseOptions = BaseOptions.builder()+            .setModelAssetPath("selfie_segmenter.tflite")+            .build()++        val options = ImageSegmenter.ImageSegmenterOptions.builder()+            .setBaseOptions(baseOptions)+            .setRunningMode(RunningMode.LIVE_STREAM)+            .setOutputCategoryMask(false)+            .setOutputConfidenceMasks(true)+            .setResultListener { result, _ ->+                val masks = result.confidenceMasks()+                if (masks.isPresent && masks.get().isNotEmpty()) {+                    val mpImage = masks.get()[0]+                    val w = mpImage.width+                    val h = mpImage.height+                    val floatBuffer = ByteBufferExtractor.extract(mpImage).asFloatBuffer()+                    floatBuffer.rewind()+                    val pixels = IntArray(w * h)+                    for (i in pixels.indices) {+                        val alpha = (floatBuffer.get().coerceIn(0f, 1f) * 255).toInt()+                        pixels[i] = Color.argb(alpha, 255, 255, 255)+                    }+                    val maskBitmap = Bitmap.createBitmap(pixels, w, h, Bitmap.Config.ARGB_8888)+                    onMaskGenerated(maskBitmap)+                }+            }+            .build()++        imageSegmenter = ImageSegmenter.createFromOptions(context, options)+    }++    @androidx.annotation.OptIn(androidx.camera.core.ExperimentalGetImage::class)+    override fun analyze(imageProxy: ImageProxy) {+        val bitmap = imageProxy.toBitmap()+        val mpImage = BitmapImageBuilder(bitmap).build()+        imageSegmenter.segmentAsync(mpImage, imageProxy.imageInfo.timestamp)+        imageProxy.close()+    }++    fun close() {+        imageSegmenter.close()+    }+}
camera/src/main/java/com/vayunmathur/camera/util/CameraViewModel.kt
diff --git a/camera/src/main/java/com/vayunmathur/camera/util/CameraViewModel.kt b/camera/src/main/java/com/vayunmathur/camera/util/CameraViewModel.ktnew file mode 100644index 0000000000..94c32f62ca--- /dev/null+++ b/camera/src/main/java/com/vayunmathur/camera/util/CameraViewModel.kt@@ -0,0 +1,269 @@+package com.vayunmathur.camera.util++import android.app.Application+import android.content.ContentValues+import android.content.Context+import android.location.Location+import android.location.LocationManager+import android.os.Environment+import android.provider.MediaStore+import androidx.camera.core.CameraSelector+import androidx.camera.core.ImageCapture+import androidx.camera.core.ImageCaptureException+import androidx.camera.video.FileOutputOptions+import androidx.camera.video.Recording+import androidx.camera.video.VideoRecordEvent+import androidx.camera.view.CameraController+import androidx.camera.view.LifecycleCameraController+import androidx.camera.view.video.AudioConfig+import androidx.lifecycle.AndroidViewModel+import androidx.lifecycle.viewModelScope+import com.vayunmathur.library.util.DataStoreUtils+import kotlinx.coroutines.delay+import kotlinx.coroutines.flow.MutableStateFlow+import kotlinx.coroutines.flow.asStateFlow+import kotlinx.coroutines.launch+import java.text.SimpleDateFormat+import java.util.Date+import java.util.Locale++enum class CameraMode { PHOTO, PORTRAIT, PANORAMA, VIDEO, SLOW_MO, TIMELAPSE }+enum class FlashMode { ON, OFF, AUTO }+enum class TimerDuration(val seconds: Int) { NONE(0), THREE(3), FIVE(5), TEN(10) }+enum class AspectRatioOption(val label: String) { RATIO_16_9("16:9"), RATIO_4_3("4:3"), RATIO_1_1("1:1") }++class CameraViewModel(private val app: Application) : AndroidViewModel(app) {+    private val ds = DataStoreUtils.getInstance(app)++    private val _cameraMode = MutableStateFlow(CameraMode.PHOTO)+    val cameraMode = _cameraMode.asStateFlow()++    private val _lensFacing = MutableStateFlow(CameraSelector.LENS_FACING_BACK)+    val lensFacing = _lensFacing.asStateFlow()++    private val _flashMode = MutableStateFlow(FlashMode.OFF)+    val flashMode = _flashMode.asStateFlow()++    private val _timerDuration = MutableStateFlow(TimerDuration.NONE)+    val timerDuration = _timerDuration.asStateFlow()++    private val _aspectRatio = MutableStateFlow(AspectRatioOption.RATIO_4_3)+    val aspectRatio = _aspectRatio.asStateFlow()++    private val _isRecording = MutableStateFlow(false)+    val isRecording = _isRecording.asStateFlow()++    private val _timerCountdown = MutableStateFlow(0)+    val timerCountdown = _timerCountdown.asStateFlow()++    private val _qrResult = MutableStateFlow<String?>(null)+    val qrResult = _qrResult.asStateFlow()++    private val _zoomRatio = MutableStateFlow(1f)+    val zoomRatio = _zoomRatio.asStateFlow()++    private val _isCapturing = MutableStateFlow(false)+    val isCapturing = _isCapturing.asStateFlow()++    private val _locationEnabled = MutableStateFlow(false)+    val locationEnabled = _locationEnabled.asStateFlow()++    private var lastLocation: Location? = null+    private var currentRecording: Recording? = null++    val panoramaEngine = PanoramaEngine(app)++    init {+        loadSettings()+    }++    private fun loadSettings() {+        ds.getString("camera_flash")?.let { _flashMode.value = FlashMode.valueOf(it) }+        ds.getString("camera_timer")?.let { _timerDuration.value = TimerDuration.valueOf(it) }+        ds.getString("camera_aspect_ratio")?.let { _aspectRatio.value = AspectRatioOption.valueOf(it) }+        ds.getString("camera_location")?.let { _locationEnabled.value = it.toBoolean() }+    }++    fun setFlashMode(mode: FlashMode) {+        _flashMode.value = mode+        viewModelScope.launch { ds.setString("camera_flash", mode.name) }+    }++    fun setTimerDuration(duration: TimerDuration) {+        _timerDuration.value = duration+        viewModelScope.launch { ds.setString("camera_timer", duration.name) }+    }++    fun setAspectRatio(ratio: AspectRatioOption) {+        _aspectRatio.value = ratio+        viewModelScope.launch { ds.setString("camera_aspect_ratio", ratio.name) }+    }++    fun setLocationEnabled(enabled: Boolean) {+        _locationEnabled.value = enabled+        viewModelScope.launch { ds.setString("camera_location", enabled.toString()) }+    }++    fun setCameraMode(mode: CameraMode) {+        _cameraMode.value = mode+    }++    fun flipCamera() {+        _lensFacing.value = if (_lensFacing.value == CameraSelector.LENS_FACING_BACK)+            CameraSelector.LENS_FACING_FRONT else CameraSelector.LENS_FACING_BACK+    }++    fun setQrResult(text: String?) {+        _qrResult.value = text+    }++    fun setZoomRatio(ratio: Float) {+        _zoomRatio.value = ratio+    }++    @android.annotation.SuppressLint("MissingPermission")+    fun updateLocation() {+        if (!_locationEnabled.value) return+        try {+            val lm = app.getSystemService(Context.LOCATION_SERVICE) as LocationManager+            lastLocation = lm.getLastKnownLocation(LocationManager.FUSED_PROVIDER)+                ?: lm.getLastKnownLocation(LocationManager.GPS_PROVIDER)+        } catch (_: Exception) { }+    }++    fun takePhoto(controller: LifecycleCameraController) {+        val timer = _timerDuration.value+        if (timer.seconds > 0) {+            viewModelScope.launch {+                for (i in timer.seconds downTo 1) {+                    _timerCountdown.value = i+                    delay(1000)+                }+                _timerCountdown.value = 0+                capturePhoto(controller)+            }+        } else {+            capturePhoto(controller)+        }+    }++    private fun capturePhoto(controller: LifecycleCameraController) {+        _isCapturing.value = true+        val timestamp = SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(Date())+        val contentValues = ContentValues().apply {+            put(MediaStore.MediaColumns.DISPLAY_NAME, "IMG_$timestamp.jpg")+            put(MediaStore.MediaColumns.MIME_TYPE, "image/jpeg")+            put(MediaStore.MediaColumns.RELATIVE_PATH, Environment.DIRECTORY_DCIM + "/Camera")+        }++        val metadata = ImageCapture.Metadata().apply {+            if (_locationEnabled.value && lastLocation != null) {+                location = lastLocation+            }+        }++        val outputOptions = ImageCapture.OutputFileOptions.Builder(+            app.contentResolver,+            MediaStore.Images.Media.EXTERNAL_CONTENT_URI,+            contentValues+        ).setMetadata(metadata).build()++        controller.takePicture(+            outputOptions,+            androidx.core.content.ContextCompat.getMainExecutor(app),+            object : ImageCapture.OnImageSavedCallback {+                override fun onImageSaved(outputFileResults: ImageCapture.OutputFileResults) {+                    _isCapturing.value = false+                }+                override fun onError(exception: ImageCaptureException) {+                    _isCapturing.value = false+                }+            }+        )+    }++    @android.annotation.SuppressLint("MissingPermission")+    fun toggleRecording(controller: LifecycleCameraController) {+        if (_isRecording.value) {+            currentRecording?.stop()+            currentRecording = null+            _isRecording.value = false+            return+        }++        val timestamp = SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(Date())+        val prefix = when (_cameraMode.value) {+            CameraMode.SLOW_MO -> "SLOMO"+            CameraMode.TIMELAPSE -> "TL"+            else -> "VID"+        }+        val contentValues = ContentValues().apply {+            put(MediaStore.MediaColumns.DISPLAY_NAME, "${prefix}_$timestamp")+            put(MediaStore.MediaColumns.MIME_TYPE, "video/mp4")+            put(MediaStore.MediaColumns.RELATIVE_PATH, Environment.DIRECTORY_DCIM + "/Camera")+        }++        val mediaStoreOutput = MediaStore.Video.Media.EXTERNAL_CONTENT_URI+        val cacheFile = java.io.File(app.cacheDir, "VID_$timestamp.mp4")+        val outputOptions = FileOutputOptions.Builder(cacheFile).build()+        val recordingMode = _cameraMode.value++        _isRecording.value = true+        currentRecording = controller.startRecording(+            outputOptions,+            AudioConfig.create(recordingMode == CameraMode.VIDEO),+            androidx.core.content.ContextCompat.getMainExecutor(app)+        ) { event ->+            if (event is VideoRecordEvent.Finalize) {+                _isRecording.value = false+                viewModelScope.launch(kotlinx.coroutines.Dispatchers.IO) {+                    if (!cacheFile.exists()) return@launch+                    val fileToSave = when (recordingMode) {+                        CameraMode.SLOW_MO -> {+                            val processed = java.io.File(app.cacheDir, "SLOMO_$timestamp.mp4")+                            VideoProcessor.adjustSpeed(cacheFile, processed, 0.25f)+                            cacheFile.delete()+                            processed+                        }+                        CameraMode.TIMELAPSE -> {+                            val processed = java.io.File(app.cacheDir, "TL_$timestamp.mp4")+                            VideoProcessor.adjustSpeed(cacheFile, processed, 8f)+                            cacheFile.delete()+                            processed+                        }+                        else -> cacheFile+                    }+                    val uri = app.contentResolver.insert(mediaStoreOutput, contentValues)+                    uri?.let {+                        app.contentResolver.openOutputStream(it)?.use { os ->+                            fileToSave.inputStream().use { input -> input.copyTo(os) }+                        }+                    }+                    fileToSave.delete()+                }+            }+        }+    }++    fun startPanorama() {+        panoramaEngine.startSweep()+    }++    fun stopPanorama() {+        panoramaEngine.stopSweep()+        viewModelScope.launch {+            val result = panoramaEngine.stitch()+            if (result != null) {+                panoramaEngine.saveToMediaStore(result)+                result.recycle()+            }+            panoramaEngine.reset()+        }+    }++    fun getImageCaptureFlashMode(): Int = when (_flashMode.value) {+        FlashMode.ON -> ImageCapture.FLASH_MODE_ON+        FlashMode.OFF -> ImageCapture.FLASH_MODE_OFF+        FlashMode.AUTO -> ImageCapture.FLASH_MODE_AUTO+    }+}
camera/src/main/java/com/vayunmathur/camera/util/PanoramaEngine.kt
diff --git a/camera/src/main/java/com/vayunmathur/camera/util/PanoramaEngine.kt b/camera/src/main/java/com/vayunmathur/camera/util/PanoramaEngine.ktnew file mode 100644index 0000000000..194e793cea--- /dev/null+++ b/camera/src/main/java/com/vayunmathur/camera/util/PanoramaEngine.kt@@ -0,0 +1,285 @@+package com.vayunmathur.camera.util++import android.content.ContentValues+import android.content.Context+import android.graphics.Bitmap+import android.hardware.Sensor+import android.hardware.SensorEvent+import android.hardware.SensorEventListener+import android.hardware.SensorManager+import android.os.Environment+import android.provider.MediaStore+import kotlinx.coroutines.Dispatchers+import kotlinx.coroutines.flow.MutableStateFlow+import kotlinx.coroutines.flow.asStateFlow+import kotlinx.coroutines.withContext+import org.opencv.android.OpenCVLoader+import org.opencv.android.Utils+import org.opencv.calib3d.Calib3d+import org.opencv.core.Core+import org.opencv.core.CvType+import org.opencv.core.DMatch+import org.opencv.core.Mat+import org.opencv.core.MatOfByte+import org.opencv.core.MatOfDMatch+import org.opencv.core.MatOfKeyPoint+import org.opencv.core.MatOfPoint2f+import org.opencv.core.Point+import org.opencv.core.Rect+import org.opencv.core.Size+import org.opencv.features2d.BFMatcher+import org.opencv.features2d.ORB+import org.opencv.imgproc.Imgproc+import java.text.SimpleDateFormat+import java.util.Date+import java.util.Locale++class PanoramaEngine(private val context: Context) : SensorEventListener {++    private val sensorManager = context.getSystemService(Context.SENSOR_SERVICE) as SensorManager+    private val gyroscope = sensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE)++    private val _isSweeping = MutableStateFlow(false)+    val isSweeping = _isSweeping.asStateFlow()++    private val _isStitching = MutableStateFlow(false)+    val isStitching = _isStitching.asStateFlow()++    private val _frameCount = MutableStateFlow(0)+    val frameCount = _frameCount.asStateFlow()++    private val _sweepAngle = MutableStateFlow(0f)+    val sweepAngle = _sweepAngle.asStateFlow()++    private val frames = mutableListOf<Bitmap>()+    private var accumulatedAngle = 0f+    private var lastTimestamp = 0L+    private var lastCaptureAngle = 0f++    @Volatile+    var latestFrame: Bitmap? = null++    companion object {+        private const val CAPTURE_INTERVAL_DEGREES = 25f+        private const val MAX_FRAMES = 8+        private const val MAX_SWEEP_DEGREES = 180f+        private const val FRAME_SCALE = 0.5f++        init {+            OpenCVLoader.initLocal()+        }+    }++    fun startSweep() {+        frames.clear()+        accumulatedAngle = 0f+        lastCaptureAngle = 0f+        lastTimestamp = 0L+        _frameCount.value = 0+        _sweepAngle.value = 0f+        _isSweeping.value = true+        captureFrame()+        gyroscope?.let {+            sensorManager.registerListener(this, it, SensorManager.SENSOR_DELAY_UI)+        }+    }++    fun stopSweep() {+        _isSweeping.value = false+        sensorManager.unregisterListener(this)+    }++    private fun captureFrame() {+        val frame = latestFrame ?: return+        val w = (frame.width * FRAME_SCALE).toInt()+        val h = (frame.height * FRAME_SCALE).toInt()+        val scaled = Bitmap.createScaledBitmap(frame, w, h, true)+        frames.add(scaled)+        _frameCount.value = frames.size+        lastCaptureAngle = accumulatedAngle+    }++    override fun onSensorChanged(event: SensorEvent) {+        if (!_isSweeping.value) return+        if (event.sensor.type != Sensor.TYPE_GYROSCOPE) return++        val timestamp = event.timestamp+        if (lastTimestamp != 0L) {+            val dt = (timestamp - lastTimestamp) / 1_000_000_000f+            val yawRate = Math.toDegrees(event.values[1].toDouble()).toFloat()+            accumulatedAngle += Math.abs(yawRate * dt).toFloat()+            _sweepAngle.value = accumulatedAngle+        }+        lastTimestamp = timestamp++        if (accumulatedAngle - lastCaptureAngle >= CAPTURE_INTERVAL_DEGREES+            && frames.size < MAX_FRAMES+        ) {+            captureFrame()+        }++        if (accumulatedAngle >= MAX_SWEEP_DEGREES || frames.size >= MAX_FRAMES) {+            stopSweep()+        }+    }++    override fun onAccuracyChanged(sensor: Sensor?, accuracy: Int) {}++    suspend fun stitch(): Bitmap? {+        if (frames.size < 2) return null+        _isStitching.value = true+        return withContext(Dispatchers.IO) {+            try {+                val mats = frames.map { bmp ->+                    val mat = Mat()+                    Utils.bitmapToMat(bmp, mat)+                    mat+                }++                var result = mats[0].clone()+                val orb = ORB.create(1000)+                val matcher = BFMatcher.create(Core.NORM_HAMMING, true)++                for (i in 1 until mats.size) {+                    result = stitchPair(result, mats[i], orb, matcher) ?: run {+                        mats.forEach { it.release() }+                        return@withContext null+                    }+                }++                mats.forEach { it.release() }++                val bitmap = Bitmap.createBitmap(result.cols(), result.rows(), Bitmap.Config.ARGB_8888)+                Utils.matToBitmap(result, bitmap)+                result.release()+                bitmap+            } catch (_: Exception) {+                null+            } finally {+                _isStitching.value = false+            }+        }+    }++    private fun stitchPair(base: Mat, next: Mat, orb: ORB, matcher: BFMatcher): Mat? {+        val kp1 = MatOfKeyPoint()+        val desc1 = Mat()+        val kp2 = MatOfKeyPoint()+        val desc2 = Mat()++        val gray1 = Mat()+        val gray2 = Mat()+        Imgproc.cvtColor(base, gray1, Imgproc.COLOR_RGBA2GRAY)+        Imgproc.cvtColor(next, gray2, Imgproc.COLOR_RGBA2GRAY)++        orb.detectAndCompute(gray1, Mat(), kp1, desc1)+        orb.detectAndCompute(gray2, Mat(), kp2, desc2)+        gray1.release()+        gray2.release()++        if (desc1.empty() || desc2.empty() || desc1.rows() < 10 || desc2.rows() < 10) {+            return null+        }++        val matches = MatOfDMatch()+        matcher.match(desc2, desc1, matches)+        desc1.release()+        desc2.release()++        val matchList = matches.toList().sortedBy { it.distance }+        val goodMatches = matchList.take((matchList.size * 0.3).toInt().coerceAtLeast(10))+        if (goodMatches.size < 10) return null++        val kpList1 = kp1.toList()+        val kpList2 = kp2.toList()++        val srcPts = MatOfPoint2f(*goodMatches.map { kpList2[it.queryIdx].pt }.toTypedArray())+        val dstPts = MatOfPoint2f(*goodMatches.map { kpList1[it.trainIdx].pt }.toTypedArray())++        val mask = MatOfByte()+        val H = Calib3d.findHomography(srcPts, dstPts, Calib3d.RANSAC, 5.0, mask)+        srcPts.release()+        dstPts.release()+        kp1.release()+        kp2.release()++        if (H.empty()) return null++        val corners = MatOfPoint2f(+            Point(0.0, 0.0),+            Point(next.cols().toDouble(), 0.0),+            Point(next.cols().toDouble(), next.rows().toDouble()),+            Point(0.0, next.rows().toDouble())+        )+        val warpedCorners = MatOfPoint2f()+        Core.perspectiveTransform(corners, warpedCorners, H)+        corners.release()++        val allPts = warpedCorners.toList() + listOf(+            Point(0.0, 0.0),+            Point(base.cols().toDouble(), 0.0),+            Point(base.cols().toDouble(), base.rows().toDouble()),+            Point(0.0, base.rows().toDouble())+        )+        warpedCorners.release()++        val minX = allPts.minOf { it.x }+        val minY = allPts.minOf { it.y }+        val maxX = allPts.maxOf { it.x }+        val maxY = allPts.maxOf { it.y }++        val translation = Mat.eye(3, 3, CvType.CV_64F)+        translation.put(0, 2, -minX)+        translation.put(1, 2, -minY)++        val outW = (maxX - minX).toInt()+        val outH = (maxY - minY).toInt()+        if (outW <= 0 || outH <= 0 || outW > 10000 || outH > 10000) {+            translation.release()+            H.release()+            return null+        }++        val warpedNext = Mat()+        val combinedH = Mat()+        Core.gemm(translation, H, 1.0, Mat(), 0.0, combinedH)+        Imgproc.warpPerspective(next, warpedNext, combinedH, Size(outW.toDouble(), outH.toDouble()))++        val output = warpedNext.clone()+        val roi = Rect((-minX).toInt(), (-minY).toInt(), base.cols(), base.rows())+        if (roi.x >= 0 && roi.y >= 0 && roi.x + roi.width <= output.cols() && roi.y + roi.height <= output.rows()) {+            base.copyTo(Mat(output, roi))+        }++        translation.release()+        H.release()+        combinedH.release()+        warpedNext.release()++        return output+    }++    fun saveToMediaStore(bitmap: Bitmap) {+        val timestamp = SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(Date())+        val contentValues = ContentValues().apply {+            put(MediaStore.MediaColumns.DISPLAY_NAME, "PANO_$timestamp.jpg")+            put(MediaStore.MediaColumns.MIME_TYPE, "image/jpeg")+            put(MediaStore.MediaColumns.RELATIVE_PATH, Environment.DIRECTORY_DCIM + "/Camera")+        }+        val uri = context.contentResolver.insert(+            MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues+        ) ?: return+        context.contentResolver.openOutputStream(uri)?.use { os ->+            bitmap.compress(Bitmap.CompressFormat.JPEG, 95, os)+        }+    }++    fun reset() {+        frames.forEach { it.recycle() }+        frames.clear()+        _frameCount.value = 0+        _sweepAngle.value = 0f+        _isSweeping.value = false+        _isStitching.value = false+    }+}
camera/src/main/java/com/vayunmathur/camera/util/QrAnalyzer.kt
diff --git a/camera/src/main/java/com/vayunmathur/camera/util/QrAnalyzer.kt b/camera/src/main/java/com/vayunmathur/camera/util/QrAnalyzer.ktnew file mode 100644index 0000000000..9cf4b1dea6--- /dev/null+++ b/camera/src/main/java/com/vayunmathur/camera/util/QrAnalyzer.kt@@ -0,0 +1,42 @@+package com.vayunmathur.camera.util++import androidx.annotation.OptIn+import androidx.camera.core.ExperimentalGetImage+import androidx.camera.core.ImageAnalysis+import androidx.camera.core.ImageProxy+import com.google.zxing.BinaryBitmap+import com.google.zxing.MultiFormatReader+import com.google.zxing.NotFoundException+import com.google.zxing.PlanarYUVLuminanceSource+import com.google.zxing.common.HybridBinarizer++class QrAnalyzer(private val onQrDetected: (String) -> Unit) : ImageAnalysis.Analyzer {+    private val reader = MultiFormatReader()++    @OptIn(ExperimentalGetImage::class)+    override fun analyze(imageProxy: ImageProxy) {+        val buffer = imageProxy.planes[0].buffer+        val bytes = ByteArray(buffer.remaining())+        buffer.get(bytes)++        val source = PlanarYUVLuminanceSource(+            bytes,+            imageProxy.width,+            imageProxy.height,+            0, 0,+            imageProxy.width,+            imageProxy.height,+            false+        )+        val bitmap = BinaryBitmap(HybridBinarizer(source))++        try {+            val result = reader.decodeWithState(bitmap)+            onQrDetected(result.text)+        } catch (_: NotFoundException) {+        } finally {+            reader.reset()+            imageProxy.close()+        }+    }+}
camera/src/main/java/com/vayunmathur/camera/util/VideoProcessor.kt
diff --git a/camera/src/main/java/com/vayunmathur/camera/util/VideoProcessor.kt b/camera/src/main/java/com/vayunmathur/camera/util/VideoProcessor.ktnew file mode 100644index 0000000000..18ae295511--- /dev/null+++ b/camera/src/main/java/com/vayunmathur/camera/util/VideoProcessor.kt@@ -0,0 +1,58 @@+package com.vayunmathur.camera.util++import android.media.MediaCodec+import android.media.MediaExtractor+import android.media.MediaFormat+import android.media.MediaMuxer+import java.io.File+import java.nio.ByteBuffer++object VideoProcessor {+    fun adjustSpeed(inputFile: File, outputFile: File, speedFactor: Float) {+        val extractor = MediaExtractor()+        extractor.setDataSource(inputFile.path)++        val muxer = MediaMuxer(outputFile.path, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4)++        var videoTrackIndex = -1+        var muxerTrackIndex = -1+        for (i in 0 until extractor.trackCount) {+            val format = extractor.getTrackFormat(i)+            val mime = format.getString(MediaFormat.KEY_MIME) ?: ""+            if (mime.startsWith("video/")) {+                videoTrackIndex = i+                muxerTrackIndex = muxer.addTrack(format)+                break+            }+        }++        if (videoTrackIndex < 0) {+            extractor.release()+            muxer.release()+            return+        }++        extractor.selectTrack(videoTrackIndex)+        muxer.start()++        val buffer = ByteBuffer.allocate(2 * 1024 * 1024)+        val info = MediaCodec.BufferInfo()++        while (true) {+            val size = extractor.readSampleData(buffer, 0)+            if (size < 0) break++            info.size = size+            info.flags = extractor.sampleFlags+            info.presentationTimeUs = (extractor.sampleTime / speedFactor).toLong()+            info.offset = 0++            muxer.writeSampleData(muxerTrackIndex, buffer, info)+            extractor.advance()+        }++        muxer.stop()+        muxer.release()+        extractor.release()+    }+}
camera/src/main/res/drawable/flash_auto_24px.xml
diff --git a/camera/src/main/res/drawable/flash_auto_24px.xml b/camera/src/main/res/drawable/flash_auto_24px.xmlnew file mode 100644index 0000000000..dd0ed34d34--- /dev/null+++ b/camera/src/main/res/drawable/flash_auto_24px.xml@@ -0,0 +1,20 @@+<!--+  ~ Copyright (C) 2026 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.+  -->+<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">+      +    <path android:fillColor="@android:color/white" android:pathData="M280,624L408,440L294,440L374,160L160,160L160,480L280,480L280,624ZM200,880L200,560L80,560L80,80L480,80L400,360L560,360L200,880ZM280,480L280,480L160,480L160,480L280,480L280,480L280,480ZM585,440L720,80L784,80L921,440L859,440L827,348L679,348L647,440L585,440ZM697,296L807,296L754,146L752,146L697,296Z"/>+    +</vector>
camera/src/main/res/drawable/flash_off_24px.xml
diff --git a/camera/src/main/res/drawable/flash_off_24px.xml b/camera/src/main/res/drawable/flash_off_24px.xmlnew file mode 100644index 0000000000..16899be59c--- /dev/null+++ b/camera/src/main/res/drawable/flash_off_24px.xml@@ -0,0 +1,20 @@+<!--+  ~ Copyright (C) 2026 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.+  -->+<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">+      +    <path android:fillColor="@android:color/white" android:pathData="M280,80L680,80L600,360L760,360L643,529L586,472L608,440L554,440L507,393L574,160L360,160L360,246L280,166L280,80ZM400,880L400,560L280,560L280,394L55,169L112,112L848,848L791,905L550,664L400,880ZM473,359L473,359L473,359L473,359L473,359L473,359L473,359Z"/>+    +</vector>
camera/src/main/res/drawable/flash_on_24px.xml
diff --git a/camera/src/main/res/drawable/flash_on_24px.xml b/camera/src/main/res/drawable/flash_on_24px.xmlnew file mode 100644index 0000000000..9cc1833337--- /dev/null+++ b/camera/src/main/res/drawable/flash_on_24px.xml@@ -0,0 +1,20 @@+<!--+  ~ Copyright (C) 2026 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.+  -->+<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">+      +    <path android:fillColor="@android:color/white" android:pathData="M480,624L608,440L494,440L574,160L360,160L360,480L480,480L480,624ZM400,880L400,560L280,560L280,80L680,80L600,360L760,360L400,880ZM480,480L480,480L360,480L360,480L480,480L480,480L480,480Z"/>+    +</vector>
camera/src/main/res/drawable/flip_camera_android_24px.xml
diff --git a/camera/src/main/res/drawable/flip_camera_android_24px.xml b/camera/src/main/res/drawable/flip_camera_android_24px.xmlnew file mode 100644index 0000000000..c8cc537dfb--- /dev/null+++ b/camera/src/main/res/drawable/flip_camera_android_24px.xml@@ -0,0 +1,20 @@+<!--+  ~ Copyright (C) 2026 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.+  -->+<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">+      +    <path android:fillColor="@android:color/white" android:pathData="M480,880Q337,880 227,790Q117,700 88,560L170,560Q198,666 284,733Q370,800 480,800Q566,800 640,757.5Q714,715 756,640L640,640L640,560L880,560L880,800L800,800L800,720Q743,796 659,838Q575,880 480,880ZM395,565Q360,530 360,480Q360,430 395,395Q430,360 480,360Q530,360 565,395Q600,430 600,480Q600,530 565,565Q530,600 480,600Q430,600 395,565ZM80,400L80,160L160,160L160,240Q217,164 301,122Q385,80 480,80Q623,80 733,170Q843,260 872,400L790,400Q762,294 676,227Q590,160 480,160Q394,160 320,202.5Q246,245 204,320L320,320L320,400L80,400Z"/>+    +</vector>
camera/src/main/res/drawable/ic_launcher_foreground.xml
diff --git a/camera/src/main/res/drawable/ic_launcher_foreground.xml b/camera/src/main/res/drawable/ic_launcher_foreground.xmlnew file mode 100644index 0000000000..1c2fe6b3b1--- /dev/null+++ b/camera/src/main/res/drawable/ic_launcher_foreground.xml@@ -0,0 +1,30 @@+<!--+  ~ Copyright (C) 2026 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.+  -->+<vector xmlns:android="http://schemas.android.com/apk/res/android"+    android:width="108dp"+    android:height="108dp"+    android:viewportWidth="960"+    android:viewportHeight="960"+    android:tint="#000000">+  <group android:scaleX="0.58"+      android:scaleY="0.58"+      android:translateX="201.6"+      android:translateY="201.6">+    <path+        android:fillColor="@android:color/white"+        android:pathData="M480,700Q555,700 607.5,647.5Q660,595 660,520Q660,445 607.5,392.5Q555,340 480,340Q405,340 352.5,392.5Q300,445 300,520Q300,595 352.5,647.5Q405,700 480,700ZM480,620Q438,620 409,591Q380,562 380,520Q380,478 409,449Q438,420 480,420Q522,420 551,449Q580,478 580,520Q580,562 551,591Q522,620 480,620ZM160,840Q127,840 103.5,816.5Q80,793 80,760L80,280Q80,247 103.5,223.5Q127,200 160,200L286,200L360,120L600,120L674,200L800,200Q833,200 856.5,223.5Q880,247 880,280L880,760Q880,793 856.5,816.5Q833,840 800,840L160,840ZM160,760L800,760Q800,760 800,760Q800,760 800,760L800,280Q800,280 800,280Q800,280 800,280L638,280L565,200L395,200L322,280L160,280Q160,280 160,280Q160,280 160,280L160,760Q160,760 160,760Q160,760 160,760ZM480,520Q480,520 480,520Q480,520 480,520L480,520Q480,520 480,520Q480,520 480,520L480,520L480,520L480,520L480,520L480,520Q480,520 480,520Q480,520 480,520L480,520Q480,520 480,520Q480,520 480,520Z"/>+  </group>+</vector>
camera/src/main/res/drawable/ic_photo_library.xml
diff --git a/camera/src/main/res/drawable/ic_photo_library.xml b/camera/src/main/res/drawable/ic_photo_library.xmlnew file mode 100644index 0000000000..56cdac83f1--- /dev/null+++ b/camera/src/main/res/drawable/ic_photo_library.xml@@ -0,0 +1,9 @@+<vector xmlns:android="http://schemas.android.com/apk/res/android"+    android:width="24dp"+    android:height="24dp"+    android:viewportWidth="24"+    android:viewportHeight="24">+    <path+        android:fillColor="@android:color/white"+        android:pathData="M22,16V4c0,-1.1 -0.9,-2 -2,-2H8c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2zM11,12l2.03,2.71L16,11l4,5H8l3,-4zM2,6v14c0,1.1 0.9,2 2,2h14v-2H4V6H2z"/>+</vector>
camera/src/main/res/drawable/ic_timer.xml
diff --git a/camera/src/main/res/drawable/ic_timer.xml b/camera/src/main/res/drawable/ic_timer.xmlnew file mode 100644index 0000000000..706bb8f8a0--- /dev/null+++ b/camera/src/main/res/drawable/ic_timer.xml@@ -0,0 +1,9 @@+<vector xmlns:android="http://schemas.android.com/apk/res/android"+    android:width="24dp"+    android:height="24dp"+    android:viewportWidth="24"+    android:viewportHeight="24">+    <path+        android:fillColor="@android:color/white"+        android:pathData="M15,1H9v2h6V1zM11,14h2V8h-2v6zM19.03,7.39l1.42,-1.42c-0.43,-0.51 -0.9,-0.99 -1.41,-1.41l-1.42,1.42C16.07,4.74 14.12,4 12,4c-4.97,0 -9,4.03 -9,9s4.03,9 9,9 9,-4.03 9,-9c0,-2.12 -0.74,-4.07 -1.97,-5.61zM12,20c-3.87,0 -7,-3.13 -7,-7s3.13,-7 7,-7 7,3.13 7,7 -3.13,7 -7,7z"/>+</vector>
camera/src/main/res/drawable/photo_camera_24px.xml
diff --git a/camera/src/main/res/drawable/photo_camera_24px.xml b/camera/src/main/res/drawable/photo_camera_24px.xmlnew file mode 100644index 0000000000..1dd3edd29b--- /dev/null+++ b/camera/src/main/res/drawable/photo_camera_24px.xml@@ -0,0 +1,20 @@+<!--+  ~ Copyright (C) 2026 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.+  -->+<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">+      +    <path android:fillColor="@android:color/white" android:pathData="M480,700Q555,700 607.5,647.5Q660,595 660,520Q660,445 607.5,392.5Q555,340 480,340Q405,340 352.5,392.5Q300,445 300,520Q300,595 352.5,647.5Q405,700 480,700ZM480,620Q438,620 409,591Q380,562 380,520Q380,478 409,449Q438,420 480,420Q522,420 551,449Q580,478 580,520Q580,562 551,591Q522,620 480,620ZM160,840Q127,840 103.5,816.5Q80,793 80,760L80,280Q80,247 103.5,223.5Q127,200 160,200L286,200L360,120L600,120L674,200L800,200Q833,200 856.5,223.5Q880,247 880,280L880,760Q880,793 856.5,816.5Q833,840 800,840L160,840ZM160,760L800,760Q800,760 800,760Q800,760 800,760L800,280Q800,280 800,280Q800,280 800,280L638,280L565,200L395,200L322,280L160,280Q160,280 160,280Q160,280 160,280L160,760Q160,760 160,760Q160,760 160,760ZM480,520Q480,520 480,520Q480,520 480,520L480,520Q480,520 480,520Q480,520 480,520L480,520L480,520L480,520L480,520L480,520Q480,520 480,520Q480,520 480,520L480,520Q480,520 480,520Q480,520 480,520Z"/>+    +</vector>
camera/src/main/res/drawable/raw_off_24px.xml
diff --git a/camera/src/main/res/drawable/raw_off_24px.xml b/camera/src/main/res/drawable/raw_off_24px.xmlnew file mode 100644index 0000000000..d2f9bd1a6f--- /dev/null+++ b/camera/src/main/res/drawable/raw_off_24px.xml@@ -0,0 +1,20 @@+<!--+  ~ Copyright (C) 2026 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.+  -->+<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">+      +    <path android:fillColor="@android:color/white" android:pathData="M792,904L56,168L112,112L848,848L792,904ZM740,600L710,478L686,572L588,476L560,360L620,360L650,480L680,360L740,360L770,480L800,360L860,360L800,600L740,600ZM350,600L392,432L440,480L440,480L440,480L500,540L426,540L410,600L350,600ZM120,600L120,360L260,360Q284,360 302,378Q320,396 320,420L320,460Q320,478 310.5,492.5Q301,507 284,516L320,600L260,600L224,520L180,520L180,600L120,600ZM180,460L260,460Q260,460 260,460Q260,460 260,460L260,420Q260,420 260,420Q260,420 260,420L180,420L180,460Z"/>+    +</vector>
camera/src/main/res/drawable/raw_on_24px.xml
diff --git a/camera/src/main/res/drawable/raw_on_24px.xml b/camera/src/main/res/drawable/raw_on_24px.xmlnew file mode 100644index 0000000000..a5cce08071--- /dev/null+++ b/camera/src/main/res/drawable/raw_on_24px.xml@@ -0,0 +1,20 @@+<!--+  ~ Copyright (C) 2026 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.+  -->+<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">+      +    <path android:fillColor="@android:color/white" android:pathData="M120,600L120,360L260,360Q284,360 302,378Q320,396 320,420L320,460Q320,478 310.5,492.5Q301,507 284,516L320,600L260,600L224,520L180,520L180,600L120,600ZM350,600L410,360L510,360L570,600L510,600L496,540L426,540L410,600L350,600ZM620,600L560,360L620,360L650,480L680,360L740,360L770,480L800,360L860,360L800,600L740,600L710,478L680,600L620,600ZM440,480L480,480L470,440L450,440L440,480ZM180,460L260,460Q260,460 260,460Q260,460 260,460L260,420Q260,420 260,420Q260,420 260,420L180,420L180,460Z"/>+    +</vector>
camera/src/main/res/drawable/video_camera_back_24px.xml
diff --git a/camera/src/main/res/drawable/video_camera_back_24px.xml b/camera/src/main/res/drawable/video_camera_back_24px.xmlnew file mode 100644index 0000000000..c6972d565d--- /dev/null+++ b/camera/src/main/res/drawable/video_camera_back_24px.xml@@ -0,0 +1,20 @@+<!--+  ~ Copyright (C) 2026 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.+  -->+<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">+      +    <path android:fillColor="@android:color/white" android:pathData="M200,640L600,640L462,460L370,580L308,500L200,640ZM160,800Q127,800 103.5,776.5Q80,753 80,720L80,240Q80,207 103.5,183.5Q127,160 160,160L640,160Q673,160 696.5,183.5Q720,207 720,240L720,420L880,260L880,700L720,540L720,720Q720,753 696.5,776.5Q673,800 640,800L160,800ZM160,720L640,720Q640,720 640,720Q640,720 640,720L640,240Q640,240 640,240Q640,240 640,240L160,240Q160,240 160,240Q160,240 160,240L160,720Q160,720 160,720Q160,720 160,720ZM160,720Q160,720 160,720Q160,720 160,720L160,240Q160,240 160,240Q160,240 160,240L160,240Q160,240 160,240Q160,240 160,240L160,720Q160,720 160,720Q160,720 160,720Z"/>+    +</vector>
camera/src/main/res/mipmap-anydpi/ic_launcher.xml
diff --git a/camera/src/main/res/mipmap-anydpi/ic_launcher.xml b/camera/src/main/res/mipmap-anydpi/ic_launcher.xmlnew file mode 100644index 0000000000..ef49c99170--- /dev/null+++ b/camera/src/main/res/mipmap-anydpi/ic_launcher.xml@@ -0,0 +1,6 @@+<?xml version="1.0" encoding="utf-8"?>+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">+    <background android:drawable="@color/ic_launcher_background"/>+    <foreground android:drawable="@drawable/ic_launcher_foreground"/>+    <monochrome android:drawable="@drawable/ic_launcher_foreground"/>+</adaptive-icon>\ No newline at end of file
camera/src/main/res/resources.properties
diff --git a/camera/src/main/res/resources.properties b/camera/src/main/res/resources.propertiesnew file mode 100644index 0000000000..467b3efec9--- /dev/null+++ b/camera/src/main/res/resources.properties@@ -0,0 +1 @@+unqualifiedResLocale=en-US
camera/src/main/res/values/strings.xml
diff --git a/camera/src/main/res/values/strings.xml b/camera/src/main/res/values/strings.xmlnew file mode 100644index 0000000000..ee6ab6e807--- /dev/null+++ b/camera/src/main/res/values/strings.xml@@ -0,0 +1,41 @@+<resources>+    <string name="app_name">Camera</string>++    <string name="mode_photo">Photo</string>+    <string name="mode_video">Video</string>++    <string name="flash_on">Flash On</string>+    <string name="flash_off">Flash Off</string>+    <string name="flash_auto">Flash Auto</string>++    <string name="flip_camera">Flip Camera</string>+    <string name="open_gallery">Gallery</string>+    <string name="settings">Settings</string>+    <string name="capture">Capture</string>+    <string name="start_recording">Record</string>+    <string name="stop_recording">Stop</string>++    <string name="grant_camera_permission">Grant Camera Permission</string>++    <string name="settings_timer">Timer</string>+    <string name="timer_off">Off</string>+    <string name="timer_3s">3s</string>+    <string name="timer_5s">5s</string>+    <string name="timer_10s">10s</string>++    <string name="settings_aspect_ratio">Aspect Ratio</string>+    <string name="ratio_16_9">16:9</string>+    <string name="ratio_4_3">4:3</string>+    <string name="ratio_1_1">1:1</string>++    <string name="settings_flash">Flash</string>++    <string name="settings_location">Location</string>+    <string name="settings_location_description">Save location in photo metadata</string>++    <string name="mode_portrait">Portrait</string>++    <string name="qr_result">QR Code</string>+    <string name="open_url">Open URL</string>+    <string name="copy_text">Copy</string>+</resources>
settings.gradle.kts
diff --git a/settings.gradle.kts b/settings.gradle.ktsindex a16884c4c8..d0d4557943 100644--- a/settings.gradle.kts+++ b/settings.gradle.kts@@ -54,3 +54,4 @@ include(":email") include(":weather") include(":messages") include(":web")+include(":camera")