Skip to content

Conversation

@buhleryesco
Copy link

@buhleryesco buhleryesco commented Dec 23, 2025

If only x or y is set while the other is null, the set value was ignored and it was auto centered upon start.

Fixed to match iOS ~line 1959 Plugin.swift

Summary by CodeRabbit

  • Bug Fixes
    • Camera preview now respects user-specified positioning coordinates while maintaining auto-centering behavior for unspecified axes.

✏️ Tip: You can customize this high-level summary in your review settings.

If only x or y is set while the other is null, the set value was ignored and it was auto centered upon start.

Fixed to match iOS ~line 1959 Plugin.swift
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 23, 2025

📝 Walkthrough

Walkthrough

The camera preview centering logic is updated to conditionally auto-center based on configuration values. When x or y coordinates are not explicitly set (value -1), they are auto-centered; otherwise, explicitly provided coordinates are preserved. No public API changes.

Changes

Cohort / File(s) Summary
Camera Preview Centering Logic
android/src/main/java/app/capgo/capacitor/camera/preview/CameraXView.java
Modified conditional logic to auto-center preview only on axes where configuration values equal -1; preserves explicitly set x/y coordinates instead of always auto-centering both axes

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rabbit adjusted the lens with care,
Centering frames with selective flair,
When coordinates hide (that minus-one way),
Auto-align takes the stage for the day,
But explicit values? They get their say! 📸

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main bug fix: addressing the issue where setting only x or y parameter was being ignored due to auto-centering logic.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8653b21 and e848a9f.

📒 Files selected for processing (1)
  • android/src/main/java/app/capgo/capacitor/camera/preview/CameraXView.java
🔇 Additional comments (1)
android/src/main/java/app/capgo/capacitor/camera/preview/CameraXView.java (1)

666-672: LGTM! Fix correctly preserves explicit coordinate values.

The conditional auto-centering logic properly addresses the issue where single x or y parameter assignments were being ignored. Each coordinate is now independently checked and only auto-centered if set to -1, which allows users to specify just x (with y auto-centered) or just y (with x auto-centered).

Optional: Minor comment clarity improvement

The comment on line 666 could be slightly more precise:

-                    // Center the preview only overwrite what was not explicitly set
+                    // Auto-center only the coordinates that were not explicitly set (value == -1)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@buhleryesco
Copy link
Author

@coderabbitai generate docstrings

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 24, 2025

✅ Actions performed

Initiated docstring generation; will generate only if new commits exist.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 24, 2025

Note

Docstrings generation - SUCCESS
Generated docstrings for this pull request at #274

coderabbitai bot added a commit that referenced this pull request Dec 24, 2025
Docstrings generation was requested by @buhleryesco.

* #273 (comment)

The following files were modified:

* `android/src/main/java/app/capgo/capacitor/camera/preview/CameraXView.java`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant