Skip to content

Commit

Permalink
Keep screen on while the camera is on
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecorry31 committed Nov 5, 2023
1 parent 7e06449 commit 122cb6b
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.kylecorry.trail_sense.shared.views
import android.annotation.SuppressLint
import android.content.Context
import android.graphics.Bitmap
import android.graphics.RectF
import android.util.AttributeSet
import android.util.Size
import android.view.GestureDetector
Expand All @@ -13,7 +12,6 @@ import android.widget.FrameLayout
import android.widget.ImageButton
import android.widget.SeekBar
import androidx.camera.view.PreviewView
import androidx.core.view.drawToBitmap
import androidx.core.view.isVisible
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
Expand All @@ -24,9 +22,7 @@ import com.kylecorry.andromeda.camera.ICamera
import com.kylecorry.andromeda.camera.ImageCaptureSettings
import com.kylecorry.andromeda.core.bitmap.BitmapUtils.toBitmap
import com.kylecorry.andromeda.core.ui.setOnProgressChangeListener
import com.kylecorry.andromeda.core.units.PixelCoordinate
import com.kylecorry.sol.math.SolMath
import com.kylecorry.sol.math.SolMath.toDegrees
import com.kylecorry.trail_sense.R
import java.io.File
import kotlin.math.abs
Expand Down Expand Up @@ -58,8 +54,6 @@ class CameraView(context: Context, attrs: AttributeSet?) : FrameLayout(context,
private var isStarted = false
private val startLock = Any()

private var onSingleTapCallback: (e: MotionEvent) -> Unit = {}

fun start(
resolution: Size? = null,
lifecycleOwner: LifecycleOwner? = null,
Expand Down Expand Up @@ -92,6 +86,9 @@ class CameraView(context: Context, attrs: AttributeSet?) : FrameLayout(context,
isStarted = true
}

// Keep the screen on while the camera is on
keepScreenOn = true

camera?.stop(this::onCameraUpdate)
imageListener = onImage
camera = Camera(
Expand All @@ -110,6 +107,7 @@ class CameraView(context: Context, attrs: AttributeSet?) : FrameLayout(context,
fun stop() {
camera?.stop(this::onCameraUpdate)
camera = null
keepScreenOn = false
synchronized(startLock) {
isStarted = false
}
Expand Down

0 comments on commit 122cb6b

Please sign in to comment.