Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ android {
applicationId = "com.gridpointcode"
minSdk = 26
targetSdk = 37
versionCode = 1
versionCode = 2
versionName = "0.1.0"
buildConfigField("String", "PACKS", "\"$packs\"")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.gridpointcode

import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri
import androidx.compose.ui.test.onNodeWithText
import androidx.test.core.app.ActivityScenario
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.rule.GrantPermissionRule
import com.gridpointcode.core.formatted
import org.junit.Assert.assertEquals
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
Expand Down Expand Up @@ -126,6 +128,23 @@ class ArrivalTest {
reader.assertShowing("G3RJM8X3L1")
}

/**
* The tests above name the activity, so they never touch the manifest. A
* browser does not: it offers only apps whose filter says browsable, and
* Play counts a link without it as broken.
*/
@Test
fun aBrowserCanHandEachLinkToTheApp() {
for (link in listOf("https://gridpointcode.com/play?c=G3RJM8X3L1", "geo:43.649061,-79.371679")) {
val tapped = Intent(Intent.ACTION_VIEW, Uri.parse(link))
.addCategory(Intent.CATEGORY_BROWSABLE)
.setPackage(reader.context.packageName)
@Suppress("DEPRECATION")
val found = reader.context.packageManager.queryIntentActivities(tapped, PackageManager.MATCH_DEFAULT_ONLY)
assertEquals(link, listOf(MainActivity::class.java.name), found.map { it.activityInfo.name })
}
}

@Test
fun textSelectedInAnotherAppOpensItsPlace() {
launch(Intent(Intent.ACTION_PROCESS_TEXT).putExtra(Intent.EXTRA_PROCESS_TEXT, "#G3RJM-8X3L1"))
Expand Down
5 changes: 4 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,13 @@
<data android:scheme="https" android:host="gridpointcode.com" android:pathPrefix="/play" />
</intent-filter>

<!-- Any other app's "open location" opens here too. -->
<!-- Any other app's "open location" opens here too, and so does a
geo link tapped in a browser, which only offers apps that say
they are browsable. -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="geo" />
</intent-filter>

Expand Down
Loading