summaryrefslogtreecommitdiff
path: root/android-app/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'android-app/app/src')
-rw-r--r--android-app/app/src/androidTest/kotlin/org/terst/nav/MainActivitySmokeTest.kt29
-rw-r--r--android-app/app/src/main/kotlin/org/terst/nav/MainActivity.kt16
2 files changed, 43 insertions, 2 deletions
diff --git a/android-app/app/src/androidTest/kotlin/org/terst/nav/MainActivitySmokeTest.kt b/android-app/app/src/androidTest/kotlin/org/terst/nav/MainActivitySmokeTest.kt
new file mode 100644
index 0000000..fec571a
--- /dev/null
+++ b/android-app/app/src/androidTest/kotlin/org/terst/nav/MainActivitySmokeTest.kt
@@ -0,0 +1,29 @@
+package org.terst.nav
+
+import androidx.test.core.app.ActivityScenario
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import org.junit.Test
+import org.junit.runner.RunWith
+
+/**
+ * Smoke test: verifies MainActivity launches without crashing.
+ *
+ * Run on an emulator/device via:
+ * ./gradlew connectedDebugAndroidTest
+ *
+ * In CI, requires an emulator step before the Gradle task.
+ */
+@RunWith(AndroidJUnit4::class)
+class MainActivitySmokeTest {
+
+ @Test
+ fun mainActivity_launches_withoutCrash() {
+ ActivityScenario.launch(MainActivity::class.java).use { scenario ->
+ // If we reach this line the activity started without throwing.
+ // onActivity lets us assert it is in a resumed state.
+ scenario.onActivity { activity ->
+ assert(!activity.isFinishing) { "MainActivity finished immediately after launch" }
+ }
+ }
+ }
+}
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 a6c063b..aa35914 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
@@ -2,6 +2,8 @@ package org.terst.nav
import android.Manifest
import android.content.pm.PackageManager
+import android.graphics.Bitmap
+import android.graphics.Canvas
import android.graphics.BitmapFactory
import android.location.Location
import android.media.MediaPlayer
@@ -516,8 +518,18 @@ class MainActivity : AppCompatActivity() {
}
private fun setupTidalCurrentMapLayers(style: Style) {
- // Add tidal arrow icon
- style.addImage(TIDAL_ARROW_ICON_ID, BitmapFactory.decodeResource(resources, R.drawable.ic_tidal_arrow))
+ // Add tidal arrow icon (vector drawable — must rasterise manually; BitmapFactory returns null for VDs)
+ val tidalArrowDrawable = ContextCompat.getDrawable(this, R.drawable.ic_tidal_arrow) ?: return
+ val tidalArrowBitmap = Bitmap.createBitmap(
+ tidalArrowDrawable.intrinsicWidth.coerceAtLeast(24),
+ tidalArrowDrawable.intrinsicHeight.coerceAtLeast(24),
+ Bitmap.Config.ARGB_8888
+ )
+ Canvas(tidalArrowBitmap).also { canvas ->
+ tidalArrowDrawable.setBounds(0, 0, canvas.width, canvas.height)
+ tidalArrowDrawable.draw(canvas)
+ }
+ style.addImage(TIDAL_ARROW_ICON_ID, tidalArrowBitmap)
// Create source
tidalCurrentSource = GeoJsonSource(TIDAL_CURRENT_SOURCE_ID)