feat(gift): 선물 신청 프로필과 정책 링크를 연결한다
This commit is contained in:
+2
-1
@@ -266,7 +266,8 @@ class CreatorChannelActivity :
|
|||||||
GiftSendRequestActivity.newIntent(
|
GiftSendRequestActivity.newIntent(
|
||||||
context = this,
|
context = this,
|
||||||
creatorMemberId = creatorId,
|
creatorMemberId = creatorId,
|
||||||
creatorNickname = header.nickname
|
creatorNickname = header.nickname,
|
||||||
|
profileImageUrl = header.profileImageUrl
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,17 +17,26 @@ internal fun Context.openGiftAgreementPage() {
|
|||||||
startActivity(Intent(Intent.ACTION_VIEW, GIFT_AGREEMENT_URL.toUri()))
|
startActivity(Intent(Intent.ACTION_VIEW, GIFT_AGREEMENT_URL.toUri()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal fun Context.openGiftDamagePolicyPage() {
|
||||||
|
startActivity(Intent(Intent.ACTION_VIEW, GIFT_DAMAGE_POLICY_URL.toUri()))
|
||||||
|
}
|
||||||
|
|
||||||
private const val GIFT_AGREEMENT_URL = "https://app.notion.com/p/3eb27b359673802b937ae741ab7b4ad3"
|
private const val GIFT_AGREEMENT_URL = "https://app.notion.com/p/3eb27b359673802b937ae741ab7b4ad3"
|
||||||
|
private const val GIFT_DAMAGE_POLICY_URL = "https://app.notion.com/p/3f227b3596738018ba5dea2e5205293b"
|
||||||
|
|
||||||
internal fun CheckBox.setRequiredLink(onClick: () -> Unit) {
|
internal fun CheckBox.setRequiredLink(onClick: () -> Unit) {
|
||||||
val requiredLength = context.getString(R.string.gift_send_required).length
|
setLink(context.getString(R.string.gift_send_required), onClick)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun CheckBox.setLink(linkText: String, onClick: () -> Unit) {
|
||||||
|
val linkStart = text.indexOf(linkText)
|
||||||
val linkedText = SpannableString(text).apply {
|
val linkedText = SpannableString(text).apply {
|
||||||
setSpan(
|
setSpan(
|
||||||
object : ClickableSpan() {
|
object : ClickableSpan() {
|
||||||
override fun onClick(widget: View) = onClick()
|
override fun onClick(widget: View) = onClick()
|
||||||
},
|
},
|
||||||
length - requiredLength,
|
linkStart,
|
||||||
length,
|
linkStart + linkText.length,
|
||||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,12 +13,14 @@ import androidx.core.text.color
|
|||||||
import androidx.core.view.WindowCompat
|
import androidx.core.view.WindowCompat
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.widget.addTextChangedListener
|
import androidx.core.widget.addTextChangedListener
|
||||||
|
import coil.transform.CircleCropTransformation
|
||||||
import kr.co.vividnext.sodalive.R
|
import kr.co.vividnext.sodalive.R
|
||||||
import kr.co.vividnext.sodalive.base.BaseActivity
|
import kr.co.vividnext.sodalive.base.BaseActivity
|
||||||
import kr.co.vividnext.sodalive.common.LoadingDialog
|
import kr.co.vividnext.sodalive.common.LoadingDialog
|
||||||
import kr.co.vividnext.sodalive.common.ToastMessage
|
import kr.co.vividnext.sodalive.common.ToastMessage
|
||||||
import kr.co.vividnext.sodalive.databinding.ActivityGiftSendRequestBinding
|
import kr.co.vividnext.sodalive.databinding.ActivityGiftSendRequestBinding
|
||||||
import kr.co.vividnext.sodalive.databinding.ItemGiftSendSizeBinding
|
import kr.co.vividnext.sodalive.databinding.ItemGiftSendSizeBinding
|
||||||
|
import kr.co.vividnext.sodalive.extensions.loadUrl
|
||||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||||
|
|
||||||
class GiftSendRequestActivity : BaseActivity<ActivityGiftSendRequestBinding>(ActivityGiftSendRequestBinding::inflate) {
|
class GiftSendRequestActivity : BaseActivity<ActivityGiftSendRequestBinding>(ActivityGiftSendRequestBinding::inflate) {
|
||||||
@@ -61,6 +63,15 @@ class GiftSendRequestActivity : BaseActivity<ActivityGiftSendRequestBinding>(Act
|
|||||||
isAppearanceLightNavigationBars = false
|
isAppearanceLightNavigationBars = false
|
||||||
}
|
}
|
||||||
binding.tvCreatorNickname.text = entry.creatorNickname
|
binding.tvCreatorNickname.text = entry.creatorNickname
|
||||||
|
intent.getStringExtra(EXTRA_CREATOR_PROFILE_IMAGE_URL)
|
||||||
|
?.takeIf { it.isNotBlank() }
|
||||||
|
?.let { profileImageUrl ->
|
||||||
|
binding.ivCreatorProfile.loadUrl(profileImageUrl) {
|
||||||
|
transformations(CircleCropTransformation())
|
||||||
|
placeholder(R.drawable.bg_placeholder)
|
||||||
|
error(R.drawable.bg_placeholder)
|
||||||
|
}
|
||||||
|
}
|
||||||
binding.btnBack.setOnClickListener { finish() }
|
binding.btnBack.setOnClickListener { finish() }
|
||||||
sizes = GiftSendRequestPresenter.selectDefaultSize(emptyList())
|
sizes = GiftSendRequestPresenter.selectDefaultSize(emptyList())
|
||||||
bindSizeOptions()
|
bindSizeOptions()
|
||||||
@@ -173,12 +184,15 @@ class GiftSendRequestActivity : BaseActivity<ActivityGiftSendRequestBinding>(Act
|
|||||||
}
|
}
|
||||||
cbTerms.setRequiredLink(::onTermsRequiredClick)
|
cbTerms.setRequiredLink(::onTermsRequiredClick)
|
||||||
cbPrivacy.setRequiredLink(::onPrivacyRequiredClick)
|
cbPrivacy.setRequiredLink(::onPrivacyRequiredClick)
|
||||||
|
cbDamageLoss.setRequiredLink(::onDamagePolicyLinkClick)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onTermsRequiredClick() = openGiftAgreementPage()
|
private fun onTermsRequiredClick() = openGiftAgreementPage()
|
||||||
|
|
||||||
private fun onPrivacyRequiredClick() = openGiftAgreementPage()
|
private fun onPrivacyRequiredClick() = openGiftAgreementPage()
|
||||||
|
|
||||||
|
private fun onDamagePolicyLinkClick() = openGiftDamagePolicyPage()
|
||||||
|
|
||||||
private fun currentFormState() = with(binding) {
|
private fun currentFormState() = with(binding) {
|
||||||
GiftSendFormState(
|
GiftSendFormState(
|
||||||
senderName = etSenderName.text.toString(),
|
senderName = etSenderName.text.toString(),
|
||||||
@@ -266,11 +280,18 @@ class GiftSendRequestActivity : BaseActivity<ActivityGiftSendRequestBinding>(Act
|
|||||||
companion object {
|
companion object {
|
||||||
const val EXTRA_CREATOR_MEMBER_ID = "extra_creator_member_id"
|
const val EXTRA_CREATOR_MEMBER_ID = "extra_creator_member_id"
|
||||||
const val EXTRA_CREATOR_NICKNAME = "extra_creator_nickname"
|
const val EXTRA_CREATOR_NICKNAME = "extra_creator_nickname"
|
||||||
|
const val EXTRA_CREATOR_PROFILE_IMAGE_URL = "extra_creator_profile_image_url"
|
||||||
|
|
||||||
fun newIntent(context: Context, creatorMemberId: Long, creatorNickname: String): Intent =
|
fun newIntent(
|
||||||
|
context: Context,
|
||||||
|
creatorMemberId: Long,
|
||||||
|
creatorNickname: String,
|
||||||
|
profileImageUrl: String? = null
|
||||||
|
): Intent =
|
||||||
Intent(context, GiftSendRequestActivity::class.java).apply {
|
Intent(context, GiftSendRequestActivity::class.java).apply {
|
||||||
putExtra(EXTRA_CREATOR_MEMBER_ID, creatorMemberId)
|
putExtra(EXTRA_CREATOR_MEMBER_ID, creatorMemberId)
|
||||||
putExtra(EXTRA_CREATOR_NICKNAME, creatorNickname)
|
putExtra(EXTRA_CREATOR_NICKNAME, creatorNickname)
|
||||||
|
putExtra(EXTRA_CREATOR_PROFILE_IMAGE_URL, profileImageUrl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ import android.widget.TextView
|
|||||||
import androidx.core.view.children
|
import androidx.core.view.children
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.test.core.app.ApplicationProvider
|
import androidx.test.core.app.ApplicationProvider
|
||||||
|
import coil.EventListener
|
||||||
|
import coil.ImageLoader
|
||||||
|
import coil.request.ImageRequest
|
||||||
|
import coil.transform.CircleCropTransformation
|
||||||
import io.reactivex.rxjava3.android.plugins.RxAndroidPlugins
|
import io.reactivex.rxjava3.android.plugins.RxAndroidPlugins
|
||||||
import io.reactivex.rxjava3.core.Single
|
import io.reactivex.rxjava3.core.Single
|
||||||
import io.reactivex.rxjava3.plugins.RxJavaPlugins
|
import io.reactivex.rxjava3.plugins.RxJavaPlugins
|
||||||
@@ -23,6 +27,7 @@ import io.reactivex.rxjava3.schedulers.Schedulers
|
|||||||
import io.reactivex.rxjava3.subjects.SingleSubject
|
import io.reactivex.rxjava3.subjects.SingleSubject
|
||||||
import kr.co.vividnext.sodalive.R
|
import kr.co.vividnext.sodalive.R
|
||||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||||
|
import kr.co.vividnext.sodalive.common.ImageLoaderProvider
|
||||||
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||||
import kr.co.vividnext.sodalive.v2.gift.data.GiftApi
|
import kr.co.vividnext.sodalive.v2.gift.data.GiftApi
|
||||||
import kr.co.vividnext.sodalive.v2.gift.data.GiftCancelResponse
|
import kr.co.vividnext.sodalive.v2.gift.data.GiftCancelResponse
|
||||||
@@ -956,6 +961,138 @@ class GiftNavigationTest {
|
|||||||
assertRecipientAgreementLink(GiftDetailAddressAgreement.PRIVACY)
|
assertRecipientAgreementLink(GiftDetailAddressAgreement.PRIVACY)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `선물 신청 Intent는 크리에이터 id 닉네임 프로필 URL을 원본 그대로 전달한다`() {
|
||||||
|
val profileImageUrl = "https://example.com/creator-profile.jpg"
|
||||||
|
val intent = GiftSendRequestActivity.newIntent(
|
||||||
|
ApplicationProvider.getApplicationContext(),
|
||||||
|
creatorMemberId = 71L,
|
||||||
|
creatorNickname = "크리에이터",
|
||||||
|
profileImageUrl = profileImageUrl
|
||||||
|
)
|
||||||
|
|
||||||
|
assertEquals(71L, intent.getLongExtra(GiftSendRequestActivity.EXTRA_CREATOR_MEMBER_ID, 0L))
|
||||||
|
assertEquals("크리에이터", intent.getStringExtra(GiftSendRequestActivity.EXTRA_CREATOR_NICKNAME))
|
||||||
|
assertEquals(profileImageUrl, intent.getStringExtra(GiftSendRequestActivity.EXTRA_CREATOR_PROFILE_IMAGE_URL))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Config(qualifiers = "ko")
|
||||||
|
@GraphicsMode(GraphicsMode.Mode.NATIVE)
|
||||||
|
fun `선물 신청 화면은 프로필 ImageView를 바인딩하고 URL이 없으면 placeholder를 유지한다`() {
|
||||||
|
val profileImageUrl = "https://example.com/creator-profile.jpg"
|
||||||
|
if (!ImageLoaderProvider.isInitialized) {
|
||||||
|
ImageLoaderProvider.init(ApplicationProvider.getApplicationContext())
|
||||||
|
}
|
||||||
|
val requests = mutableListOf<ImageRequest>()
|
||||||
|
val originalImageLoader = ImageLoaderProvider.imageLoader
|
||||||
|
replaceImageLoader(
|
||||||
|
ImageLoader.Builder(ApplicationProvider.getApplicationContext())
|
||||||
|
.eventListenerFactory(
|
||||||
|
EventListener.Factory {
|
||||||
|
object : EventListener {
|
||||||
|
override fun onStart(request: ImageRequest) {
|
||||||
|
requests += request
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.build()
|
||||||
|
)
|
||||||
|
try {
|
||||||
|
val withProfileController = Robolectric.buildActivity(
|
||||||
|
GiftSendRequestActivity::class.java,
|
||||||
|
GiftSendRequestActivity.newIntent(
|
||||||
|
ApplicationProvider.getApplicationContext(),
|
||||||
|
creatorMemberId = 71L,
|
||||||
|
creatorNickname = "크리에이터",
|
||||||
|
profileImageUrl = profileImageUrl
|
||||||
|
)
|
||||||
|
).setup().visible()
|
||||||
|
val withoutProfileController = Robolectric.buildActivity(
|
||||||
|
GiftSendRequestActivity::class.java,
|
||||||
|
GiftSendRequestActivity.newIntent(
|
||||||
|
ApplicationProvider.getApplicationContext(),
|
||||||
|
creatorMemberId = 71L,
|
||||||
|
creatorNickname = "크리에이터",
|
||||||
|
profileImageUrl = null
|
||||||
|
)
|
||||||
|
).setup().visible()
|
||||||
|
val withProfileImage = withProfileController.get().binding.ivCreatorProfile
|
||||||
|
val withoutProfileImage = withoutProfileController.get().binding.ivCreatorProfile
|
||||||
|
|
||||||
|
assertEquals(listOf(profileImageUrl), requests.map { it.data })
|
||||||
|
assertEquals(listOf(CircleCropTransformation()), requests.single().transformations)
|
||||||
|
assertNotNull(withoutProfileImage.drawable)
|
||||||
|
|
||||||
|
withProfileController.pause().stop().destroy()
|
||||||
|
withoutProfileController.pause().stop().destroy()
|
||||||
|
} finally {
|
||||||
|
replaceImageLoader(originalImageLoader)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Config(qualifiers = "ko")
|
||||||
|
@GraphicsMode(GraphicsMode.Mode.NATIVE)
|
||||||
|
fun `파손 면책 필수만 정책을 열고 폼 동의 CTA를 유지한다`() {
|
||||||
|
val controller = Robolectric.buildActivity(
|
||||||
|
GiftSendRequestActivity::class.java,
|
||||||
|
GiftSendRequestActivity.newIntent(
|
||||||
|
ApplicationProvider.getApplicationContext(),
|
||||||
|
creatorMemberId = 71L,
|
||||||
|
creatorNickname = "크리에이터",
|
||||||
|
profileImageUrl = null
|
||||||
|
)
|
||||||
|
).setup().visible()
|
||||||
|
val activity = controller.get()
|
||||||
|
completeGiftSendForm(activity)
|
||||||
|
val checkBox = activity.binding.cbDamageLoss
|
||||||
|
val span = checkBox.requiredLink()
|
||||||
|
val spanned = checkBox.text as Spanned
|
||||||
|
val senderName = activity.binding.etSenderName.text.toString()
|
||||||
|
val phoneNumber = activity.binding.etPhoneNumber.text.toString()
|
||||||
|
val postcode = activity.binding.tvPostcode.text.toString()
|
||||||
|
val address = activity.binding.tvAddress.text.toString()
|
||||||
|
val detailAddress = activity.binding.etDetailAddress.text.toString()
|
||||||
|
val termsAgreed = activity.binding.cbTerms.isChecked
|
||||||
|
val privacyAgreed = activity.binding.cbPrivacy.isChecked
|
||||||
|
val damageLossAgreed = checkBox.isChecked
|
||||||
|
val ctaEnabled = activity.binding.btnSend.isEnabled
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
activity.getString(R.string.gift_send_required),
|
||||||
|
spanned.subSequence(spanned.getSpanStart(span), spanned.getSpanEnd(span)).toString()
|
||||||
|
)
|
||||||
|
assertFalse(checkBox.text.contains("(자세히보기)"))
|
||||||
|
checkBox.measure(
|
||||||
|
View.MeasureSpec.makeMeasureSpec(360, View.MeasureSpec.EXACTLY),
|
||||||
|
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)
|
||||||
|
)
|
||||||
|
checkBox.layout(0, 0, checkBox.measuredWidth, checkBox.measuredHeight)
|
||||||
|
checkBox.dispatchTap(checkBox.glyphRightInteriorPoint(spanned.getSpanStart(span) - 1))
|
||||||
|
assertNull(shadowOf(activity).nextStartedActivity)
|
||||||
|
checkBox.isChecked = damageLossAgreed
|
||||||
|
|
||||||
|
checkBox.dispatchTap(checkBox.requiredLinkCenter())
|
||||||
|
val launched = shadowOf(activity).nextStartedActivity
|
||||||
|
assertNotNull(launched)
|
||||||
|
assertEquals(Intent.ACTION_VIEW, launched.action)
|
||||||
|
assertEquals("https://app.notion.com/p/3f227b3596738018ba5dea2e5205293b", launched.data.toString())
|
||||||
|
assertEquals(senderName, activity.binding.etSenderName.text.toString())
|
||||||
|
assertEquals(phoneNumber, activity.binding.etPhoneNumber.text.toString())
|
||||||
|
assertEquals(postcode, activity.binding.tvPostcode.text.toString())
|
||||||
|
assertEquals(address, activity.binding.tvAddress.text.toString())
|
||||||
|
assertEquals(detailAddress, activity.binding.etDetailAddress.text.toString())
|
||||||
|
assertEquals(termsAgreed, activity.binding.cbTerms.isChecked)
|
||||||
|
assertEquals(privacyAgreed, activity.binding.cbPrivacy.isChecked)
|
||||||
|
assertEquals(damageLossAgreed, checkBox.isChecked)
|
||||||
|
assertEquals(ctaEnabled, activity.binding.btnSend.isEnabled)
|
||||||
|
assertNull(shadowOf(activity).nextStartedActivity)
|
||||||
|
|
||||||
|
controller.pause().stop().destroy()
|
||||||
|
}
|
||||||
|
|
||||||
private fun assertRecipientAgreementLink(agreement: GiftDetailAddressAgreement) {
|
private fun assertRecipientAgreementLink(agreement: GiftDetailAddressAgreement) {
|
||||||
api.direction = "RECEIVED"
|
api.direction = "RECEIVED"
|
||||||
val controller = Robolectric.buildActivity(
|
val controller = Robolectric.buildActivity(
|
||||||
@@ -1095,6 +1232,13 @@ class GiftNavigationTest {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun replaceImageLoader(imageLoader: ImageLoader) {
|
||||||
|
ImageLoaderProvider::class.java.getDeclaredField("imageLoader").apply {
|
||||||
|
isAccessible = true
|
||||||
|
set(ImageLoaderProvider, imageLoader)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun CheckBox.describeRequiredLinkPoint(point: Pair<Float, Float>): String {
|
private fun CheckBox.describeRequiredLinkPoint(point: Pair<Float, Float>): String {
|
||||||
val textLayout = checkNotNull(layout)
|
val textLayout = checkNotNull(layout)
|
||||||
val vertical = point.second - totalPaddingTop + scrollY
|
val vertical = point.second - totalPaddingTop + scrollY
|
||||||
|
|||||||
Reference in New Issue
Block a user