From 055aabe908b5026423f73c7766c83cf354ec06bc Mon Sep 17 00:00:00 2001 From: leesumin0526 Date: Tue, 25 Jun 2024 00:38:14 +0900 Subject: [PATCH] =?UTF-8?q?[maro/#47]=20feat=20::=20=EC=B9=B4=EC=B9=B4?= =?UTF-8?q?=EC=98=A4=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/workspace.xml | 74 ++++-------- UMC_6th/app/build.gradle.kts | 5 + UMC_6th/app/src/main/AndroidManifest.xml | 9 +- .../com/example/umc_6th/GlobalApplication.kt | 13 ++ .../com/example/umc_6th/auth/LoginActivity.kt | 113 ++++++++---------- .../com/example/umc_6th/ui/LockerFragment.kt | 2 +- .../com/example/umc_6th/ui/LookFragment.kt | 1 + .../src/main/res/layout/activity_login.xml | 1 + UMC_6th/settings.gradle.kts | 3 +- 9 files changed, 101 insertions(+), 120 deletions(-) create mode 100644 UMC_6th/app/src/main/java/com/example/umc_6th/GlobalApplication.kt diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 69daa53..98d7ca3 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -131,54 +131,15 @@ - @@ -1017,6 +986,7 @@ - \ No newline at end of file diff --git a/UMC_6th/app/build.gradle.kts b/UMC_6th/app/build.gradle.kts index f1f6d04..0d9d219 100644 --- a/UMC_6th/app/build.gradle.kts +++ b/UMC_6th/app/build.gradle.kts @@ -4,6 +4,8 @@ plugins { id("kotlin-kapt") } + + android { namespace = "com.example.umc_6th" compileSdk = 34 @@ -16,6 +18,7 @@ android { dataBinding = true } + defaultConfig { applicationId = "com.example.umc_6th" minSdk = 24 @@ -43,9 +46,11 @@ android { jvmTarget = JavaVersion.VERSION_1_8.toString() } + } dependencies { + implementation("com.kakao.sdk:v2-user:2.12.1") implementation("com.google.android.material:material:1.10.0") implementation("androidx.room:room-migration:2.6.0") implementation("androidx.room:room-runtime:2.6.0") diff --git a/UMC_6th/app/src/main/AndroidManifest.xml b/UMC_6th/app/src/main/AndroidManifest.xml index 3f5d35c..2143b63 100644 --- a/UMC_6th/app/src/main/AndroidManifest.xml +++ b/UMC_6th/app/src/main/AndroidManifest.xml @@ -8,6 +8,7 @@ + - - + + + + handleLoginResult(token, error) + } + } else { + UserApiClient.instance.loginWithKakaoAccount(this) { token, error -> + handleLoginResult(token, error) + } + } } - override fun onLoginFailure(message : String) { - Toast.makeText(this, message, Toast.LENGTH_SHORT).show() + private fun handleLoginResult(token: OAuthToken?, error: Throwable?) { + if (error != null) { + Log.e("LoginActivity", "카카오 로그인 실패", error) + Toast.makeText(this, "로그인 실패: ${error.localizedMessage}", Toast.LENGTH_SHORT).show() + } else if (token != null) { + Log.i("LoginActivity", "카카오 로그인 성공 ${token.accessToken}") + Toast.makeText(this, "로그인 성공", Toast.LENGTH_SHORT).show() + // 로그인 성공 시 MainActivity로 이동 + startActivity(Intent(this, MainActivity::class.java)) + finish() + } } -} \ No newline at end of file +} diff --git a/UMC_6th/app/src/main/java/com/example/umc_6th/ui/LockerFragment.kt b/UMC_6th/app/src/main/java/com/example/umc_6th/ui/LockerFragment.kt index 580efd3..eb7d771 100644 --- a/UMC_6th/app/src/main/java/com/example/umc_6th/ui/LockerFragment.kt +++ b/UMC_6th/app/src/main/java/com/example/umc_6th/ui/LockerFragment.kt @@ -8,9 +8,9 @@ import android.view.View import android.view.ViewGroup import androidx.appcompat.app.AppCompatActivity import com.example.umc_6th.adapters.LockerVPAdapter -import com.example.umc_6th.auth.LoginActivity import com.example.umc_6th.databinding.FragmentLockerBinding import com.example.umc_6th.util.BottomSheetFragment +import com.example.yourapp.LoginActivity import com.google.android.material.tabs.TabLayoutMediator class LockerFragment : Fragment() { diff --git a/UMC_6th/app/src/main/java/com/example/umc_6th/ui/LookFragment.kt b/UMC_6th/app/src/main/java/com/example/umc_6th/ui/LookFragment.kt index 9fa7f07..34a2e2b 100644 --- a/UMC_6th/app/src/main/java/com/example/umc_6th/ui/LookFragment.kt +++ b/UMC_6th/app/src/main/java/com/example/umc_6th/ui/LookFragment.kt @@ -13,6 +13,7 @@ import com.example.umc_6th.adapters.SongRVAdapter import com.example.umc_6th.database.SongService import com.example.umc_6th.databinding.FragmentLookBinding + class LookFragment : Fragment(), LookView { lateinit var binding: FragmentLookBinding diff --git a/UMC_6th/app/src/main/res/layout/activity_login.xml b/UMC_6th/app/src/main/res/layout/activity_login.xml index 7a3b16f..ba3c8fb 100644 --- a/UMC_6th/app/src/main/res/layout/activity_login.xml +++ b/UMC_6th/app/src/main/res/layout/activity_login.xml @@ -272,6 +272,7 @@ android:layout_height="45dp" android:layout_marginStart="15dp" android:layout_marginEnd="15dp" + android:onClick="loginWithKakao" android:src="@drawable/kakako_44" />