diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index bbf6914a..2a7f34b5 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -14,6 +14,7 @@ + = -SENSOR_SENSITIVITY && event.values[0] <= SENSOR_SENSITIVITY) { + turnOffScreen() + } else { + turnOnScreen() + } + } + } + + private fun turnOffScreen() { + if (proximityWakeLock?.isHeld == false) { + proximityWakeLock!!.acquire() + } + } + + private fun turnOnScreen() { + if (proximityWakeLock?.isHeld == true) { + proximityWakeLock!!.release(PowerManager.RELEASE_FLAG_WAIT_FOR_NO_PROXIMITY) + } + } }