File tree Expand file tree Collapse file tree
android/src/main/java/com/orientationdirector/implementation Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,11 +38,13 @@ class Utils(private val context: ReactContext) {
3838 //
3939 // ////////////////////////////////////
4040
41+ val isPitchInLandscapeModeRange = checkIfPitchIsInLandscapeModeRange(pitchDegrees)
42+
4143 return when {
4244 rollDegrees.equals(- 0f ) && (pitchDegrees.equals(0f ) || pitchDegrees.equals(- 0f )) -> Orientation .FACE_UP
4345 rollDegrees.equals(- 180f ) && (pitchDegrees.equals(0f ) || pitchDegrees.equals(- 0f )) -> Orientation .FACE_DOWN
44- rollDegrees in tolerance.. landscapeRightLimit - tolerance -> Orientation .LANDSCAPE_RIGHT
45- rollDegrees in landscapeLeftLimit + tolerance.. - tolerance -> Orientation .LANDSCAPE_LEFT
46+ rollDegrees in tolerance.. landscapeRightLimit - tolerance && isPitchInLandscapeModeRange -> Orientation .LANDSCAPE_RIGHT
47+ rollDegrees in landscapeLeftLimit + tolerance.. - tolerance && isPitchInLandscapeModeRange -> Orientation .LANDSCAPE_LEFT
4648 pitchDegrees in portraitLimit.. - 0f -> Orientation .PORTRAIT
4749 else -> Orientation .PORTRAIT_UPSIDE_DOWN
4850 }
@@ -94,4 +96,9 @@ class Utils(private val context: ReactContext) {
9496
9597 return context.currentActivity!! .requestedOrientation;
9698 }
99+
100+ private fun checkIfPitchIsInLandscapeModeRange (pitchDegrees : Float ): Boolean {
101+ val tolerance = 5f
102+ return pitchDegrees > - tolerance && pitchDegrees < tolerance
103+ }
97104}
You can’t perform that action at this time.
0 commit comments