mirror of
https://github.com/vide/matedroid.git
synced 2026-01-20 00:03:17 +08:00
feat: make all maps tappable to open external map app
- Dashboard location card: opens geo: URI at car coordinates - Drive detail map: opens Google Maps with route from start to end - Charge detail map: opens geo: URI at charge location - Dashboard now shows coordinates when car is not at a saved location 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.5
parent
53aa57c152
commit
d30ee67edf
@@ -1,7 +1,10 @@
|
||||
package com.matedroid.ui.screens.charges
|
||||
|
||||
import android.content.Intent
|
||||
import android.graphics.Paint
|
||||
import android.net.Uri
|
||||
import androidx.compose.foundation.Canvas
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
@@ -369,8 +372,16 @@ private fun LocationHeaderCard(detail: ChargeDetail) {
|
||||
private fun ChargeMapCard(latitude: Double, longitude: Double) {
|
||||
val context = LocalContext.current
|
||||
|
||||
fun openInMaps() {
|
||||
val geoUri = Uri.parse("geo:$latitude,$longitude?q=$latitude,$longitude")
|
||||
val intent = Intent(Intent.ACTION_VIEW, geoUri)
|
||||
context.startActivity(intent)
|
||||
}
|
||||
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable { openInMaps() },
|
||||
colors = CardDefaults.cardColors(
|
||||
containerColor = MaterialTheme.colorScheme.surface
|
||||
)
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.matedroid.ui.screens.drives
|
||||
|
||||
import android.content.Intent
|
||||
import android.graphics.Color as AndroidColor
|
||||
import android.graphics.Paint
|
||||
import android.net.Uri
|
||||
import androidx.compose.foundation.Canvas
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
@@ -358,8 +361,27 @@ private fun DriveMapCard(positions: List<DrivePosition>) {
|
||||
|
||||
if (validPositions.isEmpty()) return
|
||||
|
||||
val startPoint = validPositions.firstOrNull()
|
||||
val endPoint = validPositions.lastOrNull()
|
||||
|
||||
fun openInMaps() {
|
||||
if (startPoint != null && endPoint != null) {
|
||||
// Open Google Maps with directions from start to end
|
||||
val uri = Uri.parse(
|
||||
"https://www.google.com/maps/dir/?api=1" +
|
||||
"&origin=${startPoint.latitude},${startPoint.longitude}" +
|
||||
"&destination=${endPoint.latitude},${endPoint.longitude}" +
|
||||
"&travelmode=driving"
|
||||
)
|
||||
val intent = Intent(Intent.ACTION_VIEW, uri)
|
||||
context.startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable { openInMaps() },
|
||||
colors = CardDefaults.cardColors(
|
||||
containerColor = MaterialTheme.colorScheme.surface
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user