diff --git a/app/src/main/java/com/el/yello/presentation/main/MainActivity.kt b/app/src/main/java/com/el/yello/presentation/main/MainActivity.kt index 6f50227c..037f5cc4 100644 --- a/app/src/main/java/com/el/yello/presentation/main/MainActivity.kt +++ b/app/src/main/java/com/el/yello/presentation/main/MainActivity.kt @@ -15,6 +15,7 @@ import com.el.yello.R import com.el.yello.databinding.ActivityMainBinding import com.el.yello.presentation.event.EventActivity import com.el.yello.presentation.main.MainViewModel.Companion.CODE_UNAVAILABLE_EVENT +import com.el.yello.presentation.main.dialog.invite.InviteFriendDialog import com.el.yello.presentation.main.dialog.notice.NoticeDialog import com.el.yello.presentation.main.myyello.MyYelloFragment import com.el.yello.presentation.main.myyello.read.MyYelloReadActivity @@ -52,6 +53,7 @@ class MainActivity : BindingActivity(R.layout.activity_main private var backPressedTime: Long = 0 private var userSubsStateJob: Job? = null + private var inviteFriendDialog: InviteFriendDialog? = null private val onBackPressedCallback = object : OnBackPressedCallback(true) { override fun handleOnBackPressed() { @@ -76,6 +78,16 @@ class MainActivity : BindingActivity(R.layout.activity_main setupGetNoticeState() setupGetVoteCountState() setupGetEventState() + navigateToRecommendShowDialog() + } + + private fun navigateToRecommendShowDialog() { + if (intent.getBooleanExtra(RECOMMEND_FRAGMENT, false)) { + binding.bnvMain.selectedItemId = R.id.menu_recommend + navigateTo() + val inviteFriendDialog = InviteFriendDialog.newInstance(viewModel.getYelloId(), PREVIOUS_Screen) + inviteFriendDialog.show(supportFragmentManager, INVITE_FRIEND_DIALOG) + } } private fun initBackPressedCallback() { @@ -334,6 +346,11 @@ class MainActivity : BindingActivity(R.layout.activity_main } } + override fun onDestroy() { + super.onDestroy() + inviteFriendDialog = null + } + companion object { private const val EXTRA_TYPE = "type" private const val EXTRA_PATH = "path" @@ -354,6 +371,10 @@ class MainActivity : BindingActivity(R.layout.activity_main private const val EVENT_CLICK_RECOMMEND_NAVIGATION = "click_recommend_navigation" private const val TAG_NOTICE_DIALOG = "NOTICE_DIALOG" + private const val RECOMMEND_FRAGMENT = "RecommendFragment" + private const val INVITE_FRIEND_DIALOG = "InviteFriendDialog" + private const val PREVIOUS_Screen = "Previous Screen" + @JvmStatic fun getIntent(context: Context, type: String? = null, path: String? = null) = Intent(context, MainActivity::class.java).apply { diff --git a/app/src/main/java/com/el/yello/presentation/main/MainViewModel.kt b/app/src/main/java/com/el/yello/presentation/main/MainViewModel.kt index 4ed0a5f1..fa09520e 100644 --- a/app/src/main/java/com/el/yello/presentation/main/MainViewModel.kt +++ b/app/src/main/java/com/el/yello/presentation/main/MainViewModel.kt @@ -182,6 +182,8 @@ class MainViewModel @Inject constructor( } } + fun getYelloId() = authRepository.getYelloId() + companion object { const val CODE_UNAVAILABLE_EVENT = "100" } diff --git a/app/src/main/java/com/el/yello/presentation/main/dialog/invite/InviteFriendDialog.kt b/app/src/main/java/com/el/yello/presentation/main/dialog/invite/InviteFriendDialog.kt index d680fe0f..85df17a3 100644 --- a/app/src/main/java/com/el/yello/presentation/main/dialog/invite/InviteFriendDialog.kt +++ b/app/src/main/java/com/el/yello/presentation/main/dialog/invite/InviteFriendDialog.kt @@ -14,8 +14,8 @@ import com.el.yello.R import com.el.yello.databinding.FragmentInviteFriendDialogBinding import com.el.yello.util.manager.AmplitudeManager import com.example.ui.base.BindingDialogFragment -import com.example.ui.extension.toast import com.example.ui.extension.setOnSingleClickListener +import com.example.ui.extension.toast import com.kakao.sdk.common.util.KakaoCustomTabsClient import com.kakao.sdk.share.ShareClient import com.kakao.sdk.share.WebSharerClient diff --git a/app/src/main/java/com/el/yello/presentation/setting/ProfileQuitInviteDialog.kt b/app/src/main/java/com/el/yello/presentation/setting/ProfileQuitInviteDialog.kt new file mode 100644 index 00000000..d96f1e2c --- /dev/null +++ b/app/src/main/java/com/el/yello/presentation/setting/ProfileQuitInviteDialog.kt @@ -0,0 +1,63 @@ +package com.el.yello.presentation.setting + +import android.content.Intent +import android.content.res.Resources +import android.os.Bundle +import android.view.View +import android.view.WindowManager +import com.el.yello.R +import com.el.yello.databinding.FragmentProfileQuitInviteFriendBinding +import com.el.yello.presentation.main.MainActivity +import com.el.yello.util.manager.AmplitudeManager +import com.example.ui.base.BindingDialogFragment +import com.example.ui.extension.setOnSingleClickListener +import dagger.hilt.android.AndroidEntryPoint + +@AndroidEntryPoint +class ProfileQuitInviteDialog : + BindingDialogFragment(R.layout.fragment_profile_quit_invite_friend) { + + override fun onStart() { + super.onStart() + setDialogBackground() + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + binding.btnProfileInviteNo.setOnSingleClickListener { + ProfileQuitDialog().show(parentFragmentManager, QUIT_DIALOG) + dismiss() + } + binding.btnProfileInviteYes.setOnSingleClickListener { + AmplitudeManager.trackEventWithProperties(EVENT_CLICK_WITHDRAWAL_RECOMMEND) + val intent = Intent(requireContext(), MainActivity::class.java).apply { + flags = Intent.FLAG_ACTIVITY_CLEAR_TASK + putExtra(RECOMMEND_FRAGMENT, true) + } + startActivity(intent) + dismiss() + } + } + + private fun setDialogBackground() { + val deviceWidth = Resources.getSystem().displayMetrics.widthPixels + val dialogHorizontalMargin = (Resources.getSystem().displayMetrics.density * 16) * 2 + + dialog?.window?.apply { + setLayout( + (deviceWidth - dialogHorizontalMargin * 2).toInt(), + WindowManager.LayoutParams.WRAP_CONTENT, + ) + setBackgroundDrawableResource(R.color.transparent) + } + dialog?.setCanceledOnTouchOutside(false) + dialog?.setCancelable(true) + } + + private companion object { + const val QUIT_DIALOG = "quitDialog" + private const val RECOMMEND_FRAGMENT = "RecommendFragment" + private const val EVENT_CLICK_WITHDRAWAL_RECOMMEND = "click_withdrawal_recommend" + } +} diff --git a/app/src/main/java/com/el/yello/presentation/setting/ProfileQuitReasonActivity.kt b/app/src/main/java/com/el/yello/presentation/setting/ProfileQuitReasonActivity.kt index 8f5429cb..7be47ab3 100644 --- a/app/src/main/java/com/el/yello/presentation/setting/ProfileQuitReasonActivity.kt +++ b/app/src/main/java/com/el/yello/presentation/setting/ProfileQuitReasonActivity.kt @@ -22,7 +22,7 @@ class ProfileQuitReasonActivity : private var clickedItemPosition: Int = RecyclerView.NO_POSITION private var isItemClicked: Boolean = false - private var profileQuitDialog: ProfileQuitDialog? = null + private var profileQuitInviteDialog: ProfileQuitInviteDialog? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -65,8 +65,8 @@ class ProfileQuitReasonActivity : private fun initInviteDialogBtnListener() { binding.btnProfileQuitReasonDone.setOnSingleClickListener { - profileQuitDialog = ProfileQuitDialog() - profileQuitDialog?.show(supportFragmentManager, QUIT_DIALOG) + profileQuitInviteDialog = ProfileQuitInviteDialog() + profileQuitInviteDialog?.show(supportFragmentManager, QUIT_DIALOG) } } @@ -96,7 +96,7 @@ class ProfileQuitReasonActivity : override fun onDestroy() { super.onDestroy() - profileQuitDialog?.dismiss() + profileQuitInviteDialog?.dismiss() _adapter = null } diff --git a/app/src/main/res/drawable/img_quit_invite_friend.xml b/app/src/main/res/drawable/img_quit_invite_friend.xml new file mode 100644 index 00000000..e0c50a96 --- /dev/null +++ b/app/src/main/res/drawable/img_quit_invite_friend.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/fragment_profile_quit_invite_friend.xml b/app/src/main/res/layout/fragment_profile_quit_invite_friend.xml new file mode 100644 index 00000000..24a1a25b --- /dev/null +++ b/app/src/main/res/layout/fragment_profile_quit_invite_friend.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4f734657..2e682638 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -222,6 +222,9 @@ 친구 수 받은 쪽지 친구 끊기 + 친구가 없다면\n친구를 초대할 수도 있어요. + 다음에 할게요 + 오,그런 방법이! 정말 탈퇴하시겠습니까? 아니요 네, 탈퇴합니다