Skip to content

Commit

Permalink
Merge pull request #12 from YAPP-Github/feature/tgyuu/PC-105
Browse files Browse the repository at this point in the history
[PC-105] 테스트용 카카오 로그인 추가
  • Loading branch information
tgyuuAn authored Dec 26, 2024
2 parents 4f35c86 + d65316b commit c36817a
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 7 deletions.
Binary file modified .DS_Store
Binary file not shown.
4 changes: 4 additions & 0 deletions .github/workflows/android_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up local.properties
run: |
echo "KAKAO_APP_KEY=${{ secrets.KAKAO_APP_KEY }}" >> local.properties
- name: Build with Gradle
run: ./gradlew assembleDebug --build-cache --stacktrace

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/android_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Set up local.properties
run: |
echo "KAKAO_APP_KEY=${{ secrets.KAKAO_APP_KEY }}" >> local.properties
- name: Build with Gradle
run: ./gradlew assembleDebug --build-cache --stacktrace

Expand Down
9 changes: 9 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import java.util.Properties

plugins {
id("piece.android.application")
id("piece.android.compose")
Expand All @@ -12,6 +14,11 @@ android {
targetSdk = 34

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

val localProperties = Properties()
localProperties.load(project.rootProject.file("local.properties").bufferedReader())
manifestPlaceholders["KAKAO_APP_KEY"] = localProperties["KAKAO_APP_KEY"] as String
buildConfigField("String", "KAKAO_APP_KEY", "\"${localProperties["KAKAO_APP_KEY"]}\"")
}

packaging { resources { excludes += "/META-INF/*" } }
Expand All @@ -36,6 +43,8 @@ dependencies {
implementation(libs.mavericks)
implementation(libs.mavericks.hilt)

implementation(libs.kakao.user)

implementation(projects.feature.auth)
implementation(projects.feature.etc)
implementation(projects.feature.matching)
Expand Down
16 changes: 15 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".PieceApplication"
android:allowBackup="true"
Expand All @@ -24,6 +26,18 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

<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_APP_KEY}" />
</intent-filter>
</activity>
</application>
</manifest>
7 changes: 6 additions & 1 deletion app/src/main/java/com/puzzle/piece/PieceApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ package com.puzzle.piece

import android.app.Application
import com.airbnb.mvrx.Mavericks
import com.kakao.sdk.common.KakaoSdk
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class PieceApplication : Application() {
override fun onCreate() {
super.onCreate()
Mavericks.initialize(this)
initMavericks()
initKakao()
}

private fun initMavericks() = Mavericks.initialize(this)
private fun initKakao() = KakaoSdk.init(this, BuildConfig.KAKAO_APP_KEY)
}
4 changes: 4 additions & 0 deletions feature/auth/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ plugins {
android {
namespace = "com.puzzle.auth"
}

dependencies {
implementation(libs.kakao.user)
}
24 changes: 20 additions & 4 deletions feature/auth/src/main/java/com/puzzle/auth/AuthScreen.kt
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
package com.puzzle.auth

import android.util.Log
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.sp
import androidx.hilt.navigation.compose.hiltViewModel
import com.kakao.sdk.user.UserApiClient
import com.puzzle.navigation.AuthGraph
import com.puzzle.navigation.MatchingGraph
import com.puzzle.navigation.NavigationEvent

@Composable
fun AuthRoute(viewModel: AuthViewModel = hiltViewModel()) {
val context = LocalContext.current

Box(
Column(
modifier = Modifier
.fillMaxSize()
.clickable {
Expand All @@ -27,8 +30,21 @@ fun AuthRoute(viewModel: AuthViewModel = hiltViewModel()) {
)
)
},
contentAlignment = Alignment.Center,
) {
Text(
text = "카카오 로그인",
fontSize = 30.sp,
modifier = Modifier.clickable {
UserApiClient.instance.loginWithKakaoAccount(context) { token, error ->
if (error != null) {
Log.e("test", "로그인 실패", error)
} else if (token != null) {
Log.i("test", "로그인 성공 ${token.accessToken}")
}
}
}
)

Text(
text = "AuthRoute",
fontSize = 30.sp,
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ amplitude-analytics = { module = "com.amplitude:analytics-android", version.ref
coil-compose = { module = "io.coil-kt:coil-compose", version.ref = "coil" }
lottie-compose = { module = "com.airbnb.android:lottie-compose", version.ref = "lottie-compose" }

kakao-common = { module = "com.kakao.sdk:v2-common", version.ref = "kakao" }
kakao-user = { module = "com.kakao.sdk:v2-user", version.ref = "kakao" }

mavericks = { module = "com.airbnb.android:mavericks", version.ref = "mavericks" }
mavericks-compose = { module = "com.airbnb.android:mavericks-compose", version.ref = "mavericks" }
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven { url = java.net.URI("https://devrepo.kakao.com/nexus/content/groups/public/") }
}
}

Expand Down

0 comments on commit c36817a

Please sign in to comment.