Fix several color and animation issues with media-send.

This commit is contained in:
Alex Hart
2026-08-11 10:51:47 -03:00
parent 335b4ac8e7
commit b99d6f74db
7 changed files with 15 additions and 29 deletions
@@ -4,6 +4,7 @@ import androidx.camera.compose.CameraXViewfinder
import androidx.camera.core.SurfaceRequest
import androidx.camera.lifecycle.ProcessCameraProvider
import androidx.camera.viewfinder.compose.MutableCoordinateTransformer
import androidx.camera.viewfinder.core.ImplementationMode
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.Spring
@@ -82,6 +83,7 @@ fun CameraScreen(
enableQrScanning: Boolean = false,
fillViewport: Boolean = false,
landscape: Boolean? = null,
implementationMode: ImplementationMode = ImplementationMode.EXTERNAL,
content: @Composable BoxScope.() -> Unit = {}
) {
val context = LocalContext.current
@@ -147,6 +149,7 @@ fun CameraScreen(
val currentSurfaceRequest = surfaceRequest!!
CameraXViewfinder(
implementationMode = implementationMode,
surfaceRequest = currentSurfaceRequest,
coordinateTransformer = coordinateTransformer,
contentScale = if (fillViewport) ContentScale.Crop else ContentScale.Fit,
@@ -42,9 +42,6 @@ private object CaptureButtonColors {
/** Background fill: custom control color (0xCC333333) */
val Background = Color(0xCC333333)
/** Outer ring stroke: pure white (0xFFFFFFFF) */
val Arc = Color.White
/** Inner fill: pure white (0xFFFFFFFF) */
val CaptureFill = Color.White
@@ -4,6 +4,6 @@
-->
<resources>
<color name="CameraHud_control_background">#4D333333</color>
<color name="CameraHud_control_background">#CC333333</color>
<color name="CameraHud_control_red_background">#FFD92F20</color>
</resources>
+1
View File
@@ -70,6 +70,7 @@ dependencies {
// CameraX
implementation(libs.androidx.camera.core)
implementation(libs.androidx.camera.compose)
// Testing
testImplementation(testFixtures(project(":core:ui")))
@@ -18,6 +18,7 @@ import android.system.Os
import android.system.OsConstants
import android.widget.Toast
import androidx.camera.core.CameraSelector
import androidx.camera.viewfinder.core.ImplementationMode
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
@@ -461,7 +462,8 @@ fun CameraXScreen(
onCheckPermissions: () -> Unit,
hasCameraPermission: () -> Boolean,
onRequestMicPermission: () -> Unit,
storiesEnabled: Boolean = CameraDependencies.isStoriesFeatureEnabled()
storiesEnabled: Boolean = CameraDependencies.isStoriesFeatureEnabled(),
implementationMode: ImplementationMode = ImplementationMode.EXTERNAL
) {
val context = LocalContext.current
@@ -634,6 +636,7 @@ fun CameraXScreen(
captureMode = captureMode,
enableQrScanning = state.isQrScanEnabled,
landscape = cameraState.isLandscape,
implementationMode = implementationMode,
modifier = Modifier.padding(bottom = viewportBottomMargin)
) {
if (isPortraitPhone) {
@@ -5,6 +5,7 @@
package org.signal.mediasend.screens.capture
import androidx.camera.viewfinder.core.ImplementationMode
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.tooling.preview.Preview
@@ -40,7 +41,8 @@ fun MediaCameraCaptureScreen(
onCheckPermissions = permissions.requestCapturePermissions,
onRequestMicPermission = permissions.requestMicrophonePermission,
hasCameraPermission = permissions.hasCameraPermission,
storiesEnabled = state.storiesEnabled
storiesEnabled = state.storiesEnabled,
implementationMode = ImplementationMode.EMBEDDED
)
}
@@ -5,12 +5,7 @@
package org.signal.mediasend.screens.capture
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.ContentTransform
import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.animation.slideInHorizontally
import androidx.compose.animation.slideOutHorizontally
import androidx.compose.animation.Crossfade
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement.spacedBy
@@ -82,23 +77,8 @@ fun MediaCaptureScreen(
.fillMaxSize()
.background(color = Color.Black)
) {
AnimatedContent(
targetState = selectedCaptureScreen,
transitionSpec = {
if (targetState is MediaSendRoute.Capture.TextStory) {
ContentTransform(
targetContentEnter = slideInHorizontally { width -> width },
initialContentExit = ExitTransition.KeepUntilTransitionsFinished,
targetContentZIndex = TEXT_STORY_Z_INDEX
)
} else {
ContentTransform(
targetContentEnter = EnterTransition.None,
initialContentExit = slideOutHorizontally { width -> width },
targetContentZIndex = CAMERA_Z_INDEX
)
}
}
Crossfade(
targetState = selectedCaptureScreen
) { captureScreen ->
when (captureScreen) {
is MediaSendRoute.Capture.TextStory -> textStoryEditorSlot()