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

Feature/#4 kakao login #66

Merged
merged 36 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
4c8f95d
[add] #4 gradle add for kakao
cacaocoffee Jul 1, 2024
1a2a997
[feat] #4 kakao hash key
cacaocoffee Jul 1, 2024
226f992
[mod] #4 convention ์ ์šฉ
cacaocoffee Jul 2, 2024
a3d3dea
[feat] #4 ๋ชจ๋“ˆ ๋ถ„๋ฆฌ ๋ฐ ๋กœ๊ทธ์ธ ๊ธฐ๋Šฅ ์ถ”๊ฐ€
cacaocoffee Jul 3, 2024
19c2fed
[add] #4 gradle add for kakao
cacaocoffee Jul 1, 2024
0407d46
[feat] #4 kakao hash key
cacaocoffee Jul 1, 2024
8a4274c
[feat] #4 Kakao login UI
cacaocoffee Jul 3, 2024
09e75d6
[add] #4 hlit dependency
cacaocoffee Jul 4, 2024
7fcf694
[feat] #4 ClientModule
cacaocoffee Jul 5, 2024
808b9a7
[feat] #4 RecordyApplication sdk ์ดˆ๊ธฐํ™”
cacaocoffee Jul 5, 2024
dd42e2d
[feat] #4 ClientModule
cacaocoffee Jul 5, 2024
a044f82
[refactor] #4 LoginScreen refactor
cacaocoffee Jul 6, 2024
e250ea9
[add] #4 LoginState
cacaocoffee Jul 9, 2024
fd7b3e4
[chore] #4 gradle ์ˆ˜์ •
cacaocoffee Jul 9, 2024
a8f4b54
[feat] #4 OAuthEntryPoint
cacaocoffee Jul 9, 2024
ce458c9
[feat] #4 LoginState, LoginViewModel
cacaocoffee Jul 9, 2024
c2dd076
[feat] #4 LoginScreen
cacaocoffee Jul 9, 2024
aefb505
[feat] #4 kakao hash key
cacaocoffee Jul 1, 2024
7848a27
[mod] #4 convention ์ ์šฉ
cacaocoffee Jul 2, 2024
6081c66
[feat] #4 ๋ชจ๋“ˆ ๋ถ„๋ฆฌ ๋ฐ ๋กœ๊ทธ์ธ ๊ธฐ๋Šฅ ์ถ”๊ฐ€
cacaocoffee Jul 3, 2024
e761061
[feat] #4 kakao hash key
cacaocoffee Jul 1, 2024
8cc8f8d
[feat] #4 Kakao login UI
cacaocoffee Jul 3, 2024
72f45c7
[refactor] #4 LoginScreen refactor
cacaocoffee Jul 6, 2024
7b7d2db
[Add] #4 ic_signup.png
cacaocoffee Jul 10, 2024
c2892e3
[feat] #4 PolicyScreen
cacaocoffee Jul 10, 2024
c1a767a
[feat] #4 NamingScreen
cacaocoffee Jul 10, 2024
aab6d7e
[feat] #4 SignUpState, SignUpViewModel
cacaocoffee Jul 10, 2024
9a09a88
[feat] #4 SignUpScreen.kt
cacaocoffee Jul 10, 2024
7edef48
[feat] #4 SignUpSucessScreen
cacaocoffee Jul 10, 2024
3f7caab
[mod] #4 RecordyValidateTextfield
cacaocoffee Jul 10, 2024
52129de
[chore] #4 ktlint format
cacaocoffee Jul 10, 2024
ba89190
[mod] #4 login,SignUp adjust background & view
cacaocoffee Jul 10, 2024
ba9879c
[mod] #4 ktlint formatting
cacaocoffee Jul 10, 2024
c565e7d
[add] #4 yml update - kakao native Key
cacaocoffee Jul 10, 2024
7c9bba2
[chore] #4 apply code review
cacaocoffee Jul 11, 2024
39adf17
[chore] #4 apply redesign login view
cacaocoffee Jul 11, 2024
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
50 changes: 26 additions & 24 deletions .github/workflows/android-pull-request-ci.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
name: Android Pull Request CI
on:
pull_request:
branches: [ develop ]
pull_request:
branches: [ develop ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v4
build:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v4

- name: Setup JDK 17
uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: '17'
- name: Setup JDK 17
uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: '17'

- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Setup Android SDK
uses: android-actions/setup-android@v3

- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Add Local Properties
env:
BASE_URL: ${{ secrets.BASE_URL }}
KAKAO_NATIVE_KEY: ${{ secrets.KAKAO_NATIVE_KEY }}
run: |
echo base.url=\"$BASE_URL\" >> ./local.properties
- name: Add Local Properties
env:
BASE_URL: ${{ secrets.BASE_URL }}
KAKAO_NATIVE_KEY: ${{ secrets.KAKAO_NATIVE_KEY }}
run: |
echo base.url=\"$BASE_URL\" >> ./local.properties
echo kakao.native.key=\"KAKAO_NATIVE_KEY\" >> ./local.properties
echo kakaoNativeKey=\"$KAKAO_NATIVE_KEY\" >> ./local.properties
- name: Run ktlint
run: ./gradlew ktlintCheck
- name: Run ktlint
run: ./gradlew ktlintCheck

3 changes: 3 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ dependencies {
implementation(projects.core.buildconfig)
implementation(projects.core.datastore)
implementation(projects.core.network)
implementation(projects.data.oauth)
implementation(projects.domain.oauth)
implementation(projects.feature.navigator)
implementation(libs.kakao.login)
}
15 changes: 14 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@
android:theme="@style/Theme.Recordy"
android:usesCleartextTraffic="true"
tools:targetApi="31">
<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" />

<!-- Redirect URI: "kakao${NATIVE_APP_KEY}://oauth" -->
<data android:host="oauth"
android:scheme="kakao${KAKAO_NATIVE_KEY}" />
</intent-filter>
</activity>
</application>

</manifest>
</manifest>
17 changes: 16 additions & 1 deletion app/src/main/java/com/record/recordy/RecordyApplication.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
package com.record.recordy

import android.app.Application
import android.util.Log
import com.kakao.sdk.common.KakaoSdk
import com.kakao.sdk.common.util.Utility
import com.record.buildconfig.BuildConfig.KAKAO_NATIVE_KEY
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class RecordyApplication : Application()
class RecordyApplication : Application() {
override fun onCreate() {
super.onCreate()
setKakaoSdk()
val keyHash = Utility.getKeyHash(this)
Log.d("ํ‚คํ•ด์‹œ", " $keyHash")
}

private fun setKakaoSdk() {
KakaoSdk.init(this, KAKAO_NATIVE_KEY)
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.android.build.api.dsl.ApplicationExtension
import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties
import com.record.convention.configureAndroidCompose
import com.record.convention.configureKotlinAndroid
import com.record.convention.extension.getLibrary
Expand All @@ -24,6 +25,7 @@ internal class AndroidApplicationPlugin : Plugin<Project> {
targetSdk = libs.getVersion("targetSdk").requiredVersion.toInt()
versionCode = libs.getVersion("versionCode").requiredVersion.toInt()
versionName = libs.getVersion("versionName").requiredVersion
manifestPlaceholders["KAKAO_NATIVE_KEY"] = gradleLocalProperties(rootDir, providers).getProperty("kakaoNativeKey")
}
}

Expand All @@ -32,4 +34,4 @@ internal class AndroidApplicationPlugin : Plugin<Project> {
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ internal fun Project.configureBuildConfig(
"BASE_URL",
gradleLocalProperties(rootDir, providers).getProperty("base.url")
)
buildConfigField(
"String",
"KAKAO_NATIVE_KEY",
gradleLocalProperties(rootDir, providers).getProperty("kakao.native.key")
)
}

buildFeatures {
buildConfig = true
}
}
}
}
1 change: 1 addition & 0 deletions core/buildconfig/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ android {

dependencies {
implementation(projects.core.common)
implementation(libs.kakao.login)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ package com.record.buildconfig.impl

import com.record.buildconfig.BuildConfig.BASE_URL
import com.record.buildconfig.BuildConfig.DEBUG
import com.record.buildconfig.BuildConfig.KAKAO_NATIVE_KEY
import com.record.common.buildconfig.BuildConfigFieldProvider
import com.record.common.buildconfig.BuildConfigFields

class BuildConfigFieldsProviderImpl : BuildConfigFieldProvider {
override fun get(): BuildConfigFields =
BuildConfigFields(
baseUrl = BASE_URL,
kakaoNativeKey = KAKAO_NATIVE_KEY,
isDebug = DEBUG,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ package com.record.common.buildconfig

data class BuildConfigFields(
val baseUrl: String,
val kakaoNativeKey: String,
val isDebug: Boolean,
)
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import com.record.model.ValidateResult
@Composable
fun RecordyValidateTextfield(
modifier: Modifier = Modifier,
errorState: ValidateResult = ValidateResult.ValidationError,
errorState: ValidateResult = ValidateResult.Inputting,
placeholder: String = "EX) ๋ ˆ์ฝ”๋””๋‘ฅ์ด๋“ค",
maxLines: Int = 1,
maxLength: Int = 10,
Expand All @@ -46,8 +46,8 @@ fun RecordyValidateTextfield(
keyboardActions: KeyboardActions = KeyboardActions.Default,
padding: PaddingValues = PaddingValues(horizontal = 16.dp),
overlapErrorMessage: String = "์ด๋ฏธ ์‚ฌ์šฉ์ค‘์ธ ๋‹‰๋„ค์ž„์ด์—์š”",
validationErrorMessage: String = "ํ•œ๊ธ€, ์ˆซ์ž, ๋ฐ‘์ค„ ๋ฐ ๋งˆ์นจํ‘œ๋งŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์–ด์š”",
successMessage: String = "์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ๋‹‰๋„ค์ž„์ด์—์š”",
validationErrorMessage: String = "โ“˜ ํ•œ๊ธ€, ์ˆซ์ž, ๋ฐ‘์ค„ ๋ฐ ๋งˆ์นจํ‘œ๋งŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์–ด์š”",
successMessage: String = "โ“˜ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ๋‹‰๋„ค์ž„์ด์—์š”",
inputtingMessage: String = "",
) {
var value by remember { mutableStateOf("") }
Expand All @@ -56,7 +56,8 @@ fun RecordyValidateTextfield(

Column(
modifier = Modifier
.fillMaxSize()
.wrapContentHeight()
.fillMaxWidth()
.padding(padding)
.clip(shape),
) {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions data/auth/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
plugins {
alias(libs.plugins.recordy.data)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.recordy.android.hilt)
}

android {
namespace = "com.record.auth"
}

dependencies {
implementation(projects.core.network)
implementation(projects.core.model)
implementation(projects.core.datastore)
implementation(projects.domain.auth)

implementation(libs.kotlinx.serialization.json)
implementation(libs.retrofit.core)
implementation(libs.retrofit.kotlin.serialization)
implementation(libs.okhttp.logging)
implementation(libs.kakao.login)
}
22 changes: 22 additions & 0 deletions data/oauth/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
plugins {
alias(libs.plugins.recordy.data)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.recordy.android.hilt)
}

android {
namespace = "com.record.oauth"
}

dependencies {
implementation(projects.core.network)
implementation(projects.core.model)
implementation(projects.core.datastore)
implementation(projects.domain.oauth)

implementation(libs.kotlinx.serialization.json)
implementation(libs.retrofit.core)
implementation(libs.retrofit.kotlin.serialization)
implementation(libs.okhttp.logging)
implementation(libs.kakao.login)
}
16 changes: 16 additions & 0 deletions data/oauth/src/main/java/com/recordy/oauth/di/ClientModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.recordy.oauth.di

import com.kakao.sdk.user.UserApiClient
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object ClientModule {
@Provides
@Singleton
fun provideKakaoClient(): UserApiClient = UserApiClient.instance
}
19 changes: 19 additions & 0 deletions data/oauth/src/main/java/com/recordy/oauth/di/KakaoAuthModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.recordy.oauth.di

import com.recordy.oauth.repository.KakaoAuthManager
import com.recordy.oauth.repository.OAuthInteractor
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ActivityComponent
import dagger.hilt.android.scopes.ActivityScoped

@Module
@InstallIn(ActivityComponent::class)
abstract class KakaoAuthModule {
@Binds
@ActivityScoped
abstract fun provideKakaoAuthRepository(
kakaoAuthInteractor: KakaoAuthManager,
): OAuthInteractor
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package com.recordy.oauth.repository

import android.content.Context
import com.kakao.sdk.common.model.ClientError
import com.kakao.sdk.common.model.ClientErrorCause
import com.kakao.sdk.user.UserApiClient
import com.recordy.oauth.model.KakaoToken
import dagger.hilt.android.qualifiers.ActivityContext
import kotlinx.coroutines.suspendCancellableCoroutine
import timber.log.Timber
import javax.inject.Inject
import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException

class KakaoAuthManager @Inject constructor(
private val client: UserApiClient,
@ActivityContext private val context: Context,
) : OAuthInteractor {
override suspend fun loginByKakao(): Result<KakaoToken> =
suspendCancellableCoroutine {
when (client.isKakaoTalkLoginAvailable(context)) {
true -> {
client.loginWithKakaoTalk(context) { token, error ->
if (error != null) {
if (error is ClientError && error.reason == ClientErrorCause.Cancelled) {
return@loginWithKakaoTalk
}
client.loginWithKakaoAccount(context) { accountToken, accountError ->
if (accountError != null) {
it.resume(Result.failure(accountError))
return@loginWithKakaoAccount
}
if (accountToken != null) {
it.resume(Result.success(KakaoToken(accountToken.accessToken, accountToken.refreshToken)))
return@loginWithKakaoAccount
}
}
} else if (token != null) {
it.resume(Result.success(KakaoToken(token.accessToken, token.refreshToken)))
return@loginWithKakaoTalk
}
}
}

false -> {
client.loginWithKakaoAccount(context) { token, error ->
if (error != null) {
it.resume(Result.failure(error))
return@loginWithKakaoAccount
}
if (token != null) {
it.resume(Result.success(KakaoToken(token.accessToken, token.refreshToken)))
return@loginWithKakaoAccount
}
it.resumeWithException(Throwable("Unreachable code"))
}
}
}
}

override fun logout() {
client.logout(Timber::e)
}

override fun withdraw() {
client.unlink(Timber::e)
}
}
3 changes: 2 additions & 1 deletion data/recordy/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ dependencies {
implementation(projects.core.network)
implementation(projects.core.model)
implementation(projects.core.datastore)
implementation(projects.domain.recordy)
implementation(projects.domain.auth)

implementation(libs.kotlinx.serialization.json)
implementation(libs.retrofit.core)
implementation(libs.retrofit.kotlin.serialization)
implementation(libs.okhttp.logging)
implementation(libs.kakao.login)
}
8 changes: 8 additions & 0 deletions domain/auth/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
plugins {
alias(libs.plugins.recordy.java.library)
}

dependencies {
implementation(projects.core.model)
implementation(libs.kotlinx.coroutines.core)
}
8 changes: 8 additions & 0 deletions domain/oauth/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
plugins {
alias(libs.plugins.recordy.java.library)
}

dependencies {
implementation(projects.core.model)
implementation(libs.kotlinx.coroutines.core)
}
Loading