Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] 카카오 공유하기 딥링크 구현 #119

Merged
merged 1 commit into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/src/main/java/com/dpm/spot/di/DataSourceModule.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.dpm.spot.di

import com.dpm.data.datasource.AuthDataSource
import com.dpm.data.datasource.ExampleDataSource
import com.dpm.data.datasource.HomeDataSource
import com.dpm.data.datasource.SeatReviewDataSource
import com.dpm.data.datasource.SignupRemoteDataSource
import com.dpm.data.datasource.ViewfinderDataSource
import com.dpm.data.datasource.WebSvgDataSource
import com.dpm.data.datasource.local.AuthDataSourceImpl
import com.dpm.data.datasource.remote.ExampleDataSourcelmpl
import com.dpm.data.datasource.remote.HomeDataSourceImpl
import com.dpm.data.datasource.remote.SeatReviewDataSourceImpl
Expand Down Expand Up @@ -57,4 +59,10 @@ abstract class DataSourceModule {
abstract fun bindSignupDataSource(
signupDataSourceImpl: SignupRemoteDataSourceImpl,
): SignupRemoteDataSource

@Binds
@Singleton
abstract fun bindAuthDataSource(
authDataSourceImpl: AuthDataSourceImpl
): AuthDataSource
}
8 changes: 8 additions & 0 deletions app/src/main/java/com/dpm/spot/di/RepositoryModule.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.dpm.spot.di

import com.dpm.data.repository.AuthRepositoryImpl
import com.dpm.data.repository.ExampleRepositoryImpl
import com.dpm.data.repository.HomeRepositoryImpl
import com.dpm.data.repository.SeatReviewRepositoryImpl
import com.dpm.data.repository.SignupRepositoryImpl
import com.dpm.data.repository.ViewfinderRepositoryImpl
import com.dpm.data.repository.WebSvgRepositoryImpl
import com.dpm.domain.repository.AuthRepository
import com.dpm.domain.repository.ExampleRepository
import com.dpm.domain.repository.HomeRepository
import com.dpm.domain.repository.SeatReviewRepository
Expand Down Expand Up @@ -57,4 +59,10 @@ abstract class RepositoryModule {
abstract fun bindSignupRepository(
signupRepositoryImpl: SignupRepositoryImpl,
): SignupRepository

@Binds
@Singleton
abstract fun bindAuthRepository(
authRepositoryImpl: AuthRepositoryImpl
): AuthRepository
}
4 changes: 4 additions & 0 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ object KotlinDependencies {
const val dateTime = "org.jetbrains.kotlinx:kotlinx-datetime:${Versions.kotlinDateTimeVersion}"
}

object JavaDependencies {
const val javaxInject = "javax.inject:javax.inject:1"
}

