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 @@ -26,8 +26,8 @@ class Utils(private val context: ReactContext) {
2626 val rollDegrees = Math .toDegrees(rollRadians.toDouble()).toFloat()
2727
2828 // This is needed to account for inaccuracy due to subtle movements such as tilting
29- val pitchTolerance = 5f
30- val tolerance = 20f
29+ val pitchTolerance = 15f
30+ val rollTolerance = 20f
3131
3232 // ////////////////////////////////////
3333 // These limits are set based on SensorManager.getOrientation reference
@@ -44,8 +44,8 @@ class Utils(private val context: ReactContext) {
4444 return when {
4545 rollDegrees.equals(- 0f ) && (pitchDegrees.equals(0f ) || pitchDegrees.equals(- 0f )) -> Orientation .FACE_UP
4646 rollDegrees.equals(- 180f ) && (pitchDegrees.equals(0f ) || pitchDegrees.equals(- 0f )) -> Orientation .FACE_DOWN
47- rollDegrees in tolerance .. landscapeRightLimit - tolerance && isPitchInLandscapeModeRange -> Orientation .LANDSCAPE_RIGHT
48- rollDegrees in landscapeLeftLimit + tolerance .. - tolerance && isPitchInLandscapeModeRange -> Orientation .LANDSCAPE_LEFT
47+ rollDegrees in rollTolerance .. landscapeRightLimit - rollTolerance && isPitchInLandscapeModeRange -> Orientation .LANDSCAPE_RIGHT
48+ rollDegrees in landscapeLeftLimit + rollTolerance .. - rollTolerance && isPitchInLandscapeModeRange -> Orientation .LANDSCAPE_LEFT
4949 pitchDegrees in portraitLimit.. pitchTolerance -> Orientation .PORTRAIT
5050 else -> Orientation .PORTRAIT_UPSIDE_DOWN
5151 }
You can’t perform that action at this time.
0 commit comments