-
Notifications
You must be signed in to change notification settings - Fork 1
fix(android): broken interface computation #89
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
fix(android): broken interface computation #89
Conversation
WalkthroughThe code refactors a method in the Changes
Possibly related PRs
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
android/src/main/java/com/orientationdirector/implementation/Utils.kt
Outdated
Show resolved
Hide resolved
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.
Actionable comments posted: 2
🧹 Nitpick comments (1)
android/src/main/java/com/orientationdirector/implementation/Utils.kt (1)
30-32: Consider extracting the tolerance constants.The inline helper function is clean, but the tolerance values are scattered throughout the method. Consider extracting them as constants for better maintainability and consistency.
+private const val FACE_UP_DOWN_PITCH_TOLERANCE = 30f +private const val ORIENTATION_TOLERANCE = 45f +private const val FACE_UP_DOWN_ROLL_TOLERANCE = 30f fun convertToDeviceOrientationFrom(orientationAngles: FloatArray): Orientation { // ... existing code ... - val faceUpDownPitchTolerance = 30f fun isValueCloseTo(value: Float, target: Float, tolerance: Float): Boolean { return value in (target - tolerance)..(target + tolerance) }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
android/src/main/java/com/orientationdirector/implementation/Utils.kt(1 hunks)
🔇 Additional comments (1)
android/src/main/java/com/orientationdirector/implementation/Utils.kt (1)
34-54: Orientation mappings and tolerances confirmed
All mappings inconvertToDeviceOrientationFromalign with the expected device orientations, and the existing tests cover each principal case. While the 45° roll and 30° pitch tolerances do produce overlapping detection regions at their boundaries (for example, roll = ±45° with pitch within ±30°), thewhen‐branch order (face up/down → portrait → portrait-upside-down → landscape) ensures a deterministic outcome.• File: android/src/main/java/com/orientationdirector/implementation/Utils.kt
– faceUp/down: pitch ±30°, roll ±45°
– portrait/u-down: pitch ±45° around ±90°
– landscape: roll ±45° around ±90°
– branch priority avoids ambiguity on overlaps
• Tests in UtilsTest.kt validate the central angle cases for each orientationIf you need to guarantee behavior exactly at the tolerance boundaries, you may add tests for those edge values or adjust the tolerance constants. Otherwise, no changes are required here.
android/src/main/java/com/orientationdirector/implementation/Utils.kt
Outdated
Show resolved
Hide resolved
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Summary by CodeRabbit
Bug Fixes
Refactor