-
Notifications
You must be signed in to change notification settings - Fork 57
add documentation to :ui:components:capture #470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
5d33918
b25daa3
2eee47b
f498e40
438617a
67d6909
387531d
2b4093b
fe2606b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -155,6 +155,18 @@ private fun CaptureKeyHandler( | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * A capture button that can be used for both image and video capture. | ||
| * | ||
| * @param modifier the modifier for this component | ||
| * @param onImageCapture the callback for an image capture event | ||
| * @param onStartRecording the callback for a start recording event | ||
| * @param onStopRecording the callback for a stop recording event | ||
| * @param onLockVideoRecording The callback for a lock video recording event. The boolean parameter indicates if the recording should be locked. | ||
| * @param onIncrementZoom The callback for a zoom increment event, providing the zoom increment value. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: explain why there is a zoom option here. It seems out of place without explanation. |
||
| * @param captureButtonUiState the [CaptureButtonUiState] for this component | ||
| * @param captureButtonSize the size of the capture button | ||
| */ | ||
| @Composable | ||
| internal fun CaptureButton( | ||
| modifier: Modifier = Modifier, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -134,6 +134,11 @@ private const val BLINK_TIME = 100L | |
| private val TAP_TO_FOCUS_INDICATOR_SIZE = 56.dp | ||
| private const val FOCUS_INDICATOR_RESULT_DELAY = 100L | ||
|
|
||
| /** | ||
| * A composable that displays the elapsed time since the start of a video recording. | ||
| * | ||
| * @param elapsedTimeUiState the [ElapsedTimeUiState] for this component | ||
| */ | ||
| @Composable | ||
| fun ElapsedTimeText(modifier: Modifier = Modifier, elapsedTimeUiState: ElapsedTimeUiState) { | ||
| if (elapsedTimeUiState is ElapsedTimeUiState.Enabled) { | ||
|
|
@@ -146,6 +151,14 @@ fun ElapsedTimeText(modifier: Modifier = Modifier, elapsedTimeUiState: ElapsedTi | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * A composable that displays a toggle button for pausing and resuming video recording. | ||
| * | ||
| * @param modifier the modifier for this component | ||
| * @param onSetPause the callback for setting the pause state | ||
| * @param size the size of the button | ||
| * @param currentRecordingState the current recording state | ||
| */ | ||
| @OptIn(ExperimentalMaterial3ExpressiveApi::class) | ||
| @Composable | ||
| fun PauseResumeToggleButton( | ||
|
|
@@ -177,6 +190,14 @@ fun PauseResumeToggleButton( | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * A composable that displays a toggle button for enabling and disabling audio. | ||
| * | ||
| * @param modifier the modifier for this component | ||
| * @param buttonSize the size of the button | ||
| * @param audioUiState the [AudioUiState] for this component | ||
| * @param onToggleAudio the callback for toggling audio | ||
| */ | ||
| @OptIn(ExperimentalMaterial3ExpressiveApi::class) | ||
| @Composable | ||
| fun AmplitudeToggleButton( | ||
|
|
@@ -235,6 +256,14 @@ fun AmplitudeToggleButton( | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * A composable that displays a toggle button for switching between image and video capture. | ||
| * | ||
| * @param uiState the [CaptureModeToggleUiState.Available] for this component | ||
| * @param onChangeCaptureMode the callback for changing the capture mode | ||
| * @param onToggleWhenDisabled the callback for when the toggle is disabled | ||
| * @param modifier the modifier for this component | ||
| */ | ||
| @Composable | ||
| fun CaptureModeToggleButton( | ||
| uiState: CaptureModeToggleUiState.Available, | ||
|
|
@@ -304,6 +333,14 @@ fun CaptureModeToggleButton( | |
| ) | ||
| } | ||
|
|
||
| /** | ||
| * A composable that displays a snackbar with a test tag. | ||
| * | ||
| * @param modifier the modifier for this component | ||
| * @param snackbarToShow the [SnackbarData] to show | ||
| * @param snackbarHostState the [SnackbarHostState] for this component | ||
| * @param onSnackbarResult the callback for the snackbar result | ||
| */ | ||
| @Composable | ||
| fun TestableSnackbar( | ||
| modifier: Modifier = Modifier, | ||
|
|
@@ -510,6 +547,19 @@ fun PreviewDisplay( | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * A composable that displays the capture button. | ||
| * | ||
| * @param modifier the modifier for this component | ||
| * @param captureButtonUiState the [CaptureButtonUiState] for this component | ||
| * @param isQuickSettingsOpen true if the quick settings are open | ||
| * @param onToggleQuickSettings the callback for toggling the quick settings | ||
| * @param onIncrementZoom A callback to increment the zoom, providing the zoom increment value. | ||
| * @param onCaptureImage A callback to capture an image, providing the `ContentResolver` for saving. | ||
| * @param onStartVideoRecording The callback for starting a video recording. | ||
| * @param onStopVideoRecording The callback for stopping a video recording. | ||
| * @param onLockVideoRecording A callback to lock video recording. The boolean parameter indicates if the recording should be locked. | ||
| */ | ||
| @Composable | ||
| fun CaptureButton( | ||
| modifier: Modifier = Modifier, | ||
|
|
@@ -548,6 +598,12 @@ fun CaptureButton( | |
| ) | ||
| } | ||
|
|
||
| /** | ||
| * A composable that displays the stabilization icon. | ||
| * | ||
| * @param stabilizationUiState the [StabilizationUiState] for this component | ||
| * @param modifier the modifier for this component | ||
| */ | ||
| @OptIn(ExperimentalMaterial3ExpressiveApi::class) | ||
| @Composable | ||
| fun StabilizationIcon(stabilizationUiState: StabilizationUiState, modifier: Modifier = Modifier) { | ||
|
|
@@ -625,6 +681,12 @@ fun StabilizationIcon(stabilizationUiState: StabilizationUiState, modifier: Modi | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * A composable that displays the video quality icon. | ||
| * | ||
| * @param videoQuality the [VideoQuality] for this component | ||
| * @param modifier the modifier for this component | ||
| */ | ||
| @OptIn(ExperimentalMaterial3ExpressiveApi::class) | ||
| @Composable | ||
| fun VideoQualityIcon(videoQuality: VideoQuality, modifier: Modifier = Modifier) { | ||
|
|
@@ -671,6 +733,14 @@ fun VideoQualityIcon(videoQuality: VideoQuality, modifier: Modifier = Modifier) | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * A composable that displays the flip camera button. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are a few composables that are documented like this. I think you should add a little more about the behavior of each composable. This description is already basically captured by virtue of the signature: |
||
| * | ||
| * @param enabledCondition the enabled condition for this component | ||
| * @param flipLensUiState the [FlipLensUiState] for this component | ||
| * @param onClick the callback for when the button is clicked | ||
| * @param modifier the modifier for this component | ||
| */ | ||
| @OptIn(ExperimentalMaterial3ExpressiveApi::class) | ||
| @Composable | ||
| fun FlipCameraButton( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,14 +16,20 @@ | |
| package com.google.jetpackcamera.ui.components.capture | ||
|
|
||
| /** | ||
| * A helper class that prevents multiple clicks. | ||
| * A helper class that debounces events, preventing multiple rapid-fire executions. | ||
| */ | ||
| internal class MultipleEventsCutter { | ||
| internal class EventDebouncer { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I don't think this class is used currently. It can probably be deleted. |
||
| private val now: Long | ||
| get() = System.currentTimeMillis() | ||
|
|
||
| private var lastEventTimeMs: Long = 0 | ||
|
|
||
| /** | ||
| * Processes an event, executing it only if a specified duration has passed since the last | ||
| * event. This prevents multiple rapid-fire executions of the same event. | ||
| * | ||
| * @param event The lambda function representing the event to be executed. | ||
| */ | ||
| fun processEvent(event: () -> Unit) { | ||
| if (now - lastEventTimeMs >= DURATION_BETWEEN_CLICKS_MS) { | ||
| event.invoke() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,15 @@ import androidx.compose.material3.lightColorScheme | |
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.platform.LocalContext | ||
|
|
||
| /** | ||
| * A composable that provides a Material Design theme for previews within the Jetpack Camera App. | ||
| * | ||
| * This theme adapts to system dark mode settings and supports dynamic colors on Android 12+. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: This is technically true, but I don't think we'll need to support the light theme in the future. No need to change anything now, except for maybe adding a TODO to remove the ability to change the theme. |
||
| * | ||
| * @param darkTheme Whether the theme should be in dark mode. Defaults to `isSystemInDarkTheme()`. | ||
| * @param dynamicColor Whether dynamic color should be enabled. Defaults to `true`. | ||
| * @param content The composable content to which the theme will be applied. | ||
| */ | ||
| @Composable | ||
| fun PreviewPreviewTheme( | ||
| darkTheme: Boolean = isSystemInDarkTheme(), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This description seems a little sparse. What are the different modes it can be in? What about the lock behavior?