fix(liveroom): 딥링크 이동 안내 문구를 단순화한다
This commit is contained in:
@@ -22,7 +22,6 @@ import android.graphics.Path
|
||||
import android.graphics.Rect
|
||||
import android.graphics.Typeface
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.CountDownTimer
|
||||
@@ -124,7 +123,6 @@ import kr.co.vividnext.sodalive.settings.language.LanguageManager
|
||||
import kr.co.vividnext.sodalive.settings.notification.MemberRole
|
||||
import org.koin.android.ext.android.inject
|
||||
import org.json.JSONObject
|
||||
import java.util.Locale
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.regex.Pattern
|
||||
import kotlin.random.Random
|
||||
@@ -254,9 +252,8 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
||||
private val deepLinkConfirmReceiver = object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context?, intent: Intent?) {
|
||||
val bundle = intent?.getBundleExtra(Constants.EXTRA_DATA) ?: return
|
||||
val destinationPageName = resolveDestinationPageName(bundle)
|
||||
|
||||
showDeepLinkNavigationDialog(destinationPageName) {
|
||||
showDeepLinkNavigationDialog {
|
||||
val nextIntent = Intent(applicationContext, MainActivity::class.java).apply {
|
||||
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
||||
putExtra(Constants.EXTRA_DATA, bundle)
|
||||
@@ -1227,10 +1224,7 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
||||
private fun handleNoticeUrlClick(url: String) {
|
||||
val viewIntent = Intent(Intent.ACTION_VIEW, url.toUri())
|
||||
if (isInAppDeepLinkIntent(viewIntent)) {
|
||||
val deepLinkExtras = buildDeepLinkExtrasFromUri(viewIntent.data)
|
||||
val destinationPageName = resolveDestinationPageName(deepLinkExtras)
|
||||
|
||||
showDeepLinkNavigationDialog(destinationPageName) {
|
||||
showDeepLinkNavigationDialog {
|
||||
startActivity(viewIntent)
|
||||
finish()
|
||||
}
|
||||
@@ -1261,89 +1255,12 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
||||
}
|
||||
}
|
||||
|
||||
private fun buildDeepLinkExtrasFromUri(data: Uri?): Bundle {
|
||||
val extras = Bundle()
|
||||
if (data == null) {
|
||||
return extras
|
||||
}
|
||||
|
||||
fun putQuery(key: String) {
|
||||
val value = data.getQueryParameter(key)
|
||||
if (!value.isNullOrBlank()) {
|
||||
extras.putString(key, value)
|
||||
}
|
||||
}
|
||||
|
||||
putQuery("room_id")
|
||||
putQuery("channel_id")
|
||||
putQuery("message_id")
|
||||
putQuery("audition_id")
|
||||
putQuery("content_id")
|
||||
putQuery("deep_link_value")
|
||||
putQuery("deep_link_sub5")
|
||||
|
||||
val deepLinkValue = extras.getString("deep_link_value")
|
||||
val deepLinkValueId = extras.getString("deep_link_sub5")
|
||||
|
||||
if (!deepLinkValue.isNullOrBlank() && !deepLinkValueId.isNullOrBlank()) {
|
||||
when (deepLinkValue.lowercase(Locale.ROOT)) {
|
||||
"live" -> if (!extras.containsKey("room_id")) {
|
||||
extras.putString("room_id", deepLinkValueId)
|
||||
}
|
||||
|
||||
"channel" -> if (!extras.containsKey("channel_id")) {
|
||||
extras.putString("channel_id", deepLinkValueId)
|
||||
}
|
||||
|
||||
"content" -> if (!extras.containsKey("content_id")) {
|
||||
extras.putString("content_id", deepLinkValueId)
|
||||
}
|
||||
|
||||
"audition" -> if (!extras.containsKey("audition_id")) {
|
||||
extras.putString("audition_id", deepLinkValueId)
|
||||
}
|
||||
|
||||
else -> Unit
|
||||
}
|
||||
}
|
||||
|
||||
return extras
|
||||
}
|
||||
|
||||
private fun resolveDestinationPageName(bundle: Bundle): String {
|
||||
val roomId = bundle.getString("room_id")?.toLongOrNull()
|
||||
?: bundle.getLong(Constants.EXTRA_ROOM_ID).takeIf { it > 0 }
|
||||
val channelId = bundle.getString("channel_id")?.toLongOrNull()
|
||||
?: bundle.getLong(Constants.EXTRA_USER_ID).takeIf { it > 0 }
|
||||
val messageId = bundle.getString("message_id")?.toLongOrNull()
|
||||
?: bundle.getLong(Constants.EXTRA_MESSAGE_ID).takeIf { it > 0 }
|
||||
val contentId = bundle.getString("content_id")?.toLongOrNull()
|
||||
?: bundle.getLong(Constants.EXTRA_AUDIO_CONTENT_ID).takeIf { it > 0 }
|
||||
|
||||
return when {
|
||||
roomId != null && roomId > 0 -> getString(R.string.screen_live_room_deeplink_target_live_room)
|
||||
channelId != null && channelId > 0 -> getString(R.string.screen_live_room_deeplink_target_channel_profile)
|
||||
contentId != null && contentId > 0 -> getString(R.string.screen_live_room_deeplink_target_content_detail)
|
||||
messageId != null && messageId > 0 -> getString(R.string.screen_live_room_deeplink_target_message)
|
||||
else -> {
|
||||
when (bundle.getString("deep_link_value")?.lowercase(Locale.ROOT)) {
|
||||
"live" -> getString(R.string.screen_live_room_deeplink_target_live_room)
|
||||
"channel" -> getString(R.string.screen_live_room_deeplink_target_channel_profile)
|
||||
"content" -> getString(R.string.screen_live_room_deeplink_target_content_detail)
|
||||
"series" -> getString(R.string.screen_live_room_deeplink_target_series_detail)
|
||||
"audition" -> getString(R.string.screen_live_room_deeplink_target_audition)
|
||||
else -> getString(R.string.screen_live_room_deeplink_target_default)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showDeepLinkNavigationDialog(destinationPageName: String, onConfirm: () -> Unit) {
|
||||
private fun showDeepLinkNavigationDialog(onConfirm: () -> Unit) {
|
||||
SodaDialog(
|
||||
activity = this,
|
||||
layoutInflater = layoutInflater,
|
||||
title = getString(R.string.screen_live_room_deeplink_move_title),
|
||||
desc = getString(R.string.screen_live_room_deeplink_move_message, destinationPageName),
|
||||
desc = getString(R.string.screen_live_room_deeplink_move_message),
|
||||
confirmButtonTitle = getString(R.string.screen_live_room_yes),
|
||||
confirmButtonClick = {
|
||||
onConfirm()
|
||||
|
||||
Reference in New Issue
Block a user