feat(gift): 선물 상세 딥링크를 연결한다

This commit is contained in:
2026-10-08 15:05:23 +09:00
parent e5e41af4c4
commit 4f36286580
4 changed files with 243 additions and 6 deletions
+10
View File
@@ -95,6 +95,16 @@
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="gift-detail"
android:scheme="${URISCHEME}" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
<!-- PayVerse 리다이렉트에 등록할 커스텀 스킴/호스트 --> <!-- PayVerse 리다이렉트에 등록할 커스텀 스킴/호스트 -->
@@ -20,6 +20,7 @@ import kr.co.vividnext.sodalive.v2.content.action.ContentActionCommand
import kr.co.vividnext.sodalive.v2.content.action.handleContentAction import kr.co.vividnext.sodalive.v2.content.action.handleContentAction
import kr.co.vividnext.sodalive.v2.creator.action.CreatorActionCommand import kr.co.vividnext.sodalive.v2.creator.action.CreatorActionCommand
import kr.co.vividnext.sodalive.v2.creator.action.handleCreatorAction import kr.co.vividnext.sodalive.v2.creator.action.handleCreatorAction
import kr.co.vividnext.sodalive.v2.gift.GiftDetailActivity
import kr.co.vividnext.sodalive.v2.main.MainV2Activity import kr.co.vividnext.sodalive.v2.main.MainV2Activity
import java.util.Locale import java.util.Locale
@@ -263,6 +264,7 @@ class DeepLinkActivity : AppCompatActivity() {
} }
private fun routeForegroundDeepLink(bundle: Bundle): Boolean { private fun routeForegroundDeepLink(bundle: Bundle): Boolean {
val giftApplicationNo = bundle.getString("gift_application_no")?.takeIf { it.isNotBlank() }
val roomId = bundle.getString("room_id")?.toLongOrNull() val roomId = bundle.getString("room_id")?.toLongOrNull()
?: bundle.getLong(Constants.EXTRA_ROOM_ID).takeIf { it > 0 } ?: bundle.getLong(Constants.EXTRA_ROOM_ID).takeIf { it > 0 }
val channelId = bundle.getString("channel_id")?.toLongOrNull() val channelId = bundle.getString("channel_id")?.toLongOrNull()
@@ -278,6 +280,11 @@ class DeepLinkActivity : AppCompatActivity() {
val communityPostId = bundle.getString(Constants.EXTRA_COMMUNITY_POST_ID)?.toLongOrNull() val communityPostId = bundle.getString(Constants.EXTRA_COMMUNITY_POST_ID)?.toLongOrNull()
?: bundle.getLong(Constants.EXTRA_COMMUNITY_POST_ID).takeIf { it > 0 } ?: bundle.getLong(Constants.EXTRA_COMMUNITY_POST_ID).takeIf { it > 0 }
if (giftApplicationNo != null) {
startActivity(GiftDetailActivity.newIntent(applicationContext, giftApplicationNo))
return true
}
if (isDmChatDeepLink(bundle) && roomId != null && roomId > 0) { if (isDmChatDeepLink(bundle) && roomId != null && roomId > 0) {
handleChatAction(ChatActionCommand.DmRoom(roomId)) handleChatAction(ChatActionCommand.DmRoom(roomId))
return true return true
@@ -402,17 +409,18 @@ class DeepLinkActivity : AppCompatActivity() {
putIfAbsent: (key: String, value: String?) -> Unit putIfAbsent: (key: String, value: String?) -> Unit
) { ) {
val host = data.host?.lowercase(Locale.ROOT).orEmpty() val host = data.host?.lowercase(Locale.ROOT).orEmpty()
val pathSegments = data.pathSegments.filter { it.isNotBlank() } val rawPathSegments = data.pathSegments
val pathSegments = rawPathSegments.filter { it.isNotBlank() }
val pathType: String val pathType: String
val pathId: String? val pathId: String?
if (host.isNotBlank() && host != "payverse") { if (host.isNotBlank() && host != "payverse") {
pathType = host pathType = host
pathId = pathSegments.firstOrNull() pathId = if (pathType == "gift-detail") rawPathSegments.firstOrNull() else pathSegments.firstOrNull()
} else if (pathSegments.isNotEmpty()) { } else if (pathSegments.isNotEmpty()) {
pathType = pathSegments[0].lowercase(Locale.ROOT) pathType = pathSegments[0].lowercase(Locale.ROOT)
pathId = pathSegments.getOrNull(1) pathId = if (pathType == "gift-detail") rawPathSegments.getOrNull(1) else pathSegments.getOrNull(1)
} else { } else {
return return
} }
@@ -458,6 +466,8 @@ class DeepLinkActivity : AppCompatActivity() {
putIfAbsent("audition_id", pathId) putIfAbsent("audition_id", pathId)
putIfAbsent("deep_link_sub5", pathId) putIfAbsent("deep_link_sub5", pathId)
} }
"gift-detail" -> putIfAbsent("gift_application_no", pathId)
} }
} }
@@ -74,6 +74,7 @@ import kr.co.vividnext.sodalive.v2.content.action.ContentActionCommand
import kr.co.vividnext.sodalive.v2.content.action.handleContentAction import kr.co.vividnext.sodalive.v2.content.action.handleContentAction
import kr.co.vividnext.sodalive.v2.creator.action.CreatorActionCommand import kr.co.vividnext.sodalive.v2.creator.action.CreatorActionCommand
import kr.co.vividnext.sodalive.v2.creator.action.handleCreatorAction import kr.co.vividnext.sodalive.v2.creator.action.handleCreatorAction
import kr.co.vividnext.sodalive.v2.gift.GiftDetailActivity
import kr.co.vividnext.sodalive.v2.live.action.LiveActionCoordinator import kr.co.vividnext.sodalive.v2.live.action.LiveActionCoordinator
import kr.co.vividnext.sodalive.v2.live.action.LiveCreationResult import kr.co.vividnext.sodalive.v2.live.action.LiveCreationResult
import kr.co.vividnext.sodalive.v2.live.action.resolveLiveCreationResult import kr.co.vividnext.sodalive.v2.live.action.resolveLiveCreationResult
@@ -782,8 +783,12 @@ class MainV2Activity : BaseActivity<ActivityMainV2Binding>(ActivityMainV2Binding
private fun executeDeeplink(intent: Intent) { private fun executeDeeplink(intent: Intent) {
val routeBundle = resolveDeepLinkBundle(intent) ?: return val routeBundle = resolveDeepLinkBundle(intent) ?: return
val giftApplicationNo = routeBundle.getString("gift_application_no")?.takeIf { it.isNotBlank() }
if (executeBundleRoute(routeBundle)) { if (executeBundleRoute(routeBundle)) {
if (giftApplicationNo != null) {
intent.removeExtra(Constants.EXTRA_DATA)
}
clearDeferredDeepLink() clearDeferredDeepLink()
} }
} }
@@ -874,16 +879,17 @@ class MainV2Activity : BaseActivity<ActivityMainV2Binding>(ActivityMainV2Binding
putIfAbsent: (key: String, value: String?) -> Unit putIfAbsent: (key: String, value: String?) -> Unit
) { ) {
val host = data.host?.lowercase(Locale.ROOT).orEmpty() val host = data.host?.lowercase(Locale.ROOT).orEmpty()
val pathSegments = data.pathSegments.filter { it.isNotBlank() } val rawPathSegments = data.pathSegments
val pathSegments = rawPathSegments.filter { it.isNotBlank() }
val pathType: String val pathType: String
val pathId: String? val pathId: String?
if (host.isNotBlank() && host != "payverse") { if (host.isNotBlank() && host != "payverse") {
pathType = host pathType = host
pathId = pathSegments.firstOrNull() pathId = if (pathType == "gift-detail") rawPathSegments.firstOrNull() else pathSegments.firstOrNull()
} else if (pathSegments.isNotEmpty()) { } else if (pathSegments.isNotEmpty()) {
pathType = pathSegments[0].lowercase(Locale.ROOT) pathType = pathSegments[0].lowercase(Locale.ROOT)
pathId = pathSegments.getOrNull(1) pathId = if (pathType == "gift-detail") rawPathSegments.getOrNull(1) else pathSegments.getOrNull(1)
} else { } else {
return return
} }
@@ -923,10 +929,13 @@ class MainV2Activity : BaseActivity<ActivityMainV2Binding>(ActivityMainV2Binding
putIfAbsent("audition_id", pathId) putIfAbsent("audition_id", pathId)
putIfAbsent("deep_link_sub5", pathId) putIfAbsent("deep_link_sub5", pathId)
} }
"gift-detail" -> putIfAbsent("gift_application_no", pathId)
} }
} }
private fun executeBundleRoute(bundle: Bundle): Boolean { private fun executeBundleRoute(bundle: Bundle): Boolean {
val giftApplicationNo = bundle.getString("gift_application_no")?.takeIf { it.isNotBlank() }
val roomId = bundle.getString("room_id")?.toLongOrNull() val roomId = bundle.getString("room_id")?.toLongOrNull()
?: bundle.getLong(Constants.EXTRA_ROOM_ID).takeIf { it > 0 } ?: bundle.getLong(Constants.EXTRA_ROOM_ID).takeIf { it > 0 }
val channelId = bundle.getString("channel_id")?.toLongOrNull() val channelId = bundle.getString("channel_id")?.toLongOrNull()
@@ -942,6 +951,11 @@ class MainV2Activity : BaseActivity<ActivityMainV2Binding>(ActivityMainV2Binding
val communityPostId = bundle.getString(Constants.EXTRA_COMMUNITY_POST_ID)?.toLongOrNull() val communityPostId = bundle.getString(Constants.EXTRA_COMMUNITY_POST_ID)?.toLongOrNull()
?: bundle.getLong(Constants.EXTRA_COMMUNITY_POST_ID).takeIf { it > 0 } ?: bundle.getLong(Constants.EXTRA_COMMUNITY_POST_ID).takeIf { it > 0 }
if (giftApplicationNo != null) {
startActivity(GiftDetailActivity.newIntent(applicationContext, giftApplicationNo))
return true
}
if (isDmChatDeepLink(bundle) && roomId != null && roomId > 0) { if (isDmChatDeepLink(bundle) && roomId != null && roomId > 0) {
handleChatAction(ChatActionCommand.DmRoom(roomId)) handleChatAction(ChatActionCommand.DmRoom(roomId))
return true return true
@@ -72,6 +72,209 @@ import org.koin.dsl.module
@RunWith(RobolectricTestRunner::class) @RunWith(RobolectricTestRunner::class)
@Config(sdk = [28], application = Application::class) @Config(sdk = [28], application = Application::class)
class GiftNavigationTest { class GiftNavigationTest {
@Test
fun `foreground 선물 상세 딥링크는 원본 신청번호로 상세를 연다`() {
val previousForegroundState = kr.co.vividnext.sodalive.app.SodaLiveApp.isAppInForeground
val applicationNo = "A-1002609300001"
try {
kr.co.vividnext.sodalive.app.SodaLiveApp.isAppInForeground = true
val controller = Robolectric.buildActivity(
kr.co.vividnext.sodalive.main.DeepLinkActivity::class.java,
Intent(Intent.ACTION_VIEW, android.net.Uri.parse("sodalive://gift-detail/$applicationNo"))
).setup()
assertGiftDetailIntent(shadowOf(controller.get()).nextStartedActivity, applicationNo)
controller.pause().stop().destroy()
} finally {
kr.co.vividnext.sodalive.app.SodaLiveApp.isAppInForeground = previousForegroundState
}
}
@Test
fun `신청번호가 없거나 blank인 선물 상세 딥링크는 상세를 열지 않는다`() {
val previousForegroundState = kr.co.vividnext.sodalive.app.SodaLiveApp.isAppInForeground
try {
kr.co.vividnext.sodalive.app.SodaLiveApp.isAppInForeground = true
listOf("sodalive://gift-detail", "sodalive://gift-detail/%20").forEach { deepLink ->
val controller = Robolectric.buildActivity(
kr.co.vividnext.sodalive.main.DeepLinkActivity::class.java,
Intent(Intent.ACTION_VIEW, android.net.Uri.parse(deepLink))
).setup()
val startedIntent = shadowOf(controller.get()).nextStartedActivity
assertTrue(GiftDetailActivity::class.java.name != startedIntent?.component?.className)
controller.pause().stop().destroy()
}
} finally {
kr.co.vividnext.sodalive.app.SodaLiveApp.isAppInForeground = previousForegroundState
}
}
@Test
fun `foreground 선물 상세 딥링크는 blank 첫 세그먼트 뒤 신청번호를 사용하지 않는다`() {
val previousForegroundState = kr.co.vividnext.sodalive.app.SodaLiveApp.isAppInForeground
try {
kr.co.vividnext.sodalive.app.SodaLiveApp.isAppInForeground = true
val controller = Robolectric.buildActivity(
kr.co.vividnext.sodalive.main.DeepLinkActivity::class.java,
Intent(Intent.ACTION_VIEW, android.net.Uri.parse("sodalive://gift-detail/%20/A-1002609300001"))
).setup()
assertTrue(
GiftDetailActivity::class.java.name !=
shadowOf(controller.get()).nextStartedActivity?.component?.className
)
controller.pause().stop().destroy()
} finally {
kr.co.vividnext.sodalive.app.SodaLiveApp.isAppInForeground = previousForegroundState
}
}
@Test
fun `cold start 선물 상세 파서는 blank 첫 세그먼트 뒤 신청번호를 사용하지 않는다`() {
val mainIntent = Intent(
ApplicationProvider.getApplicationContext(),
kr.co.vividnext.sodalive.v2.main.MainV2Activity::class.java
).putExtra(
kr.co.vividnext.sodalive.common.Constants.EXTRA_DATA,
Bundle().apply {
putString("deep_link", "sodalive://gift-detail/%20/A-1002609300001")
}
)
val controller = Robolectric.buildActivity(
kr.co.vividnext.sodalive.v2.main.MainV2Activity::class.java,
mainIntent
)
val mainActivity = controller.get()
kr.co.vividnext.sodalive.v2.main.MainV2Activity::class.java
.getDeclaredMethod("executeDeeplink", Intent::class.java)
.apply { isAccessible = true }
.invoke(mainActivity, mainIntent)
assertNull(shadowOf(mainActivity).nextStartedActivity)
}
@Test
fun `cold start 선물 상세 entry Intent는 한 번만 소비하고 새 Intent는 처리한다`() {
val applicationContext = ApplicationProvider.getApplicationContext<android.content.Context>()
val entryIntent = Intent(
applicationContext,
kr.co.vividnext.sodalive.v2.main.MainV2Activity::class.java
).putExtra(
kr.co.vividnext.sodalive.common.Constants.EXTRA_DATA,
Bundle().apply {
putString("deep_link", "sodalive://gift-detail/A-1002609300001")
}
)
val controller = Robolectric.buildActivity(
kr.co.vividnext.sodalive.v2.main.MainV2Activity::class.java,
entryIntent
)
val mainActivity = controller.get()
val executeDeeplink = kr.co.vividnext.sodalive.v2.main.MainV2Activity::class.java
.getDeclaredMethod("executeDeeplink", Intent::class.java)
.apply { isAccessible = true }
executeDeeplink.invoke(mainActivity, entryIntent)
assertGiftDetailIntent(shadowOf(mainActivity).nextStartedActivity, "A-1002609300001")
assertNull(shadowOf(mainActivity).nextStartedActivity)
val recreatedActivity = Robolectric.buildActivity(
kr.co.vividnext.sodalive.v2.main.MainV2Activity::class.java,
entryIntent
).get()
executeDeeplink.invoke(recreatedActivity, entryIntent)
assertNull(shadowOf(recreatedActivity).nextStartedActivity)
executeDeeplink.invoke(mainActivity, entryIntent)
assertNull(shadowOf(mainActivity).nextStartedActivity)
val futureIntent = Intent(
applicationContext,
kr.co.vividnext.sodalive.v2.main.MainV2Activity::class.java
).putExtra(
kr.co.vividnext.sodalive.common.Constants.EXTRA_DATA,
Bundle().apply {
putString("deep_link", "sodalive://gift-detail/A-1002609300002")
}
)
executeDeeplink.invoke(mainActivity, futureIntent)
assertGiftDetailIntent(shadowOf(mainActivity).nextStartedActivity, "A-1002609300002")
}
@Test
fun `cold start 선물 상세 딥링크는 Splash와 Main을 거쳐 상세를 한 번만 연다`() {
val previousForegroundState = kr.co.vividnext.sodalive.app.SodaLiveApp.isAppInForeground
val applicationNo = "A-1002609300001"
try {
kr.co.vividnext.sodalive.app.SodaLiveApp.isAppInForeground = false
val deepLinkController = Robolectric.buildActivity(
kr.co.vividnext.sodalive.main.DeepLinkActivity::class.java,
Intent(Intent.ACTION_VIEW, android.net.Uri.parse("sodalive://gift-detail/$applicationNo"))
).setup()
val splashIntent = shadowOf(deepLinkController.get()).nextStartedActivity
assertEquals(
kr.co.vividnext.sodalive.splash.SplashActivity::class.java.name,
splashIntent.component?.className
)
assertEquals(
applicationNo,
splashIntent.getBundleExtra(kr.co.vividnext.sodalive.common.Constants.EXTRA_DATA)
?.getString("gift_application_no")
)
com.google.firebase.FirebaseApp.initializeApp(ApplicationProvider.getApplicationContext())
val splashController = Robolectric.buildActivity(
kr.co.vividnext.sodalive.splash.SplashActivity::class.java,
splashIntent
)
kr.co.vividnext.sodalive.splash.SplashActivity::class.java
.getDeclaredMethod("startNextActivity")
.apply { isAccessible = true }
.invoke(splashController.get())
org.robolectric.shadows.ShadowLooper.idleMainLooper(500, java.util.concurrent.TimeUnit.MILLISECONDS)
val mainIntent = shadowOf(splashController.get()).nextStartedActivity
assertEquals(
kr.co.vividnext.sodalive.v2.main.MainV2Activity::class.java.name,
mainIntent.component?.className
)
assertEquals(
applicationNo,
mainIntent.getBundleExtra(kr.co.vividnext.sodalive.common.Constants.EXTRA_DATA)
?.getString("gift_application_no")
)
val mainController = Robolectric.buildActivity(
kr.co.vividnext.sodalive.v2.main.MainV2Activity::class.java,
mainIntent
)
val mainActivity = mainController.get()
kr.co.vividnext.sodalive.v2.main.MainV2Activity::class.java
.getDeclaredMethod("executeDeeplink", Intent::class.java)
.apply { isAccessible = true }
.invoke(mainActivity, mainIntent)
assertGiftDetailIntent(shadowOf(mainActivity).nextStartedActivity, applicationNo)
assertNull(shadowOf(mainActivity).nextStartedActivity)
deepLinkController.pause().stop().destroy()
} finally {
kr.co.vividnext.sodalive.app.SodaLiveApp.isAppInForeground = previousForegroundState
}
}
private fun assertGiftDetailIntent(intent: Intent?, applicationNo: String) {
assertNotNull(intent)
assertEquals(GiftDetailActivity::class.java.name, intent?.component?.className)
assertEquals(applicationNo, intent?.getStringExtra(GiftDetailActivity.EXTRA_APPLICATION_NO))
}
private lateinit var api: NavigationFakeApi private lateinit var api: NavigationFakeApi
private lateinit var inboxApi: InboxFakeApi private lateinit var inboxApi: InboxFakeApi