Skip to content

Commit

Permalink
Merge pull request #16 from Nexters/feature/#5-kakao-sign-in
Browse files Browse the repository at this point in the history
#5: 카카오 및 키미 로그인 API 설정
  • Loading branch information
DwEnn authored Aug 12, 2023
2 parents 0fd308c + e1ef9fb commit b1b1315
Show file tree
Hide file tree
Showing 45 changed files with 553 additions and 123 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ jobs:

- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Update KAKAO_NATIVE_APP_KEY from Secrets
env:
KAKAO_NATIVE_APP_KEY: $
run: echo KAKAO_NATIVE_APP_KEY=\"KAKAO_NATIVE_APP_KEY\" > ./local.properties
- name: App Module ktlintCheck
run: ./gradlew app:ktlintCheck
- name: Presentation Module ktlintCheck
Expand All @@ -46,6 +50,10 @@ jobs:

- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Update KAKAO_NATIVE_APP_KEY from Secrets
env:
KAKAO_NATIVE_APP_KEY: $
run: echo KAKAO_NATIVE_APP_KEY=\"KAKAO_NATIVE_APP_KEY\" > ./local.properties
- name: Debug Build with Gradle
run: ./gradlew assembleDebug
- name: Upload APK
Expand Down
13 changes: 13 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import Dependencies.setAndroidTestDependencies
import Dependencies.setComposeDependencies
import Dependencies.setCoreKtxDependencies
import Dependencies.setHiltDependencies
import Dependencies.setKakaoSignInDependencies
import Dependencies.setKotlinStdLibDependencies
import Dependencies.setLoggerDependencies
import Dependencies.setSplashDependencies
import Dependencies.setTestDependencies
import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties


