diff --git a/composeApp/release/baselineProfiles/0/composeApp-release.dm b/composeApp/release/baselineProfiles/0/composeApp-release.dm index 07706a1c..5a9331cc 100644 Binary files a/composeApp/release/baselineProfiles/0/composeApp-release.dm and b/composeApp/release/baselineProfiles/0/composeApp-release.dm differ diff --git a/composeApp/release/baselineProfiles/1/composeApp-release.dm b/composeApp/release/baselineProfiles/1/composeApp-release.dm index 1ef032f7..98890494 100644 Binary files a/composeApp/release/baselineProfiles/1/composeApp-release.dm and b/composeApp/release/baselineProfiles/1/composeApp-release.dm differ diff --git a/composeApp/src/androidMain/AndroidManifest.xml b/composeApp/src/androidMain/AndroidManifest.xml index a8dd5c0d..2c6cc402 100644 --- a/composeApp/src/androidMain/AndroidManifest.xml +++ b/composeApp/src/androidMain/AndroidManifest.xml @@ -1,26 +1,30 @@ - + - - + android:usesCleartextTraffic="false" + tools:targetApi="29"> + + + + + + + - - + + + @@ -73,10 +82,11 @@ - + + + + + diff --git a/composeApp/src/androidMain/kotlin/zed/rainxch/githubstore/MainActivity.kt b/composeApp/src/androidMain/kotlin/zed/rainxch/githubstore/MainActivity.kt index 17334fc0..6624fe83 100644 --- a/composeApp/src/androidMain/kotlin/zed/rainxch/githubstore/MainActivity.kt +++ b/composeApp/src/androidMain/kotlin/zed/rainxch/githubstore/MainActivity.kt @@ -13,6 +13,7 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.tooling.preview.Preview import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen import androidx.core.util.Consumer +import zed.rainxch.githubstore.app.deeplink.DeepLinkParser class MainActivity : ComponentActivity() { @@ -20,19 +21,16 @@ class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { installSplashScreen() - enableEdgeToEdge() super.onCreate(savedInstanceState) - deepLinkUri = intent?.data?.toString() + handleIncomingIntent(intent) setContent { DisposableEffect(Unit) { val listener = Consumer { newIntent -> - newIntent.data?.toString()?.let { - deepLinkUri = it - } + handleIncomingIntent(newIntent) } addOnNewIntentListener(listener) onDispose { @@ -43,6 +41,23 @@ class MainActivity : ComponentActivity() { App(deepLinkUri = deepLinkUri) } } + + private fun handleIncomingIntent(intent: Intent?) { + if (intent == null) return + + val uriString = when (intent.action) { + Intent.ACTION_VIEW -> intent.data?.toString() + + Intent.ACTION_SEND -> { + val sharedText = intent.getStringExtra(Intent.EXTRA_TEXT) + sharedText?.let { DeepLinkParser.extractSupportedUrl(it) } + } + + else -> null + } + + uriString?.let { deepLinkUri = it } + } } @Preview diff --git a/composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/Main.kt b/composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/Main.kt index e114987c..686cef05 100644 --- a/composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/Main.kt +++ b/composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/Main.kt @@ -38,7 +38,8 @@ fun App(deepLinkUri: String? = null) { ) } - DeepLinkDestination.None -> { /* ignore unrecognized deep links */ + DeepLinkDestination.None -> { + /* ignore unrecognized deep links */ } } } diff --git a/composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/deeplink/DeepLinkParser.kt b/composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/deeplink/DeepLinkParser.kt index 0a10a064..7096f29f 100644 --- a/composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/deeplink/DeepLinkParser.kt +++ b/composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/deeplink/DeepLinkParser.kt @@ -174,4 +174,9 @@ object DeepLinkParser { } return null } + + fun extractSupportedUrl(text: String): String? { + val regex = """https?://(?:www\.)?(?:github\.com|github-store\.org)[^\s<>"']+""".toRegex(RegexOption.IGNORE_CASE) + return regex.find(text)?.value + } } \ No newline at end of file