From ee4d686439c00acd25bb78f9becab2bc688a3660 Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Mon, 19 Feb 2024 16:31:24 +0900 Subject: [PATCH 01/26] =?UTF-8?q?[ui]=20#244=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=EB=B7=B0=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/layout/activity_setting.xml | 287 +++++++++++++++++++ 1 file changed, 287 insertions(+) create mode 100644 app/src/main/res/layout/activity_setting.xml diff --git a/app/src/main/res/layout/activity_setting.xml b/app/src/main/res/layout/activity_setting.xml new file mode 100644 index 00000000..6ce03d97 --- /dev/null +++ b/app/src/main/res/layout/activity_setting.xml @@ -0,0 +1,287 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 8257758f68027a800c8157602420724f4d91f03c Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Mon, 19 Feb 2024 16:33:21 +0900 Subject: [PATCH 02/26] =?UTF-8?q?[feat]=20#244=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 권환 확인, 알림 토글, 원온원, 약관, 로그아웃, 탈퇴 --- app/src/main/AndroidManifest.xml | 4 + .../main/mypage/MyPageFragment.kt | 12 ++ .../main/mypage/setting/SettingActivity.kt | 141 ++++++++++++++++++ app/src/main/res/layout/fragment_my_page.xml | 1 + 4 files changed, 158 insertions(+) create mode 100644 app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingActivity.kt diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e95cc344..938f7c14 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -82,6 +82,10 @@ android:name=".presentation.main.notification.NotificationActivity" android:exported="false" android:screenOrientation="portrait" /> + diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageFragment.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageFragment.kt index faba564a..75915a41 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageFragment.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageFragment.kt @@ -29,6 +29,7 @@ import org.go.sopt.winey.domain.entity.User import org.go.sopt.winey.domain.repository.DataStoreRepository import org.go.sopt.winey.presentation.main.MainViewModel import org.go.sopt.winey.presentation.main.mypage.myfeed.MyFeedFragment +import org.go.sopt.winey.presentation.main.mypage.setting.SettingActivity import org.go.sopt.winey.presentation.main.notification.NotificationActivity import org.go.sopt.winey.presentation.nickname.NicknameActivity import org.go.sopt.winey.presentation.onboarding.guide.GuideActivity @@ -38,6 +39,7 @@ import org.go.sopt.winey.util.fragment.snackBar import org.go.sopt.winey.util.fragment.viewLifeCycle import org.go.sopt.winey.util.fragment.viewLifeCycleScope import org.go.sopt.winey.util.view.UiState +import org.go.sopt.winey.util.view.setOnSingleClickListener import javax.inject.Inject @AndroidEntryPoint @@ -65,6 +67,10 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ setupDeleteUserState() checkFromWineyFeed() + + binding.ivMypageSetting.setOnSingleClickListener { + navigateToSettingScreen() + } } private fun initCheckNotificationPermission() { @@ -203,6 +209,12 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ } } + private fun navigateToSettingScreen() { + Intent(requireContext(), SettingActivity::class.java).apply { + startActivity(this) + } + } + private fun setupGetUserState() { mainViewModel.getUserState.flowWithLifecycle(lifecycle).onEach { state -> when (state) { diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingActivity.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingActivity.kt new file mode 100644 index 00000000..30ee7900 --- /dev/null +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingActivity.kt @@ -0,0 +1,141 @@ +package org.go.sopt.winey.presentation.main.mypage.setting + +import android.Manifest +import android.content.Intent +import android.content.pm.PackageManager +import android.net.Uri +import android.os.Build +import android.os.Bundle +import androidx.activity.viewModels +import androidx.core.content.ContextCompat +import androidx.core.view.isGone +import androidx.core.view.isVisible +import dagger.hilt.android.AndroidEntryPoint +import org.go.sopt.winey.R +import org.go.sopt.winey.databinding.ActivitySettingBinding +import org.go.sopt.winey.presentation.main.MainViewModel +import org.go.sopt.winey.presentation.model.WineyDialogLabel +import org.go.sopt.winey.util.amplitude.AmplitudeUtils +import org.go.sopt.winey.util.binding.BindingActivity +import org.go.sopt.winey.util.context.stringOf +import org.go.sopt.winey.util.fragment.WineyDialogFragment +import javax.inject.Inject + +@AndroidEntryPoint +class SettingActivity : BindingActivity(R.layout.activity_setting) { + private val settingViewModel by viewModels() + private val mainViewModel by viewModels() + + @Inject + lateinit var amplitudeUtils: AmplitudeUtils + private var isNotificationPermissionAllowed = true + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + addListener() + addObserver() + initNotificationPermissionState() + } + + override fun onStart() { + super.onStart() + initNotificationPermissionState() + updateNotificationToggleByPermission() + } + + private fun addListener() { + init1On1ButtonClickListener() + initLogoutButtonClickListener() + initTermsButtonClickListener() + initWithdrawButtonClickListener() + } + + private fun addObserver() { + + } + + private fun initNotificationPermissionState() { + isNotificationPermissionAllowed = + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + ContextCompat.checkSelfPermission( + this, + Manifest.permission.POST_NOTIFICATIONS + ) == PackageManager.PERMISSION_GRANTED + } else { + true + } + } + + private fun updateNotificationToggleByPermission() { + if (isNotificationPermissionAllowed) { + binding.ivSettingAgree.isVisible = true + + binding.llSettingAgreePermissionChange.isGone = true + binding.tvSettingAgreePermission.isGone = true + } else { + binding.ivSettingAgree.isGone = true + + binding.llSettingAgreePermissionChange.isVisible = true + binding.tvSettingAgreePermission.isVisible = true + } + } + + private fun init1On1ButtonClickListener() { + binding.clSettingTo1on1.setOnClickListener { + val url = ONE_ON_ONE_URL + val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) + startActivity(intent) + } + } + + private fun initTermsButtonClickListener() { + binding.clSettingToTerms.setOnClickListener { + val url = TERMS_URL + val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) + startActivity(intent) + } + } + + private fun initLogoutButtonClickListener() { + binding.clSettingLogout.setOnClickListener { + amplitudeUtils.logEvent("click_logout") + val dialog = WineyDialogFragment.newInstance( + WineyDialogLabel( + stringOf(R.string.mypage_logout_dialog_title), + stringOf(R.string.mypage_logout_dialog_subtitle), + stringOf(R.string.mypage_logout_dialog_negative_button), + stringOf(R.string.mypage_logout_dialog_positive_button) + ), + handleNegativeButton = {}, + handlePositiveButton = { mainViewModel.postLogout() } + ) + dialog.show(supportFragmentManager, TAG_LOGOUT_DIALOG) + } + } + + private fun initWithdrawButtonClickListener() { + binding.clSettingWithdraw.setOnClickListener { + val dialog = WineyDialogFragment.newInstance( + WineyDialogLabel( + stringOf(R.string.mypage_withdraw_dialog_title), + stringOf(R.string.mypage_withdraw_dialog_subtitle), + stringOf(R.string.mypage_withdraw_dialog_negative_button), + stringOf(R.string.mypage_withdraw_dialog_positive_button) + ), + handleNegativeButton = { settingViewModel.deleteUser() }, + handlePositiveButton = {} + ) + dialog.show(supportFragmentManager, TAG_WITHDRAW_DIALOG) + } + } + + companion object { + + private const val ONE_ON_ONE_URL = "https://open.kakao.com/o/s751Susf" + private const val TERMS_URL = + "https://empty-weaver-a9f.notion.site/iney-9dbfe130c7df4fb9a0903481c3e377e6?pvs=4" + + private const val TAG_LOGOUT_DIALOG = "LOGOUT_DIALOG" + private const val TAG_WITHDRAW_DIALOG = "WITHDRAW_DIALOG" + } +} diff --git a/app/src/main/res/layout/fragment_my_page.xml b/app/src/main/res/layout/fragment_my_page.xml index 3f802198..508f3d0e 100644 --- a/app/src/main/res/layout/fragment_my_page.xml +++ b/app/src/main/res/layout/fragment_my_page.xml @@ -26,6 +26,7 @@ app:layout_constraintTop_toTopOf="parent" /> Date: Mon, 19 Feb 2024 16:33:51 +0900 Subject: [PATCH 03/26] =?UTF-8?q?[feat]=20#244=20=ED=83=88=ED=87=B4=20?= =?UTF-8?q?=EC=84=9C=EB=B2=84=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/mypage/setting/SettingViewModel.kt | 46 +++++++++++++++++++ .../xml/mypage_noti_agree_motion_scene.xml | 18 ++++---- 2 files changed, 55 insertions(+), 9 deletions(-) create mode 100644 app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingViewModel.kt diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingViewModel.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingViewModel.kt new file mode 100644 index 00000000..1563bc0a --- /dev/null +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingViewModel.kt @@ -0,0 +1,46 @@ +package org.go.sopt.winey.presentation.main.mypage.setting + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.launch +import org.go.sopt.winey.domain.repository.AuthRepository +import org.go.sopt.winey.domain.repository.DataStoreRepository +import org.go.sopt.winey.util.view.UiState +import retrofit2.HttpException +import timber.log.Timber +import javax.inject.Inject + +@HiltViewModel +class SettingViewModel @Inject constructor( + private val authRepository: AuthRepository, + private val dataStoreRepository: DataStoreRepository +) : ViewModel() { + + private val _deleteUserState = MutableStateFlow>(UiState.Empty) + val deleteUserState: StateFlow> = _deleteUserState.asStateFlow() + + fun deleteUser() { + viewModelScope.launch { + authRepository.deleteUser() + .onSuccess { response -> + Timber.d("SUCCESS DELETE USER") + _deleteUserState.value = UiState.Success(response) + } + .onFailure { t -> + _deleteUserState.value = UiState.Failure(t.message.toString()) + + if (t is HttpException) { + Timber.e("HTTP FAIL DELETE USER: ${t.code()} ${t.message}") + return@onFailure + } + + Timber.e("FAIL DELETE USER: ${t.message}") + } + } + } + +} diff --git a/app/src/main/res/xml/mypage_noti_agree_motion_scene.xml b/app/src/main/res/xml/mypage_noti_agree_motion_scene.xml index 3a56fd20..835624b8 100644 --- a/app/src/main/res/xml/mypage_noti_agree_motion_scene.xml +++ b/app/src/main/res/xml/mypage_noti_agree_motion_scene.xml @@ -24,12 +24,12 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="4dp" - motion:layout_constraintBottom_toBottomOf="@+id/iv_mypage_switch" - motion:layout_constraintStart_toStartOf="@+id/iv_mypage_switch" - motion:layout_constraintTop_toTopOf="@+id/iv_mypage_switch"/> + motion:layout_constraintBottom_toBottomOf="@+id/iv_setting_switch" + motion:layout_constraintStart_toStartOf="@+id/iv_setting_switch" + motion:layout_constraintTop_toTopOf="@+id/iv_setting_switch"/> + motion:layout_constraintBottom_toBottomOf="@+id/iv_setting_switch" + motion:layout_constraintEnd_toEndOf="@+id/iv_setting_switch" + motion:layout_constraintTop_toTopOf="@+id/iv_setting_switch" /> Date: Wed, 21 Feb 2024 15:57:39 +0900 Subject: [PATCH 04/26] =?UTF-8?q?[feat]=20#244=20=EC=95=8C=EB=A6=BC=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=20=EC=97=AC=EB=B6=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/mypage/MyPageFragment.kt | 20 --- .../main/mypage/MyPageViewModel.kt | 27 --- .../main/mypage/setting/SettingActivity.kt | 163 ++++++++++++++++-- .../main/mypage/setting/SettingViewModel.kt | 32 ++++ 4 files changed, 181 insertions(+), 61 deletions(-) diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageFragment.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageFragment.kt index 75915a41..006008a9 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageFragment.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageFragment.kt @@ -36,7 +36,6 @@ import org.go.sopt.winey.presentation.onboarding.guide.GuideActivity import org.go.sopt.winey.util.amplitude.AmplitudeUtils import org.go.sopt.winey.util.binding.BindingFragment import org.go.sopt.winey.util.fragment.snackBar -import org.go.sopt.winey.util.fragment.viewLifeCycle import org.go.sopt.winey.util.fragment.viewLifeCycleScope import org.go.sopt.winey.util.view.UiState import org.go.sopt.winey.util.view.setOnSingleClickListener @@ -64,7 +63,6 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ registerBackPressedCallback() setupGetUserState() - setupDeleteUserState() checkFromWineyFeed() @@ -176,24 +174,6 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ } } - private fun setupDeleteUserState() { - myPageViewModel.deleteUserState.flowWithLifecycle(viewLifeCycle) - .onEach { state -> - when (state) { - is UiState.Success -> { - myPageViewModel.clearDataStore() - navigateToGuideScreen() - } - - is UiState.Failure -> { - snackBar(binding.root) { state.msg } - } - - else -> { - } - } - }.launchIn(viewLifeCycleScope) - } private fun navigateToGuideScreen() { Intent(requireContext(), GuideActivity::class.java).apply { diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageViewModel.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageViewModel.kt index 6346e006..db894610 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageViewModel.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageViewModel.kt @@ -22,9 +22,6 @@ class MyPageViewModel @Inject constructor( private val _deleteUserState = MutableStateFlow>(UiState.Empty) val deleteUserState: StateFlow> = _deleteUserState.asStateFlow() - private val _patchAllowedNotificationState = MutableStateFlow>(UiState.Empty) - val patchAllowedNotificationState: StateFlow> = _patchAllowedNotificationState.asStateFlow() - fun deleteUser() { viewModelScope.launch { authRepository.deleteUser() @@ -45,29 +42,5 @@ class MyPageViewModel @Inject constructor( } } - fun patchAllowedNotification(isAllowed: Boolean) { - viewModelScope.launch { - authRepository.patchAllowedNotification(!isAllowed) - .onSuccess { response -> - Timber.d("SUCCESS PATCH ALLOWED NOTI") - _patchAllowedNotificationState.value = UiState.Success(response) - } - .onFailure { t -> - _patchAllowedNotificationState.value = UiState.Failure(t.message.toString()) - - if (t is HttpException) { - Timber.e("HTTP FAIL ALLOWED NOTI : ${t.code()} ${t.message}") - return@onFailure - } - - Timber.e("FAIL ALLOWED NOTI : ${t.message}") - } - } - } - fun clearDataStore() { - viewModelScope.launch { - dataStoreRepository.clearDataStore() - } - } } diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingActivity.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingActivity.kt index 30ee7900..32c93607 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingActivity.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingActivity.kt @@ -6,19 +6,30 @@ import android.content.pm.PackageManager import android.net.Uri import android.os.Build import android.os.Bundle +import android.provider.Settings import androidx.activity.viewModels import androidx.core.content.ContextCompat import androidx.core.view.isGone import androidx.core.view.isVisible +import androidx.lifecycle.flowWithLifecycle +import androidx.lifecycle.lifecycleScope import dagger.hilt.android.AndroidEntryPoint +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.flow.launchIn +import kotlinx.coroutines.flow.onEach +import kotlinx.coroutines.launch import org.go.sopt.winey.R import org.go.sopt.winey.databinding.ActivitySettingBinding +import org.go.sopt.winey.domain.entity.User +import org.go.sopt.winey.domain.repository.DataStoreRepository import org.go.sopt.winey.presentation.main.MainViewModel import org.go.sopt.winey.presentation.model.WineyDialogLabel import org.go.sopt.winey.util.amplitude.AmplitudeUtils import org.go.sopt.winey.util.binding.BindingActivity +import org.go.sopt.winey.util.context.snackBar import org.go.sopt.winey.util.context.stringOf import org.go.sopt.winey.util.fragment.WineyDialogFragment +import org.go.sopt.winey.util.view.UiState import javax.inject.Inject @AndroidEntryPoint @@ -26,6 +37,9 @@ class SettingActivity : BindingActivity(R.layout.activit private val settingViewModel by viewModels() private val mainViewModel by viewModels() + @Inject + lateinit var dataStoreRepository: DataStoreRepository + @Inject lateinit var amplitudeUtils: AmplitudeUtils private var isNotificationPermissionAllowed = true @@ -40,7 +54,6 @@ class SettingActivity : BindingActivity(R.layout.activit override fun onStart() { super.onStart() initNotificationPermissionState() - updateNotificationToggleByPermission() } private fun addListener() { @@ -48,38 +61,114 @@ class SettingActivity : BindingActivity(R.layout.activit initLogoutButtonClickListener() initTermsButtonClickListener() initWithdrawButtonClickListener() + initNotiPermissionButtonClickListener() } private fun addObserver() { } - private fun initNotificationPermissionState() { - isNotificationPermissionAllowed = - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - ContextCompat.checkSelfPermission( - this, - Manifest.permission.POST_NOTIFICATIONS - ) == PackageManager.PERMISSION_GRANTED - } else { - true - } + private fun switchOnNotification() { + binding.ivSettingAgree.transitionToState(R.id.end, -1) + patchUserInfo() + settingViewModel.patchAllowedNotification(isAllowed = false) + } + + private fun switchOffNotification() { + binding.ivSettingAgree.transitionToState(R.id.start, -1) + patchUserInfo() + settingViewModel.patchAllowedNotification(isAllowed = true) + } + + private fun initNotiPermissionButtonClickListener() { + binding.llSettingAgreePermissionChange.setOnClickListener { + showSystemNotificationSetting() + } + } + + private fun showSystemNotificationSetting() { + Intent().apply { + action = Settings.ACTION_APP_NOTIFICATION_SETTINGS + putExtra(Settings.EXTRA_APP_PACKAGE, this) + flags = Intent.FLAG_ACTIVITY_NEW_TASK + startActivity(this) + } + } + + private fun showNotificationOffConfirmDialog() { + val dialog = WineyDialogFragment.newInstance( + WineyDialogLabel( + stringOf(R.string.notification_off_dialog_title), + stringOf(R.string.notification_off_dialog_subtitle), + stringOf(R.string.notification_off_dialog_negative_button), + stringOf(R.string.notification_off_dialog_positive_button) + ), + handleNegativeButton = {}, + handlePositiveButton = { switchOffNotification() } + ) + dialog.show( + supportFragmentManager, + TAG_NOTIFICATION_OFF_DIALOG + ) } - private fun updateNotificationToggleByPermission() { + private fun updateNotificationAllowSwitchState(data: User) { if (isNotificationPermissionAllowed) { binding.ivSettingAgree.isVisible = true - binding.llSettingAgreePermissionChange.isGone = true binding.tvSettingAgreePermission.isGone = true + when (data.fcmIsAllowed) { + true -> { + binding.ivSettingAgree.transitionToState(R.id.end, 1) + } + + false -> { + binding.ivSettingAgree.transitionToState(R.id.start, 1) + } + } } else { binding.ivSettingAgree.isGone = true - binding.llSettingAgreePermissionChange.isVisible = true binding.tvSettingAgreePermission.isVisible = true } } + private fun patchUserInfo() { + lifecycleScope.launch { + val data = dataStoreRepository.getUserInfo().first() + val newData = data?.copy(fcmIsAllowed = false) + dataStoreRepository.saveUserInfo(newData) + } + } + + private fun initNotiToggleButtonClickListener() { + binding.ivSettingSwitch.setOnClickListener { + val isAllowed = when (binding.ivSettingAgree.currentState) { + R.id.start -> false + R.id.end -> true + else -> false + } + + if (!isAllowed) { + switchOnNotification() + } else { + showNotificationOffConfirmDialog() + } + } + } + + private fun initNotificationPermissionState() { + isNotificationPermissionAllowed = + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + ContextCompat.checkSelfPermission( + this, + Manifest.permission.POST_NOTIFICATIONS + ) == PackageManager.PERMISSION_GRANTED + } else { + true + } + } + private fun init1On1ButtonClickListener() { binding.clSettingTo1on1.setOnClickListener { val url = ONE_ON_ONE_URL @@ -129,6 +218,50 @@ class SettingActivity : BindingActivity(R.layout.activit } } + private fun setupDeleteUserState() { + settingViewModel.deleteUserState.flowWithLifecycle(lifecycle) + .onEach { state -> + when (state) { + is UiState.Success -> { + settingViewModel.clearDataStore() + //navigateToGuideScreen() + } + + is UiState.Failure -> { + snackBar(binding.root) { state.msg } + } + + else -> { + } + } + }.launchIn(lifecycleScope) + } + + private fun setupPatchAllowedNotificationState() { + settingViewModel.patchAllowedNotificationState.flowWithLifecycle(lifecycle) + .onEach { state -> + when (state) { + is UiState.Success -> { + when (state.data) { + true -> { + binding.ivSettingAgree.transitionToState(R.id.end, -1) + } + + false -> { + binding.ivSettingAgree.transitionToState(R.id.start, -1) + } + + null -> { + binding.ivSettingAgree.transitionToState(R.id.start, -1) + } + } + } + + else -> {} + } + } + } + companion object { private const val ONE_ON_ONE_URL = "https://open.kakao.com/o/s751Susf" @@ -137,5 +270,7 @@ class SettingActivity : BindingActivity(R.layout.activit private const val TAG_LOGOUT_DIALOG = "LOGOUT_DIALOG" private const val TAG_WITHDRAW_DIALOG = "WITHDRAW_DIALOG" + + private const val TAG_NOTIFICATION_OFF_DIALOG = "offNotification" } } diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingViewModel.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingViewModel.kt index 1563bc0a..ff473a7a 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingViewModel.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingViewModel.kt @@ -23,6 +23,11 @@ class SettingViewModel @Inject constructor( private val _deleteUserState = MutableStateFlow>(UiState.Empty) val deleteUserState: StateFlow> = _deleteUserState.asStateFlow() + + private val _patchAllowedNotificationState = MutableStateFlow>(UiState.Empty) + val patchAllowedNotificationState: StateFlow> = + _patchAllowedNotificationState.asStateFlow() + fun deleteUser() { viewModelScope.launch { authRepository.deleteUser() @@ -43,4 +48,31 @@ class SettingViewModel @Inject constructor( } } + fun patchAllowedNotification(isAllowed: Boolean) { + viewModelScope.launch { + authRepository.patchAllowedNotification(!isAllowed) + .onSuccess { response -> + Timber.d("SUCCESS PATCH ALLOWED NOTI") + _patchAllowedNotificationState.value = UiState.Success(response) + } + .onFailure { t -> + _patchAllowedNotificationState.value = UiState.Failure(t.message.toString()) + + if (t is HttpException) { + Timber.e("HTTP FAIL ALLOWED NOTI : ${t.code()} ${t.message}") + return@onFailure + } + + Timber.e("FAIL ALLOWED NOTI : ${t.message}") + } + } + } + + + fun clearDataStore() { + viewModelScope.launch { + dataStoreRepository.clearDataStore() + } + } + } From 7b572468fa6c185dde004e6d234668ed99546bc4 Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Fri, 23 Feb 2024 15:58:12 +0900 Subject: [PATCH 05/26] =?UTF-8?q?[feat]=20#244=20=EB=92=A4=EB=A1=9C?= =?UTF-8?q?=EA=B0=80=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../winey/presentation/main/MainViewModel.kt | 2 +- .../main/mypage/MyPageFragment.kt | 55 +++---------------- .../main/mypage/MyPageViewModel.kt | 2 - .../main/mypage/setting/SettingActivity.kt | 45 +++++++++++++-- .../main/mypage/setting/SettingViewModel.kt | 3 - 5 files changed, 48 insertions(+), 59 deletions(-) diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/MainViewModel.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/MainViewModel.kt index 269da462..9c360126 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/MainViewModel.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/MainViewModel.kt @@ -58,7 +58,7 @@ class MainViewModel @Inject constructor( } } - private fun postLogout() { + fun postLogout() { viewModelScope.launch { _logoutState.value = UiState.Loading diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageFragment.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageFragment.kt index d09511b2..5db45c08 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageFragment.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageFragment.kt @@ -1,13 +1,10 @@ package org.go.sopt.winey.presentation.main.mypage import android.Manifest -import android.content.ActivityNotFoundException -import android.content.Context import android.content.Intent import android.content.pm.PackageManager import android.os.Build import android.os.Bundle -import android.provider.Settings import android.view.View import androidx.activity.OnBackPressedCallback import androidx.core.content.ContextCompat @@ -29,7 +26,6 @@ import org.go.sopt.winey.domain.entity.UserV2 import org.go.sopt.winey.domain.repository.DataStoreRepository import org.go.sopt.winey.presentation.main.MainViewModel import org.go.sopt.winey.presentation.main.mypage.myfeed.MyFeedActivity -import org.go.sopt.winey.presentation.main.mypage.myfeed.MyFeedFragment import org.go.sopt.winey.presentation.main.mypage.setting.SettingActivity import org.go.sopt.winey.presentation.main.notification.NotificationActivity import org.go.sopt.winey.presentation.nickname.NicknameActivity @@ -71,6 +67,7 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ private fun addListener() { initEditNicknameButtonClickListener() initMyFeedButtonClickListener() + initSettingButtonClickListener() registerBackPressedCallback() } @@ -92,44 +89,6 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ } } - private fun navigateToNotificationSetting(context: Context) { - val intent = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - setNotificationIntentActionOreo(context) - } else { - setNorificationIntentActionOreoLess(context) - } - try { - context.startActivity(intent) - } catch (e: ActivityNotFoundException) { - e.printStackTrace() - } - } - - private fun setNotificationIntentActionOreo(context: Context): Intent { - return Intent().also { intent -> - intent.action = Settings.ACTION_APP_NOTIFICATION_SETTINGS - intent.putExtra(Settings.EXTRA_APP_PACKAGE, context.packageName) - intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK - } - } - - private fun setNorificationIntentActionOreoLess(context: Context): Intent { - return Intent().also { intent -> - intent.action = "android.settings.APP_NOTIFICATION_SETTINGS" - intent.putExtra("app_package", context.packageName) - intent.putExtra("app_uid", context.applicationInfo?.uid) - intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK - } - } - - private fun patchUserInfo() { - lifecycleScope.launch { - val data = dataStoreRepository.getUserInfo().first() - val newData = data?.copy(fcmIsAllowed = false) - dataStoreRepository.saveUserInfo(newData) - } - } - // 닉네임 액티비티 갔다가 다시 돌아왔을 때 유저 데이터 갱신하도록 override fun onStart() { super.onStart() @@ -156,6 +115,12 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ } } + private fun initSettingButtonClickListener() { + binding.ivMypageSetting.setOnClickListener { + navigateToSettingScreen() + } + } + // 마이페이지 왔다가 다시 알림 화면으로 돌아가도록 private fun registerBackPressedCallback() { val callback = object : OnBackPressedCallback(true) { @@ -195,7 +160,6 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ } } - private fun navigateToGuideScreen() { Intent(requireContext(), GuideActivity::class.java).apply { addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK) @@ -249,11 +213,6 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ amplitudeUtils.logEvent("view_goalsetting") } - private fun showTargetNotOverDialog() { - val dialog = MyPageNotOverDialogFragment() - dialog.show(parentFragmentManager, dialog.tag) - } - private inline fun navigateAndBackStack() { parentFragmentManager.commit { replace(R.id.fcv_main, T::class.simpleName) diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageViewModel.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageViewModel.kt index db894610..6bf730d8 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageViewModel.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageViewModel.kt @@ -41,6 +41,4 @@ class MyPageViewModel @Inject constructor( } } } - - } diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingActivity.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingActivity.kt index 32c93607..6c24ef05 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingActivity.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingActivity.kt @@ -20,7 +20,7 @@ import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.launch import org.go.sopt.winey.R import org.go.sopt.winey.databinding.ActivitySettingBinding -import org.go.sopt.winey.domain.entity.User +import org.go.sopt.winey.domain.entity.UserV2 import org.go.sopt.winey.domain.repository.DataStoreRepository import org.go.sopt.winey.presentation.main.MainViewModel import org.go.sopt.winey.presentation.model.WineyDialogLabel @@ -30,6 +30,7 @@ import org.go.sopt.winey.util.context.snackBar import org.go.sopt.winey.util.context.stringOf import org.go.sopt.winey.util.fragment.WineyDialogFragment import org.go.sopt.winey.util.view.UiState +import org.go.sopt.winey.util.view.setOnSingleClickListener import javax.inject.Inject @AndroidEntryPoint @@ -49,11 +50,13 @@ class SettingActivity : BindingActivity(R.layout.activit addListener() addObserver() initNotificationPermissionState() + initUserData() } override fun onStart() { super.onStart() initNotificationPermissionState() + updateNotificationButtonByPermission() } private fun addListener() { @@ -61,11 +64,14 @@ class SettingActivity : BindingActivity(R.layout.activit initLogoutButtonClickListener() initTermsButtonClickListener() initWithdrawButtonClickListener() - initNotiPermissionButtonClickListener() + initNotificationPermissionButtonClickListener() + initNotiToggleButtonClickListener() + initBackButtonClickListener() } private fun addObserver() { - + setupDeleteUserState() + setupPatchAllowedNotificationState() } private fun switchOnNotification() { @@ -80,7 +86,7 @@ class SettingActivity : BindingActivity(R.layout.activit settingViewModel.patchAllowedNotification(isAllowed = true) } - private fun initNotiPermissionButtonClickListener() { + private fun initNotificationPermissionButtonClickListener() { binding.llSettingAgreePermissionChange.setOnClickListener { showSystemNotificationSetting() } @@ -112,7 +118,16 @@ class SettingActivity : BindingActivity(R.layout.activit ) } - private fun updateNotificationAllowSwitchState(data: User) { + private fun initUserData() { + lifecycleScope.launch { + val data = dataStoreRepository.getUserInfo().first() + if (data != null) { + updateNotificationAllowSwitchState(data) + } + } + } + + private fun updateNotificationAllowSwitchState(data: UserV2) { if (isNotificationPermissionAllowed) { binding.ivSettingAgree.isVisible = true binding.llSettingAgreePermissionChange.isGone = true @@ -133,6 +148,20 @@ class SettingActivity : BindingActivity(R.layout.activit } } + private fun updateNotificationButtonByPermission() { + if (isNotificationPermissionAllowed) { + binding.ivSettingAgree.isVisible = true + + binding.llSettingAgreePermissionChange.isGone = true + binding.tvSettingAgreePermission.isGone = true + } else { + binding.ivSettingAgree.isGone = true + + binding.llSettingAgreePermissionChange.isVisible = true + binding.tvSettingAgreePermission.isVisible = true + } + } + private fun patchUserInfo() { lifecycleScope.launch { val data = dataStoreRepository.getUserInfo().first() @@ -185,6 +214,12 @@ class SettingActivity : BindingActivity(R.layout.activit } } + private fun initBackButtonClickListener() { + binding.ivSettingBack.setOnSingleClickListener { + finish() + } + } + private fun initLogoutButtonClickListener() { binding.clSettingLogout.setOnClickListener { amplitudeUtils.logEvent("click_logout") diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingViewModel.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingViewModel.kt index ff473a7a..f6ae5b5e 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingViewModel.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingViewModel.kt @@ -23,7 +23,6 @@ class SettingViewModel @Inject constructor( private val _deleteUserState = MutableStateFlow>(UiState.Empty) val deleteUserState: StateFlow> = _deleteUserState.asStateFlow() - private val _patchAllowedNotificationState = MutableStateFlow>(UiState.Empty) val patchAllowedNotificationState: StateFlow> = _patchAllowedNotificationState.asStateFlow() @@ -68,11 +67,9 @@ class SettingViewModel @Inject constructor( } } - fun clearDataStore() { viewModelScope.launch { dataStoreRepository.clearDataStore() } } - } From 19ab2c10bae49eedbdd54873c2e19491ca8ed55c Mon Sep 17 00:00:00 2001 From: leeeha Date: Mon, 26 Feb 2024 14:51:11 +0900 Subject: [PATCH 06/26] =?UTF-8?q?[chore]=20#249=20ktlint=20=EC=B2=B4?= =?UTF-8?q?=ED=81=AC=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sopt/winey/data/model/remote/response/ResponseGetUserDto.kt | 2 +- .../go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt | 1 - .../sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt | 2 -- .../main/java/org/go/sopt/winey/presentation/model/UserLevel.kt | 2 +- .../main/java/org/go/sopt/winey/util/binding/BindingAdapter.kt | 1 - 5 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/go/sopt/winey/data/model/remote/response/ResponseGetUserDto.kt b/app/src/main/java/org/go/sopt/winey/data/model/remote/response/ResponseGetUserDto.kt index 40300574..665bffa9 100644 --- a/app/src/main/java/org/go/sopt/winey/data/model/remote/response/ResponseGetUserDto.kt +++ b/app/src/main/java/org/go/sopt/winey/data/model/remote/response/ResponseGetUserDto.kt @@ -32,7 +32,7 @@ data class ResponseGetUserDto( @SerialName("remainingAmount") val remainingAmount: Int, @SerialName("remainingCount") - val remainingCount: Int, + val remainingCount: Int ) fun toUser(): UserV2 { diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt index e091055e..01a972cc 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt @@ -30,7 +30,6 @@ import org.go.sopt.winey.presentation.main.feed.detail.DetailActivity import org.go.sopt.winey.presentation.main.feed.upload.UploadActivity import org.go.sopt.winey.presentation.main.mypage.MyPageFragment import org.go.sopt.winey.presentation.main.notification.NotificationActivity -import org.go.sopt.winey.presentation.model.UserLevel import org.go.sopt.winey.presentation.model.WineyDialogLabel import org.go.sopt.winey.util.activity.showReportGoogleForm import org.go.sopt.winey.util.amplitude.AmplitudeUtils diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt index e338d9c0..8c7eb5f3 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt @@ -3,13 +3,11 @@ package org.go.sopt.winey.presentation.main.feed import android.content.Context import android.view.LayoutInflater import android.view.ViewGroup -import androidx.core.view.isVisible import androidx.recyclerview.widget.RecyclerView import org.go.sopt.winey.R import org.go.sopt.winey.databinding.ItemWineyfeedGoalBinding import org.go.sopt.winey.domain.entity.UserV2 import org.go.sopt.winey.presentation.model.UserLevel -import timber.log.Timber import kotlin.math.roundToInt class WineyFeedGoalAdapter( diff --git a/app/src/main/java/org/go/sopt/winey/presentation/model/UserLevel.kt b/app/src/main/java/org/go/sopt/winey/presentation/model/UserLevel.kt index ccc8146a..c9cb6332 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/model/UserLevel.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/model/UserLevel.kt @@ -4,5 +4,5 @@ enum class UserLevel(val rankName: String) { FIRST("평민"), SECOND("기사"), THIRD("귀족"), - FORTH("황제"), + FORTH("황제") } diff --git a/app/src/main/java/org/go/sopt/winey/util/binding/BindingAdapter.kt b/app/src/main/java/org/go/sopt/winey/util/binding/BindingAdapter.kt index c045c97d..1d8b280c 100644 --- a/app/src/main/java/org/go/sopt/winey/util/binding/BindingAdapter.kt +++ b/app/src/main/java/org/go/sopt/winey/util/binding/BindingAdapter.kt @@ -30,7 +30,6 @@ import org.go.sopt.winey.util.context.stringOf import org.go.sopt.winey.util.number.formatAmountNumber import org.go.sopt.winey.util.view.InputUiState import org.go.sopt.winey.util.view.InputUiState.* -import timber.log.Timber import java.text.DecimalFormat @BindingAdapter("likedAmount") From e6a770b814e9227e915a894b50d1012470f420b6 Mon Sep 17 00:00:00 2001 From: leeeha Date: Mon, 26 Feb 2024 14:53:48 +0900 Subject: [PATCH 07/26] =?UTF-8?q?[chore]=20#249=20=EC=A3=BC=EC=84=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt index 8c7eb5f3..ba54b38a 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt @@ -37,7 +37,7 @@ class WineyFeedGoalAdapter( if (!isInitialized) { isInitialized = true - // 최초 1회만 실행 (아이템 뷰의 재활용에 따라 예전 초기 데이터가 반영되는 문제 해결) + // 최초 1회만 실행 (아이템 뷰의 재활용에 따라 예전 데이터가 다시 바인딩 되는 문제 해결) updateProgressBar(initialUser) } } From 1496f31dead96b0491ce98f0650796dd65b873ef Mon Sep 17 00:00:00 2001 From: leeeha Date: Mon, 26 Feb 2024 15:14:34 +0900 Subject: [PATCH 08/26] =?UTF-8?q?[ui]=20#250=20=EC=95=8C=EB=A6=BC=20?= =?UTF-8?q?=EB=B1=83=EC=A7=80=20=EC=95=84=EC=9D=B4=EC=BD=98=20=EC=83=89?= =?UTF-8?q?=EC=83=81=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/drawable/ic_wineyfeed_notification_new.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/res/drawable/ic_wineyfeed_notification_new.xml b/app/src/main/res/drawable/ic_wineyfeed_notification_new.xml index db5b80da..05a124d0 100644 --- a/app/src/main/res/drawable/ic_wineyfeed_notification_new.xml +++ b/app/src/main/res/drawable/ic_wineyfeed_notification_new.xml @@ -4,7 +4,7 @@ android:viewportWidth="48" android:viewportHeight="48"> + android:pathData="M29,19m-3,0a3,3 0,1 1,6 0a3,3 0,1 1,-6 0" + android:fillColor="#FF5150"/> From 4789e3dcc0ce3b165aa51e9867ed9a6d5900a693 Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Mon, 26 Feb 2024 22:15:53 +0900 Subject: [PATCH 09/26] =?UTF-8?q?[feat]=20#244=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=95=84=EC=9B=83,=20=ED=83=88=ED=87=B4=20=EC=8B=9C=20?= =?UTF-8?q?=ED=99=94=EB=A9=B4=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/mypage/setting/SettingActivity.kt | 41 ++++++++++++++++++- .../main/mypage/setting/SettingViewModel.kt | 1 + 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingActivity.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingActivity.kt index 6c24ef05..98b7264f 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingActivity.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingActivity.kt @@ -8,6 +8,7 @@ import android.os.Build import android.os.Bundle import android.provider.Settings import androidx.activity.viewModels +import androidx.core.content.ContentProviderCompat.requireContext import androidx.core.content.ContextCompat import androidx.core.view.isGone import androidx.core.view.isVisible @@ -24,6 +25,8 @@ import org.go.sopt.winey.domain.entity.UserV2 import org.go.sopt.winey.domain.repository.DataStoreRepository import org.go.sopt.winey.presentation.main.MainViewModel import org.go.sopt.winey.presentation.model.WineyDialogLabel +import org.go.sopt.winey.presentation.onboarding.guide.GuideActivity +import org.go.sopt.winey.presentation.onboarding.login.LoginActivity import org.go.sopt.winey.util.amplitude.AmplitudeUtils import org.go.sopt.winey.util.binding.BindingActivity import org.go.sopt.winey.util.context.snackBar @@ -72,6 +75,7 @@ class SettingActivity : BindingActivity(R.layout.activit private fun addObserver() { setupDeleteUserState() setupPatchAllowedNotificationState() + setupLogoutState() } private fun switchOnNotification() { @@ -259,7 +263,7 @@ class SettingActivity : BindingActivity(R.layout.activit when (state) { is UiState.Success -> { settingViewModel.clearDataStore() - //navigateToGuideScreen() + navigateToGuideScreen() } is UiState.Failure -> { @@ -296,6 +300,41 @@ class SettingActivity : BindingActivity(R.layout.activit } } } + private fun setupLogoutState() { + mainViewModel.logoutState.flowWithLifecycle(lifecycle).onEach { state -> + when (state) { + is UiState.Loading -> { + } + + is UiState.Success -> { + navigateToLoginScreen() + } + + is UiState.Failure -> { + snackBar(binding.root) { state.msg } + } + + is UiState.Empty -> { + } + } + }.launchIn(lifecycleScope) + } + + private fun navigateToLoginScreen() { + Intent(this, LoginActivity::class.java).apply { + addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) + startActivity(this) + finish() + } + } + + private fun navigateToGuideScreen() { + Intent(this, GuideActivity::class.java).apply { + addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK) + startActivity(this) + } + } + companion object { diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingViewModel.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingViewModel.kt index f6ae5b5e..ab13085d 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingViewModel.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingViewModel.kt @@ -7,6 +7,7 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch +import org.go.sopt.winey.data.model.remote.response.ResponseLogoutDto import org.go.sopt.winey.domain.repository.AuthRepository import org.go.sopt.winey.domain.repository.DataStoreRepository import org.go.sopt.winey.util.view.UiState From 22dc4b4b9664ca9872be8618e02d725bf979a386 Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Mon, 26 Feb 2024 22:30:36 +0900 Subject: [PATCH 10/26] =?UTF-8?q?[fix]=20#244=20=EC=8B=9C=EC=8A=A4?= =?UTF-8?q?=ED=85=9C=20=EC=84=A4=EC=A0=95=20=EC=9D=B4=EB=8F=99=EC=8B=9C=20?= =?UTF-8?q?=ED=81=AC=EB=9E=98=EC=8B=9C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/main/mypage/setting/SettingActivity.kt | 5 ++--- .../presentation/main/mypage/setting/SettingViewModel.kt | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingActivity.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingActivity.kt index 98b7264f..f6c237ef 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingActivity.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingActivity.kt @@ -8,7 +8,6 @@ import android.os.Build import android.os.Bundle import android.provider.Settings import androidx.activity.viewModels -import androidx.core.content.ContentProviderCompat.requireContext import androidx.core.content.ContextCompat import androidx.core.view.isGone import androidx.core.view.isVisible @@ -99,7 +98,7 @@ class SettingActivity : BindingActivity(R.layout.activit private fun showSystemNotificationSetting() { Intent().apply { action = Settings.ACTION_APP_NOTIFICATION_SETTINGS - putExtra(Settings.EXTRA_APP_PACKAGE, this) + putExtra(Settings.EXTRA_APP_PACKAGE, packageName) flags = Intent.FLAG_ACTIVITY_NEW_TASK startActivity(this) } @@ -300,6 +299,7 @@ class SettingActivity : BindingActivity(R.layout.activit } } } + private fun setupLogoutState() { mainViewModel.logoutState.flowWithLifecycle(lifecycle).onEach { state -> when (state) { @@ -335,7 +335,6 @@ class SettingActivity : BindingActivity(R.layout.activit } } - companion object { private const val ONE_ON_ONE_URL = "https://open.kakao.com/o/s751Susf" diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingViewModel.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingViewModel.kt index ab13085d..f6ae5b5e 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingViewModel.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/setting/SettingViewModel.kt @@ -7,7 +7,6 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch -import org.go.sopt.winey.data.model.remote.response.ResponseLogoutDto import org.go.sopt.winey.domain.repository.AuthRepository import org.go.sopt.winey.domain.repository.DataStoreRepository import org.go.sopt.winey.util.view.UiState From 11e797112dc8e9e34e53b0ebd65bd3664583a604 Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Mon, 26 Feb 2024 22:42:03 +0900 Subject: [PATCH 11/26] =?UTF-8?q?[mod]=20#244=20=EB=92=A4=EB=A1=9C?= =?UTF-8?q?=EA=B0=80=EA=B8=B0=20=EB=B2=84=ED=8A=BC=20=ED=86=B5=EC=9D=BC=20?= =?UTF-8?q?=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/layout/activity_setting.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/layout/activity_setting.xml b/app/src/main/res/layout/activity_setting.xml index 6ce03d97..7a62a270 100644 --- a/app/src/main/res/layout/activity_setting.xml +++ b/app/src/main/res/layout/activity_setting.xml @@ -24,7 +24,7 @@ android:layout_height="wrap_content" android:layout_marginVertical="4dp" android:padding="12dp" - android:src="@drawable/ic_myfeed_back" + android:src="@drawable/ic_all_back" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> From 4ebd0f6b5c7a855f988faa28a70f167f29872077 Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Fri, 1 Mar 2024 14:18:57 +0900 Subject: [PATCH 12/26] =?UTF-8?q?[mod]=20#244=20overScrollMode=20never=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/layout/fragment_my_page.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/res/layout/fragment_my_page.xml b/app/src/main/res/layout/fragment_my_page.xml index c92467bf..eadbd331 100644 --- a/app/src/main/res/layout/fragment_my_page.xml +++ b/app/src/main/res/layout/fragment_my_page.xml @@ -45,6 +45,7 @@ From d17283acbef865e686dbccd71d0987372a0b28b7 Mon Sep 17 00:00:00 2001 From: leeeha Date: Fri, 1 Mar 2024 19:56:35 +0900 Subject: [PATCH 13/26] =?UTF-8?q?[fix]=20#249=20=EB=94=94=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=20=EB=AA=A8=EB=93=9C=EC=97=90=EC=84=9C=EB=8A=94=20?= =?UTF-8?q?=EC=9D=B8=EC=95=B1=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=8B=A4=ED=96=89=ED=95=98=EC=A7=80=20?= =?UTF-8?q?=EC=95=8A=EB=8F=84=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../go/sopt/winey/presentation/splash/SplashActivity.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/go/sopt/winey/presentation/splash/SplashActivity.kt b/app/src/main/java/org/go/sopt/winey/presentation/splash/SplashActivity.kt index e0d37cb1..5f7bb4c8 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/splash/SplashActivity.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/splash/SplashActivity.kt @@ -19,6 +19,7 @@ import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.delay import kotlinx.coroutines.flow.firstOrNull import kotlinx.coroutines.launch +import org.go.sopt.winey.BuildConfig import org.go.sopt.winey.R import org.go.sopt.winey.databinding.ActivitySplashBinding import org.go.sopt.winey.domain.repository.DataStoreRepository @@ -101,7 +102,12 @@ class SplashActivity : BindingActivity(R.layout.activity_ private fun showLottieAnimation() { lifecycleScope.launch { delay(DELAY_TIME) - checkAppUpdateInfo() + + if (BuildConfig.DEBUG) { + checkAutoLogin() + } else { + checkAppUpdateInfo() + } } } From b29bc2b9891ca6a04a9f7f8ae4ac4f35de3a6c94 Mon Sep 17 00:00:00 2001 From: leeeha Date: Fri, 1 Mar 2024 20:35:05 +0900 Subject: [PATCH 14/26] =?UTF-8?q?[chore]=20#249=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=20=EC=95=A1=ED=8B=B0=EB=B9=84=ED=8B=B0,=20=EB=B7=B0?= =?UTF-8?q?=EB=AA=A8=EB=8D=B8=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 사용하지 않는 함수 삭제 - 함수 선언 위치 변경 --- .../onboarding/login/LoginActivity.kt | 53 +++++++++---------- .../onboarding/login/LoginViewModel.kt | 34 ++++-------- 2 files changed, 35 insertions(+), 52 deletions(-) diff --git a/app/src/main/java/org/go/sopt/winey/presentation/onboarding/login/LoginActivity.kt b/app/src/main/java/org/go/sopt/winey/presentation/onboarding/login/LoginActivity.kt index 9ddc7c4a..f13b609f 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/onboarding/login/LoginActivity.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/onboarding/login/LoginActivity.kt @@ -46,30 +46,6 @@ class LoginActivity : } } - private fun sendEventToAmplitude(type: EventType) { - val eventProperties = JSONObject() - - try { - when (type) { - EventType.TYPE_VIEW_SCREEN -> eventProperties.put("screen_name", "sign_up") - EventType.TYPE_CLICK_BUTTON -> { - eventProperties.put("button_name", "kakao_signup_button") - .put("paging_number", 1) - } - else -> {} - } - } catch (e: JSONException) { - System.err.println("Invalid JSON") - e.printStackTrace() - } - - when (type) { - EventType.TYPE_VIEW_SCREEN -> amplitudeUtils.logEvent("view_signup", eventProperties) - EventType.TYPE_CLICK_BUTTON -> amplitudeUtils.logEvent("click_button", eventProperties) - else -> {} - } - } - private fun initLoginObserver() { viewModel.loginState.flowWithLifecycle(lifecycle).onEach { state -> when (state) { @@ -78,11 +54,6 @@ class LoginActivity : } is UiState.Success -> { - Timber.e("${state.data?.userId}") - Timber.e("${state.data?.accessToken}") - Timber.e("${state.data?.refreshToken}") - Timber.e("${state.data?.isRegistered}") - if (state.data?.isRegistered == true) { navigateTo() } else { @@ -106,4 +77,28 @@ class LoginActivity : startActivity(this) } } + + private fun sendEventToAmplitude(type: EventType) { + val eventProperties = JSONObject() + + try { + when (type) { + EventType.TYPE_VIEW_SCREEN -> eventProperties.put("screen_name", "sign_up") + EventType.TYPE_CLICK_BUTTON -> { + eventProperties.put("button_name", "kakao_signup_button") + .put("paging_number", 1) + } + else -> {} + } + } catch (e: JSONException) { + System.err.println("Invalid JSON") + e.printStackTrace() + } + + when (type) { + EventType.TYPE_VIEW_SCREEN -> amplitudeUtils.logEvent("view_signup", eventProperties) + EventType.TYPE_CLICK_BUTTON -> amplitudeUtils.logEvent("click_button", eventProperties) + else -> {} + } + } } diff --git a/app/src/main/java/org/go/sopt/winey/presentation/onboarding/login/LoginViewModel.kt b/app/src/main/java/org/go/sopt/winey/presentation/onboarding/login/LoginViewModel.kt index ad367e93..355e98d0 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/onboarding/login/LoginViewModel.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/onboarding/login/LoginViewModel.kt @@ -14,9 +14,11 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import org.go.sopt.winey.data.model.remote.request.RequestLoginDto import org.go.sopt.winey.data.model.remote.response.ResponseLoginDto +import org.go.sopt.winey.domain.entity.UserV2 import org.go.sopt.winey.domain.repository.AuthRepository import org.go.sopt.winey.domain.repository.DataStoreRepository import org.go.sopt.winey.domain.repository.KakaoLoginRepository +import org.go.sopt.winey.presentation.main.MainViewModel import org.go.sopt.winey.util.view.UiState import retrofit2.HttpException import timber.log.Timber @@ -28,15 +30,11 @@ class LoginViewModel @Inject constructor( private val authRepository: AuthRepository, private val dataStoreRepository: DataStoreRepository ) : ViewModel() { - private val _isKakaoLogin = MutableStateFlow(false) - val isKakaoLogin = _isKakaoLogin.asStateFlow() - private val _loginState = MutableStateFlow>(UiState.Empty) val loginState: StateFlow> = _loginState.asStateFlow() - val kakaoLoginCallback: (OAuthToken?, Throwable?) -> Unit = { token, error -> + private val kakaoLoginCallback: (OAuthToken?, Throwable?) -> Unit = { token, error -> KakaoLoginCallback { - _isKakaoLogin.value = true Timber.d("액세스토큰 ${token?.accessToken}") Timber.d("리프레시토큰 ${token?.refreshToken}") if (token != null) { @@ -52,17 +50,19 @@ class LoginViewModel @Inject constructor( kakaoLoginRepository.loginKakao(kakaoLoginCallback, context) } - fun postLogin(socialToken: String, socialType: String) { + private fun postLogin(socialToken: String, socialType: String) { viewModelScope.launch { _loginState.value = UiState.Loading authRepository.postLogin(socialToken, RequestLoginDto(socialType)) .onSuccess { response -> - Timber.e("로그인 성공") if (response != null) { + Timber.d("로그인 성공") + Timber.d("액세스 : ${response.accessToken} \n 리프레시 : ${response.refreshToken}") + saveAccessToken(response.accessToken, response.refreshToken) saveUserId(response.userId) - Timber.e("액세스 : ${response.accessToken} , 리프레시 : ${response.refreshToken}") + _loginState.value = UiState.Success(response) } else { Timber.e("response is null") @@ -78,33 +78,21 @@ class LoginViewModel @Inject constructor( } } - fun saveSocialToken(socialAccessToken: String, socialRefreshToken: String) = + private fun saveSocialToken(socialAccessToken: String, socialRefreshToken: String) = viewModelScope.launch(Dispatchers.IO) { dataStoreRepository.saveSocialToken(socialAccessToken, socialRefreshToken) } - suspend fun getSocialToken() = withContext(Dispatchers.IO) { - dataStoreRepository.getSocialAccessToken().first() - } - - fun saveAccessToken(accessToken: String, refreshToken: String) = + private fun saveAccessToken(accessToken: String, refreshToken: String) = viewModelScope.launch(Dispatchers.IO) { dataStoreRepository.saveAccessToken(accessToken, refreshToken) } - fun saveUserId(userId: Int) = + private fun saveUserId(userId: Int) = viewModelScope.launch(Dispatchers.IO) { dataStoreRepository.saveUserId(userId) } - suspend fun getAccessToken() = withContext(Dispatchers.IO) { - dataStoreRepository.getAccessToken().first() - } - - suspend fun getRefreshToken() = withContext(Dispatchers.IO) { - dataStoreRepository.getRefreshToken().first() - } - companion object { private const val KAKAO = "KAKAO" } From b7a887fc283b5b01b0118a87fdbb7448f98a96fb Mon Sep 17 00:00:00 2001 From: leeeha Date: Fri, 1 Mar 2024 21:21:08 +0900 Subject: [PATCH 15/26] =?UTF-8?q?[fix]=20#249=20WineyFeedGoalAdapter=20?= =?UTF-8?q?=EC=B4=88=EA=B8=B0=ED=99=94=20=EC=8B=9C=EC=A0=90=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 유저 데이터 조회 중일 때는 로딩 프로그레스바 띄우고 - 조회 완료되면 컨캣 어댑터 다시 초기화 하기 --- .../winey/presentation/main/MainViewModel.kt | 4 +- .../main/feed/WineyFeedFragment.kt | 53 +++++++++++----- .../main/feed/WineyFeedGoalAdapter.kt | 4 +- .../main/res/layout/fragment_winey_feed.xml | 60 +++++++++++-------- 4 files changed, 79 insertions(+), 42 deletions(-) diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/MainViewModel.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/MainViewModel.kt index 269da462..98e18ebd 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/MainViewModel.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/MainViewModel.kt @@ -26,7 +26,7 @@ class MainViewModel @Inject constructor( private val dataStoreRepository: DataStoreRepository, private val notificationRepository: NotificationRepository ) : ViewModel() { - private val _getUserState = MutableStateFlow>(UiState.Loading) + private val _getUserState = MutableStateFlow>(UiState.Empty) val getUserState: StateFlow> = _getUserState.asStateFlow() private val _logoutState = MutableStateFlow>(UiState.Empty) @@ -41,7 +41,7 @@ class MainViewModel @Inject constructor( authRepository.getUser() .onSuccess { response -> - Timber.e("SUCCESS GET USER IN MAIN") + Timber.d("SUCCESS GET USER IN MAIN") dataStoreRepository.saveUserInfo(response) _getUserState.value = UiState.Success(response) } diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt index 01a972cc..4bb7c9e0 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt @@ -17,12 +17,12 @@ import androidx.recyclerview.widget.SimpleItemAnimator import com.google.android.material.bottomnavigation.BottomNavigationView import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.flow.first -import kotlinx.coroutines.flow.firstOrNull import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.launch import org.go.sopt.winey.R import org.go.sopt.winey.databinding.FragmentWineyFeedBinding +import org.go.sopt.winey.domain.entity.UserV2 import org.go.sopt.winey.domain.entity.WineyFeed import org.go.sopt.winey.domain.repository.DataStoreRepository import org.go.sopt.winey.presentation.main.MainViewModel @@ -59,9 +59,9 @@ class WineyFeedFragment : private val viewModel by viewModels() private val mainViewModel by activityViewModels() private lateinit var wineyFeedAdapter: WineyFeedAdapter - private lateinit var wineyFeedHeaderAdapter: WineyFeedHeaderAdapter - private lateinit var wineyFeedGoalAdapter: WineyFeedGoalAdapter private lateinit var wineyFeedLoadAdapter: WineyFeedLoadAdapter + private lateinit var wineyFeedHeaderAdapter: WineyFeedHeaderAdapter + private var wineyFeedGoalAdapter: WineyFeedGoalAdapter? = null private var clickedFeedId = -1 @Inject @@ -107,7 +107,6 @@ class WineyFeedFragment : /** Adapter */ private fun initAdapter() { - initGoalAdapter() wineyFeedHeaderAdapter = WineyFeedHeaderAdapter( onBannerClicked = { navigateToWineyInstagram() @@ -127,21 +126,16 @@ class WineyFeedFragment : } ) wineyFeedLoadAdapter = WineyFeedLoadAdapter() + initConcatAdapter() + } + private fun initConcatAdapter() { binding.rvWineyfeedPost.adapter = ConcatAdapter( wineyFeedHeaderAdapter, - wineyFeedGoalAdapter, wineyFeedAdapter.withLoadStateFooter(wineyFeedLoadAdapter) ) } - private fun initGoalAdapter() { - viewLifeCycleScope.launch { - val user = dataStoreRepository.getUserInfo().firstOrNull() ?: return@launch - wineyFeedGoalAdapter = WineyFeedGoalAdapter(requireContext(), user) - } - } - private fun navigateToWineyInstagram() { val url = INSTAGRAM_URL val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) @@ -276,13 +270,25 @@ class WineyFeedFragment : mainViewModel.getUserState.flowWithLifecycle(viewLifeCycle) .onEach { state -> when (state) { + is UiState.Loading -> { + showLoadingProgressBar() + } + is UiState.Success -> { - // 피드 생성, 삭제에 따라 유저 데이터와 프로그레스바 갱신 val userInfo = state.data ?: return@onEach - wineyFeedGoalAdapter.updateProgressBar(userInfo) + + if (wineyFeedGoalAdapter == null) { + updateConcatAdapter(userInfo) + } else { + // 피드 생성, 삭제에 따라 유저 데이터와 프로그레스바 갱신 + wineyFeedGoalAdapter?.updateGoalProgressBar(userInfo) + } + + dismissLoadingProgressBar() } is UiState.Failure -> { + dismissLoadingProgressBar() snackBar(binding.root) { state.msg } } @@ -291,6 +297,25 @@ class WineyFeedFragment : }.launchIn(viewLifeCycleScope) } + private fun updateConcatAdapter(user: UserV2) { + wineyFeedGoalAdapter = WineyFeedGoalAdapter(requireContext(), user) + binding.rvWineyfeedPost.adapter = ConcatAdapter( + wineyFeedHeaderAdapter, + wineyFeedGoalAdapter, + wineyFeedAdapter.withLoadStateFooter(wineyFeedLoadAdapter) + ) + } + + private fun showLoadingProgressBar() { + binding.pbWineyfeedLoading.isVisible = true + binding.rvWineyfeedPost.isVisible = false + } + + private fun dismissLoadingProgressBar() { + binding.pbWineyfeedLoading.isVisible = false + binding.rvWineyfeedPost.isVisible = true + } + private fun initGetWineyFeedListStateObserver() { viewModel.getWineyFeedListState.flowWithLifecycle(viewLifeCycle) .onEach { state -> diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt index ba54b38a..19c4e87f 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt @@ -38,12 +38,12 @@ class WineyFeedGoalAdapter( isInitialized = true // 최초 1회만 실행 (아이템 뷰의 재활용에 따라 예전 데이터가 다시 바인딩 되는 문제 해결) - updateProgressBar(initialUser) + updateGoalProgressBar(initialUser) } } } - fun updateProgressBar(user: UserV2) { + fun updateGoalProgressBar(user: UserV2) { if (::binding.isInitialized) { binding.user = user updateProgressBarRate(user) diff --git a/app/src/main/res/layout/fragment_winey_feed.xml b/app/src/main/res/layout/fragment_winey_feed.xml index 4293241b..829fd56d 100644 --- a/app/src/main/res/layout/fragment_winey_feed.xml +++ b/app/src/main/res/layout/fragment_winey_feed.xml @@ -4,6 +4,7 @@ xmlns:tools="http://schemas.android.com/tools"> + @@ -14,17 +15,19 @@ android:layout_height="match_parent"> + android:layout_height="wrap_content" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> - + + + + + + + android:clipToPadding="false" + android:nestedScrollingEnabled="false" + android:orientation="vertical" + android:paddingBottom="50dp" + app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" + tools:listitem="@layout/item_wineyfeed_post" /> - - - - + - From ad3134ab46498cc51eab36ea9b993360150097a9 Mon Sep 17 00:00:00 2001 From: leeeha Date: Fri, 1 Mar 2024 21:48:53 +0900 Subject: [PATCH 16/26] =?UTF-8?q?[refactor]=20#249=20=EB=B7=B0=ED=99=80?= =?UTF-8?q?=EB=8D=94=EC=97=90=EC=84=9C=EB=A7=8C=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EB=90=98=EB=8A=94=20=EB=B3=80=EC=88=98=EB=8A=94=20=EC=96=B4?= =?UTF-8?q?=EB=8C=91=ED=84=B0=EA=B0=80=20=EC=95=84=EB=8B=8C=20=EB=B7=B0?= =?UTF-8?q?=ED=99=80=EB=8D=94=EC=9D=98=20=ED=94=84=EB=A1=9C=ED=8D=BC?= =?UTF-8?q?=ED=8B=B0=EB=A1=9C=20=EC=A0=95=EC=9D=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/main/feed/WineyFeedGoalAdapter.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt index 19c4e87f..1852e010 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt @@ -8,6 +8,7 @@ import org.go.sopt.winey.R import org.go.sopt.winey.databinding.ItemWineyfeedGoalBinding import org.go.sopt.winey.domain.entity.UserV2 import org.go.sopt.winey.presentation.model.UserLevel +import timber.log.Timber import kotlin.math.roundToInt class WineyFeedGoalAdapter( @@ -15,9 +16,9 @@ class WineyFeedGoalAdapter( private val initialUser: UserV2 ) : RecyclerView.Adapter() { private lateinit var binding: ItemWineyfeedGoalBinding - private var isInitialized = false override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): WineyFeedGoalViewHolder { + Timber.d("onCreateViewHolder") binding = ItemWineyfeedGoalBinding.inflate( LayoutInflater.from(parent.context), parent, @@ -27,17 +28,20 @@ class WineyFeedGoalAdapter( } override fun onBindViewHolder(holder: WineyFeedGoalViewHolder, position: Int) { + Timber.d("onBindViewHolder") holder.bind() } override fun getItemCount(): Int = ITEM_COUNT - inner class WineyFeedGoalViewHolder : RecyclerView.ViewHolder(binding.root) { + inner class WineyFeedGoalViewHolder: RecyclerView.ViewHolder(binding.root) { + private var isInitialized = false + fun bind() { if (!isInitialized) { isInitialized = true - // 최초 1회만 실행 (아이템 뷰의 재활용에 따라 예전 데이터가 다시 바인딩 되는 문제 해결) + // 초기 유저 데이터로 최초 1회만 바인딩 updateGoalProgressBar(initialUser) } } @@ -45,6 +49,7 @@ class WineyFeedGoalAdapter( fun updateGoalProgressBar(user: UserV2) { if (::binding.isInitialized) { + // 피드 생성, 삭제에 따라 바뀌는 유저 데이터 반영 binding.user = user updateProgressBarRate(user) } From 38599e1a10c2da05394fc4989e25bb027ab9315a Mon Sep 17 00:00:00 2001 From: leeeha Date: Fri, 1 Mar 2024 21:51:14 +0900 Subject: [PATCH 17/26] =?UTF-8?q?[chore]=20#249=20ktlint=20=EB=B0=98?= =?UTF-8?q?=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt | 2 +- .../sopt/winey/presentation/onboarding/login/LoginActivity.kt | 1 - .../winey/presentation/onboarding/login/LoginViewModel.kt | 4 ---- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt index 1852e010..d62b40d8 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt @@ -34,7 +34,7 @@ class WineyFeedGoalAdapter( override fun getItemCount(): Int = ITEM_COUNT - inner class WineyFeedGoalViewHolder: RecyclerView.ViewHolder(binding.root) { + inner class WineyFeedGoalViewHolder : RecyclerView.ViewHolder(binding.root) { private var isInitialized = false fun bind() { diff --git a/app/src/main/java/org/go/sopt/winey/presentation/onboarding/login/LoginActivity.kt b/app/src/main/java/org/go/sopt/winey/presentation/onboarding/login/LoginActivity.kt index f13b609f..19b6a21d 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/onboarding/login/LoginActivity.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/onboarding/login/LoginActivity.kt @@ -20,7 +20,6 @@ import org.go.sopt.winey.util.context.snackBar import org.go.sopt.winey.util.view.UiState import org.json.JSONException import org.json.JSONObject -import timber.log.Timber import javax.inject.Inject @AndroidEntryPoint diff --git a/app/src/main/java/org/go/sopt/winey/presentation/onboarding/login/LoginViewModel.kt b/app/src/main/java/org/go/sopt/winey/presentation/onboarding/login/LoginViewModel.kt index 355e98d0..21f30781 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/onboarding/login/LoginViewModel.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/onboarding/login/LoginViewModel.kt @@ -9,16 +9,12 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow -import kotlinx.coroutines.flow.first import kotlinx.coroutines.launch -import kotlinx.coroutines.withContext import org.go.sopt.winey.data.model.remote.request.RequestLoginDto import org.go.sopt.winey.data.model.remote.response.ResponseLoginDto -import org.go.sopt.winey.domain.entity.UserV2 import org.go.sopt.winey.domain.repository.AuthRepository import org.go.sopt.winey.domain.repository.DataStoreRepository import org.go.sopt.winey.domain.repository.KakaoLoginRepository -import org.go.sopt.winey.presentation.main.MainViewModel import org.go.sopt.winey.util.view.UiState import retrofit2.HttpException import timber.log.Timber From 4e0931fc20b464f8fc26648dc84864c58db39625 Mon Sep 17 00:00:00 2001 From: leeeha Date: Sat, 2 Mar 2024 00:25:40 +0900 Subject: [PATCH 18/26] =?UTF-8?q?[del]=20#249=20=EB=A7=88=EC=9D=B4?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=ED=94=84=EB=9E=98=EA=B7=B8?= =?UTF-8?q?=EB=A8=BC=ED=8A=B8=EC=97=90=EC=84=9C=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/mypage/MyPageFragment.kt | 15 ------- .../main/mypage/MyPageViewModel.kt | 44 ------------------- 2 files changed, 59 deletions(-) delete mode 100644 app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageViewModel.kt diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageFragment.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageFragment.kt index 5db45c08..bc86b9e0 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageFragment.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageFragment.kt @@ -41,7 +41,6 @@ import javax.inject.Inject @AndroidEntryPoint class MyPageFragment : BindingFragment(R.layout.fragment_my_page) { private val mainViewModel by activityViewModels() - private val myPageViewModel by viewModels() @Inject lateinit var dataStoreRepository: DataStoreRepository @@ -160,13 +159,6 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ } } - private fun navigateToGuideScreen() { - Intent(requireContext(), GuideActivity::class.java).apply { - addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK) - startActivity(this) - } - } - private fun navigateToNicknameScreen() { Intent(requireContext(), NicknameActivity::class.java).apply { putExtra(KEY_PREV_SCREEN_NAME, VAL_MY_PAGE_SCREEN) @@ -213,13 +205,6 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ amplitudeUtils.logEvent("view_goalsetting") } - private inline fun navigateAndBackStack() { - parentFragmentManager.commit { - replace(R.id.fcv_main, T::class.simpleName) - addToBackStack(null) - } - } - companion object { private const val KEY_PREV_SCREEN_NAME = "PREV_SCREEN_NAME" private const val VAL_MY_PAGE_SCREEN = "MyPageFragment" diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageViewModel.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageViewModel.kt deleted file mode 100644 index 6bf730d8..00000000 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageViewModel.kt +++ /dev/null @@ -1,44 +0,0 @@ -package org.go.sopt.winey.presentation.main.mypage - -import androidx.lifecycle.ViewModel -import androidx.lifecycle.viewModelScope -import dagger.hilt.android.lifecycle.HiltViewModel -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.StateFlow -import kotlinx.coroutines.flow.asStateFlow -import kotlinx.coroutines.launch -import org.go.sopt.winey.domain.repository.AuthRepository -import org.go.sopt.winey.domain.repository.DataStoreRepository -import org.go.sopt.winey.util.view.UiState -import retrofit2.HttpException -import timber.log.Timber -import javax.inject.Inject - -@HiltViewModel -class MyPageViewModel @Inject constructor( - private val authRepository: AuthRepository, - private val dataStoreRepository: DataStoreRepository -) : ViewModel() { - private val _deleteUserState = MutableStateFlow>(UiState.Empty) - val deleteUserState: StateFlow> = _deleteUserState.asStateFlow() - - fun deleteUser() { - viewModelScope.launch { - authRepository.deleteUser() - .onSuccess { response -> - Timber.d("SUCCESS DELETE USER") - _deleteUserState.value = UiState.Success(response) - } - .onFailure { t -> - _deleteUserState.value = UiState.Failure(t.message.toString()) - - if (t is HttpException) { - Timber.e("HTTP FAIL DELETE USER: ${t.code()} ${t.message}") - return@onFailure - } - - Timber.e("FAIL DELETE USER: ${t.message}") - } - } - } -} From 8f479efb2894f72d162ab649ae09aeb855a0c6b7 Mon Sep 17 00:00:00 2001 From: leeeha Date: Sat, 2 Mar 2024 00:29:58 +0900 Subject: [PATCH 19/26] =?UTF-8?q?[del]=20#249=20=EB=8D=94=EC=9D=B4?= =?UTF-8?q?=EC=83=81=20=EC=82=AC=EC=9A=A9=ED=95=98=EC=A7=80=20=EC=95=8A?= =?UTF-8?q?=EB=8A=94=20=EC=BD=94=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/main/feed/WineyFeedFragment.kt | 8 +------- .../presentation/main/mypage/MyPageFragment.kt | 15 +-------------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt index 4bb7c9e0..169871ff 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt @@ -533,13 +533,8 @@ class WineyFeedFragment : } private fun navigateToMyPageWithBundle() { - val myPageFragment = MyPageFragment().apply { - arguments = Bundle().apply { - putBoolean(KEY_FROM_WINEY_FEED, true) - } - } activity?.supportFragmentManager?.commit { - replace(R.id.fcv_main, myPageFragment) + replace(R.id.fcv_main, MyPageFragment()) } syncBnvSelectedItem() } @@ -557,7 +552,6 @@ class WineyFeedFragment : private const val TAG_FEED_REPORT_DIALOG = "FEED_REPORT_DIALOG" private const val TAG_UPLOAD_DIALOG = "UPLOAD_DIALOG" - private const val KEY_FROM_WINEY_FEED = "fromWineyFeed" private const val KEY_FEED_ID = "feedId" private const val KEY_FEED_WRITER_ID = "feedWriterId" const val KEY_FEED_TYPE = "feedType" diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageFragment.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageFragment.kt index bc86b9e0..94d2868a 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageFragment.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageFragment.kt @@ -52,15 +52,12 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) amplitudeUtils.logEvent("view_mypage") - initCheckNotificationPermission() + initCheckNotificationPermission() initUserData() initNavigation() - addListener() addObserver() - - checkFromWineyFeed() } private fun addListener() { @@ -72,8 +69,6 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ private fun addObserver() { setupGetUserState() - - checkFromWineyFeed() } private fun initCheckNotificationPermission() { @@ -95,13 +90,6 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ initCheckNotificationPermission() } - private fun checkFromWineyFeed() { - val isFromWineyFeed = arguments?.getBoolean(KEY_FROM_WINEY_FEED) - if (isFromWineyFeed == true) { - showTargetSettingBottomSheet() - } - } - private fun initEditNicknameButtonClickListener() { binding.ivMypageEditNickname.setOnSingleClickListener { navigateToNicknameScreen() @@ -209,7 +197,6 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ private const val KEY_PREV_SCREEN_NAME = "PREV_SCREEN_NAME" private const val VAL_MY_PAGE_SCREEN = "MyPageFragment" private const val KEY_FROM_NOTI = "fromNoti" - private const val KEY_FROM_WINEY_FEED = "fromWineyFeed" private const val KEY_TO_MYFEED = "toMyFeed" } } From 38a4d9b1e9b7a4fcf2e39a446e609fcc9bf0314f Mon Sep 17 00:00:00 2001 From: leeeha Date: Sat, 2 Mar 2024 00:29:58 +0900 Subject: [PATCH 20/26] =?UTF-8?q?[del]=20#249=20=EB=8D=94=EC=9D=B4?= =?UTF-8?q?=EC=83=81=20=EC=82=AC=EC=9A=A9=ED=95=98=EC=A7=80=20=EC=95=8A?= =?UTF-8?q?=EB=8A=94=20=EC=BD=94=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/feed/WineyFeedFragment.kt | 8 +------- .../main/mypage/MyPageFragment.kt | 20 +------------------ 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt index 4bb7c9e0..169871ff 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt @@ -533,13 +533,8 @@ class WineyFeedFragment : } private fun navigateToMyPageWithBundle() { - val myPageFragment = MyPageFragment().apply { - arguments = Bundle().apply { - putBoolean(KEY_FROM_WINEY_FEED, true) - } - } activity?.supportFragmentManager?.commit { - replace(R.id.fcv_main, myPageFragment) + replace(R.id.fcv_main, MyPageFragment()) } syncBnvSelectedItem() } @@ -557,7 +552,6 @@ class WineyFeedFragment : private const val TAG_FEED_REPORT_DIALOG = "FEED_REPORT_DIALOG" private const val TAG_UPLOAD_DIALOG = "UPLOAD_DIALOG" - private const val KEY_FROM_WINEY_FEED = "fromWineyFeed" private const val KEY_FEED_ID = "feedId" private const val KEY_FEED_WRITER_ID = "feedWriterId" const val KEY_FEED_TYPE = "feedType" diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageFragment.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageFragment.kt index bc86b9e0..c7aca66e 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageFragment.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageFragment.kt @@ -8,11 +8,7 @@ import android.os.Bundle import android.view.View import androidx.activity.OnBackPressedCallback import androidx.core.content.ContextCompat -import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels -import androidx.fragment.app.commit -import androidx.fragment.app.replace -import androidx.fragment.app.viewModels import androidx.lifecycle.flowWithLifecycle import androidx.lifecycle.lifecycleScope import dagger.hilt.android.AndroidEntryPoint @@ -29,7 +25,6 @@ import org.go.sopt.winey.presentation.main.mypage.myfeed.MyFeedActivity import org.go.sopt.winey.presentation.main.mypage.setting.SettingActivity import org.go.sopt.winey.presentation.main.notification.NotificationActivity import org.go.sopt.winey.presentation.nickname.NicknameActivity -import org.go.sopt.winey.presentation.onboarding.guide.GuideActivity import org.go.sopt.winey.util.amplitude.AmplitudeUtils import org.go.sopt.winey.util.binding.BindingFragment import org.go.sopt.winey.util.fragment.snackBar @@ -52,15 +47,12 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) amplitudeUtils.logEvent("view_mypage") - initCheckNotificationPermission() + initCheckNotificationPermission() initUserData() initNavigation() - addListener() addObserver() - - checkFromWineyFeed() } private fun addListener() { @@ -72,8 +64,6 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ private fun addObserver() { setupGetUserState() - - checkFromWineyFeed() } private fun initCheckNotificationPermission() { @@ -95,13 +85,6 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ initCheckNotificationPermission() } - private fun checkFromWineyFeed() { - val isFromWineyFeed = arguments?.getBoolean(KEY_FROM_WINEY_FEED) - if (isFromWineyFeed == true) { - showTargetSettingBottomSheet() - } - } - private fun initEditNicknameButtonClickListener() { binding.ivMypageEditNickname.setOnSingleClickListener { navigateToNicknameScreen() @@ -209,7 +192,6 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ private const val KEY_PREV_SCREEN_NAME = "PREV_SCREEN_NAME" private const val VAL_MY_PAGE_SCREEN = "MyPageFragment" private const val KEY_FROM_NOTI = "fromNoti" - private const val KEY_FROM_WINEY_FEED = "fromWineyFeed" private const val KEY_TO_MYFEED = "toMyFeed" } } From ac1b44c9ee8b339f3554b51c2b29e10ab1fd49d5 Mon Sep 17 00:00:00 2001 From: leeeha Date: Sat, 2 Mar 2024 19:21:38 +0900 Subject: [PATCH 21/26] =?UTF-8?q?[del]=20#247=20=EB=8D=94=EC=9D=B4?= =?UTF-8?q?=EC=83=81=20=EC=82=AC=EC=9A=A9=ED=95=98=EC=A7=80=20=EC=95=8A?= =?UTF-8?q?=EB=8A=94=20=EB=AA=A9=ED=91=9C=EC=84=A4=EC=A0=95=20=EB=8B=A4?= =?UTF-8?q?=EC=9D=B4=EC=96=BC=EB=A1=9C=EA=B7=B8=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/feed/WineyFeedFragment.kt | 55 +------------------ 1 file changed, 2 insertions(+), 53 deletions(-) diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt index c887dda0..8fb982a8 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt @@ -475,23 +475,6 @@ class WineyFeedFragment : } /** Amplitude Event Tagging */ - private fun sendDialogClickEvent(isNavigate: Boolean) { - val eventProperties = JSONObject() - - try { - if (isNavigate) { - eventProperties.put("method", "yes") - } else { - eventProperties.put("method", "no") - } - } catch (e: JSONException) { - System.err.println("Invalid JSON") - e.printStackTrace() - } - - amplitudeUtils.logEvent("click_goalsetting", eventProperties) - } - private fun sendWineyFeedEvent(type: EventType, feed: WineyFeed) { val eventProperties = JSONObject() @@ -521,46 +504,11 @@ class WineyFeedFragment : } } - private fun showDefaultGoalSettingDialog() { - amplitudeUtils.logEvent("view_goalsetting_popup") - - val dialog = WineyDialogFragment.newInstance( - WineyDialogLabel( - stringOf(R.string.wineyfeed_goal_dialog_title), - stringOf(R.string.wineyfeed_goal_dialog_subtitle), - stringOf(R.string.wineyfeed_goal_dialog_negative_button), - stringOf(R.string.wineyfeed_goal_dialog_positive_button) - ), - handleNegativeButton = { - sendDialogClickEvent(false) - }, - handlePositiveButton = { - sendDialogClickEvent(true) - navigateToMyPageWithBundle() - } - ) - - activity?.supportFragmentManager?.let { dialog.show(it, TAG_DEFAULT_GOAL_SETTING_DIALOG) } - } - - private fun navigateToMyPageWithBundle() { - activity?.supportFragmentManager?.commit { - replace(R.id.fcv_main, MyPageFragment()) - } - syncBnvSelectedItem() - } - - private fun syncBnvSelectedItem() { - val bottomNav: BottomNavigationView = requireActivity().findViewById(R.id.bnv_main) - bottomNav.selectedItemId = R.id.menu_mypage - } - companion object { private const val INSTAGRAM_URL = "https://instagram.com/winey__official?igshid=MzRlODBiNWFlZA==" - private const val MSG_WINEYFEED_ERROR = "ERROR" - private const val TAG_DEFAULT_GOAL_SETTING_DIALOG = "DEFAULT_GOAL_SETTING_DIALOG" + private const val TAG_FEED_DELETE_DIALOG = "FEED_DELETE_DIALOG" private const val TAG_FEED_REPORT_DIALOG = "FEED_REPORT_DIALOG" private const val TAG_UPLOAD_DIALOG = "UPLOAD_DIALOG" @@ -570,6 +518,7 @@ class WineyFeedFragment : private const val WINEY_FEED_SCREEN = "WineyFeedFragment" private const val KEY_FEED_ID = "feedId" private const val KEY_FEED_WRITER_ID = "feedWriterId" + const val KEY_FEED_TYPE = "feedType" const val KEY_LEVEL_UP = "LEVEL_UP_MOMENT" } From f97d002f12083fe4476a188e9df1bf832b745d1f Mon Sep 17 00:00:00 2001 From: leeeha Date: Sat, 2 Mar 2024 19:23:23 +0900 Subject: [PATCH 22/26] =?UTF-8?q?[del]=20#247=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EB=A1=9C=EA=B7=B8=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt index 24f53afa..eb14283d 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt @@ -8,6 +8,7 @@ import org.go.sopt.winey.R import org.go.sopt.winey.databinding.ItemWineyfeedGoalBinding import org.go.sopt.winey.domain.entity.UserV2 import org.go.sopt.winey.presentation.model.UserLevel +import timber.log.Timber import kotlin.math.roundToInt class WineyFeedGoalAdapter( @@ -17,7 +18,6 @@ class WineyFeedGoalAdapter( private lateinit var binding: ItemWineyfeedGoalBinding override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): WineyFeedGoalViewHolder { - Timber.d("onCreateViewHolder") binding = ItemWineyfeedGoalBinding.inflate( LayoutInflater.from(parent.context), parent, @@ -27,7 +27,6 @@ class WineyFeedGoalAdapter( } override fun onBindViewHolder(holder: WineyFeedGoalViewHolder, position: Int) { - Timber.d("onBindViewHolder") holder.bind() } From d88111d299da6200fd66b598aaa429c3c709baf7 Mon Sep 17 00:00:00 2001 From: leeeha Date: Sat, 2 Mar 2024 19:31:53 +0900 Subject: [PATCH 23/26] =?UTF-8?q?[chore]=20#247=20ktlint=20=EB=B0=98?= =?UTF-8?q?=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt | 3 --- .../sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt | 1 - 2 files changed, 4 deletions(-) diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt index 8fb982a8..dd04f690 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt @@ -6,7 +6,6 @@ import android.os.Bundle import android.view.View import androidx.core.view.isVisible import androidx.fragment.app.activityViewModels -import androidx.fragment.app.commit import androidx.fragment.app.viewModels import androidx.lifecycle.flowWithLifecycle import androidx.lifecycle.lifecycleScope @@ -14,7 +13,6 @@ import androidx.paging.LoadState import androidx.paging.PagingData import androidx.recyclerview.widget.ConcatAdapter import androidx.recyclerview.widget.SimpleItemAnimator -import com.google.android.material.bottomnavigation.BottomNavigationView import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.launchIn @@ -28,7 +26,6 @@ import org.go.sopt.winey.domain.repository.DataStoreRepository import org.go.sopt.winey.presentation.main.MainViewModel import org.go.sopt.winey.presentation.main.feed.detail.DetailActivity import org.go.sopt.winey.presentation.main.feed.upload.UploadActivity -import org.go.sopt.winey.presentation.main.mypage.MyPageFragment import org.go.sopt.winey.presentation.main.mypage.goal.GoalPathActivity import org.go.sopt.winey.presentation.main.notification.NotificationActivity import org.go.sopt.winey.presentation.model.WineyDialogLabel diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt index eb14283d..06369ebe 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedGoalAdapter.kt @@ -8,7 +8,6 @@ import org.go.sopt.winey.R import org.go.sopt.winey.databinding.ItemWineyfeedGoalBinding import org.go.sopt.winey.domain.entity.UserV2 import org.go.sopt.winey.presentation.model.UserLevel -import timber.log.Timber import kotlin.math.roundToInt class WineyFeedGoalAdapter( From 6579265c58de376e975e9cd92b451b57b2587116 Mon Sep 17 00:00:00 2001 From: leeeha Date: Sat, 2 Mar 2024 19:44:06 +0900 Subject: [PATCH 24/26] =?UTF-8?q?[del]=20#247=20=EB=A7=88=EC=9D=B4?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=ED=94=84=EB=9E=98=EA=B7=B8?= =?UTF-8?q?=EB=A8=BC=ED=8A=B8=EC=97=90=EC=84=9C=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/mypage/MyPageFragment.kt | 96 +++++++------------ 1 file changed, 32 insertions(+), 64 deletions(-) diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageFragment.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageFragment.kt index 8dcc4fdb..db0ee8aa 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageFragment.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/MyPageFragment.kt @@ -1,18 +1,15 @@ package org.go.sopt.winey.presentation.main.mypage -import android.Manifest import android.content.Intent -import android.content.pm.PackageManager -import android.os.Build import android.os.Bundle import android.view.View import androidx.activity.OnBackPressedCallback -import androidx.core.content.ContextCompat import androidx.fragment.app.activityViewModels import androidx.lifecycle.flowWithLifecycle import androidx.lifecycle.lifecycleScope import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.flow.first +import kotlinx.coroutines.flow.firstOrNull import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.launch @@ -49,17 +46,32 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ super.onViewCreated(view, savedInstanceState) amplitudeUtils.logEvent("view_mypage") - initCheckNotificationPermission() initUserData() - initNavigation() addListener() addObserver() } + // 닉네임 액티비티 갔다가 다시 돌아왔을 때 유저 데이터 갱신하도록 + override fun onStart() { + super.onStart() + mainViewModel.getUser() + } + + private fun initUserData() { + viewLifeCycleScope.launch { + val userInfo = dataStoreRepository.getUserInfo().firstOrNull() ?: return@launch + updateUserInfo(userInfo) + } + } + + private fun updateUserInfo(data: UserV2) { + binding.data = data + } + private fun addListener() { initEditNicknameButtonClickListener() - initMyFeedButtonClickListener() initSettingButtonClickListener() + initMyFeedButtonClickListener() initGoalPathButtonClickListener() registerBackPressedCallback() } @@ -68,31 +80,18 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ setupGetUserState() } - private fun initCheckNotificationPermission() { - isNotificationPermissionAllowed = - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - ContextCompat.checkSelfPermission( - requireContext(), - Manifest.permission.POST_NOTIFICATIONS - ) == PackageManager.PERMISSION_GRANTED - } else { - true - } - } - - // 닉네임 액티비티 갔다가 다시 돌아왔을 때 유저 데이터 갱신하도록 - override fun onStart() { - super.onStart() - mainViewModel.getUser() - initCheckNotificationPermission() - } - private fun initEditNicknameButtonClickListener() { binding.ivMypageEditNickname.setOnSingleClickListener { navigateToNicknameScreen() } } + private fun initSettingButtonClickListener() { + binding.ivMypageSetting.setOnClickListener { + navigateToSettingScreen() + } + } + private fun initMyFeedButtonClickListener() { binding.btnMypageMyfeed.setOnSingleClickListener { navigateToMyFeedScreen() @@ -101,19 +100,7 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ private fun initGoalPathButtonClickListener() { binding.btnMypageTrip.setOnClickListener { - navigateToGoalPath() - } - } - - private fun navigateToGoalPath() { - Intent(requireContext(), GoalPathActivity::class.java).apply { - startActivity(this) - } - } - - private fun initSettingButtonClickListener() { - binding.ivMypageSetting.setOnClickListener { - navigateToSettingScreen() + navigateToGoalPathScreen() } } @@ -136,26 +123,6 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, callback) } - private fun initUserData() { - viewLifeCycleScope.launch { - val data = dataStoreRepository.getUserInfo().first() - if (data != null) { - updateUserInfo(data) - } - } - } - - private fun initNavigation() { - val receivedBundle = arguments - if (receivedBundle != null) { - val value = receivedBundle.getBoolean(KEY_TO_MYFEED) - if (value) { - navigateToMyFeedScreen() - arguments?.clear() - } - } - } - private fun navigateToNicknameScreen() { Intent(requireContext(), NicknameActivity::class.java).apply { putExtra(KEY_PREV_SCREEN_NAME, MY_PAGE_SCREEN) @@ -175,6 +142,12 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ } } + private fun navigateToGoalPathScreen() { + Intent(requireContext(), GoalPathActivity::class.java).apply { + startActivity(this) + } + } + private fun setupGetUserState() { mainViewModel.getUserState.flowWithLifecycle(lifecycle).onEach { state -> when (state) { @@ -192,14 +165,9 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ }.launchIn(lifecycleScope) } - private fun updateUserInfo(data: UserV2) { - binding.data = data - } - companion object { private const val KEY_PREV_SCREEN_NAME = "PREV_SCREEN_NAME" private const val MY_PAGE_SCREEN = "MyPageFragment" private const val KEY_FROM_NOTI = "fromNoti" - private const val KEY_TO_MYFEED = "toMyFeed" } } From cdefac67a20829a2900259f6832ad4ac6da94056 Mon Sep 17 00:00:00 2001 From: leeeha Date: Sat, 2 Mar 2024 19:45:48 +0900 Subject: [PATCH 25/26] =?UTF-8?q?[del]=20#247=20=EB=A7=88=EC=9D=B4?= =?UTF-8?q?=ED=94=BC=EB=93=9C=EA=B0=80=20=ED=94=84=EB=9E=98=EA=B7=B8?= =?UTF-8?q?=EB=A8=BC=ED=8A=B8=EC=97=90=EC=84=9C=20=EC=95=A1=ED=8B=B0?= =?UTF-8?q?=EB=B9=84=ED=8B=B0=EB=A1=9C=20=EB=B0=94=EB=80=8C=EB=A9=B4?= =?UTF-8?q?=EC=84=9C=20=EB=B6=88=ED=95=84=EC=9A=94=ED=95=B4=EC=A7=84=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../winey/presentation/main/MainActivity.kt | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/MainActivity.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/MainActivity.kt index ae3f926f..bc42c514 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/MainActivity.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/MainActivity.kt @@ -41,7 +41,6 @@ class MainActivity : BindingActivity(R.layout.activity_main private val isUploadSuccess by lazy { intent.getBooleanExtra(KEY_FEED_UPLOAD, false) } private val isDeleteSuccess by lazy { intent.getBooleanExtra(KEY_FEED_DELETE, false) } - private val prevScreenName by lazy { intent.getStringExtra(KEY_PREV_SCREEN) } private val notiType by lazy { intent.getStringExtra(KEY_NOTI_TYPE) } private val feedId by lazy { intent.getStringExtra(KEY_FEED_ID) } @@ -126,11 +125,7 @@ class MainActivity : BindingActivity(R.layout.activity_main return } - if (prevScreenName == MY_FEED_SCREEN) { - navigateToMyPageFragment(KEY_TO_MYFEED, true) - } else { - navigateTo() - } + navigateTo() } private fun showWineyFeedResultSnackBar() { @@ -205,12 +200,6 @@ class MainActivity : BindingActivity(R.layout.activity_main } } - private inline fun navigateTo() { - supportFragmentManager.commit { - replace(R.id.fcv_main, T::class.simpleName) - } - } - private fun navigateToMyPageFragment(key: String, value: Boolean) { supportFragmentManager.commit { val bundle = Bundle() @@ -234,19 +223,20 @@ class MainActivity : BindingActivity(R.layout.activity_main startActivity(intent) } + private inline fun navigateTo() { + supportFragmentManager.commit { + replace(R.id.fcv_main, T::class.simpleName) + } + } + companion object { private const val KEY_FEED_UPLOAD = "upload" private const val KEY_FEED_DELETE = "delete" - private const val KEY_NOTI_TYPE = "notiType" private const val KEY_FROM_NOTI = "fromNoti" - private const val KEY_TO_MYFEED = "toMyFeed" const val KEY_FEED_ID = "feedId" const val KEY_TO_MYPAGE = "navigateMypage" const val KEY_FROM_GOAL_PATH = "fromGoalPath" - - private const val KEY_PREV_SCREEN = "PREV_SCREEN_NAME" - private const val MY_FEED_SCREEN = "MyFeedFragment" } } From 631b635a92aed5d8d967e97a3095920e85e4738e Mon Sep 17 00:00:00 2001 From: leeeha Date: Sat, 2 Mar 2024 19:55:55 +0900 Subject: [PATCH 26/26] =?UTF-8?q?[refactor]=20#247=20=EB=AA=A9=ED=91=9C?= =?UTF-8?q?=EC=97=AC=EC=A0=95=20=EC=95=A1=ED=8B=B0=EB=B9=84=ED=8B=B0?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EC=82=AC=EC=9A=A9=EB=90=98=EB=8A=94=20?= =?UTF-8?q?=EC=9C=A0=EC=A0=80=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=A0=84?= =?UTF-8?q?=EC=97=AD=20=EB=B3=80=EC=88=98=EB=A1=9C=20=EC=84=A0=EC=96=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/mypage/goal/GoalPathActivity.kt | 75 ++++++++++--------- 1 file changed, 40 insertions(+), 35 deletions(-) diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/goal/GoalPathActivity.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/goal/GoalPathActivity.kt index 26122b00..ba8545b2 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/goal/GoalPathActivity.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/mypage/goal/GoalPathActivity.kt @@ -13,6 +13,7 @@ import kotlinx.coroutines.flow.firstOrNull import kotlinx.coroutines.launch import org.go.sopt.winey.R import org.go.sopt.winey.databinding.ActivityGoalPathBinding +import org.go.sopt.winey.domain.entity.UserV2 import org.go.sopt.winey.domain.repository.DataStoreRepository import org.go.sopt.winey.presentation.main.MainActivity import org.go.sopt.winey.presentation.main.feed.WineyFeedFragment @@ -23,6 +24,10 @@ import javax.inject.Inject @AndroidEntryPoint class GoalPathActivity : BindingActivity(R.layout.activity_goal_path) { + @Inject + lateinit var dataStoreRepository: DataStoreRepository + + private var userInfo: UserV2? = null private val levelUpFromWineyFeed by lazy { intent.getBooleanExtra( WineyFeedFragment.KEY_LEVEL_UP, @@ -30,47 +35,37 @@ class GoalPathActivity : BindingActivity(R.layout.activ ) } - @Inject - lateinit var dataStoreRepository: DataStoreRepository - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setupFragmentByLevel() + initUserData() initRemainingGoal() - + setupFragmentByLevel() initBackButtonClickListener() registerBackPressedCallback() } - private fun registerBackPressedCallback() { - val callback = object : OnBackPressedCallback(true) { - override fun handleOnBackPressed() { - if (levelUpFromWineyFeed) { - navigateToMainScreen() - } else { - finish() - } - } + private fun initUserData() { + lifecycleScope.launch { + userInfo = dataStoreRepository.getUserInfo().firstOrNull() ?: return@launch } - onBackPressedDispatcher.addCallback(this, callback) } - private fun initBackButtonClickListener() { - binding.ivGoalPathBack.setOnClickListener { - if (levelUpFromWineyFeed) { - navigateToMainScreen() - } else { - finish() - } + private fun initRemainingGoal() { + lifecycleScope.launch { + binding.tvGoalPathRemainingMoney.text = + getString( + R.string.goal_path_remaining_money, + userInfo?.remainingAmount?.formatAmountNumber() + ) + binding.tvGoalPathRemainingFeed.text = + getString(R.string.goal_path_remaining_feed, userInfo?.remainingCount) } } private fun setupFragmentByLevel() { lifecycleScope.launch { - val userInfo = dataStoreRepository.getUserInfo().firstOrNull() ?: return@launch - - when (userInfo.userLevel) { + when (userInfo?.userLevel) { UserLevel.FIRST.rankName -> { navigateTo() } @@ -105,19 +100,29 @@ class GoalPathActivity : BindingActivity(R.layout.activ } } - private fun initRemainingGoal() { - lifecycleScope.launch { - val userInfo = dataStoreRepository.getUserInfo().firstOrNull() ?: return@launch - binding.tvGoalPathRemainingMoney.text = - getString( - R.string.goal_path_remaining_money, - userInfo.remainingAmount.formatAmountNumber() - ) - binding.tvGoalPathRemainingFeed.text = - getString(R.string.goal_path_remaining_feed, userInfo.remainingCount) + private fun initBackButtonClickListener() { + binding.ivGoalPathBack.setOnClickListener { + if (levelUpFromWineyFeed) { + navigateToMainScreen() + } else { + finish() + } } } + private fun registerBackPressedCallback() { + val callback = object : OnBackPressedCallback(true) { + override fun handleOnBackPressed() { + if (levelUpFromWineyFeed) { + navigateToMainScreen() + } else { + finish() + } + } + } + onBackPressedDispatcher.addCallback(this, callback) + } + private fun navigateToMainScreen() { Intent(this@GoalPathActivity, MainActivity::class.java).apply { putExtra(MainActivity.KEY_FROM_GOAL_PATH, true)