summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaude <noreply@anthropic.com>2026-05-27 15:38:39 +0000
committerClaude <noreply@anthropic.com>2026-05-27 15:38:39 +0000
commit6261b85ba8ddd7a7d300f92f40fba185d425d2b6 (patch)
treee665a36468246bbaafb0972091cfecbc281263fe
parentb18f2c94e7dd171c1d8209158237f88bea43f051 (diff)
Embed anchor watch form inline in Safety Dashboard
Replaces the "Configure Anchor Watch" button with depth and rode EditTexts directly in the anchor card; radius updates live via TextWatcher. Removes the separate AnchorWatchHandler overlay flow and onConfigureAnchor() from SafetyListener. https://claude.ai/code/session_01KXYBuAHZkvv63DeUG6XaZD
-rw-r--r--android-app/app/src/main/kotlin/org/terst/nav/MainActivity.kt4
-rw-r--r--android-app/app/src/main/kotlin/org/terst/nav/ui/safety/SafetyFragment.kt25
-rw-r--r--android-app/app/src/main/res/layout/fragment_safety.xml76
3 files changed, 93 insertions, 12 deletions
diff --git a/android-app/app/src/main/kotlin/org/terst/nav/MainActivity.kt b/android-app/app/src/main/kotlin/org/terst/nav/MainActivity.kt
index e4bc9b5..da887f4 100644
--- a/android-app/app/src/main/kotlin/org/terst/nav/MainActivity.kt
+++ b/android-app/app/src/main/kotlin/org/terst/nav/MainActivity.kt
@@ -504,10 +504,6 @@ class MainActivity : AppCompatActivity(), SafetyFragment.SafetyListener {
}
}
- override fun onConfigureAnchor() {
- showOverlay(org.terst.nav.ui.anchorwatch.AnchorWatchHandler())
- }
-
override fun onHardwareSourceChanged(source: HardwareSource, enabled: Boolean) {
viewModel.onHardwareSourceChanged(source, enabled)
if (source == HardwareSource.NMEA_INSTRUMENTS) {
diff --git a/android-app/app/src/main/kotlin/org/terst/nav/ui/safety/SafetyFragment.kt b/android-app/app/src/main/kotlin/org/terst/nav/ui/safety/SafetyFragment.kt
index d906094..c4b6e1e 100644
--- a/android-app/app/src/main/kotlin/org/terst/nav/ui/safety/SafetyFragment.kt
+++ b/android-app/app/src/main/kotlin/org/terst/nav/ui/safety/SafetyFragment.kt
@@ -1,9 +1,12 @@
package org.terst.nav.ui.safety
import android.os.Bundle
+import android.text.Editable
+import android.text.TextWatcher
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.widget.EditText
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
@@ -14,6 +17,7 @@ import org.terst.nav.R
import org.terst.nav.ais.CpaAlert
import org.terst.nav.ais.CpaSeverity
import org.terst.nav.ais.label
+import org.terst.nav.safety.AnchorWatchState
import org.terst.nav.settings.HardwareSource
import org.terst.nav.ui.doc.DocFragment
@@ -21,7 +25,6 @@ class SafetyFragment : Fragment() {
interface SafetyListener {
fun onActivateMob()
- fun onConfigureAnchor()
fun onHardwareSourceChanged(source: HardwareSource, enabled: Boolean)
fun onQuitRequested()
}
@@ -52,9 +55,25 @@ class SafetyFragment : Fragment() {
listener?.onActivateMob()
}
- view.findViewById<MaterialButton>(R.id.button_anchor_config).setOnClickListener {
- listener?.onConfigureAnchor()
+ val etDepth = view.findViewById<EditText>(R.id.et_anchor_depth)
+ val etRode = view.findViewById<EditText>(R.id.et_anchor_rode)
+ val tvRadius = view.findViewById<TextView>(R.id.tv_anchor_suggested_radius)
+ val watcher = object : TextWatcher {
+ override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) = Unit
+ override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) = Unit
+ override fun afterTextChanged(s: Editable?) {
+ val depth = etDepth.text.toString().toDoubleOrNull()
+ val rode = etRode.text.toString().toDoubleOrNull()
+ tvRadius.text = if (depth != null && rode != null && depth >= 0.0 && rode > 0.0) {
+ val r = AnchorWatchState.calculateRecommendedWatchCircleRadius(depth, 2.0, rode)
+ getString(R.string.anchor_suggested_radius_fmt, r)
+ } else {
+ getString(R.string.anchor_suggested_radius_empty)
+ }
+ }
}
+ etDepth.addTextChangedListener(watcher)
+ etRode.addTextChangedListener(watcher)
val flags = (requireActivity().application as NavApplication).featureFlags
diff --git a/android-app/app/src/main/res/layout/fragment_safety.xml b/android-app/app/src/main/res/layout/fragment_safety.xml
index 1072abe..1d499ab 100644
--- a/android-app/app/src/main/res/layout/fragment_safety.xml
+++ b/android-app/app/src/main/res/layout/fragment_safety.xml
@@ -127,13 +127,79 @@
android:text="Status: Inactive"
android:textColor="?attr/colorOnSurfaceVariant" />
- <com.google.android.material.button.MaterialButton
- android:id="@+id/button_anchor_config"
- style="@style/Widget.Material3.Button.TonalButton"
+ <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="16dp"
- android:text="CONFIGURE ANCHOR WATCH" />
+ android:orientation="horizontal"
+ android:layout_marginTop="16dp">
+
+ <LinearLayout
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:orientation="vertical"
+ android:layout_marginEnd="8dp">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/anchor_depth_label"
+ android:textSize="12sp"
+ android:textColor="?attr/colorOnSurfaceVariant" />
+
+ <EditText
+ android:id="@+id/et_anchor_depth"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:hint="@string/anchor_depth_hint"
+ android:inputType="numberDecimal"
+ android:importantForAutofill="no" />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:orientation="vertical"
+ android:layout_marginStart="8dp">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/anchor_rode_label"
+ android:textSize="12sp"
+ android:textColor="?attr/colorOnSurfaceVariant" />
+
+ <EditText
+ android:id="@+id/et_anchor_rode"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:hint="@string/anchor_rode_hint"
+ android:inputType="numberDecimal"
+ android:importantForAutofill="no" />
+
+ </LinearLayout>
+
+ </LinearLayout>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="12dp"
+ android:text="@string/anchor_suggested_radius_label"
+ android:textSize="12sp"
+ android:textColor="?attr/colorOnSurfaceVariant" />
+
+ <TextView
+ android:id="@+id/tv_anchor_suggested_radius"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="2dp"
+ android:text="@string/anchor_suggested_radius_empty"
+ android:textSize="16sp"
+ android:textStyle="bold"
+ android:textColor="?attr/colorOnSurface" />
</LinearLayout>