diff --git a/app/src/main/java/com/kylecorry/trail_sense/shared/views/CameraView.kt b/app/src/main/java/com/kylecorry/trail_sense/shared/views/CameraView.kt index e1022f62d..96be740de 100644 --- a/app/src/main/java/com/kylecorry/trail_sense/shared/views/CameraView.kt +++ b/app/src/main/java/com/kylecorry/trail_sense/shared/views/CameraView.kt @@ -280,9 +280,9 @@ class CameraView(context: Context, attrs: AttributeSet?) : FrameLayout(context, private val mScaleDetector = ScaleGestureDetector(context, scaleListener) override fun onTouchEvent(event: MotionEvent): Boolean { - var consumed = mScaleDetector.onTouchEvent(event) - consumed = consumed || gestureDetector.onTouchEvent(event) - return consumed || super.onTouchEvent(event) + mScaleDetector.onTouchEvent(event) + gestureDetector.onTouchEvent(event) + return true } diff --git a/app/src/main/java/com/kylecorry/trail_sense/tools/augmented_reality/AugmentedRealityFragment.kt b/app/src/main/java/com/kylecorry/trail_sense/tools/augmented_reality/AugmentedRealityFragment.kt index 294f62503..6d136b182 100644 --- a/app/src/main/java/com/kylecorry/trail_sense/tools/augmented_reality/AugmentedRealityFragment.kt +++ b/app/src/main/java/com/kylecorry/trail_sense/tools/augmented_reality/AugmentedRealityFragment.kt @@ -115,6 +115,8 @@ class AugmentedRealityFragment : BoundFragment( binding.camera.setScaleType(PreviewView.ScaleType.FIT_CENTER) binding.camera.setShowTorch(false) + binding.arView.bind(binding.camera) + binding.arView.setLayers(listOf(gridLayer, sunLayer, moonLayer, beaconLayer)) binding.cameraToggle.setOnClickListener { diff --git a/app/src/main/java/com/kylecorry/trail_sense/tools/augmented_reality/AugmentedRealityView.kt b/app/src/main/java/com/kylecorry/trail_sense/tools/augmented_reality/AugmentedRealityView.kt index a451bb381..db8681c28 100644 --- a/app/src/main/java/com/kylecorry/trail_sense/tools/augmented_reality/AugmentedRealityView.kt +++ b/app/src/main/java/com/kylecorry/trail_sense/tools/augmented_reality/AugmentedRealityView.kt @@ -27,6 +27,7 @@ import com.kylecorry.trail_sense.shared.declination.DeclinationUtils import com.kylecorry.trail_sense.shared.sensors.SensorService import com.kylecorry.trail_sense.shared.text import com.kylecorry.trail_sense.shared.textDimensions +import com.kylecorry.trail_sense.shared.views.CameraView import com.kylecorry.trail_sense.tools.augmented_reality.position.ARPoint import java.time.Duration import kotlin.math.atan2 @@ -418,9 +419,17 @@ class AugmentedRealityView : CanvasView { private val mGestureDetector = GestureDetector(context, gestureListener) + private var camera: CameraView? = null + override fun onTouchEvent(event: MotionEvent): Boolean { - val consumed = mGestureDetector.onTouchEvent(event) - return consumed || super.onTouchEvent(event) + mGestureDetector.onTouchEvent(event) + camera?.onTouchEvent(event) + return true + } + + fun bind(camera: CameraView){ + this.camera = camera + // TODO: Listen for fov and size changes } data class HorizonCoordinate( diff --git a/app/src/main/java/com/kylecorry/trail_sense/tools/clinometer/ui/ClinometerFragment.kt b/app/src/main/java/com/kylecorry/trail_sense/tools/clinometer/ui/ClinometerFragment.kt index 16e37d275..ede469f73 100644 --- a/app/src/main/java/com/kylecorry/trail_sense/tools/clinometer/ui/ClinometerFragment.kt +++ b/app/src/main/java/com/kylecorry/trail_sense/tools/clinometer/ui/ClinometerFragment.kt @@ -162,6 +162,8 @@ class ClinometerFragment : BoundFragment() { binding.arView.showReticle = false binding.arView.showPosition = false + binding.arView.bind(binding.camera) + observe(sideClinometer) { updateUI() } observe(cameraClinometer) { updateUI() } observe(deviceOrientation) { updateUI() }