-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
225 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
android/app/src/main/java/com/woowacourse/friendogly/application/FriendoglyApplication.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,24 @@ | ||
package com.woowacourse.friendogly.application | ||
|
||
import android.app.Application | ||
import com.kakao.sdk.common.KakaoSdk | ||
import com.naver.maps.map.NaverMapSdk | ||
import com.woowacourse.friendogly.BuildConfig | ||
import com.woowacourse.friendogly.kakao.di.KakaoModule | ||
|
||
class FriendoglyApplication : Application() { | ||
override fun onCreate() { | ||
super.onCreate() | ||
initNaverMapSdk() | ||
KakaoSdk.init(this, BuildConfig.KAKAO_NATIVE_APP_KEY) | ||
} | ||
|
||
private fun initNaverMapSdk() { | ||
NaverMapSdk.getInstance(this).client = | ||
NaverMapSdk.NaverCloudPlatformClient(BuildConfig.NAVER_CLIEND_ID) | ||
} | ||
|
||
companion object { | ||
val kakaoModule: KakaoModule = KakaoModule() | ||
} | ||
} |
2 changes: 0 additions & 2 deletions
2
android/app/src/main/java/com/woowacourse/friendogly/data/Empty
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
android/app/src/main/java/com/woowacourse/friendogly/data/datasource/KakaoLoginDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.woowacourse.friendogly.data.datasource | ||
|
||
import android.content.Context | ||
import com.woowacourse.friendogly.data.model.KakaoAccessTokenDto | ||
|
||
interface KakaoLoginDataSource { | ||
suspend fun login(context: Context): Result<KakaoAccessTokenDto> | ||
|
||
companion object { | ||
private var instance: KakaoLoginDataSource? = null | ||
|
||
fun setInstance(dataSource: KakaoLoginDataSource) { | ||
instance = dataSource | ||
} | ||
|
||
fun getInstance(): KakaoLoginDataSource = requireNotNull(instance) | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
android/app/src/main/java/com/woowacourse/friendogly/data/mapper/KakaoAccessTokenMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.woowacourse.friendogly.data.mapper | ||
|
||
import com.woowacourse.friendogly.data.model.KakaoAccessTokenDto | ||
import com.woowacourse.friendogly.domain.model.KakaoAccessToken | ||
|
||
fun KakaoAccessTokenDto.toDomain(): KakaoAccessToken { | ||
return KakaoAccessToken( | ||
idToken = this.idToken, | ||
accessToken = this.accessToken, | ||
) | ||
} |
6 changes: 6 additions & 0 deletions
6
android/app/src/main/java/com/woowacourse/friendogly/data/model/KakaoAccessTokenDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.woowacourse.friendogly.data.model | ||
|
||
data class KakaoAccessTokenDto( | ||
val accessToken: String, | ||
val idToken: String, | ||
) |
14 changes: 14 additions & 0 deletions
14
.../app/src/main/java/com/woowacourse/friendogly/data/repository/KakaoLoginRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.woowacourse.friendogly.data.repository | ||
|
||
import android.content.Context | ||
import com.woowacourse.friendogly.data.datasource.KakaoLoginDataSource | ||
import com.woowacourse.friendogly.data.mapper.toDomain | ||
import com.woowacourse.friendogly.domain.model.KakaoAccessToken | ||
import com.woowacourse.friendogly.domain.repository.KakaoLoginRepository | ||
|
||
class KakaoLoginRepositoryImpl( | ||
private val dataSource: KakaoLoginDataSource, | ||
) : KakaoLoginRepository { | ||
override suspend fun login(context: Context): Result<KakaoAccessToken> = | ||
dataSource.login(context = context).mapCatching { it.toDomain() } | ||
} |
1 change: 0 additions & 1 deletion
1
android/app/src/main/java/com/woowacourse/friendogly/domain/Empty
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
android/app/src/main/java/com/woowacourse/friendogly/domain/model/KakaoAccessToken.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.woowacourse.friendogly.domain.model | ||
|
||
data class KakaoAccessToken( | ||
val accessToken: String?, | ||
val idToken: String?, | ||
) |
18 changes: 18 additions & 0 deletions
18
...id/app/src/main/java/com/woowacourse/friendogly/domain/repository/KakaoLoginRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.woowacourse.friendogly.domain.repository | ||
|
||
import android.content.Context | ||
import com.woowacourse.friendogly.domain.model.KakaoAccessToken | ||
|
||
interface KakaoLoginRepository { | ||
suspend fun login(context: Context): Result<KakaoAccessToken> | ||
|
||
companion object { | ||
private var instance: KakaoLoginRepository? = null | ||
|
||
fun setInstance(repository: KakaoLoginRepository) { | ||
instance = repository | ||
} | ||
|
||
fun getInstance(): KakaoLoginRepository = requireNotNull(instance) | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
android/app/src/main/java/com/woowacourse/friendogly/domain/usecase/KakaoLoginUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.woowacourse.friendogly.domain.usecase | ||
|
||
import android.content.Context | ||
import com.woowacourse.friendogly.domain.model.KakaoAccessToken | ||
import com.woowacourse.friendogly.domain.repository.KakaoLoginRepository | ||
|
||
class KakaoLoginUseCase( | ||
private val repository: KakaoLoginRepository, | ||
) { | ||
suspend operator fun invoke(context: Context): Result<KakaoAccessToken> = repository.login(context = context) | ||
} |
46 changes: 46 additions & 0 deletions
46
...app/src/main/java/com/woowacourse/friendogly/kakao/datasource/KakaoLoginDataSourceImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.woowacourse.friendogly.kakao.datasource | ||
|
||
import android.content.Context | ||
import com.kakao.sdk.auth.model.OAuthToken | ||
import com.kakao.sdk.user.UserApiClient | ||
import com.woowacourse.friendogly.data.datasource.KakaoLoginDataSource | ||
import com.woowacourse.friendogly.data.model.KakaoAccessTokenDto | ||
import com.woowacourse.friendogly.kakao.mapper.toData | ||
import com.woowacourse.friendogly.kakao.model.KakaoAccessTokenResponse | ||
import kotlinx.coroutines.suspendCancellableCoroutine | ||
import kotlin.coroutines.resume | ||
import kotlin.coroutines.resumeWithException | ||
|
||
class KakaoLoginDataSourceImpl : KakaoLoginDataSource { | ||
/** | ||
* @param context: Activity context | ||
*/ | ||
override suspend fun login(context: Context): Result<KakaoAccessTokenDto> = | ||
runCatching { | ||
suspendCancellableCoroutine { continuation -> | ||
val callback: (OAuthToken?, Throwable?) -> Unit = { token, throwable -> | ||
when { | ||
throwable != null -> continuation.resumeWithException(throwable) | ||
token != null && continuation.isActive -> { | ||
val idToken = | ||
token.idToken | ||
?: throw IllegalArgumentException("kakao login idToken이 없습니다.") | ||
val accessToken = | ||
KakaoAccessTokenResponse( | ||
accessToken = token.accessToken, | ||
idToken = idToken, | ||
) | ||
continuation.resume(accessToken.toData()) | ||
} | ||
} | ||
} | ||
|
||
val userApiClient = UserApiClient.instance | ||
if (userApiClient.isKakaoTalkLoginAvailable(context)) { | ||
userApiClient.loginWithKakaoTalk(context, callback = callback) | ||
} else { | ||
userApiClient.loginWithKakaoAccount(context, callback = callback) | ||
} | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
android/app/src/main/java/com/woowacourse/friendogly/kakao/di/KakaoModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.woowacourse.friendogly.kakao.di | ||
|
||
import com.woowacourse.friendogly.data.datasource.KakaoLoginDataSource | ||
import com.woowacourse.friendogly.data.repository.KakaoLoginRepositoryImpl | ||
import com.woowacourse.friendogly.domain.repository.KakaoLoginRepository | ||
import com.woowacourse.friendogly.domain.usecase.KakaoLoginUseCase | ||
import com.woowacourse.friendogly.kakao.datasource.KakaoLoginDataSourceImpl | ||
|
||
class KakaoModule { | ||
private val kakaoLoginDataSource: KakaoLoginDataSource = KakaoLoginDataSourceImpl() | ||
|
||
private val kakaoLoginRepository: KakaoLoginRepository = | ||
KakaoLoginRepositoryImpl(dataSource = kakaoLoginDataSource) | ||
|
||
val kakaoLoginUseCase: KakaoLoginUseCase = KakaoLoginUseCase(repository = kakaoLoginRepository) | ||
} |
11 changes: 11 additions & 0 deletions
11
android/app/src/main/java/com/woowacourse/friendogly/kakao/mapper/KakaoTokenDtoMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.woowacourse.friendogly.kakao.mapper | ||
|
||
import com.woowacourse.friendogly.data.model.KakaoAccessTokenDto | ||
import com.woowacourse.friendogly.kakao.model.KakaoAccessTokenResponse | ||
|
||
fun KakaoAccessTokenResponse.toData(): KakaoAccessTokenDto { | ||
return KakaoAccessTokenDto( | ||
accessToken = this.accessToken, | ||
idToken = this.idToken, | ||
) | ||
} |
6 changes: 6 additions & 0 deletions
6
android/app/src/main/java/com/woowacourse/friendogly/kakao/model/KakaoAccessTokenResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.woowacourse.friendogly.kakao.model | ||
|
||
data class KakaoAccessTokenResponse( | ||
val accessToken: String, | ||
val idToken: String, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
...main/java/com/woowacourse/friendogly/presentation/ui/register/RegisterNavigationAction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters