hsicen/hencoderplus/camera1-to-camerax
Claude Code and agent skill by hsicen/hencoderplus
- community
Checking that the SKILL.md file is still in the repository.
Use this skill to migrate legacy Android camera implementations (Camera1
Install
npx vskill@latest install hsicen/hencoderplus/camera1-to-cameraxSKILL.md
Step 0: Add Dependencies
Check for and add the required CameraX dependencies. Use version 1.3.0 or higher for interoperability, or version 1.5.0 or higher for Compose extensions.
If you are using a Version Catalog (libs.versions.toml), add the following:
<br />
And in your build.gradle.kts (or build.gradle):
<br />
Without a Version Catalog, fall back to these standard Gradle dependencies:
<br />
Step 1: Remove Legacy Implementation
- Delete all
android.hardware.Camerainstances. - Delete
SurfaceViewandSurfaceHolder.Callbackimplementations (surfaceCreated,surfaceChanged,surfaceDestroyed). - Remove custom lifecycle handling that opens or releases the camera in
onResumeoronPause. - Remove manual matrix calculations for orientation.
Step 2: Initialize ProcessCameraProvider
Request the ProcessCameraProvider and bind use cases to the Activity or Fragment lifecycle.
<br />
Step 3: Implement the Preview \& Tap-to-Focus
Choose exactly one of the following patterns based on the app's UI toolkit:
Option A: For Android Views (XML Legacy)
Use androidx.camera.view.PreviewView.
1. Set up preview:
<br />
2. Handle tap-to-focus:
<br />
Option B: For Jetpack Compose
Use androidx.camera.compose.CameraXViewfinder.
1. Set up preview and SurfaceRequest:
<br />
2. Render viewfinder:
<br />
3. Handle tap-to-focus in Compose:
<br />
4. Update target rotation for Compose:
<br />
Step 4: Capture Photo
Use the ImageCapture use case to take the picture. The ImageProxy handles rotation directly.
<br />
Step 5: Switch Cameras
To flip between front and rear cameras, change the CameraSelector and re-trigger the ProcessCameraProvider logic.
<br />
Constraints
- Don't manage the camera lifecycle manually : Bind the camera to a
LifecycleOwnerthrough theProcessCameraProvider. Avoid manual camera open or close logic inonResumeoronPause. - Don't calculate focus matrices manually :
MeteringPointFactoryhandles coordinate transformations, including device rotation offsets. Avoid custom matrix implementations. - Don't forget to close the ImageProxy : Remember to invoke
image.close()in the capture callback. Skipping this call locks the capture pipeline and interrupts subsequent photos. - Don't wrap `PreviewView` in `AndroidView` for Compose code : For Compose UI layouts, use
CameraXViewfinder. CompilingPreviewViewin anAndroidViewis an old fallback option that introduces resizing issues.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.skills/camera1-to-camerax/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/hsicen/hencoderplus/camera1-to-camerax)