mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-3397 Deep links | Fix | Deep link handling fixes (#2274)
This commit is contained in:
parent
d34cd7e941
commit
790373dfcc
3 changed files with 23 additions and 13 deletions
|
@ -138,7 +138,9 @@ object DefaultDeepLinkResolver : DeepLinkResolver {
|
|||
}
|
||||
|
||||
override fun isDeepLink(link: String): Boolean {
|
||||
return link.contains(defaultInviteRegex) || link.contains(DEEP_LINK_PATTERN)
|
||||
return link.contains(defaultInviteRegex)
|
||||
|| link.contains(defaultLinkToObjectRegex)
|
||||
|| link.contains(DEEP_LINK_PATTERN)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -393,16 +393,17 @@ class MainActivity : AppCompatActivity(R.layout.activity_main), AppNavigation.Pr
|
|||
}
|
||||
when(intent.action) {
|
||||
Intent.ACTION_VIEW -> {
|
||||
val data = intent.dataString
|
||||
if (data != null && DefaultDeepLinkResolver.isDeepLink(data)) {
|
||||
// Clearing intent to only handle it once:
|
||||
with(intent) {
|
||||
setAction(null)
|
||||
setData(null)
|
||||
putExtras(Bundle())
|
||||
intent.data?.let { uri ->
|
||||
val data = uri.toString()
|
||||
if (DefaultDeepLinkResolver.isDeepLink(data)) {
|
||||
vm.onNewDeepLink(DefaultDeepLinkResolver.resolve(data))
|
||||
|
||||
// Optionally clear to prevent repeat
|
||||
intent.action = null
|
||||
intent.data = null
|
||||
intent.replaceExtras(Bundle())
|
||||
}
|
||||
vm.onNewDeepLink(DefaultDeepLinkResolver.resolve(data))
|
||||
} else {
|
||||
} ?: run {
|
||||
intent.extras?.getString(DefaultAppActionManager.ACTION_CREATE_NEW_TYPE_KEY)?.let {
|
||||
vm.onIntentCreateObject(it)
|
||||
}
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
package com.anytypeio.anytype.other
|
||||
|
||||
import android.os.Build
|
||||
import androidx.compose.runtime.key
|
||||
import com.anytypeio.anytype.core_models.primitives.SpaceId
|
||||
import com.anytypeio.anytype.domain.misc.DeepLinkResolver
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import kotlin.test.assertIs
|
||||
import kotlin.test.assertTrue
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
|
@ -166,4 +164,13 @@ class DefaultDeepLinkResolverTest {
|
|||
// Then
|
||||
assertEquals(DeepLinkResolver.Action.Unknown, result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `check is deeplink`() {
|
||||
val link1 = "https://object.any.coop/bafyreidqrtef4gcqjepl4llsy2xbauedtcdmjkz5xl4stfgt2ippbwveoq?spaceId=bafyreifj6nkvzfowzgfzu5ns4j54gjh5tmcxa3wd6rncbiuk3opq6o4244.1u5jgzo8m1ekc"
|
||||
|
||||
assertTrue(
|
||||
deepLinkResolver.isDeepLink(link1)
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue