From 2d184ee1fb9f8c2cbf25a597b2103998f1ef87c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rover=20Release=20Bot=20=F0=9F=A4=96?= Date: Fri, 28 Apr 2023 02:22:10 +0000 Subject: [PATCH] Releasing 4.1.3 --- build.gradle.kts | 2 +- .../io/rover/sdk/core/routing/Interfaces.kt | 10 ++-------- .../routing/TransientLinkLaunchActivity.kt | 18 ++++++++++++++---- .../kotlin/io/rover/sdk/core/ui/LinkOpen.kt | 16 +++++++++++++++- 4 files changed, 32 insertions(+), 14 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index e2baee382..2ffbc1af8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -18,7 +18,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. // The version number for the build SDK modules and testbench app. -val roverSdkVersion by extra("4.1.2") +val roverSdkVersion by extra("4.1.3") // Definitions of several core shared dependencies: val kotlinVersion by extra("1.8.20") // NB: when changing this one check the two duplicates of this number below diff --git a/core/src/main/kotlin/io/rover/sdk/core/routing/Interfaces.kt b/core/src/main/kotlin/io/rover/sdk/core/routing/Interfaces.kt index 461e08940..bfd0a6dbf 100644 --- a/core/src/main/kotlin/io/rover/sdk/core/routing/Interfaces.kt +++ b/core/src/main/kotlin/io/rover/sdk/core/routing/Interfaces.kt @@ -54,14 +54,7 @@ interface LinkOpenInterface { * * Returns null if this link not handled by Rover. */ - fun intentForLink(context: Context, uri: Uri): Intent? { - val androidUri = URI(uri.toString()) - return if (localIntentForReceived(androidUri).isNotEmpty()) { - TransientLinkLaunchActivity.makeIntent(context, androidUri) - } else { - null - } - } + fun intentForLink(context: Context, uri: Uri): Intent? /** * Map a URI just received for a deep link to an explicit, mapped intent. @@ -69,5 +62,6 @@ interface LinkOpenInterface { * May return more than one intent, meant for synthesizing a back stack in the event * of the target needing synthesized back stack entries. */ + @Deprecated("Use intentForLink() instead.") fun localIntentForReceived(receivedUri: URI): List } diff --git a/core/src/main/kotlin/io/rover/sdk/core/routing/TransientLinkLaunchActivity.kt b/core/src/main/kotlin/io/rover/sdk/core/routing/TransientLinkLaunchActivity.kt index 2c8b4dc55..eee32ddb3 100644 --- a/core/src/main/kotlin/io/rover/sdk/core/routing/TransientLinkLaunchActivity.kt +++ b/core/src/main/kotlin/io/rover/sdk/core/routing/TransientLinkLaunchActivity.kt @@ -46,15 +46,25 @@ open class TransientLinkLaunchActivity : Activity() { return } - val uri = URI(intent.data.toString()) + val uri = intent.data ?: run { + log.e("Transient link launch activity was launched, but no URI was provided. Ignoring.") + return + } log.v("Transient link launch activity running for received URI: '${intent.data}'") - val intentStack = linkOpen.localIntentForReceived(uri) + val linkIntent = linkOpen.intentForLink(this, uri) ?: run { + // no fallback to making a stock ACTION_VIEW intent for this uri is needed if Rover + // Router fails to produce a Uri is needed. This is because Link Launch activity + // is only used for *inbound* links being launched with the Rover SDK. + log.e("Rover router could not give us a URL for the URI: '$uri'. Ignoring.") + return + } + + log.v("Launching intent: $linkIntent") - log.v("Launching stack ${intentStack.size} deep: ${intentStack.joinToString("\n") { it.toString() }}") + ContextCompat.startActivity(this, linkIntent, null) - if (intentStack.isNotEmpty()) ContextCompat.startActivities(this, intentStack.toTypedArray()) finish() } diff --git a/core/src/main/kotlin/io/rover/sdk/core/ui/LinkOpen.kt b/core/src/main/kotlin/io/rover/sdk/core/ui/LinkOpen.kt index 7b0c1a198..b9e761bb6 100644 --- a/core/src/main/kotlin/io/rover/sdk/core/ui/LinkOpen.kt +++ b/core/src/main/kotlin/io/rover/sdk/core/ui/LinkOpen.kt @@ -17,14 +17,28 @@ package io.rover.sdk.core.ui +import android.content.Context import android.content.Intent +import android.net.Uri +import io.rover.sdk.core.logging.log import io.rover.sdk.core.routing.LinkOpenInterface import io.rover.sdk.core.routing.Router +import io.rover.sdk.core.routing.TransientLinkLaunchActivity import java.net.URI class LinkOpen( - private val router: Router + private val router: Router, ) : LinkOpenInterface { + + override fun intentForLink(context: Context, uri: Uri): Intent? { + val javaURI = try { URI(uri.toString()) } catch (e: Throwable) { + log.e("Unable to parse URI: $uri") + return null + } + return router.route(javaURI) + } + + @Deprecated("Use intentForLink() instead.") override fun localIntentForReceived(receivedUri: URI): List { return listOfNotNull(router.route(receivedUri)) }