Skip to content

Commit

Permalink
Make navigator sighting compass larger
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecorry31 committed Nov 5, 2023
1 parent c3322f5 commit 7e06449
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.kylecorry.trail_sense.navigation.ui

import android.view.View
import androidx.camera.view.PreviewView
import androidx.core.view.isVisible
import com.kylecorry.andromeda.alerts.Alerts
import com.kylecorry.andromeda.camera.Camera
Expand Down Expand Up @@ -32,6 +33,7 @@ class SightingCompassView(

init {
camera.setShowTorch(false)
camera.setScaleType(PreviewView.ScaleType.FILL_CENTER)
}

fun start() {
Expand Down Expand Up @@ -72,6 +74,7 @@ class SightingCompassView(

fun update(){
if (!isRunning()){
compass.range = 180f
return
}
scope.launch {
Expand All @@ -95,11 +98,10 @@ class SightingCompassView(
} catch (e: Exception) {
e.printStackTrace()
}
compass.range = 180f
camera.isVisible = false
reticle.isVisible = false
fovRunner.cancel()
zoomRunner.cancel()
camera.isVisible = false
reticle.isVisible = false
}

fun isRunning(): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ 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 @@ -253,9 +255,14 @@ class CameraView(context: Context, attrs: AttributeSet?) : FrameLayout(context,
val newZoom = (zoom + remainingZoom / 2).coerceIn(0f, 1f)
zoomListener?.invoke(newZoom)
setZoom(newZoom)
return true
}
return super.onDoubleTap(e)
}

override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
return callOnClick() || super.onSingleTapConfirmed(e)
}
}

private val scaleListener = object : ScaleGestureDetector.SimpleOnScaleGestureListener() {
Expand All @@ -265,8 +272,9 @@ class CameraView(context: Context, attrs: AttributeSet?) : FrameLayout(context,
val newZoom = (zoom - 1 + detector.scaleFactor ).coerceIn(0f, 1f)
zoomListener?.invoke(newZoom)
setZoom(newZoom)
return true
}
return true
return false
}
}

Expand Down
10 changes: 5 additions & 5 deletions app/src/main/res/layout/activity_navigator.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@

<com.kylecorry.trail_sense.shared.views.CameraView
android:id="@+id/view_camera"
android:layout_width="200dp"
android:layout_height="248dp"
android:layout_width="match_parent"
android:layout_height="@dimen/circular_display_size"
android:keepScreenOn="true"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@id/linear_compass"
Expand All @@ -63,13 +63,13 @@
<View
android:id="@+id/view_camera_line"
android:layout_width="1dp"
android:layout_height="248dp"
android:layout_height="0dp"
android:background="@color/orange_40"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@id/linear_compass"
app:layout_constraintBottom_toBottomOf="@id/view_camera"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/linear_compass" />
app:layout_constraintTop_toTopOf="@id/view_camera" />


<com.kylecorry.trail_sense.navigation.ui.RoundCompassView
Expand Down

0 comments on commit 7e06449

Please sign in to comment.