Skip to content

Commit

Permalink
chore: update based on review
Browse files Browse the repository at this point in the history
  • Loading branch information
aanorbel committed Nov 4, 2024
1 parent 95bb2bd commit e969fd2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion composeApp/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />

<action android:name="org.openobservatory.ooniprobe.nettest" />
<action android:name="${applicationId}.nettest" />

<data android:mimeType="text/plain" />
</intent-filter>
Expand Down
38 changes: 20 additions & 18 deletions composeApp/src/androidMain/kotlin/org/ooni/probe/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,29 @@ class MainActivity : ComponentActivity() {
private fun manageIntent(intent: Intent) {
if (intent.action != Intent.ACTION_VIEW && intent.action != Intent.ACTION_SEND) return

if (intent.action == Intent.ACTION_VIEW) {
val uri = intent.data ?: return
when (uri.host) {
"runv2",
OrganizationConfig.ooniRunDomain,
-> {
val id = uri.lastPathSegment ?: return
deepLinkFlow.tryEmit(DeepLink.AddDescriptor(id))
}
when (intent.action) {
Intent.ACTION_VIEW -> {
val uri = intent.data ?: return
when (uri.host) {
"runv2",
OrganizationConfig.ooniRunDomain,
-> {
val id = uri.lastPathSegment ?: return
deepLinkFlow.tryEmit(DeepLink.AddDescriptor(id))
}

else -> {
Logger.e { "Unknown deep link: $uri" }
else -> {
Logger.e { "Unknown deep link: $uri" }
}
}
}
} else if (intent.action == Intent.ACTION_SEND) {
val url = intent.getStringExtra(Intent.EXTRA_TEXT) ?: return
if (Patterns.WEB_URL.matcher(url).matches()) {
deepLinkFlow.tryEmit(DeepLink.RunUrls(url))
} else {
Logger.e { "Unknown deep link: $url" }
return
Intent.ACTION_SEND -> {
val url = intent.getStringExtra(Intent.EXTRA_TEXT) ?: return
if (Patterns.WEB_URL.matcher(url).matches()) {
deepLinkFlow.tryEmit(DeepLink.RunUrls(url))
} else {
return
}
}
}
}
Expand Down
1 change: 0 additions & 1 deletion composeApp/src/commonMain/kotlin/org/ooni/probe/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import org.ooni.probe.shared.PlatformInfo
import org.ooni.probe.ui.navigation.BottomNavigationBar
import org.ooni.probe.ui.navigation.Navigation
import org.ooni.probe.ui.navigation.Screen
import org.ooni.probe.ui.navigation.safeNavigate
import org.ooni.probe.ui.theme.AppTheme

@Composable
Expand Down

0 comments on commit e969fd2

Please sign in to comment.