summaryrefslogtreecommitdiff
path: root/android-app/app/src/main/kotlin
diff options
context:
space:
mode:
Diffstat (limited to 'android-app/app/src/main/kotlin')
-rw-r--r--android-app/app/src/main/kotlin/com/example/androidapp/MainActivity.kt77
1 files changed, 77 insertions, 0 deletions
diff --git a/android-app/app/src/main/kotlin/com/example/androidapp/MainActivity.kt b/android-app/app/src/main/kotlin/com/example/androidapp/MainActivity.kt
index 3128ee3..d4c6998 100644
--- a/android-app/app/src/main/kotlin/com/example/androidapp/MainActivity.kt
+++ b/android-app/app/src/main/kotlin/com/example/androidapp/MainActivity.kt
@@ -1,7 +1,11 @@
package com.example.androidapp
import android.os.Bundle
+import android.view.View
+import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
+import androidx.constraintlayout.widget.ConstraintLayout
+import com.google.android.material.floatingactionbutton.FloatingActionButton
import org.maplibre.android.MapLibre
import org.maplibre.android.maps.MapView
import org.maplibre.android.maps.Style
@@ -9,6 +13,20 @@ import org.maplibre.android.maps.Style
class MainActivity : AppCompatActivity() {
private var mapView: MapView? = null
+ private lateinit var instrumentDisplayContainer: ConstraintLayout
+ private lateinit var fabToggleInstruments: FloatingActionButton
+
+ // Instrument TextViews
+ private lateinit var valueAws: TextView
+ private lateinit var valueTws: TextView
+ private lateinit var valueHdg: TextView
+ private lateinit var valueCog: TextView
+ private lateinit var valueBsp: TextView
+ private lateinit var valueSog: TextView
+ private lateinit var valueVmg: TextView
+ private lateinit var valueDepth: TextView
+ private lateinit var valuePolarPct: TextView
+
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -21,6 +39,65 @@ class MainActivity : AppCompatActivity() {
mapView?.getMapAsync { maplibreMap ->
maplibreMap.setStyle(Style.Builder().fromUri("https://tiles.openseamap.org/seamark/osm-bright/style.json"))
}
+
+ instrumentDisplayContainer = findViewById(R.id.instrument_display_container)
+ fabToggleInstruments = findViewById(R.id.fab_toggle_instruments)
+
+ // Initialize instrument TextViews
+ valueAws = findViewById(R.id.value_aws)
+ valueTws = findViewById(R.id.value_tws)
+ valueHdg = findViewById(R.id.value_hdg)
+ valueCog = findViewById(R.id.value_cog)
+ valueBsp = findViewById(R.id.value_bsp)
+ valueSog = findViewById(R.id.value_sog)
+ valueVmg = findViewById(R.id.value_vmg)
+ valueDepth = findViewById(R.id.value_depth)
+ valuePolarPct = findViewById(R.id.value_polar_pct)
+
+ // Set initial placeholder values
+ updateInstrumentDisplay(
+ aws = getString(R.string.placeholder_aws_value),
+ tws = getString(R.string.placeholder_tws_value),
+ hdg = getString(R.string.placeholder_hdg_value),
+ cog = getString(R.string.placeholder_cog_value),
+ bsp = getString(R.string.placeholder_bsp_value),
+ sog = getString(R.string.placeholder_sog_value),
+ vmg = getString(R.string.placeholder_vmg_value),
+ depth = getString(R.string.placeholder_depth_value),
+ polarPct = getString(R.string.placeholder_polar_value)
+ )
+
+ fabToggleInstruments.setOnClickListener {
+ if (instrumentDisplayContainer.visibility == View.VISIBLE) {
+ instrumentDisplayContainer.visibility = View.GONE
+ mapView?.visibility = View.VISIBLE
+ } else {
+ instrumentDisplayContainer.visibility = View.VISIBLE
+ mapView?.visibility = View.GONE
+ }
+ }
+ }
+
+ private fun updateInstrumentDisplay(
+ aws: String,
+ tws: String,
+ hdg: String,
+ cog: String,
+ bsp: String,
+ sog: String,
+ vmg: String,
+ depth: String,
+ polarPct: String
+ ) {
+ valueAws.text = aws
+ valueTws.text = tws
+ valueHdg.text = hdg
+ valueCog.text = cog
+ valueBsp.text = bsp
+ valueSog.text = sog
+ valueVmg.text = vmg
+ valueDepth.text = depth
+ valuePolarPct.text = polarPct
}
override fun onStart() {