Skip to content

Commit

Permalink
#180 / 초대 코드 저장 후 재접속 시 보여주기
Browse files Browse the repository at this point in the history
  • Loading branch information
haeti-dev committed Dec 20, 2023
1 parent 56eb692 commit fa94321
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() }
Expand Down Expand Up @@ -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"
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/java/sopt/uni/presentation/IntroActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<HomeActivity>()
Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK
} else if (SparkleStorage.partnerId == -1 && SparkleStorage.coupleId != -1) {
startActivity<ShareInviteCodeActivity>()
Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK
} else {
startActivity<NickNameActivity>()
Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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이 반환되었습니다.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
Expand All @@ -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() {
Expand Down

0 comments on commit fa94321

Please sign in to comment.