Update Capture Button visuals#461
Conversation
f12a849 to
d9398ce
Compare
|
/gemini summary |
There was a problem hiding this comment.
Code Review
This pull request does a great job of updating the CaptureButton component's appearance and behavior. The changes align well with the design mocks, and the fixes for VIDEO_ONLY mode and volume button capture are significant improvements. The refactoring of the animation logic using updateTransition and the introduction of InteractionSource are excellent choices that follow Compose best practices. The simplification of the preview composables is also a welcome change that improves maintainability.
I've left a couple of comments: one to address a logic regression that could cause onRelease to be called twice, and another with a suggestion to simplify a boolean check for better readability. Overall, this is a high-quality contribution.
Summary of ChangesThis pull request refines the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
|
Introduces an `isCameraRunning` flag to the `CameraState` to accurately reflect the underlying camera's status. This state is derived from the CameraX `CameraState` and is used to disable the capture button when the camera is not open or available. This commit also renames `torchEnabled` to `isTorchEnabled` for clarity and consistency, and ensures the `ZoomState` is being correctly updated in the `CameraState`. The capture button's UI has been improved to prevent flickering during brief transitional states (e.g. switching cameras). This is achieved by visually debouncing the disabled state. While the button's semantics and pointer input are disabled immediately, the visual change to a disabled appearance is delayed by one second. If the button becomes enabled again within this period, the distracting flicker is avoided. Color transitions are animated for a smoother user experience. Finally, the test suite has been made more robust by updating the tests to wait for the capture button to be both displayed and enabled before interaction.
This is the opposite of "Unavailable".
b15fb8a to
1f5bccd
Compare
…button_disabled_state
This also adds an additional interactionSource to the capture button so we can emulate touch events in our compose previews.
Also ensures the disabled state for the capture button has the correct animations for the nucleus.
Also animates to/from the pressed state
d9398ce to
647522b
Compare
Kimblebee
left a comment
There was a problem hiding this comment.
some duplicate comments regarding readibility, otherwise I think the PR looks great
Extracted hardcoded scale factors and animation durations to private constants at the top of the file in CaptureButtonComponents.kt. Updated styleguide.md to include best practices for handling magic numbers in Compose based on Duckie's advice. TAG=agy CONV=2a1a6024-c966-475a-a087-7c94cda18542
Added tests to verify that CaptureButton has correct content descriptions and roles in PressedRecording and Disabled states. Also added reference screenshot for new previews. TAG=agy CONV=2a1a6024-c966-475a-a087-7c94cda18542
Added ui-test-junit4-accessibility and accessibility-test-framework dependencies. Configured CaptureButtonTest to use enableAccessibilityChecks() and tryPerformAccessibilityChecks(). Added .focusable() to CaptureButton to enable accessibility checks on it. TAG=agy CONV=2a1a6024-c966-475a-a087-7c94cda18542
Added a rule to section 10 advising to use Modifier.focusable() when building custom components that handle input manually via low-level gestures, to ensure they are accessible and analyzed by automated checks. TAG=agy CONV=2a1a6024-c966-475a-a087-7c94cda18542
- Add focusability to custom button ring. - Add content description to lock icon. - Fix touch target size issue by expanding container width dynamically. - Add missing tryPerformAccessibilityChecks to tests. - Add screenshot tests for pressed recording state.
…, and move preview function
This PR updates the appearance and behavior of the
CaptureButtoncomponent to better match design mocks and improve preview visibility.Key Changes
LocalShutterBackgroundStyle(WHITE_20andBLACK_60).Accessibility and Localization:
CaptureButtonfocusable and added appropriate roles and content descriptions.strings.xmlfor proper localization support.Refactoring and Testing:
CompositionLocalProvider(LocalInitialPressedState provides true), avoiding manual construction of complex UI states and ensuring accurate rendering in previews.CaptureButtonScreenshotTest.ktfor better maintainability.