Modern Apps git

← Modern-Apps.git

calendar: open event location in navigation app on tap

Commit
3255a23749a3639b579ae66f6800ecd8bcc1920c
Author
Vayun Mathur <[email protected]>
When
2026-05-29 18:00 UTC (6 months ago)
Parents
750f737

Diff

calendar/src/main/java/com/vayunmathur/calendar/ui/EventScreen.kt
diff --git a/calendar/src/main/java/com/vayunmathur/calendar/ui/EventScreen.kt b/calendar/src/main/java/com/vayunmathur/calendar/ui/EventScreen.ktindex 168aa9ac1b..aca4e589a7 100644--- a/calendar/src/main/java/com/vayunmathur/calendar/ui/EventScreen.kt+++ b/calendar/src/main/java/com/vayunmathur/calendar/ui/EventScreen.kt@@ -1,8 +1,12 @@ package com.vayunmathur.calendar.ui +import android.content.ActivityNotFoundException import android.content.Context+import android.content.Intent+import android.net.Uri import android.text.format.DateFormat import androidx.compose.foundation.background+import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.padding@@ -92,8 +96,29 @@ fun EventScreen(viewModel: CalendarViewModel, instance: Instance, backStack: Nav             }, leadingContent = {                 Icon(painterResource(R.drawable.description_24px), null)             })-            if(event.location.isNotBlank()) ListItem({Text(event.location)}, leadingContent =-                {Icon(painterResource(R.drawable.globe_24px), null)},+            if(event.location.isNotBlank()) ListItem(+                { Text(event.location) },+                Modifier.clickable {+                    val intent = Intent(+                        Intent.ACTION_VIEW,+                        // "geo:0,0?q=<text>" lets any installed maps/navigation+                        // app (Google Maps, Waze, our own maps app, etc.)+                        // resolve the address. Wrap with chooser so user can+                        // pick if multiple are installed.+                        Uri.parse("geo:0,0?q=${Uri.encode(event.location)}")+                    ).apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) }+                    val chooser = Intent.createChooser(+                        intent,+                        context.getString(R.string.open_location_in_navigation)+                    ).apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) }+                    try {+                        context.startActivity(chooser)+                    } catch (_: ActivityNotFoundException) {+                        // No nav app installed — silently drop; the text is+                        // still selectable elsewhere.+                    }+                },+                leadingContent = { Icon(painterResource(R.drawable.globe_24px), null) },             )         }     }
calendar/src/main/res/values/strings.xml
diff --git a/calendar/src/main/res/values/strings.xml b/calendar/src/main/res/values/strings.xmlindex da04105feb..ade5392c5e 100644--- a/calendar/src/main/res/values/strings.xml+++ b/calendar/src/main/res/values/strings.xml@@ -80,4 +80,7 @@      <!-- Timezone picker dialog -->     <string name="choose_timezone">Choose timezone</string>++    <!-- Location row -->+    <string name="open_location_in_navigation">Open location</string> </resources>\ No newline at end of file