From 66dfc9ef7050bfb958266bf610a2c1e518151321 Mon Sep 17 00:00:00 2001 From: HaeTi Date: Thu, 21 Dec 2023 00:23:11 +0900 Subject: [PATCH] =?UTF-8?q?#180=20/=20=EC=B4=88=EB=8C=80=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=A0=80=EC=9E=A5=20=ED=9B=84=20=EC=9E=AC=EC=A0=91?= =?UTF-8?q?=EC=86=8D=20=EC=8B=9C=20=EB=B3=B4=EC=97=AC=EC=A3=BC=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/sopt/uni/data/datasource/local/SparkleStorage.kt | 5 +++++ app/src/main/java/sopt/uni/presentation/IntroActivity.kt | 6 +++++- .../main/java/sopt/uni/presentation/invite/DdayViewModel.kt | 1 + .../sopt/uni/presentation/invite/ShareInviteCodeActivity.kt | 6 ++---- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/sopt/uni/data/datasource/local/SparkleStorage.kt b/app/src/main/java/sopt/uni/data/datasource/local/SparkleStorage.kt index 23e0b467..b9a948fa 100644 --- a/app/src/main/java/sopt/uni/data/datasource/local/SparkleStorage.kt +++ b/app/src/main/java/sopt/uni/data/datasource/local/SparkleStorage.kt @@ -63,6 +63,10 @@ object SparkleStorage { get() = pref.getInt(COUPLE_ID, -1) set(value) = pref.edit { putInt(COUPLE_ID, value ?: -1).apply() } + var inviteCode: String? + get() = pref.getString(INVITE_CODE, EMPTY_TEXT) + set(value) = pref.edit { putString(INVITE_CODE, value).apply() } + var isActive: Boolean get() = prefTimer.getBoolean(ACTIVEKEY, false) set(value) = prefTimer.edit { putBoolean(ACTIVEKEY, value).apply() } @@ -98,6 +102,7 @@ const val AUTH = "auth" const val USER_ID = "userId" const val PARTNER_ID = "partnerId" const val COUPLE_ID = "coupleId" +const val INVITE_CODE = "inviteCode" const val NAME = "timer_prefs" const val ACTIVEKEY = "isTimerActive" const val TOTALTIMEKEY = "totalTime" diff --git a/app/src/main/java/sopt/uni/presentation/IntroActivity.kt b/app/src/main/java/sopt/uni/presentation/IntroActivity.kt index c5938edb..a6957ac1 100644 --- a/app/src/main/java/sopt/uni/presentation/IntroActivity.kt +++ b/app/src/main/java/sopt/uni/presentation/IntroActivity.kt @@ -10,6 +10,7 @@ import sopt.uni.data.datasource.local.SparkleStorage import sopt.uni.data.repository.shortgame.ShortGameRepository import sopt.uni.presentation.home.HomeActivity import sopt.uni.presentation.invite.NickNameActivity +import sopt.uni.presentation.invite.ShareInviteCodeActivity import sopt.uni.presentation.onboarding.OnBoardingActivity import sopt.uni.util.extension.startActivity import javax.inject.Inject @@ -32,9 +33,12 @@ class IntroActivity : AppCompatActivity() { if (SparkleStorage.accessToken != null) { Log.e("accessToken", SparkleStorage.accessToken.toString()) Log.e("partnerId", SparkleStorage.partnerId.toString()) - if (SparkleStorage.partnerId != -1) { + if (SparkleStorage.partnerId != -1 && SparkleStorage.coupleId != -1) { startActivity() Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK + } else if (SparkleStorage.partnerId == -1 && SparkleStorage.coupleId != -1) { + startActivity() + Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK } else { startActivity() Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK diff --git a/app/src/main/java/sopt/uni/presentation/invite/DdayViewModel.kt b/app/src/main/java/sopt/uni/presentation/invite/DdayViewModel.kt index fc41f72c..60a9854f 100644 --- a/app/src/main/java/sopt/uni/presentation/invite/DdayViewModel.kt +++ b/app/src/main/java/sopt/uni/presentation/invite/DdayViewModel.kt @@ -27,6 +27,7 @@ class DdayViewModel @Inject constructor( it.body()?.let { response -> Timber.d("기념일 갱신이 성공했습니다.") _inviteCode.value = response.inviteCode + SparkleStorage.inviteCode = response.inviteCode SparkleStorage.coupleId = response.coupleId } ?: run { Timber.d("기념일 갱신에서 null이 반환되었습니다.") diff --git a/app/src/main/java/sopt/uni/presentation/invite/ShareInviteCodeActivity.kt b/app/src/main/java/sopt/uni/presentation/invite/ShareInviteCodeActivity.kt index 26b9330a..7a089d61 100644 --- a/app/src/main/java/sopt/uni/presentation/invite/ShareInviteCodeActivity.kt +++ b/app/src/main/java/sopt/uni/presentation/invite/ShareInviteCodeActivity.kt @@ -9,15 +9,14 @@ import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import sopt.uni.R +import sopt.uni.data.datasource.local.SparkleStorage import sopt.uni.databinding.ActivityShareInviteCodeBinding -import sopt.uni.presentation.common.content.INVITECODE import sopt.uni.presentation.home.HomeActivity import sopt.uni.util.UiState import sopt.uni.util.binding.BindingActivity import sopt.uni.util.extension.setOnSingleClickListener import sopt.uni.util.extension.showToast import sopt.uni.util.extension.startActivity -import timber.log.Timber @AndroidEntryPoint class ShareInviteCodeActivity : @@ -34,8 +33,7 @@ class ShareInviteCodeActivity : } private fun getInviteCode() { - Timber.e(intent.getStringExtra(INVITECODE)) - binding.tvInviteCode.text = intent.getStringExtra(INVITECODE) + binding.tvInviteCode.text = SparkleStorage.inviteCode } private fun moveToPrevPage() {