From 029f60891a4d83ce1168df6de254d510165af9ae Mon Sep 17 00:00:00 2001 From: Ko SeongChan Date: Wed, 28 Feb 2024 22:35:05 +0900 Subject: [PATCH 01/14] =?UTF-8?q?HTTP=20=ED=86=B5=EC=8B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 0 -> 6148 bytes android/app/build.gradle.kts | 4 ++++ backend/.DS_Store | Bin 0 -> 6148 bytes 3 files changed, 4 insertions(+) create mode 100644 .DS_Store create mode 100644 backend/.DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..175625e414ba501c7d828e1807a27c5a3609dfda GIT binary patch literal 6148 zcmeH~&u`N(6vv;tLfs9d9zfa!DH7Ldl!7KEE?MagJ8)SL92hFeQXpDpPi?v$s!BP- zAH$Wug#U#Te4p*1B^g|h&@}l;_SZk&bLvm+I3^-7oTrb8dPF3VSljE!t}yQB)UcLo zxdRnEMw06UWgcwL^?C6GJb~*=fcI_-yY=88*T=Q}yZzIc`SBf!Nl{8u(v(qJ^Zp8- zzj!B$*_j*rTXL3Xv!dVsE?R5tTemy1BRAx`=#ySVMO@5h!+83ZYp=At%^8Plc@>F(g|FS-efA(i=m#YbY@~B+abHMJML{RmxJA%t>9_@*=j3T?hg7W zKiOHWy7Kg6s17AybWA5SVNz8> z;sHFWgeu-QhEQczH9`{WM}yFuP7R}?#)uhTX4LS%CX@#MxQ-h0YH<2s_L-vM%C+>P z#;Hq(w2wVJqLwD~7P)Xb+rU=(MzI!%4Wyhj338?uH`F(=mQv z+)0F1eeMZ(0#yQQw%X(KfB(<-|7wu0c>i$A0n&RUHufv6 lnh<2}I5q`7iZ_vrp)cS9G;~^8MGMS-2p9}L^924YfnQVh6IlQN literal 0 HcmV?d00001 diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 27dc5eeb..c345ba9d 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -62,6 +62,10 @@ dependencies { implementation("com.google.firebase:firebase-firestore:24.10.1") implementation("com.google.firebase:firebase-storage-ktx:20.3.0") + implementation ("com.squareup.retrofit2:retrofit:2.9.0") + implementation ("com.squareup.retrofit2:converter-gson:2.9.0") + implementation ("com.squareup.retrofit2:adapter-rxjava2:2.9.0") + implementation ("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0") implementation ("com.github.bumptech.glide:glide:4.12.0") annotationProcessor ("com.github.bumptech.glide:compiler:4.12.0") diff --git a/backend/.DS_Store b/backend/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..f51fa1a9e9176e5ef3e058f5b8b25b0aecdf8cd8 GIT binary patch literal 6148 zcmeHK%}T>S5T0$TO(;SS3OxqA7OYi@#Y?F5>cNN}RBA$l4aTfAsXdfJ&iX<=iO=KA z?nW%F;7P>J!0b0WKUwxm*vSHb=uL+E0CfPcPzg&m4l9J>q)SpV9zvm>5yBZr$RG@+ zOWExBiww}avmu2M_%Mbq?=O7{Vi{ocEqIEfG;6iqMX6lb*sNMrt7hGLBRTalKbxdI ze|$}|3n}BEu>IgN3a5km_K8d~KT5)}Du{+5rrcab$xu#va*_;FRqN@1Wn1>3-k8nW z-A>avY#q&;&aB&Rp?%Pq&uwdGcklRo@DM*H@#||qCo{kd{Fnhc9~@Ld*I=$u9UVB(?<2)4gd}LwU4qat z=o-v5VgyC#Qbb)U%oRiEa`ZbU&o!89)a4-5%J>|!vM@Ikp;kw~qtZdR8hK;}n1MwG z%6eL-{(t)Y{eQ8DXUqUI@UIvUmA=>S;g(EqUD_P=S_kzGm4xzgjh`iGs8)=*)QTIZ aO3?3+f#@2{HKGTFe*_c_JTL>l%D@LK`%NPN literal 0 HcmV?d00001 From c00e8ec79e4577ff71ea524aa53e1ae7863da3e9 Mon Sep 17 00:00:00 2001 From: Ko SeongChan Date: Wed, 28 Feb 2024 22:36:17 +0900 Subject: [PATCH 02/14] Rebase? --- .../app/src/main/java/com/example/sharenote/SignUpActivity.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/android/app/src/main/java/com/example/sharenote/SignUpActivity.kt b/android/app/src/main/java/com/example/sharenote/SignUpActivity.kt index d99446bb..db265ac6 100644 --- a/android/app/src/main/java/com/example/sharenote/SignUpActivity.kt +++ b/android/app/src/main/java/com/example/sharenote/SignUpActivity.kt @@ -152,3 +152,4 @@ class SignUpActivity : AppCompatActivity() { } } } + From 8776707b86d105d0a88024169d73321381d7287b Mon Sep 17 00:00:00 2001 From: Ko SeongChan Date: Thu, 29 Feb 2024 22:23:46 +0900 Subject: [PATCH 03/14] =?UTF-8?q?HTTP=20=ED=86=B5=EC=8B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 회원가입 통신 오류 --- .../java/com/example/sharenote/ApiService.kt | 11 ++++ .../com/example/sharenote/RetrofitClient.kt | 20 +++++++ .../com/example/sharenote/SignUpActivity.kt | 60 ++++++++++++------- .../main/java/com/example/sharenote/data.kt | 6 ++ 4 files changed, 74 insertions(+), 23 deletions(-) create mode 100644 android/app/src/main/java/com/example/sharenote/ApiService.kt create mode 100644 android/app/src/main/java/com/example/sharenote/RetrofitClient.kt diff --git a/android/app/src/main/java/com/example/sharenote/ApiService.kt b/android/app/src/main/java/com/example/sharenote/ApiService.kt new file mode 100644 index 00000000..aee579a5 --- /dev/null +++ b/android/app/src/main/java/com/example/sharenote/ApiService.kt @@ -0,0 +1,11 @@ +package com.example.sharenote + +import retrofit2.Call +import retrofit2.http.Body +import retrofit2.http.POST + +interface ApiService { + + @POST("users/signup") + fun signUpUser(@Body userData: UserData): Call // 회원가입을 위한 POST 요청 +} diff --git a/android/app/src/main/java/com/example/sharenote/RetrofitClient.kt b/android/app/src/main/java/com/example/sharenote/RetrofitClient.kt new file mode 100644 index 00000000..22524347 --- /dev/null +++ b/android/app/src/main/java/com/example/sharenote/RetrofitClient.kt @@ -0,0 +1,20 @@ +package com.example.sharenote + +import retrofit2.Retrofit +import retrofit2.converter.gson.GsonConverterFactory + +object RetrofitClient { + + private const val BASE_URL = "http://localhost:8080/api/user/signUp" // MongoDB API URL로 변경 + + private val retrofit: Retrofit by lazy { + Retrofit.Builder() + .baseUrl(BASE_URL) + .addConverterFactory(GsonConverterFactory.create()) + .build() + } + + val apiService: ApiService by lazy { + retrofit.create(ApiService::class.java) + } +} diff --git a/android/app/src/main/java/com/example/sharenote/SignUpActivity.kt b/android/app/src/main/java/com/example/sharenote/SignUpActivity.kt index db265ac6..bcd45d68 100644 --- a/android/app/src/main/java/com/example/sharenote/SignUpActivity.kt +++ b/android/app/src/main/java/com/example/sharenote/SignUpActivity.kt @@ -9,6 +9,9 @@ import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import com.google.firebase.auth.FirebaseAuth import com.google.firebase.firestore.FirebaseFirestore +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response class SignUpActivity : AppCompatActivity() { @@ -77,21 +80,38 @@ class SignUpActivity : AppCompatActivity() { val auth = FirebaseAuth.getInstance() if (Email.isNotEmpty() && Password.isNotEmpty()) { - auth.createUserWithEmailAndPassword(Email, Password) - .addOnCompleteListener(this) { task -> - if (task.isSuccessful) { - Toast.makeText(this, "계정 생성 완료.", Toast.LENGTH_SHORT).show() - - // 회원가입이 성공한 경우 사용자 정보를 데이터베이스에 저장 - saveUserDataToFirestore() - - finish() // 가입창 종료 + // Retrofit을 사용하여 회원가입 데이터를 서버에 전송 + val userData = UserData(Name, Email, Password) + RetrofitClient.apiService.signUpUser(userData).enqueue(object : Callback { + override fun onResponse(call: Call, response: Response) { + if (response.isSuccessful) { + // 회원가입 성공 + Toast.makeText(this@SignUpActivity, "계정 생성 완료.", Toast.LENGTH_SHORT).show() + + // Firebase에 사용자 등록 + auth.createUserWithEmailAndPassword(Email, Password) + .addOnCompleteListener(this@SignUpActivity) { task -> + if (task.isSuccessful) { + // 회원가입이 성공한 경우 사용자 정보를 Firestore에 저장 + saveUserDataToFirestore() + + finish() // 가입창 종료 + } else { + // 계정 생성 실패 + Toast.makeText(this@SignUpActivity, "계정 생성 실패", Toast.LENGTH_SHORT).show() + } + } } else { - // 계정 생성 실패 원인을 확인하여 메시지 표시 - val errorMessage = task.exception?.message ?: "계정 생성 실패" - Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT).show() + // 서버로부터 응답 실패 + Toast.makeText(this@SignUpActivity, "회원가입에 실패했습니다.", Toast.LENGTH_SHORT).show() } } + + override fun onFailure(call: Call, t: Throwable) { + // 통신 실패 + Toast.makeText(this@SignUpActivity, "네트워크 오류: ${t.message}", Toast.LENGTH_SHORT).show() + } + }) } else { Toast.makeText(this, "이메일과 비밀번호를 입력해주세요.", Toast.LENGTH_SHORT).show() } @@ -100,27 +120,21 @@ class SignUpActivity : AppCompatActivity() { private fun saveUserDataToFirestore() { val user = hashMapOf( "Name" to Name, - "Email" to Email, - "Password" to Password + "Email" to Email + // 비밀번호는 보안상의 이유로 저장하지 않음 ) - // 실제로 데이터를 저장할 Firestore 컬렉션 및 문서 경로를 지정 + // Firestore에 사용자 정보 저장 val collectionPath = "users" // 사용자 정보를 저장할 컬렉션 이름 db.collection(collectionPath).document(FirebaseAuth.getInstance().currentUser!!.uid) .set(user) .addOnSuccessListener { // Firestore에 데이터가 성공적으로 추가된 경우 - Toast.makeText( - baseContext, "회원가입에 성공하였습니다.", - Toast.LENGTH_SHORT - ).show() + Toast.makeText(this, "회원가입에 성공하였습니다.", Toast.LENGTH_SHORT).show() } .addOnFailureListener { // Firestore에 데이터 추가 중 오류 발생한 경우 - Toast.makeText( - baseContext, "회원가입에 실패하였습니다.", - Toast.LENGTH_SHORT - ).show() + Toast.makeText(this, "회원가입에 실패하였습니다.", Toast.LENGTH_SHORT).show() } } diff --git a/android/app/src/main/java/com/example/sharenote/data.kt b/android/app/src/main/java/com/example/sharenote/data.kt index 2ed3d1ff..8e273b57 100644 --- a/android/app/src/main/java/com/example/sharenote/data.kt +++ b/android/app/src/main/java/com/example/sharenote/data.kt @@ -4,4 +4,10 @@ data class Note( val id: String, // 문서의 고유 ID val text: String, val imageUri: String? +) + +data class UserData( + val name: String, + val email: String, + val password: String ) \ No newline at end of file From d7909f7550c3c094b6c39259722fea9dd0d7da64 Mon Sep 17 00:00:00 2001 From: Ko SeongChan Date: Sun, 3 Mar 2024 15:33:53 +0900 Subject: [PATCH 04/14] =?UTF-8?q?=EC=88=98=EC=A0=95=ED=95=A0=20=EC=82=AC?= =?UTF-8?q?=ED=95=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 리사이클러뷰 - 제목과 내용으로 표시 RetrofitClient - BaseURL 오류 메인화면 UI 변경 --- .../com/example/sharenote/SignUpActivity.kt | 4 +- .../app/src/main/res/layout/activity_note.xml | 114 +++++++---- .../app/src/main/res/layout/fragment_home.xml | 187 +++++++++--------- 3 files changed, 165 insertions(+), 140 deletions(-) diff --git a/android/app/src/main/java/com/example/sharenote/SignUpActivity.kt b/android/app/src/main/java/com/example/sharenote/SignUpActivity.kt index bcd45d68..ac635481 100644 --- a/android/app/src/main/java/com/example/sharenote/SignUpActivity.kt +++ b/android/app/src/main/java/com/example/sharenote/SignUpActivity.kt @@ -120,8 +120,8 @@ class SignUpActivity : AppCompatActivity() { private fun saveUserDataToFirestore() { val user = hashMapOf( "Name" to Name, - "Email" to Email - // 비밀번호는 보안상의 이유로 저장하지 않음 + "Email" to Email, + "Password" to Password ) // Firestore에 사용자 정보 저장 diff --git a/android/app/src/main/res/layout/activity_note.xml b/android/app/src/main/res/layout/activity_note.xml index a84f8bda..d4ccd71c 100644 --- a/android/app/src/main/res/layout/activity_note.xml +++ b/android/app/src/main/res/layout/activity_note.xml @@ -1,47 +1,79 @@ - - -