From ea4a20d9edb66cfcebabd0eebd1d9094da34b046 Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Mon, 2 Dec 2024 05:37:51 +0900 Subject: [PATCH 01/12] =?UTF-8?q?[ADD/#187]=20=EC=82=AC=EC=A7=84=20?= =?UTF-8?q?=EC=84=A0=ED=83=9D=EB=B7=B0=20amplitude=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/kr/genti/presentation/main/CreateSelectDialog.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/presentation/src/main/java/kr/genti/presentation/main/CreateSelectDialog.kt b/presentation/src/main/java/kr/genti/presentation/main/CreateSelectDialog.kt index 33c5aea..c79ab00 100644 --- a/presentation/src/main/java/kr/genti/presentation/main/CreateSelectDialog.kt +++ b/presentation/src/main/java/kr/genti/presentation/main/CreateSelectDialog.kt @@ -11,6 +11,7 @@ import kr.genti.core.extension.setOnSingleClickListener import kr.genti.presentation.R import kr.genti.presentation.create.CreateActivity import kr.genti.presentation.databinding.DialogCreateSelectBinding +import kr.genti.presentation.util.AmplitudeManager class CreateSelectDialog : BaseDialog(R.layout.dialog_create_select) { @@ -37,9 +38,11 @@ class CreateSelectDialog : BaseDialog(R.layout.dialog private fun initCreateBtnListeners() { with(binding) { layoutDefaultCreate.setOnSingleClickListener { + AmplitudeManager.trackEvent("click_mypicture") navigateToCreate(false) } layoutParentCreate.setOnSingleClickListener { + AmplitudeManager.trackEvent("click_parentpicture") navigateToCreate(true) } } From b441263b990f4c4f51c89801f6f1efdc5e538d53 Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Mon, 2 Dec 2024 05:57:41 +0900 Subject: [PATCH 02/12] =?UTF-8?q?[ADD/#187]=20=EC=82=AC=EC=A7=84=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=EC=99=84=EB=A3=8C=EB=B7=B0=20amplitude=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../generate/finished/FinishedActivity.kt | 16 +++-- .../generate/finished/FinishedImageDialog.kt | 28 ++++++++- .../generate/finished/FinishedRatingDialog.kt | 63 ++++++++++++------- .../generate/finished/FinishedReportDialog.kt | 50 ++++++++++----- .../presentation/main/CreateErrorDialog.kt | 16 +++-- .../presentation/main/CreateFinishedDialog.kt | 15 +++-- .../presentation/util/AmplitudeManager.kt | 5 +- 7 files changed, 129 insertions(+), 64 deletions(-) diff --git a/presentation/src/main/java/kr/genti/presentation/generate/finished/FinishedActivity.kt b/presentation/src/main/java/kr/genti/presentation/generate/finished/FinishedActivity.kt index 7172f7c..598531b 100644 --- a/presentation/src/main/java/kr/genti/presentation/generate/finished/FinishedActivity.kt +++ b/presentation/src/main/java/kr/genti/presentation/generate/finished/FinishedActivity.kt @@ -32,6 +32,9 @@ import kr.genti.presentation.util.AmplitudeManager import kr.genti.presentation.util.AmplitudeManager.EVENT_CLICK_BTN import kr.genti.presentation.util.AmplitudeManager.PROPERTY_BTN import kr.genti.presentation.util.AmplitudeManager.PROPERTY_PAGE +import kr.genti.presentation.util.AmplitudeManager.PROPERTY_TYPE +import kr.genti.presentation.util.AmplitudeManager.TYPE_ORIGINAL +import kr.genti.presentation.util.AmplitudeManager.TYPE_PARENT import kr.genti.presentation.util.GlideResultListener import kr.genti.presentation.util.downloadImage import java.io.File @@ -44,12 +47,13 @@ class FinishedActivity : BaseActivity(R.layout.activity private var finishedReportDialog: FinishedReportDialog? = null private var finishedRatingDialog: FinishedRatingDialog? = null + private var amplitudeType: Map? = null + private lateinit var tempFile: File override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - initView() initImageBtnListener() initSaveBtnListener() initShareBtnListener() @@ -61,13 +65,9 @@ class FinishedActivity : BaseActivity(R.layout.activity observeDownloadCacheImage() } - private fun initView() { - AmplitudeManager.trackEvent("view_picdone") - } - private fun initImageBtnListener() { binding.ivFinishedImage.setOnSingleClickListener { - AmplitudeManager.trackEvent("enlarge_picdone_picture") + AmplitudeManager.trackEvent("enlarge_picdone_picture", amplitudeType) finishedImageDialog = FinishedImageDialog() finishedImageDialog?.show(supportFragmentManager, DIALOG_IMAGE) } @@ -140,7 +140,11 @@ class FinishedActivity : BaseActivity(R.layout.activity btnShare.isVisible = false btnSavePaid.isVisible = true } + amplitudeType = mapOf(PROPERTY_TYPE to TYPE_ORIGINAL) + } else { + amplitudeType = mapOf(PROPERTY_TYPE to TYPE_PARENT) } + AmplitudeManager.trackEvent("view_picdone", amplitudeType) } private fun showFinishedRatingDialog() { diff --git a/presentation/src/main/java/kr/genti/presentation/generate/finished/FinishedImageDialog.kt b/presentation/src/main/java/kr/genti/presentation/generate/finished/FinishedImageDialog.kt index 6029d02..740c66f 100644 --- a/presentation/src/main/java/kr/genti/presentation/generate/finished/FinishedImageDialog.kt +++ b/presentation/src/main/java/kr/genti/presentation/generate/finished/FinishedImageDialog.kt @@ -1,22 +1,25 @@ package kr.genti.presentation.generate.finished -import android.content.DialogInterface import android.os.Bundle import android.view.View import android.view.WindowManager import androidx.fragment.app.activityViewModels import coil.load import kr.genti.core.base.BaseDialog -import kr.genti.core.extension.setGusianBlur import kr.genti.core.extension.setOnSingleClickListener import kr.genti.presentation.R import kr.genti.presentation.databinding.DialogFinishedImageBinding import kr.genti.presentation.util.AmplitudeManager +import kr.genti.presentation.util.AmplitudeManager.PROPERTY_TYPE +import kr.genti.presentation.util.AmplitudeManager.TYPE_ORIGINAL +import kr.genti.presentation.util.AmplitudeManager.TYPE_PARENT import kr.genti.presentation.util.downloadImage class FinishedImageDialog : BaseDialog(R.layout.dialog_finished_image) { private val viewModel by activityViewModels() + private var amplitudeType: Map? = null + override fun onStart() { super.onStart() dialog?.window?.apply { @@ -36,6 +39,7 @@ class FinishedImageDialog : BaseDialog(R.layout.dial initExitBtnListener() initDownloadBtnListener() + setIsPaidWithIntent() setImage() } @@ -47,14 +51,32 @@ class FinishedImageDialog : BaseDialog(R.layout.dial private fun initDownloadBtnListener() { binding.btnDownload.setOnSingleClickListener { AmplitudeManager.apply { - trackEvent("download_picdone_enlargedpicture") + trackEvent("download_picdone_enlargedpicture", amplitudeType) plusIntProperties("user_picturedownload") } requireActivity().downloadImage(viewModel.finishedImageId, viewModel.finishedImageUrl) } } + private fun setIsPaidWithIntent() { + if (arguments?.getBoolean(ARG_IS_PAID) == true) { + amplitudeType = mapOf(PROPERTY_TYPE to TYPE_PARENT) + } else { + amplitudeType = mapOf(PROPERTY_TYPE to TYPE_ORIGINAL) + } + } + private fun setImage() { binding.ivFinished.load(viewModel.finishedImageUrl) } + + companion object { + private const val ARG_IS_PAID = "ARG_IS_PAID" + + @JvmStatic + fun newInstance(isPaid: Boolean): FinishedImageDialog = + FinishedImageDialog().apply { + arguments = Bundle().apply { putBoolean(ARG_IS_PAID, isPaid) } + } + } } diff --git a/presentation/src/main/java/kr/genti/presentation/generate/finished/FinishedRatingDialog.kt b/presentation/src/main/java/kr/genti/presentation/generate/finished/FinishedRatingDialog.kt index 8e8d152..4401462 100644 --- a/presentation/src/main/java/kr/genti/presentation/generate/finished/FinishedRatingDialog.kt +++ b/presentation/src/main/java/kr/genti/presentation/generate/finished/FinishedRatingDialog.kt @@ -1,6 +1,5 @@ package kr.genti.presentation.generate.finished -import android.content.DialogInterface import android.content.Intent import android.os.Bundle import android.view.View @@ -11,19 +10,24 @@ import androidx.lifecycle.lifecycleScope import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kr.genti.core.base.BaseDialog -import kr.genti.core.extension.setGusianBlur import kr.genti.core.extension.setOnSingleClickListener import kr.genti.core.extension.stringOf import kr.genti.core.extension.toast import kr.genti.presentation.R import kr.genti.presentation.databinding.DialogFinishedRatingBinding +import kr.genti.presentation.generate.finished.FinishedImageDialog.Companion import kr.genti.presentation.main.MainActivity import kr.genti.presentation.util.AmplitudeManager +import kr.genti.presentation.util.AmplitudeManager.PROPERTY_TYPE +import kr.genti.presentation.util.AmplitudeManager.TYPE_ORIGINAL +import kr.genti.presentation.util.AmplitudeManager.TYPE_PARENT class FinishedRatingDialog : BaseDialog(R.layout.dialog_finished_rating) { private val viewModel by activityViewModels() + private var amplitudeType: Map? = null + override fun onStart() { super.onStart() dialog?.window?.apply { @@ -43,6 +47,7 @@ class FinishedRatingDialog : initSkipBtnListener() initSubmitBtnListener() + setIsPaidWithIntent() setMinRating() observeVerifyResult() observeRateResult() @@ -50,18 +55,26 @@ class FinishedRatingDialog : private fun initSkipBtnListener() { binding.btnSkip.setOnSingleClickListener { - AmplitudeManager.trackEvent("ratingpass_picdone") + AmplitudeManager.trackEvent("ratingpass_picdone", amplitudeType) viewModel.postVerifyGenerateStateToServer() } } private fun initSubmitBtnListener() { binding.btnSubmit.setOnSingleClickListener { - AmplitudeManager.trackEvent("ratingsubmit_picdone") + AmplitudeManager.trackEvent("ratingsubmit_picdone", amplitudeType) viewModel.postGenerateRateToServer(binding.ratingBar.rating.toInt()) } } + private fun setIsPaidWithIntent() { + if (arguments?.getBoolean(ARG_IS_PAID) == true) { + amplitudeType = mapOf(PROPERTY_TYPE to TYPE_PARENT) + } else { + amplitudeType = mapOf(PROPERTY_TYPE to TYPE_ORIGINAL) + } + } + private fun setMinRating() { binding.ratingBar.setOnRatingBarChangeListener { _, rating, _ -> if (rating < 1.0f) binding.ratingBar.rating = 1.0f @@ -77,26 +90,32 @@ class FinishedRatingDialog : } private fun observeVerifyResult() { - viewModel.postVerifyResult - .flowWithLifecycle(lifecycle) - .onEach { result -> - if (result) { - navigateToMain() - } else { - toast(stringOf(R.string.error_msg)) - } - }.launchIn(lifecycleScope) + viewModel.postVerifyResult.flowWithLifecycle(lifecycle).onEach { result -> + if (result) { + navigateToMain() + } else { + toast(stringOf(R.string.error_msg)) + } + }.launchIn(lifecycleScope) } private fun observeRateResult() { - viewModel.postRateResult - .flowWithLifecycle(lifecycle) - .onEach { result -> - if (result) { - navigateToMain() - } else { - toast(stringOf(R.string.error_msg)) - } - }.launchIn(lifecycleScope) + viewModel.postRateResult.flowWithLifecycle(lifecycle).onEach { result -> + if (result) { + navigateToMain() + } else { + toast(stringOf(R.string.error_msg)) + } + }.launchIn(lifecycleScope) + } + + companion object { + private const val ARG_IS_PAID = "ARG_IS_PAID" + + @JvmStatic + fun newInstance(isPaid: Boolean): FinishedRatingDialog = + FinishedRatingDialog().apply { + arguments = Bundle().apply { putBoolean(ARG_IS_PAID, isPaid) } + } } } diff --git a/presentation/src/main/java/kr/genti/presentation/generate/finished/FinishedReportDialog.kt b/presentation/src/main/java/kr/genti/presentation/generate/finished/FinishedReportDialog.kt index a76fd31..5908352 100644 --- a/presentation/src/main/java/kr/genti/presentation/generate/finished/FinishedReportDialog.kt +++ b/presentation/src/main/java/kr/genti/presentation/generate/finished/FinishedReportDialog.kt @@ -1,6 +1,5 @@ package kr.genti.presentation.generate.finished -import android.content.DialogInterface import android.os.Bundle import android.view.MotionEvent import android.view.View @@ -13,18 +12,22 @@ import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kr.genti.core.base.BaseDialog import kr.genti.core.extension.hideKeyboard -import kr.genti.core.extension.setGusianBlur import kr.genti.core.extension.setOnSingleClickListener import kr.genti.core.extension.stringOf import kr.genti.core.extension.toast import kr.genti.presentation.R import kr.genti.presentation.databinding.DialogFinishedReportBinding import kr.genti.presentation.util.AmplitudeManager +import kr.genti.presentation.util.AmplitudeManager.PROPERTY_TYPE +import kr.genti.presentation.util.AmplitudeManager.TYPE_ORIGINAL +import kr.genti.presentation.util.AmplitudeManager.TYPE_PARENT class FinishedReportDialog : BaseDialog(R.layout.dialog_finished_report) { private val viewModel by activityViewModels() + private var amplitudeType: Map? = null + override fun onStart() { super.onStart() dialog?.window?.apply { @@ -45,6 +48,7 @@ class FinishedReportDialog : binding.vm = viewModel initExitBtnListener() initSubmitBtnListener() + setIsPaidWithIntent() setHideKeyboard(view) observeReportResult() } @@ -65,6 +69,14 @@ class FinishedReportDialog : } } + private fun setIsPaidWithIntent() { + if (arguments?.getBoolean(ARG_IS_PAID) == true) { + amplitudeType = mapOf(PROPERTY_TYPE to TYPE_PARENT) + } else { + amplitudeType = mapOf(PROPERTY_TYPE to TYPE_ORIGINAL) + } + } + private fun setHideKeyboard(view: View) { view.setOnTouchListener { v, event -> if (event.action == MotionEvent.ACTION_DOWN) { @@ -76,19 +88,27 @@ class FinishedReportDialog : } private fun observeReportResult() { - viewModel.postReportResult - .flowWithLifecycle(lifecycle) - .onEach { result -> - if (result) { - AmplitudeManager.trackEvent("reportpic_picdone") - requireContext().hideKeyboard(requireView()) - with(binding) { - layoutErrorInput.isVisible = false - layoutErrorOutput.isVisible = true - } - } else { - toast(stringOf(R.string.error_msg)) + viewModel.postReportResult.flowWithLifecycle(lifecycle).onEach { result -> + if (result) { + AmplitudeManager.trackEvent("reportpic_picdone", amplitudeType) + requireContext().hideKeyboard(requireView()) + with(binding) { + layoutErrorInput.isVisible = false + layoutErrorOutput.isVisible = true } - }.launchIn(lifecycleScope) + } else { + toast(stringOf(R.string.error_msg)) + } + }.launchIn(lifecycleScope) + } + + companion object { + private const val ARG_IS_PAID = "ARG_IS_PAID" + + @JvmStatic + fun newInstance(isPaid: Boolean): FinishedReportDialog = + FinishedReportDialog().apply { + arguments = Bundle().apply { putBoolean(ARG_IS_PAID, isPaid) } + } } } diff --git a/presentation/src/main/java/kr/genti/presentation/main/CreateErrorDialog.kt b/presentation/src/main/java/kr/genti/presentation/main/CreateErrorDialog.kt index 92bcb06..5a57de7 100644 --- a/presentation/src/main/java/kr/genti/presentation/main/CreateErrorDialog.kt +++ b/presentation/src/main/java/kr/genti/presentation/main/CreateErrorDialog.kt @@ -55,14 +55,12 @@ class CreateErrorDialog : BaseDialog(R.layout.dialog_c } private fun observeResetResult() { - viewModel.postResetResult - .flowWithLifecycle(lifecycle) - .onEach { result -> - if (!result) { - toast(stringOf(R.string.error_msg)) - } else { - dismiss() - } - }.launchIn(lifecycleScope) + viewModel.postResetResult.flowWithLifecycle(lifecycle).onEach { result -> + if (!result) { + toast(stringOf(R.string.error_msg)) + } else { + dismiss() + } + }.launchIn(lifecycleScope) } } diff --git a/presentation/src/main/java/kr/genti/presentation/main/CreateFinishedDialog.kt b/presentation/src/main/java/kr/genti/presentation/main/CreateFinishedDialog.kt index d79ffb6..e439790 100644 --- a/presentation/src/main/java/kr/genti/presentation/main/CreateFinishedDialog.kt +++ b/presentation/src/main/java/kr/genti/presentation/main/CreateFinishedDialog.kt @@ -48,14 +48,13 @@ class CreateFinishedDialog : if (viewModel.checkNewPictureInitialized()) { with(viewModel.newPicture) { startActivity( - FinishedActivity - .createIntent( - requireContext(), - this.response?.responseId ?: -1, - this.response?.picture?.url.orEmpty(), - this.response?.picture?.pictureRatio?.name.orEmpty(), - this.paid, - ) + FinishedActivity.createIntent( + requireContext(), + this.response?.responseId ?: -1, + this.response?.picture?.url.orEmpty(), + this.response?.picture?.pictureRatio?.name.orEmpty(), + this.paid, + ) ) } } else { diff --git a/presentation/src/main/java/kr/genti/presentation/util/AmplitudeManager.kt b/presentation/src/main/java/kr/genti/presentation/util/AmplitudeManager.kt index 63e496a..e706112 100644 --- a/presentation/src/main/java/kr/genti/presentation/util/AmplitudeManager.kt +++ b/presentation/src/main/java/kr/genti/presentation/util/AmplitudeManager.kt @@ -71,7 +71,10 @@ object AmplitudeManager { const val EVENT_CLICK_BTN = "click_button" - const val PROPERTY_METHOD = "signup_method" const val PROPERTY_PAGE = "page_name" const val PROPERTY_BTN = "button_name" + const val PROPERTY_TYPE = "picdone_type" + + const val TYPE_ORIGINAL = "original" + const val TYPE_PARENT = "parents" } From b378a6fe0ebe9a3758f6799e651c74093465da3b Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Mon, 2 Dec 2024 06:27:54 +0900 Subject: [PATCH 03/12] =?UTF-8?q?[ADD/#187]=20=EC=82=AC=EC=A7=84=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=EB=8C=80=EA=B8=B0=EB=B7=B0=20amplitude=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../generate/finished/FinishedActivity.kt | 19 ++++++------------- .../generate/waiting/WaitingActivity.kt | 10 ++++++---- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/presentation/src/main/java/kr/genti/presentation/generate/finished/FinishedActivity.kt b/presentation/src/main/java/kr/genti/presentation/generate/finished/FinishedActivity.kt index 598531b..e14f5a0 100644 --- a/presentation/src/main/java/kr/genti/presentation/generate/finished/FinishedActivity.kt +++ b/presentation/src/main/java/kr/genti/presentation/generate/finished/FinishedActivity.kt @@ -48,6 +48,7 @@ class FinishedActivity : BaseActivity(R.layout.activity private var finishedRatingDialog: FinishedRatingDialog? = null private var amplitudeType: Map? = null + private var amplitudePage: Map? = null private lateinit var tempFile: File @@ -82,11 +83,7 @@ class FinishedActivity : BaseActivity(R.layout.activity private fun downloadImage() { AmplitudeManager.apply { - trackEvent( - EVENT_CLICK_BTN, - mapOf(PROPERTY_PAGE to "picdone"), - mapOf(PROPERTY_BTN to "picdownload"), - ) + trackEvent(EVENT_CLICK_BTN, amplitudePage, mapOf(PROPERTY_BTN to "picdownload")) plusIntProperties("user_picturedownload") } downloadImage(viewModel.finishedImageId, viewModel.finishedImageUrl) @@ -95,11 +92,7 @@ class FinishedActivity : BaseActivity(R.layout.activity private fun initShareBtnListener() { binding.btnShare.setOnSingleClickListener { AmplitudeManager.apply { - trackEvent( - EVENT_CLICK_BTN, - mapOf(PROPERTY_PAGE to "picdone"), - mapOf(PROPERTY_BTN to "picshare"), - ) + trackEvent(EVENT_CLICK_BTN, amplitudePage, mapOf(PROPERTY_BTN to "picshare")) plusIntProperties("user_share") } tempFile = File(cacheDir, TEMP_FILE_NAME) @@ -141,17 +134,17 @@ class FinishedActivity : BaseActivity(R.layout.activity btnSavePaid.isVisible = true } amplitudeType = mapOf(PROPERTY_TYPE to TYPE_ORIGINAL) + amplitudePage = mapOf(PROPERTY_PAGE to "picdone") } else { amplitudeType = mapOf(PROPERTY_TYPE to TYPE_PARENT) + amplitudePage = mapOf(PROPERTY_PAGE to "picdone_parents") } AmplitudeManager.trackEvent("view_picdone", amplitudeType) } private fun showFinishedRatingDialog() { AmplitudeManager.trackEvent( - EVENT_CLICK_BTN, - mapOf(PROPERTY_PAGE to "picdone"), - mapOf(PROPERTY_BTN to "gomain"), + EVENT_CLICK_BTN, amplitudePage, mapOf(PROPERTY_BTN to "gomain"), ) finishedRatingDialog = FinishedRatingDialog() finishedRatingDialog?.show(supportFragmentManager, DIALOG_RATING) diff --git a/presentation/src/main/java/kr/genti/presentation/generate/waiting/WaitingActivity.kt b/presentation/src/main/java/kr/genti/presentation/generate/waiting/WaitingActivity.kt index 096fac2..808974b 100644 --- a/presentation/src/main/java/kr/genti/presentation/generate/waiting/WaitingActivity.kt +++ b/presentation/src/main/java/kr/genti/presentation/generate/waiting/WaitingActivity.kt @@ -18,7 +18,6 @@ import kr.genti.core.base.BaseActivity import kr.genti.core.extension.setOnSingleClickListener import kr.genti.presentation.R import kr.genti.presentation.databinding.ActivityWaitBinding -import kr.genti.presentation.generate.finished.FinishedActivity import kr.genti.presentation.util.AmplitudeManager import kr.genti.presentation.util.AmplitudeManager.EVENT_CLICK_BTN import kr.genti.presentation.util.AmplitudeManager.PROPERTY_BTN @@ -28,6 +27,8 @@ import kr.genti.presentation.util.AmplitudeManager.PROPERTY_PAGE class WaitingActivity : BaseActivity(R.layout.activity_wait) { private var pushDialog: PushDialog? = null + private var amplitudePage: Map? = null + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -40,9 +41,7 @@ class WaitingActivity : BaseActivity(R.layout.activity_wait private fun initReturnBtnListener() { binding.btnWaitReturn.setOnSingleClickListener { AmplitudeManager.trackEvent( - EVENT_CLICK_BTN, - mapOf(PROPERTY_PAGE to "picwaiting"), - mapOf(PROPERTY_BTN to "gomain"), + EVENT_CLICK_BTN, amplitudePage, mapOf(PROPERTY_BTN to "gomain"), ) startPushDialogOrFinish() } @@ -82,6 +81,9 @@ class WaitingActivity : BaseActivity(R.layout.activity_wait private fun setUiBuIsPaidIntent() { if (intent.getBooleanExtra(EXTRA_IS_PAID, false)) { binding.tvWaitTitle.text = getString(R.string.wait_tv_title_paid) + amplitudePage = mapOf(PROPERTY_PAGE to "picwaiting_parents") + } else { + amplitudePage = mapOf(PROPERTY_PAGE to "picwaiting") } } From 17960c2269c7fb2b0bbee055f31b43606f3b4b25 Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Mon, 2 Dec 2024 16:04:47 +0900 Subject: [PATCH 04/12] =?UTF-8?q?[FIX/#187]=20=EC=83=9D=EC=84=B1=EB=B7=B0?= =?UTF-8?q?=20=EC=98=88=EC=8B=9C=20=ED=94=84=EB=A1=AC=ED=94=84=ED=8A=B8=20?= =?UTF-8?q?API=20v2=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/kr/genti/data/service/CreateService.kt | 2 +- .../genti/presentation/create/CreateViewModel.kt | 8 ++++---- .../genti/presentation/create/SelfieFragment.kt | 5 ++--- .../generate/finished/FinishedActivity.kt | 15 ++++++--------- .../generate/waiting/WaitingActivity.kt | 13 ++++++------- 5 files changed, 19 insertions(+), 24 deletions(-) diff --git a/data/src/main/java/kr/genti/data/service/CreateService.kt b/data/src/main/java/kr/genti/data/service/CreateService.kt index 997d53f..62f6f7e 100644 --- a/data/src/main/java/kr/genti/data/service/CreateService.kt +++ b/data/src/main/java/kr/genti/data/service/CreateService.kt @@ -44,7 +44,7 @@ interface CreateService { @Body request: KeyRequestDto, ): BaseResponse - @GET("api/v1/users/examples/with-picture-square/{type}") + @GET("api/v2/users/examples/with-picture-square/{type}") suspend fun getPromptExample( @Path("type") type: String ): BaseResponse> diff --git a/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt b/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt index 7299d6c..ffc7ed8 100644 --- a/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt +++ b/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt @@ -255,17 +255,17 @@ constructor( if (isValidSuccess) { startSendingImages() } else { - _purchaseValidError.emit(VALIDATION_FALSE) + _purchaseValidError.emit(PURCHASED_WITH_ERROR) } }.onFailure { - _purchaseValidError.emit(SERVER_ERROR) + _purchaseValidError.emit(PURCHASE_FAILURE) } } } companion object { - const val VALIDATION_FALSE = "VALIDATION_FALSE" - const val SERVER_ERROR = "SERVER_ERROR" + const val PURCHASE_FAILURE = "PURCHASE_FAILURE" + const val PURCHASED_WITH_ERROR = "PURCHASED_WITH_ERROR" const val TYPE_FREE_ONE = "FREE_ONE" const val TYPE_PAID_ONE = "PAID_ONE" diff --git a/presentation/src/main/java/kr/genti/presentation/create/SelfieFragment.kt b/presentation/src/main/java/kr/genti/presentation/create/SelfieFragment.kt index 5f04548..92a0b58 100644 --- a/presentation/src/main/java/kr/genti/presentation/create/SelfieFragment.kt +++ b/presentation/src/main/java/kr/genti/presentation/create/SelfieFragment.kt @@ -34,8 +34,7 @@ import kr.genti.core.state.UiState import kr.genti.domain.entity.response.ImageFileModel import kr.genti.domain.enums.PictureNumber import kr.genti.presentation.R -import kr.genti.presentation.create.CreateViewModel.Companion.SERVER_ERROR -import kr.genti.presentation.create.CreateViewModel.Companion.VALIDATION_FALSE +import kr.genti.presentation.create.CreateViewModel.Companion.PURCHASED_WITH_ERROR import kr.genti.presentation.create.billing.BillingCallback import kr.genti.presentation.create.billing.BillingManager import kr.genti.presentation.databinding.FragmentSelfieBinding @@ -300,7 +299,7 @@ class SelfieFragment : BaseFragment(R.layout.fragment_sel private fun observePurchaseValidResult() { viewModel.purchaseValidError.flowWithLifecycle(lifecycle).onEach { errorMsg -> - if (errorMsg == SERVER_ERROR) { + if (errorMsg == PURCHASED_WITH_ERROR) { showErrorDialog() } else { toast(stringOf(R.string.error_msg)) diff --git a/presentation/src/main/java/kr/genti/presentation/generate/finished/FinishedActivity.kt b/presentation/src/main/java/kr/genti/presentation/generate/finished/FinishedActivity.kt index e14f5a0..5a67830 100644 --- a/presentation/src/main/java/kr/genti/presentation/generate/finished/FinishedActivity.kt +++ b/presentation/src/main/java/kr/genti/presentation/generate/finished/FinishedActivity.kt @@ -169,9 +169,7 @@ class FinishedActivity : BaseActivity(R.layout.activity Glide.with(this.context) .load(viewModel.finishedImageUrl) .apply(RequestOptions.bitmapTransform(BlurTransformation(50))) - .listener(GlideResultListener { - binding.layoutLoading.isVisible = false - }) + .listener(GlideResultListener { binding.layoutLoading.isVisible = false }) .into(this) } } @@ -201,12 +199,11 @@ class FinishedActivity : BaseActivity(R.layout.activity .onEach { isDownloaded -> if (isDownloaded) { Intent().apply { - val uri = - FileProvider.getUriForFile( - this@FinishedActivity, - FILE_PROVIDER_AUTORITY, - tempFile, - ) + val uri = FileProvider.getUriForFile( + this@FinishedActivity, + FILE_PROVIDER_AUTORITY, + tempFile, + ) action = Intent.ACTION_SEND putExtra(Intent.EXTRA_STREAM, uri) type = IMAGE_TYPE diff --git a/presentation/src/main/java/kr/genti/presentation/generate/waiting/WaitingActivity.kt b/presentation/src/main/java/kr/genti/presentation/generate/waiting/WaitingActivity.kt index 808974b..dfbb2c1 100644 --- a/presentation/src/main/java/kr/genti/presentation/generate/waiting/WaitingActivity.kt +++ b/presentation/src/main/java/kr/genti/presentation/generate/waiting/WaitingActivity.kt @@ -34,7 +34,7 @@ class WaitingActivity : BaseActivity(R.layout.activity_wait initReturnBtnListener() setOnBackPressed() - setUiBuIsPaidIntent() + setUiByIsPaidIntent() setStatusBarTransparent() } @@ -48,12 +48,11 @@ class WaitingActivity : BaseActivity(R.layout.activity_wait } private fun setOnBackPressed() { - val onBackPressedCallback = - object : OnBackPressedCallback(true) { - override fun handleOnBackPressed() { - startPushDialogOrFinish() - } + val onBackPressedCallback = object : OnBackPressedCallback(true) { + override fun handleOnBackPressed() { + startPushDialogOrFinish() } + } this.onBackPressedDispatcher.addCallback(this, onBackPressedCallback) } @@ -78,7 +77,7 @@ class WaitingActivity : BaseActivity(R.layout.activity_wait false } - private fun setUiBuIsPaidIntent() { + private fun setUiByIsPaidIntent() { if (intent.getBooleanExtra(EXTRA_IS_PAID, false)) { binding.tvWaitTitle.text = getString(R.string.wait_tv_title_paid) amplitudePage = mapOf(PROPERTY_PAGE to "picwaiting_parents") From 6e8a57d34e37ffbe935b1424f150bdc1f3e7179e Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Mon, 2 Dec 2024 18:48:39 +0900 Subject: [PATCH 05/12] =?UTF-8?q?[ADD/#187]=20=EA=B2=B0=EC=A0=9C=20?= =?UTF-8?q?=EC=A7=84=ED=96=89=20=EC=A4=91=20=EB=A1=9C=EB=94=A9=20=EB=A1=9C?= =?UTF-8?q?=ED=8B=B0=20=ED=91=9C=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/create/CreateViewModel.kt | 18 +++++++------- .../presentation/create/SelfieFragment.kt | 17 ++++++------- .../src/main/res/layout/fragment_selfie.xml | 24 +++++++++++++++++++ 3 files changed, 42 insertions(+), 17 deletions(-) diff --git a/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt b/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt index ffc7ed8..d49a9a6 100644 --- a/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt +++ b/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt @@ -8,9 +8,7 @@ import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.coroutineScope -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.launch import kr.genti.core.state.UiState @@ -66,8 +64,8 @@ constructor( private val _totalGeneratingState = MutableStateFlow>(UiState.Empty) val totalGeneratingState: StateFlow> = _totalGeneratingState - private val _purchaseValidError = MutableSharedFlow() - val purchaseValidError: SharedFlow = _purchaseValidError + private val _purchaseValidState = MutableStateFlow>(UiState.Empty) + val purchaseValidState: StateFlow> = _purchaseValidState private var imageS3KeyList = listOf() private var firstImageS3KeyList = listOf() @@ -253,20 +251,22 @@ constructor( ) ).onSuccess { isValidSuccess -> if (isValidSuccess) { + _purchaseValidState.value = UiState.Success(true) startSendingImages() } else { - _purchaseValidError.emit(PURCHASED_WITH_ERROR) + _purchaseValidState.value = UiState.Failure(false.toString()) } }.onFailure { - _purchaseValidError.emit(PURCHASE_FAILURE) + _purchaseValidState.value = UiState.Failure(it.message.orEmpty()) } } } - companion object { - const val PURCHASE_FAILURE = "PURCHASE_FAILURE" - const val PURCHASED_WITH_ERROR = "PURCHASED_WITH_ERROR" + fun startValidProcessLoading() { + _purchaseValidState.value = UiState.Loading + } + companion object { const val TYPE_FREE_ONE = "FREE_ONE" const val TYPE_PAID_ONE = "PAID_ONE" const val TYPE_PAID_TWO = "PAID_TWO" diff --git a/presentation/src/main/java/kr/genti/presentation/create/SelfieFragment.kt b/presentation/src/main/java/kr/genti/presentation/create/SelfieFragment.kt index 92a0b58..2e48451 100644 --- a/presentation/src/main/java/kr/genti/presentation/create/SelfieFragment.kt +++ b/presentation/src/main/java/kr/genti/presentation/create/SelfieFragment.kt @@ -34,7 +34,6 @@ import kr.genti.core.state.UiState import kr.genti.domain.entity.response.ImageFileModel import kr.genti.domain.enums.PictureNumber import kr.genti.presentation.R -import kr.genti.presentation.create.CreateViewModel.Companion.PURCHASED_WITH_ERROR import kr.genti.presentation.create.billing.BillingCallback import kr.genti.presentation.create.billing.BillingManager import kr.genti.presentation.databinding.FragmentSelfieBinding @@ -71,7 +70,7 @@ class SelfieFragment : BaseFragment(R.layout.fragment_sel setGalleryImageWithPhotoPicker() setGalleryImageWithGalleryPicker() observeGeneratingState() - observePurchaseValidResult() + observePurchaseValidState() } override fun onResume() { @@ -135,6 +134,7 @@ class SelfieFragment : BaseFragment(R.layout.fragment_sel with(viewModel) { isCompleted.value = false if (isCreatingParentPic) { + startValidProcessLoading() manager.purchaseProduct() } else { startSendingImages() @@ -297,12 +297,13 @@ class SelfieFragment : BaseFragment(R.layout.fragment_sel }.launchIn(lifecycleScope) } - private fun observePurchaseValidResult() { - viewModel.purchaseValidError.flowWithLifecycle(lifecycle).onEach { errorMsg -> - if (errorMsg == PURCHASED_WITH_ERROR) { - showErrorDialog() - } else { - toast(stringOf(R.string.error_msg)) + private fun observePurchaseValidState() { + viewModel.purchaseValidState.flowWithLifecycle(lifecycle).onEach { state -> + when (state) { + is UiState.Success -> binding.layoutLoading.isVisible = false + is UiState.Failure -> showErrorDialog() + is UiState.Loading -> binding.layoutLoading.isVisible = true + is UiState.Empty -> return@onEach } }.launchIn(lifecycleScope) } diff --git a/presentation/src/main/res/layout/fragment_selfie.xml b/presentation/src/main/res/layout/fragment_selfie.xml index b829554..7597661 100644 --- a/presentation/src/main/res/layout/fragment_selfie.xml +++ b/presentation/src/main/res/layout/fragment_selfie.xml @@ -521,6 +521,30 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" /> + + + + + + \ No newline at end of file From c44e88ff0d6285a96dac89b800eb30d38523389e Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Mon, 2 Dec 2024 18:52:31 +0900 Subject: [PATCH 06/12] =?UTF-8?q?[ADD/#187]=20=ED=9A=8C=EC=9B=90=EA=B0=80?= =?UTF-8?q?=EC=9E=85=20API=20request=20=EC=A0=84=ED=99=94=EB=B2=88?= =?UTF-8?q?=ED=98=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/kr/genti/data/dto/request/SignupRequestDto.kt | 4 +++- data/src/main/java/kr/genti/data/service/InfoService.kt | 2 +- .../kr/genti/domain/entity/request/SignupRequestModel.kt | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/data/src/main/java/kr/genti/data/dto/request/SignupRequestDto.kt b/data/src/main/java/kr/genti/data/dto/request/SignupRequestDto.kt index 9a6fb41..7e78ccb 100644 --- a/data/src/main/java/kr/genti/data/dto/request/SignupRequestDto.kt +++ b/data/src/main/java/kr/genti/data/dto/request/SignupRequestDto.kt @@ -10,8 +10,10 @@ data class SignupRequestDto( val birthYear: String, @SerialName("sex") val sex: String, + @SerialName("phoneNumber") + val phoneNumber: String?, ) { companion object { - fun SignupRequestModel.toDto() = SignupRequestDto(birthYear, sex) + fun SignupRequestModel.toDto() = SignupRequestDto(birthYear, sex, phoneNumber) } } diff --git a/data/src/main/java/kr/genti/data/service/InfoService.kt b/data/src/main/java/kr/genti/data/service/InfoService.kt index 67180c2..0f07eb0 100644 --- a/data/src/main/java/kr/genti/data/service/InfoService.kt +++ b/data/src/main/java/kr/genti/data/service/InfoService.kt @@ -8,7 +8,7 @@ import retrofit2.http.DELETE import retrofit2.http.POST interface InfoService { - @POST("api/v1/users/signup") + @POST("api/v2/users/signup") suspend fun postSignupData( @Body request: SignupRequestDto, ): BaseResponse diff --git a/domain/src/main/kotlin/kr/genti/domain/entity/request/SignupRequestModel.kt b/domain/src/main/kotlin/kr/genti/domain/entity/request/SignupRequestModel.kt index a730d02..1ecef45 100644 --- a/domain/src/main/kotlin/kr/genti/domain/entity/request/SignupRequestModel.kt +++ b/domain/src/main/kotlin/kr/genti/domain/entity/request/SignupRequestModel.kt @@ -3,4 +3,5 @@ package kr.genti.domain.entity.request data class SignupRequestModel( val birthYear: String, val sex: String, + val phoneNumber: String?, ) From e6dcfe268062e937e9b4a0ec1be41adff9c066e2 Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Mon, 2 Dec 2024 19:04:10 +0900 Subject: [PATCH 07/12] =?UTF-8?q?[FEAT/#187]=20=ED=9A=8C=EC=9B=90=EA=B0=80?= =?UTF-8?q?=EC=9E=85=20=EB=A1=9C=EC=A7=81=20=EC=A0=84=ED=99=94=EB=B2=88?= =?UTF-8?q?=ED=98=B8=20=EC=9E=85=EB=A0=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/signup/SignupActivity.kt | 14 ++++-- .../auth/signup/SignupViewModel.kt | 12 +++++ .../src/main/res/layout/activity_signup.xml | 45 ++++++++++++++++++- presentation/src/main/res/values/strings.xml | 2 + 4 files changed, 69 insertions(+), 4 deletions(-) diff --git a/presentation/src/main/java/kr/genti/presentation/auth/signup/SignupActivity.kt b/presentation/src/main/java/kr/genti/presentation/auth/signup/SignupActivity.kt index d2615b0..d83cad0 100644 --- a/presentation/src/main/java/kr/genti/presentation/auth/signup/SignupActivity.kt +++ b/presentation/src/main/java/kr/genti/presentation/auth/signup/SignupActivity.kt @@ -33,6 +33,7 @@ class SignupActivity : BaseActivity(R.layout.activity_sig initSubmitBtnListener() observePostSignupState() observeYearInputState() + observePhoneInputState() } private fun initView() { @@ -48,9 +49,7 @@ class SignupActivity : BaseActivity(R.layout.activity_sig } private fun observePostSignupState() { - viewModel.postSignupState - .flowWithLifecycle(lifecycle) - .distinctUntilChanged() + viewModel.postSignupState.flowWithLifecycle(lifecycle).distinctUntilChanged() .onEach { state -> when (state) { is UiState.Success -> { @@ -76,6 +75,15 @@ class SignupActivity : BaseActivity(R.layout.activity_sig }.launchIn(lifecycleScope) } + private fun observePhoneInputState() { + viewModel.isPhoneAllSelected.flowWithLifecycle(lifecycle).distinctUntilChanged() + .onEach { isAllSelected -> + if (isAllSelected) { + hideKeyboard(binding.root) + } + }.launchIn(lifecycleScope) + } + private fun setAmplitudeUserProperty(state: UiState.Success) { AmplitudeManager.apply { trackEvent("complete_infoget") diff --git a/presentation/src/main/java/kr/genti/presentation/auth/signup/SignupViewModel.kt b/presentation/src/main/java/kr/genti/presentation/auth/signup/SignupViewModel.kt index 364c008..0ba19dc 100644 --- a/presentation/src/main/java/kr/genti/presentation/auth/signup/SignupViewModel.kt +++ b/presentation/src/main/java/kr/genti/presentation/auth/signup/SignupViewModel.kt @@ -31,6 +31,12 @@ constructor( private val _isYearAllSelected = MutableStateFlow(false) val isYearAllSelected: StateFlow = _isYearAllSelected + val selectedPhone = MutableLiveData() + val isPhoneSelected = MutableLiveData(false) + + private val _isPhoneAllSelected = MutableStateFlow(false) + val isPhoneAllSelected: StateFlow = _isPhoneAllSelected + val isAllSelected = MutableLiveData(false) private val _postSignupState = MutableStateFlow>(UiState.Empty) @@ -49,6 +55,11 @@ constructor( checkAllSelected() } + fun checkPhone() { + isPhoneSelected.value = selectedPhone.value?.isNotEmpty() + _isPhoneAllSelected.value = selectedPhone.value?.length == 11 + } + private fun checkAllSelected() { isAllSelected.value = isGenderSelected.value == true && isYearAllSelected.value == true } @@ -60,6 +71,7 @@ constructor( SignupRequestModel( selectedYear.value.toString(), selectedGender.value.toString(), + selectedPhone.value ), ).onSuccess { userRepository.setUserRole(ROLE_USER) diff --git a/presentation/src/main/res/layout/activity_signup.xml b/presentation/src/main/res/layout/activity_signup.xml index 92a4853..8fab7ce 100644 --- a/presentation/src/main/res/layout/activity_signup.xml +++ b/presentation/src/main/res/layout/activity_signup.xml @@ -189,7 +189,6 @@ android:textColor="@color/white" android:textColorHint="@color/white_40" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="0.0" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tv_signup_birth_title" /> @@ -204,6 +203,50 @@ app:layout_constraintTop_toBottomOf="@id/et_signup_birth_year" tools:background="@drawable/shape_green_gradation_fill_100_rect" /> + + + + + + + 여성 출생년도 YYYY + 전화번호 + 010XXXXXXXX 완료 다음으로 From b85da8bc80ef8f07fbf4a2a13a398f0be0256c08 Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Mon, 2 Dec 2024 20:42:25 +0900 Subject: [PATCH 08/12] =?UTF-8?q?[ADD/#187]=20=EA=B2=B0=EC=A0=9C=20?= =?UTF-8?q?=EC=8B=A4=ED=8C=A8=20=EC=8B=9C=20=EB=A1=9C=EB=94=A9=20=EB=A1=9C?= =?UTF-8?q?=ED=8B=B0=20=ED=91=9C=EC=8B=9C=20=ED=95=B4=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../genti/presentation/create/CreateViewModel.kt | 4 ++++ .../genti/presentation/create/SelfieFragment.kt | 4 +++- .../src/main/res/layout/fragment_selfie.xml | 16 ++++++++-------- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt b/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt index d49a9a6..6fbe1e5 100644 --- a/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt +++ b/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt @@ -266,6 +266,10 @@ constructor( _purchaseValidState.value = UiState.Loading } + fun resetValidProcessLoading() { + _purchaseValidState.value = UiState.Empty + } + companion object { const val TYPE_FREE_ONE = "FREE_ONE" const val TYPE_PAID_ONE = "PAID_ONE" diff --git a/presentation/src/main/java/kr/genti/presentation/create/SelfieFragment.kt b/presentation/src/main/java/kr/genti/presentation/create/SelfieFragment.kt index 2e48451..91f43b6 100644 --- a/presentation/src/main/java/kr/genti/presentation/create/SelfieFragment.kt +++ b/presentation/src/main/java/kr/genti/presentation/create/SelfieFragment.kt @@ -92,7 +92,9 @@ class SelfieFragment : BaseFragment(R.layout.fragment_sel } override fun onBillingFailure(responseCode: Int) { + viewModel.resetValidProcessLoading() toast(stringOf(R.string.error_msg)) + } }, ) @@ -303,7 +305,7 @@ class SelfieFragment : BaseFragment(R.layout.fragment_sel is UiState.Success -> binding.layoutLoading.isVisible = false is UiState.Failure -> showErrorDialog() is UiState.Loading -> binding.layoutLoading.isVisible = true - is UiState.Empty -> return@onEach + is UiState.Empty -> binding.layoutLoading.isVisible = false } }.launchIn(lifecycleScope) } diff --git a/presentation/src/main/res/layout/fragment_selfie.xml b/presentation/src/main/res/layout/fragment_selfie.xml index 7597661..632ed15 100644 --- a/presentation/src/main/res/layout/fragment_selfie.xml +++ b/presentation/src/main/res/layout/fragment_selfie.xml @@ -304,9 +304,9 @@ android:id="@+id/iv_added_first_image_bg_1" android:layout_width="0dp" android:layout_height="0dp" - android:visibility="@{vm.isFirstListCompleted ? View.VISIBLE : View.INVISIBLE}" android:layout_marginTop="14dp" android:background="@drawable/shape_gray_fill_green_line_rect" + android:visibility="@{vm.isFirstListCompleted ? View.VISIBLE : View.INVISIBLE}" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintDimensionRatio="1" app:layout_constraintEnd_toStartOf="@id/iv_added_first_image_bg_2" @@ -330,11 +330,11 @@ Date: Mon, 2 Dec 2024 21:01:49 +0900 Subject: [PATCH 09/12] =?UTF-8?q?[ADD/#187]=20currentType=20=EB=B7=B0?= =?UTF-8?q?=EB=AA=A8=EB=8D=B8=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/create/CreateViewModel.kt | 22 ++++++++++++++----- .../presentation/create/DefineFragment.kt | 11 +++++++--- .../genti/presentation/create/PoseFragment.kt | 11 +++++++--- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt b/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt index 6fbe1e5..a9beae5 100644 --- a/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt +++ b/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt @@ -25,6 +25,7 @@ import kr.genti.domain.enums.PictureNumber import kr.genti.domain.enums.PictureRatio import kr.genti.domain.repository.CreateRepository import kr.genti.domain.repository.UploadRepository +import kr.genti.presentation.util.AmplitudeManager import javax.inject.Inject @HiltViewModel @@ -35,6 +36,7 @@ constructor( private val uploadRepository: UploadRepository, ) : ViewModel() { var isCreatingParentPic = false + var currentType: String = TYPE_FREE_ONE val prompt = MutableLiveData() val isWritten = MutableLiveData(false) @@ -112,11 +114,7 @@ constructor( fun getExamplePrompt() { _getExampleState.value = UiState.Loading - val currentType = when { - !isCreatingParentPic -> TYPE_FREE_ONE - selectedNumber.value == PictureNumber.ONE -> TYPE_PAID_ONE - else -> TYPE_PAID_TWO - } + setCurrentType() viewModelScope.launch { runCatching { createRepository.getPromptExample(currentType) @@ -128,6 +126,20 @@ constructor( } } + private fun setCurrentType() { + currentType = when { + !isCreatingParentPic -> TYPE_FREE_ONE + + selectedNumber.value == PictureNumber.ONE -> TYPE_PAID_ONE.also { + AmplitudeManager.trackEvent("view_oneparentpreset") + } + + else -> TYPE_PAID_TWO.also { + AmplitudeManager.trackEvent("view_twoparentpreset") + } + } + } + fun startSendingImages() { _totalGeneratingState.value = UiState.Loading if (selectedNumber.value != PictureNumber.TWO) { diff --git a/presentation/src/main/java/kr/genti/presentation/create/DefineFragment.kt b/presentation/src/main/java/kr/genti/presentation/create/DefineFragment.kt index 8a2816f..f5cdb68 100644 --- a/presentation/src/main/java/kr/genti/presentation/create/DefineFragment.kt +++ b/presentation/src/main/java/kr/genti/presentation/create/DefineFragment.kt @@ -33,6 +33,8 @@ class DefineFragment() : BaseFragment(R.layout.fragment_d private val adapter get() = requireNotNull(_adapter) { getString(R.string.adapter_not_initialized_error_msg) } + private var amplitudePage: Map? = null + override fun onViewCreated( view: View, savedInstanceState: Bundle?, @@ -50,14 +52,17 @@ class DefineFragment() : BaseFragment(R.layout.fragment_d private fun initView() { binding.vm = viewModel viewModel.getExamplePrompt() + if (viewModel.isCreatingParentPic) { + amplitudePage = mapOf(PROPERTY_PAGE to "createparent1") + } else { + amplitudePage = mapOf(PROPERTY_PAGE to "create1") + } } private fun initCreateBtnListener() { binding.btnCreateNext.setOnSingleClickListener { AmplitudeManager.trackEvent( - EVENT_CLICK_BTN, - mapOf(PROPERTY_PAGE to "create1"), - mapOf(PROPERTY_BTN to "next"), + EVENT_CLICK_BTN, amplitudePage, mapOf(PROPERTY_BTN to "next"), ) findNavController().navigate(R.id.action_define_to_pose) viewModel.modCurrentPercent(33) diff --git a/presentation/src/main/java/kr/genti/presentation/create/PoseFragment.kt b/presentation/src/main/java/kr/genti/presentation/create/PoseFragment.kt index 26edd36..21d5446 100644 --- a/presentation/src/main/java/kr/genti/presentation/create/PoseFragment.kt +++ b/presentation/src/main/java/kr/genti/presentation/create/PoseFragment.kt @@ -19,6 +19,8 @@ import kr.genti.presentation.util.AmplitudeManager.PROPERTY_PAGE class PoseFragment() : BaseFragment(R.layout.fragment_pose) { private val viewModel by activityViewModels() + private var amplitudePage: Map? = null + override fun onViewCreated( view: View, savedInstanceState: Bundle?, @@ -32,14 +34,17 @@ class PoseFragment() : BaseFragment(R.layout.fragment_pose) private fun initView() { binding.vm = viewModel + if (viewModel.isCreatingParentPic) { + amplitudePage = mapOf(PROPERTY_PAGE to "createparent2") + } else { + amplitudePage = mapOf(PROPERTY_PAGE to "create2") + } } private fun initNextBtnListener() { binding.btnPoseNext.setOnSingleClickListener { AmplitudeManager.trackEvent( - EVENT_CLICK_BTN, - mapOf(PROPERTY_PAGE to "create2"), - mapOf(PROPERTY_BTN to "next"), + EVENT_CLICK_BTN, amplitudePage, mapOf(PROPERTY_BTN to "next"), ) findNavController().navigate(R.id.action_pose_to_selfie) viewModel.modCurrentPercent(34) From 9b5fc5b43cd96e19127ac18a79e78f6d743da25e Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Mon, 2 Dec 2024 21:25:12 +0900 Subject: [PATCH 10/12] =?UTF-8?q?[FIX/#187]=202=EC=9D=B8=20=EC=82=AC?= =?UTF-8?q?=EC=A7=84=20=EB=8B=A4=EC=8B=9C=20=EC=83=9D=EC=84=B1=ED=95=98?= =?UTF-8?q?=EA=B8=B0=20=EB=B2=84=ED=8A=BC=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/create/CreateViewModel.kt | 2 +- .../presentation/create/SelfieFragment.kt | 58 +++++++++++++++---- 2 files changed, 48 insertions(+), 12 deletions(-) diff --git a/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt b/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt index a9beae5..fb39769 100644 --- a/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt +++ b/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt @@ -135,7 +135,7 @@ constructor( } else -> TYPE_PAID_TWO.also { - AmplitudeManager.trackEvent("view_twoparentpreset") + AmplitudeManager.trackEvent("view_twoparentspreset") } } } diff --git a/presentation/src/main/java/kr/genti/presentation/create/SelfieFragment.kt b/presentation/src/main/java/kr/genti/presentation/create/SelfieFragment.kt index 91f43b6..4fbfe1a 100644 --- a/presentation/src/main/java/kr/genti/presentation/create/SelfieFragment.kt +++ b/presentation/src/main/java/kr/genti/presentation/create/SelfieFragment.kt @@ -9,6 +9,7 @@ import android.os.Build import android.os.Bundle import android.view.View import android.widget.ImageView +import android.widget.TextView import androidx.activity.OnBackPressedCallback import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.PickVisualMediaRequest @@ -25,6 +26,7 @@ import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kr.genti.core.base.BaseFragment +import kr.genti.core.extension.colorOf import kr.genti.core.extension.getFileName import kr.genti.core.extension.setOnSingleClickListener import kr.genti.core.extension.setTextWithImage @@ -34,6 +36,9 @@ import kr.genti.core.state.UiState import kr.genti.domain.entity.response.ImageFileModel import kr.genti.domain.enums.PictureNumber import kr.genti.presentation.R +import kr.genti.presentation.create.CreateViewModel.Companion.TYPE_FREE_ONE +import kr.genti.presentation.create.CreateViewModel.Companion.TYPE_PAID_ONE +import kr.genti.presentation.create.CreateViewModel.Companion.TYPE_PAID_TWO import kr.genti.presentation.create.billing.BillingCallback import kr.genti.presentation.create.billing.BillingManager import kr.genti.presentation.databinding.FragmentSelfieBinding @@ -54,6 +59,8 @@ class SelfieFragment : BaseFragment(R.layout.fragment_sel private lateinit var photoPickerResult: ActivityResultLauncher private lateinit var galleryPickerResult: ActivityResultLauncher + private var amplitudePage: Map? = null + override fun onViewCreated( view: View, savedInstanceState: Bundle?, @@ -81,6 +88,19 @@ class SelfieFragment : BaseFragment(R.layout.fragment_sel private fun initView() { binding.vm = viewModel + when (viewModel.currentType) { + TYPE_FREE_ONE -> amplitudePage = mapOf(PROPERTY_PAGE to "create3") + + TYPE_PAID_ONE -> { + amplitudePage = mapOf(PROPERTY_PAGE to "createoneparent3") + AmplitudeManager.trackEvent("view_createoneparent") + } + + TYPE_PAID_TWO -> { + amplitudePage = mapOf(PROPERTY_PAGE to "createtwoparents3") + AmplitudeManager.trackEvent("view_createtwoparents") + } + } } private fun initBillingManager() { @@ -113,16 +133,23 @@ class SelfieFragment : BaseFragment(R.layout.fragment_sel private fun initAddImageBtnListener() { with(binding) { - btnSelfieAdd.setOnSingleClickListener { - AmplitudeManager.trackEvent( - EVENT_CLICK_BTN, - mapOf(PROPERTY_PAGE to "create3"), - mapOf(PROPERTY_BTN to "selectpic"), + val buttonConfig = with(viewModel) { + listOf( + Triple(btnSelfieAdd, imageList, "selectpic" to "reselectpic"), + Triple(btnSelfieAddFirst, firstImageList, "selectpic1" to "reselectpic1"), + Triple(btnSelfieAddSecond, secondImageList, "selectpic2" to "reselectpic2") ) - checkAndGetImages(0) } - btnSelfieAddFirst.setOnSingleClickListener { checkAndGetImages(1) } - btnSelfieAddSecond.setOnSingleClickListener { checkAndGetImages(2) } + buttonConfig.forEachIndexed { index, (button, imageList, eventPair) -> + button.setOnSingleClickListener { + val amplitudeEvent = + if (imageList.isEmpty()) eventPair.first else eventPair.second + AmplitudeManager.trackEvent( + EVENT_CLICK_BTN, amplitudePage, mapOf(PROPERTY_BTN to amplitudeEvent) + ) + checkAndGetImages(index) + } + } } } @@ -238,9 +265,7 @@ class SelfieFragment : BaseFragment(R.layout.fragment_sel 1 to ::firstImageList, 2 to ::secondImageList ) - listMap[currentAddingList]?.set(uris.map { uri -> - uri.toImageFileModel() - }) + listMap[currentAddingList]?.set(uris.map { uri -> uri.toImageFileModel() }) updateCompletionState(uris.size) } setSavedImages() @@ -269,6 +294,8 @@ class SelfieFragment : BaseFragment(R.layout.fragment_sel .resetAndLoadImages(viewModel.firstImageList) listOf(ivAddedSecondImage1, ivAddedSecondImage2, ivAddedSecondImage3) .resetAndLoadImages(viewModel.secondImageList) + btnSelfieAddFirst.updateButton(viewModel.firstImageList.isEmpty()) + btnSelfieAddSecond.updateButton(viewModel.secondImageList.isEmpty()) } } } @@ -280,6 +307,15 @@ class SelfieFragment : BaseFragment(R.layout.fragment_sel } } + private fun TextView.updateButton(isEmpty: Boolean) { + text = if (isEmpty) stringOf(R.string.selfie_tv_btn_select) + else stringOf(R.string.selfie_tv_btn_reselect) + setTextColor( + if (isEmpty) colorOf(R.color.genti_green) + else colorOf(R.color.white_60) + ) + } + private fun observeGeneratingState() { viewModel.totalGeneratingState.flowWithLifecycle(lifecycle).onEach { state -> when (state) { From 11a7cd818afb9332c647e4df65f2d21611ffa761 Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Mon, 2 Dec 2024 21:29:18 +0900 Subject: [PATCH 11/12] =?UTF-8?q?[ADD/#187]=20=EA=B2=B0=EC=A0=9C=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20amplitude=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/kr/genti/presentation/create/CreateViewModel.kt | 9 +++++++++ .../java/kr/genti/presentation/create/SelfieFragment.kt | 4 +--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt b/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt index fb39769..3a169c8 100644 --- a/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt +++ b/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt @@ -264,6 +264,15 @@ constructor( ).onSuccess { isValidSuccess -> if (isValidSuccess) { _purchaseValidState.value = UiState.Success(true) + when (currentType) { + TYPE_PAID_ONE -> AmplitudeManager.trackEvent( + "complete_payment", mapOf("picture_type" to "oneparent") + ) + + TYPE_PAID_TWO -> AmplitudeManager.trackEvent( + "complete_payment", mapOf("picture_type" to "twoparents") + ) + } startSendingImages() } else { _purchaseValidState.value = UiState.Failure(false.toString()) diff --git a/presentation/src/main/java/kr/genti/presentation/create/SelfieFragment.kt b/presentation/src/main/java/kr/genti/presentation/create/SelfieFragment.kt index 4fbfe1a..9f462ce 100644 --- a/presentation/src/main/java/kr/genti/presentation/create/SelfieFragment.kt +++ b/presentation/src/main/java/kr/genti/presentation/create/SelfieFragment.kt @@ -156,9 +156,7 @@ class SelfieFragment : BaseFragment(R.layout.fragment_sel private fun initRequestCreateBtnListener() { binding.btnCreate.setOnSingleClickListener { AmplitudeManager.trackEvent( - EVENT_CLICK_BTN, - mapOf(PROPERTY_PAGE to "create3"), - mapOf(PROPERTY_BTN to "createpic"), + EVENT_CLICK_BTN, amplitudePage, mapOf(PROPERTY_BTN to "createpic"), ) with(viewModel) { isCompleted.value = false From 638aa71422d2cd22f07cc8156cb39e09d5f0b667 Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Mon, 2 Dec 2024 21:31:59 +0900 Subject: [PATCH 12/12] =?UTF-8?q?[ADD/#187]=20=EC=82=AC=EC=A7=84=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=EA=B4=80=EB=A0=A8=20amplitude=20property?= =?UTF-8?q?=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kr/genti/presentation/auth/signup/SignupActivity.kt | 5 ++++- .../java/kr/genti/presentation/create/CreateViewModel.kt | 8 ++++++++ .../java/kr/genti/presentation/create/SelfieFragment.kt | 1 - 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/presentation/src/main/java/kr/genti/presentation/auth/signup/SignupActivity.kt b/presentation/src/main/java/kr/genti/presentation/auth/signup/SignupActivity.kt index d83cad0..d6eb08d 100644 --- a/presentation/src/main/java/kr/genti/presentation/auth/signup/SignupActivity.kt +++ b/presentation/src/main/java/kr/genti/presentation/auth/signup/SignupActivity.kt @@ -96,7 +96,10 @@ class SignupActivity : BaseActivity(R.layout.activity_sig updateIntProperties("user_picturedownload", 0) updateIntProperties("user_main_scroll", 0) updateIntProperties("user_promptsuggest_refresh", 0) - updateIntProperties("user_piccreate", 0) + updateIntProperties("user_piccreate_total", 0) + updateIntProperties("user_piccreate_original", 0) + updateIntProperties("user_piccreate_oneparent", 0) + updateIntProperties("user_piccreate_twoparents", 0) updateBooleanProperties("user_alarm", false) updateBooleanProperties("user_verified", false) } diff --git a/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt b/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt index 3a169c8..db4d0bf 100644 --- a/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt +++ b/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt @@ -229,6 +229,12 @@ constructor( createRepository.postToCreate(request) } result.onSuccess { + if (isCreatingParentPic) { + AmplitudeManager.plusIntProperties("user_piccreate_oneparent") + } else { + AmplitudeManager.plusIntProperties("user_piccreate_original") + } + AmplitudeManager.plusIntProperties("user_piccreate_total") _totalGeneratingState.value = UiState.Success(it) }.onFailure { _totalGeneratingState.value = UiState.Failure(it.message.toString()) @@ -246,6 +252,8 @@ constructor( selectedRatio.value ?: return@launch, ) ).onSuccess { + AmplitudeManager.plusIntProperties("user_piccreate_twoparents") + AmplitudeManager.plusIntProperties("user_piccreate_total") _totalGeneratingState.value = UiState.Success(isCreatingParentPic) }.onFailure { _totalGeneratingState.value = UiState.Failure(it.message.toString()) diff --git a/presentation/src/main/java/kr/genti/presentation/create/SelfieFragment.kt b/presentation/src/main/java/kr/genti/presentation/create/SelfieFragment.kt index 9f462ce..85dee1a 100644 --- a/presentation/src/main/java/kr/genti/presentation/create/SelfieFragment.kt +++ b/presentation/src/main/java/kr/genti/presentation/create/SelfieFragment.kt @@ -318,7 +318,6 @@ class SelfieFragment : BaseFragment(R.layout.fragment_sel viewModel.totalGeneratingState.flowWithLifecycle(lifecycle).onEach { state -> when (state) { is UiState.Success -> { - AmplitudeManager.plusIntProperties("user_piccreate") startActivity(WaitingActivity.createIntent(requireContext(), state.data)) requireActivity().finish() }