-
Notifications
You must be signed in to change notification settings - Fork 1
feat(android): introduce new rotation sensor #80
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
Conversation
|
Note: merge this PR after this one #78 |
338f923 to
3d89a2c
Compare
WalkthroughThe code now supports device orientation calculation using the rotation vector sensor as a priority, with fallback to the accelerometer and magnetic field sensors if the rotation vector sensor is unavailable. The sensor registration logic was updated to conditionally enable the appropriate sensors, and orientation computation was modularized into distinct private methods. Changes
Sequence Diagram(s)sequenceDiagram
participant App
participant OrientationSensorsEventListener
participant SensorManager
participant RotationVectorSensor
participant Accelerometer
participant MagneticField
App->>OrientationSensorsEventListener: enable()
OrientationSensorsEventListener->>SensorManager: Check for RotationVectorSensor
alt RotationVectorSensor available
OrientationSensorsEventListener->>SensorManager: Register RotationVectorSensor listener
RotationVectorSensor-->>OrientationSensorsEventListener: onSensorChanged
OrientationSensorsEventListener->>OrientationSensorsEventListener: computeOrientationFromRotationSensor()
else
OrientationSensorsEventListener->>SensorManager: Register Accelerometer & MagneticField listeners
Accelerometer-->>OrientationSensorsEventListener: onSensorChanged
MagneticField-->>OrientationSensorsEventListener: onSensorChanged
OrientationSensorsEventListener->>OrientationSensorsEventListener: computeOrientationFromOtherSensors()
end
OrientationSensorsEventListener->>App: notifyOrientationAnglesChanged()
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🧰 Additional context used🪛 detekt (1.23.8)android/src/main/java/com/orientationdirector/implementation/OrientationSensorsEventListener.kt[warning] 50-50: This empty block of code can be removed. (detekt.empty-blocks.EmptyFunctionBlock) 🔇 Additional comments (7)
|
Goal
This PR introduces a new sensor that is best suited on modern devices to obtain better data needed when computing device orientation, as per documentation.
Summary by CodeRabbit