object AndroidXDependencies {
const val coreKtx = "androidx.core:core-ktx:${Versions.coreKtxVersion}"
const val appCompat = "androidx.appcompat:appcompat:${Versions.appCompatVersion}"
Expand Down
5 changes: 5 additions & 0 deletions data/src/main/java/com/dpm/data/datasource/AuthDataSource.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.dpm.data.datasource

interface AuthDataSource {
suspend fun getToken(): String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.dpm.data.datasource.local

import com.dpm.data.datasource.AuthDataSource
import com.dpm.domain.preference.SharedPreference
import javax.inject.Inject

class AuthDataSourceImpl @Inject constructor(
private val sharedPreference: SharedPreference
): AuthDataSource {
override suspend fun getToken(): String {
return sharedPreference.token
}
}
15 changes: 15 additions & 0 deletions data/src/main/java/com/dpm/data/repository/AuthRepositoryImpl.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.dpm.data.repository

import com.dpm.data.datasource.AuthDataSource
import com.dpm.domain.repository.AuthRepository
import javax.inject.Inject

class AuthRepositoryImpl @Inject constructor(
private val authDataSource: AuthDataSource
) : AuthRepository {
override suspend fun getToken(): Result<String> {
return runCatching {
authDataSource.getToken()
}
}
}
3 changes: 3 additions & 0 deletions domain/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ java {
}

dependencies {
JavaDependencies.run {
implementation(javaxInject)
}
KotlinDependencies.run {
implementation(kotlin)
implementation(coroutines)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.dpm.domain.repository

interface AuthRepository {
suspend fun getToken(): Result<String>
}
12 changes: 12 additions & 0 deletions domain/src/main/java/com/dpm/domain/usecase/GetTokenUseCase.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.dpm.domain.usecase

import com.dpm.domain.repository.AuthRepository
import javax.inject.Inject

class GetTokenUseCase @Inject constructor(
private val authRepository: AuthRepository
) {
suspend operator fun invoke(): Result<String> {
return authRepository.getToken()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.dpm.presentation.home
import ReviewData
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.View
import androidx.activity.viewModels
import androidx.lifecycle.asLiveData
Expand All @@ -16,10 +17,13 @@ import com.dpm.domain.entity.response.home.ResponseHomeFeed
import com.dpm.domain.entity.response.viewfinder.ResponseStadiums
import com.dpm.domain.model.seatreview.ReviewMethod
import com.dpm.presentation.extension.dpToPx
import com.dpm.presentation.extension.getCompatibleParcelableExtra
import com.dpm.presentation.home.adapter.StadiumAdapter
import com.dpm.presentation.home.dialog.LevelDescriptionDialog
import com.dpm.presentation.home.dialog.LevelupDialog
import com.dpm.presentation.home.viewmodel.HomeGuiViewModel
import com.dpm.presentation.scheme.SchemeKey
import com.dpm.presentation.scheme.viewmodel.SchemeState
import com.dpm.presentation.seatrecord.SeatRecordActivity
import com.dpm.presentation.seatrecord.adapter.LinearSpacingItemDecoration
import com.dpm.presentation.seatreview.dialog.ReviewTypeDialog
Expand All @@ -28,6 +32,7 @@ import com.dpm.presentation.seatreview.dialog.view.ViewUploadDialog
import com.dpm.presentation.setting.SettingActivity
import com.dpm.presentation.util.Utils
import com.dpm.presentation.viewfinder.StadiumActivity
import com.dpm.presentation.viewfinder.StadiumDetailActivity
import com.dpm.presentation.viewfinder.StadiumSelectionActivity
import dagger.hilt.android.AndroidEntryPoint

Expand Down Expand Up @@ -69,6 +74,7 @@ class HomeActivity : BaseActivity<ActivityHomeBinding>(
initViewStatusBar()
homeViewModel.getStadiums()
setStadiumAdapter()
handleIntentExtra()
}

private fun initReviewDialog() {
Expand Down Expand Up @@ -282,4 +288,14 @@ class HomeActivity : BaseActivity<ActivityHomeBinding>(
marginBottom = 94
).show()
}

private fun handleIntentExtra() {
val navReview = intent.getCompatibleParcelableExtra<SchemeState.NavReview>(SchemeKey.NAV_REVIEW)
if (navReview != null) {
Intent(this, StadiumDetailActivity::class.java).apply {
putExtra(SchemeKey.STADIUM_ID, navReview.stadiumId)
putExtra(SchemeKey.BLOCK_CODE, navReview.blockCode)
}.let { startActivity(it) }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ import androidx.compose.material.MaterialTheme
import androidx.lifecycle.asLiveData
import com.depromeet.presentation.databinding.FragmentKakaoSignupBinding
import com.dpm.core.base.BaseActivity
import com.dpm.presentation.extension.getCompatibleParcelableExtra
import com.dpm.presentation.extension.toast
import com.dpm.presentation.home.HomeActivity
import com.dpm.presentation.login.ui.compose.KakaoSignupScreen
import com.dpm.presentation.login.viewmodel.KakaoSignupViewModel
import com.dpm.presentation.login.viewmodel.LoginUiState
import com.dpm.presentation.scheme.SchemeKey
import com.dpm.presentation.scheme.viewmodel.SchemeState
import com.kakao.sdk.auth.model.OAuthToken
import com.kakao.sdk.common.model.ClientError
import com.kakao.sdk.common.model.ClientErrorCause
Expand Down Expand Up @@ -73,6 +76,15 @@ class KakaoSignupActivity : BaseActivity<FragmentKakaoSignupBinding>({
if (token.isNotEmpty()) {
Intent(this, NicknameInputActivity::class.java).apply {
putExtra("kakaoToken", token)
when (val data = handleIntentExtra()) {
is SchemeState.NavReview -> {
putExtra(SchemeKey.NAV_REVIEW, data)
}
is SchemeState.NavReviewDetail -> {
putExtra(SchemeKey.NAV_REVIEW_DETAIL, data)
}
else -> Unit
}
startActivity(this)
}
}
Expand All @@ -93,4 +105,19 @@ class KakaoSignupActivity : BaseActivity<FragmentKakaoSignupBinding>({
}
}
}

private fun handleIntentExtra(): SchemeState {
val navReview = intent.getCompatibleParcelableExtra<SchemeState.NavReview>(SchemeKey.NAV_REVIEW)
if (navReview != null) {
return navReview
}

val navReviewDetail = intent.getCompatibleParcelableExtra<SchemeState.NavReviewDetail>(
SchemeKey.NAV_REVIEW_DETAIL)
if (navReviewDetail != null) {
return navReviewDetail
}

return SchemeState.Nothing
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ import androidx.lifecycle.asLiveData
import com.depromeet.presentation.R
import com.depromeet.presentation.databinding.FragmentNicknameInputBinding
import com.dpm.core.base.BaseActivity
import com.dpm.presentation.extension.getCompatibleParcelableExtra
import com.dpm.presentation.login.viewmodel.NicknameInputState
import com.dpm.presentation.login.viewmodel.NicknameInputViewModel
import com.dpm.presentation.scheme.SchemeKey
import com.dpm.presentation.scheme.viewmodel.SchemeState
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
Expand Down Expand Up @@ -93,6 +96,15 @@ class NicknameInputActivity: BaseActivity<FragmentNicknameInputBinding>({
Intent(this@NicknameInputActivity, TeamSelectActivity::class.java).apply {
putExtra("nickname", etProfileEditNickname.text.toString())
putExtra("kakaoToken", intent.getStringExtra("kakaoToken"))
when (val data = handleIntentExtra()) {
is SchemeState.NavReview -> {
putExtra(SchemeKey.NAV_REVIEW, data)
}
is SchemeState.NavReviewDetail -> {
putExtra(SchemeKey.NAV_REVIEW_DETAIL, data)
}
else -> Unit
}
startActivity(this)
}
}
Expand Down Expand Up @@ -123,4 +135,19 @@ class NicknameInputActivity: BaseActivity<FragmentNicknameInputBinding>({
tvNicknameNextBtn.setBackgroundResource(R.drawable.rect_action_disabled_fill_8)
}
}

private fun handleIntentExtra(): SchemeState {
val navReview = intent.getCompatibleParcelableExtra<SchemeState.NavReview>(SchemeKey.NAV_REVIEW)
if (navReview != null) {
return navReview
}

val navReviewDetail = intent.getCompatibleParcelableExtra<SchemeState.NavReviewDetail>(
SchemeKey.NAV_REVIEW_DETAIL)
if (navReviewDetail != null) {
return navReviewDetail
}

return SchemeState.Nothing
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import androidx.lifecycle.lifecycleScope
import com.depromeet.presentation.databinding.ActivitySignupBinding
import com.dpm.core.base.BaseActivity
import com.dpm.domain.preference.SharedPreference
import com.dpm.presentation.extension.getCompatibleParcelableExtra
import com.dpm.presentation.home.HomeActivity
import com.dpm.presentation.scheme.SchemeKey
import com.dpm.presentation.scheme.viewmodel.SchemeState
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -41,8 +44,31 @@ class SignUpActivity : BaseActivity<ActivitySignupBinding>({
private fun navigateToNextScreen(destinationClass: Class<*>) {
Intent(this@SignUpActivity, destinationClass).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
when (val data = handleIntentExtra()) {
is SchemeState.NavReview -> {
putExtra(SchemeKey.NAV_REVIEW, data)
}
is SchemeState.NavReviewDetail -> {
putExtra(SchemeKey.NAV_REVIEW_DETAIL, data)
}
else -> Unit
}
startActivity(this)
finish()
}
}

private fun handleIntentExtra(): SchemeState {
val navReview = intent.getCompatibleParcelableExtra<SchemeState.NavReview>(SchemeKey.NAV_REVIEW)
if (navReview != null) {
return navReview
}

val navReviewDetail = intent.getCompatibleParcelableExtra<SchemeState.NavReviewDetail>(SchemeKey.NAV_REVIEW_DETAIL)
if (navReviewDetail != null) {
return navReviewDetail
}

return SchemeState.Nothing
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import android.text.SpannableString
import android.text.style.ForegroundColorSpan
import com.depromeet.presentation.databinding.ActivitySignupCompleteBinding
import com.dpm.core.base.BaseActivity
import com.dpm.presentation.extension.getCompatibleParcelableExtra
import com.dpm.presentation.home.HomeActivity
import com.dpm.presentation.scheme.SchemeKey
import com.dpm.presentation.scheme.viewmodel.SchemeState

class SignUpCompleteActivity : BaseActivity<ActivitySignupCompleteBinding>(
{ ActivitySignupCompleteBinding.inflate(it) }
Expand Down Expand Up @@ -59,9 +62,33 @@ class SignUpCompleteActivity : BaseActivity<ActivitySignupCompleteBinding>(
binding.tvSignupCompleteBtn.setOnClickListener {
Intent(this, HomeActivity::class.java).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
when (val data = handleIntentExtra()) {
is SchemeState.NavReview -> {
putExtra(SchemeKey.NAV_REVIEW, data)
}
is SchemeState.NavReviewDetail -> {
putExtra(SchemeKey.NAV_REVIEW_DETAIL, data)
}
else -> Unit
}
startActivity(this)
finish()
}
}
}

private fun handleIntentExtra(): SchemeState {
val navReview = intent.getCompatibleParcelableExtra<SchemeState.NavReview>(SchemeKey.NAV_REVIEW)
if (navReview != null) {
return navReview
}

val navReviewDetail = intent.getCompatibleParcelableExtra<SchemeState.NavReviewDetail>(
SchemeKey.NAV_REVIEW_DETAIL)
if (navReviewDetail != null) {
return navReviewDetail
}

return SchemeState.Nothing
}
}
Loading
Loading