@Suppress("UnstableApiUsage")
Expand All @@ -24,7 +26,13 @@ android {

@Suppress("UnstableApiUsage")
defaultConfig {
applicationId = "com.keyme.app"
minSdk = AppConfig.minSdkVersion
versionCode = AppConfig.versionCode
versionName = AppConfig.versionName

manifestPlaceholders["KAKAO_NATIVE_APP_KEY"] = getKakaoNativeAppKey()
buildConfigField("String", "KAKAO_NATIVE_APP_KEY", getKakaoNativeAppKey())
}

buildFeatures {
Expand Down Expand Up @@ -55,6 +63,7 @@ dependencies {
setSplashDependencies()
setActivityDepdendencies()
setComposeDependencies()
setKakaoSignInDependencies()

setHiltDependencies()

Expand All @@ -67,3 +76,7 @@ dependencies {
kapt {
correctErrorTypes = true
}

fun getKakaoNativeAppKey(): String {
return gradleLocalProperties(rootDir).getProperty("KAKAO_NATIVE_APP_KEY")
}
15 changes: 15 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name="com.kakao.sdk.auth.AuthCodeHandlerActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:host="oauth"
android:scheme="kakao${KAKAO_NATIVE_APP_KEY}" />
</intent-filter>
</activity>
</application>

</manifest>
2 changes: 2 additions & 0 deletions app/src/main/java/com/keyme/app/KeymeApplication.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.keyme.app

import android.app.Application
import com.kakao.sdk.common.KakaoSdk
import dagger.hilt.android.HiltAndroidApp
import timber.log.Timber

Expand All @@ -10,5 +11,6 @@ class KeymeApplication : Application() {
super.onCreate()

if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree())
KakaoSdk.init(this, BuildConfig.KAKAO_NATIVE_APP_KEY)
}
}
23 changes: 17 additions & 6 deletions app/src/main/java/com/keyme/app/ui/KeymeApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,22 @@ import com.keyme.presentation.feed.ui.feedGraph
import com.keyme.presentation.myprofile.ui.KeymeTestResultDetailDestination
import com.keyme.presentation.myprofile.ui.keymeTestResultDetailGraph
import com.keyme.presentation.myprofile.ui.myProfileGraph
import com.keyme.presentation.nickname.NicknameDestination
import com.keyme.presentation.nickname.nicknameGraph
import com.keyme.presentation.signin.signInGraph

@Composable
fun KeymeApp() {
val appState = rememberKeymeAppState()

KeymeTheme {
Scaffold(
bottomBar = {
KeymeBottomBar(
currentDestination = appState.currentDestination,
onNavigateToDestination = appState::navigate,
)
},
// bottomBar = {
// KeymeBottomBar(
// currentDestination = appState.currentDestination,
// onNavigateToDestination = appState::navigate,
// )
// },
) { innerPadding ->
NavHost(
navController = appState.navController,
Expand All @@ -42,6 +45,14 @@ fun KeymeApp() {
.fillMaxSize()
.padding(innerPadding),
) {
signInGraph(
navigateToNickname = { appState.navigate(NicknameDestination) },
// navigateToKeymeTest = { appState.navigate(KeymeTestDestination) },
// navigateToMyDaily = { appState.navigate(MyDailyDestination) },
)
nicknameGraph(
onBackClick = appState::onBackClick,
)
feedGraph(
navigateToAlarm = { appState.navigate(AlarmDestination) },
nestedGraphs = {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/keyme/app/ui/KeymeAppState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import androidx.navigation.NavHostController
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import com.keyme.app.navigation.TopLevelDestination
import com.keyme.presentation.feed.ui.FeedDestination
import com.keyme.presentation.navigation.KeymeNavigationDestination
import com.keyme.presentation.signin.SignInDestination

@Composable
fun rememberKeymeAppState(
Expand All @@ -22,7 +22,7 @@ class KeymeAppState(val navController: NavHostController) {
val currentDestination: NavDestination?
@Composable get() = navController.currentBackStackEntryAsState().value?.destination

val startDestination = FeedDestination
val startDestination = SignInDestination

fun navigate(destination: KeymeNavigationDestination) {
if (destination is TopLevelDestination) {
Expand Down
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ buildscript {
repositories {
google()
mavenCentral()
maven(url = "https://devrepo.kakao.com/nexus/content/groups/public/")
}
dependencies {
classpath("com.android.tools.build:gradle:${Versions.ANDROID_GRADLE}")
Expand All @@ -23,4 +24,4 @@ allprojects {

tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}
}
7 changes: 7 additions & 0 deletions buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ object Dependencies {
// ViewModel
private val viewModelKtx = "androidx.lifecycle:lifecycle-viewmodel-ktx:${Versions.LIFECYCLE}"

// Kakao signIn
private val kakaoSignIn = "com.kakao.sdk:v2-user:${Versions.KAKAO_SIGN_IN}"

// Lottie
private val lottieCompose = "com.airbnb.android:lottie-compose:${Versions.LOTTIE_COMPOSE}"

Expand Down Expand Up @@ -104,6 +107,10 @@ object Dependencies {
implementation(viewModelKtx)
}

fun DependencyHandler.setKakaoSignInDependencies() {
implementation(kakaoSignIn)
}

fun DependencyHandler.setLottieDependencies() {
implementation(lottieCompose)
}
Expand Down
3 changes: 3 additions & 0 deletions buildSrc/src/main/java/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ object Versions {
// Lifecycle
const val LIFECYCLE = "2.6.1"

// KakaoSignIn
const val KAKAO_SIGN_IN = "2.15.0"

// Lottie
const val LOTTIE_COMPOSE = "6.0.1"

Expand Down
7 changes: 1 addition & 6 deletions common-android.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ if (!isLibraryPlugin || !isApplicationPlugin) return

android {
defaultConfig {
if (isApplicationPlugin) {
applicationId = "com.keyme.app"
versionCode = AppConfig.versionCode
versionName = AppConfig.versionName
}
targetSdk = AppConfig.targetSdkVersion
testInstrumentationRunner = AppConfig.androidTestInstrumentationRunner
}
Expand Down Expand Up @@ -38,4 +33,4 @@ android {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
11 changes: 8 additions & 3 deletions data/src/main/java/com/keyme/data/remote/api/KeymeApi.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
package com.keyme.data.remote.api

import com.keyme.domain.entity.response.SampleResponse
import com.keyme.domain.entity.request.SignInRequest
import com.keyme.domain.entity.response.SignInResponse
import com.keyme.domain.entity.response.keymetest.KeymeTestResultStatisticsResponse
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path

interface KeymeApi {

@GET("main/sample")
suspend fun getSample(): SampleResponse
@POST("/auth/login")
suspend fun signInWithKakao(
@Body signInRequest: SignInRequest,
): SignInResponse

@GET("tests/{id}/statistics")
suspend fun getKeymeTestResultStatistics(
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.keyme.data.remote.datasource

import com.keyme.data.remote.api.KeymeApi
import com.keyme.domain.entity.request.SignInRequest
import com.keyme.domain.entity.response.SignInResponse
import javax.inject.Inject

class SignInDataSource @Inject constructor(
private val keymeApi: KeymeApi,
) {
suspend fun signInWithKakao(
token: String,
): SignInResponse {
return keymeApi.signInWithKakao(
SignInRequest(
oauthType = "KAKAO",
token = token,
),
)
}
}
2 changes: 1 addition & 1 deletion data/src/main/java/com/keyme/data/remote/di/ApiModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ApiModule {

private fun getRetrofit(): Retrofit {
return Retrofit.Builder()
.baseUrl("https://api.keyme.com/")
.baseUrl("https://api.keyme.space")
.client(getOkHttpClient())
.addConverterFactory(GsonConverterFactory.create())
.build()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.keyme.data.remote.di

import com.keyme.data.remote.repositoryimpl.ResultCircleRepositoryImpl
import com.keyme.data.remote.repositoryimpl.SampleRepositoryImpl
import com.keyme.data.remote.repositoryimpl.SignInRepositoryImpl
import com.keyme.data.remote.repositoryimpl.keymetest.KeymeTestResultRepositoryImpl
import com.keyme.domain.repository.ResultCircleRepository
import com.keyme.domain.repository.SampleRepository
import com.keyme.domain.repository.SignInRepository
import com.keyme.domain.repository.keymetest.KeymeTestResultRepository
import dagger.Binds
import dagger.Module
Expand All @@ -16,7 +16,7 @@ import dagger.hilt.android.components.ViewModelComponent
abstract class RepositoryModule {

@Binds
abstract fun bindSampleRepository(impl: SampleRepositoryImpl): SampleRepository
abstract fun bindSignInRepository(impl: SignInRepositoryImpl): SignInRepository

@Binds
abstract fun bindResultCircleRepository(impl: ResultCircleRepositoryImpl): ResultCircleRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ResultCircleRepositoryImpl @Inject constructor(

override suspend fun getDummy(): ResultCircleResponse {
return resultCircleDataSource.getSample().apply {
statusCode = "200"
code = "200"
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.keyme.data.remote.repositoryimpl

import com.keyme.data.remote.datasource.SignInDataSource
import com.keyme.domain.entity.response.SignInResponse
import com.keyme.domain.repository.SignInRepository
import javax.inject.Inject

class SignInRepositoryImpl @Inject constructor(
private val signInDataSource: SignInDataSource,
) : SignInRepository {

override suspend fun signInWithKakao(
token: String,
): SignInResponse {
return signInDataSource.signInWithKakao(
token = token,
)
}
}
4 changes: 2 additions & 2 deletions domain/src/main/java/com/keyme/domain/entity/ApiResult.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ fun <T> ApiResult<T>.onFailure(action: (Throwable) -> Unit): ApiResult<T> {
inline fun <T : Any> apiResult(call: () -> BaseResponse<T>): ApiResult<T> {
return runCatching {
val response = call()
if (response.statusCode == "200") {
if (response.code == "200") {
ApiResult.Success(response.data)
} else {
ApiResult.ApiError(response.statusCode, response.message)
ApiResult.ApiError(response.code, response.message)
}
}.getOrElse {
ApiResult.NetworkError(it)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.keyme.domain.entity

abstract class BaseResponse<T : Any> {
lateinit var statusCode: String
lateinit var code: String
lateinit var message: String
lateinit var data: T
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.keyme.domain.entity.request

data class SignInRequest(
val oauthType: String,
val token: String,
)
Loading

0 comments on commit b1b1315

Please sign in to comment.