fix(#464): skip meeting-link locations, share the maps resolve with the detail screen
This commit is contained in:
1 parent
c03dba9f90
commit
50e1c4e25e
5 files changed
+22
-18
No files matched your search
@@ -56,16 +56,6 @@
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent>
|
||||
<!-- The reminder notification's "Open in maps" button: a maps app, else a browser. -->
|
||||
<intent>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<data android:scheme="geo" />
|
||||
</intent>
|
||||
<intent>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="https" />
|
||||
</intent>
|
||||
</queries>
|
||||
|
||||
<application
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
package de.jeanlucmakiola.calendula.domain.reminders
|
||||
|
||||
private val webLinkRegex = Regex("""^(?:https?://|www\.)\S+$""", RegexOption.IGNORE_CASE)
|
||||
private val linkRegex = Regex(
|
||||
"""(?:https?://|www\.)\S+|\b[a-z0-9-]+(?:\.[a-z0-9-]+)*\.[a-z]{2,}/\S*""",
|
||||
RegexOption.IGNORE_CASE,
|
||||
)
|
||||
|
||||
/**
|
||||
* What a reminder's "Open in maps" button looks up for [location], or null
|
||||
* when there is no place to find: blank, or nothing but a (meeting) link.
|
||||
* when there is no place to find: blank, or nothing but (meeting) links.
|
||||
*/
|
||||
fun reminderMapQuery(location: String?): String? =
|
||||
location?.trim()?.takeIf { it.isNotEmpty() && !webLinkRegex.matches(it) }
|
||||
fun reminderMapQuery(location: String?): String? {
|
||||
val trimmed = location?.trim()?.takeIf { it.isNotEmpty() } ?: return null
|
||||
return trimmed.takeIf { linkRegex.replace(it, "").any(Char::isLetterOrDigit) }
|
||||
}
|
||||
@@ -90,7 +90,7 @@ import de.jeanlucmakiola.calendula.domain.timeZoneOptionOf
|
||||
import de.jeanlucmakiola.calendula.domain.zoneDescriptor
|
||||
import de.jeanlucmakiola.calendula.domain.zoneOrNull
|
||||
import de.jeanlucmakiola.calendula.ui.common.orUnnamed
|
||||
import de.jeanlucmakiola.floret.android.mapsSearchIntents
|
||||
import de.jeanlucmakiola.floret.android.resolvableMapsSearchIntent
|
||||
import de.jeanlucmakiola.floret.components.IconInfoCard
|
||||
import de.jeanlucmakiola.floret.identity.LocalFloretDarkTheme
|
||||
import de.jeanlucmakiola.floret.identity.predictiveBack
|
||||
@@ -885,6 +885,7 @@ private fun startOrSayNoApp(context: Context, intent: Intent) {
|
||||
|
||||
/** Open a maps intent for [query]; fall back to a web maps URL if no app handles geo:. */
|
||||
private fun openInMaps(context: Context, query: String) {
|
||||
val opened = mapsSearchIntents(query).any { runCatching { context.startActivity(it) }.isSuccess }
|
||||
if (!opened) Toast.makeText(context, R.string.link_open_failed, Toast.LENGTH_SHORT).show()
|
||||
val intent = context.resolvableMapsSearchIntent(query)
|
||||
if (intent != null) startOrSayNoApp(context, intent)
|
||||
else Toast.makeText(context, R.string.link_open_failed, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
@@ -21,6 +21,14 @@ class ReminderMapQueryTest {
|
||||
assertThat(reminderMapQuery("https://meet.google.com/abc-defg-hij")).isNull()
|
||||
assertThat(reminderMapQuery("HTTP://example.com")).isNull()
|
||||
assertThat(reminderMapQuery("www.example.com/room")).isNull()
|
||||
assertThat(reminderMapQuery("zoom.us/j/123")).isNull()
|
||||
assertThat(reminderMapQuery("<https://teams.microsoft.com/l/meetup-join/x>")).isNull()
|
||||
assertThat(reminderMapQuery("https://a.example\nhttps://b.example")).isNull()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `an address with a house number fraction is still a place`() {
|
||||
assertThat(reminderMapQuery("Hauptstr. 12/3, Wien")).isEqualTo("Hauptstr. 12/3, Wien")
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+1
-1
Submodule floret-kit updated: 476514a37f...78d88ac98e.
Reference in new issue
Block a user