From d323313b9051338783c64884b47579b0b57fe241 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 29 Jun 2022 10:09:08 +0900 Subject: [PATCH] =?UTF-8?q?#31=20=ED=9A=8C=EC=9B=90=EA=B0=80=EC=9E=85=20?= =?UTF-8?q?=EC=9A=94=EC=B2=AD=20=EC=BD=94=EB=93=9C=20=EC=9E=91=EC=84=B1(?= =?UTF-8?q?=EC=B4=88=EC=95=88)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SHAPEUP2022/.idea/misc.xml | 2 + SHAPEUP2022/app/src/main/AndroidManifest.xml | 60 ++++++++----------- .../com/example/shape_up_2022/JoinCreate.kt | 32 +++++++++- .../com/example/shape_up_2022/JoinShare.kt | 2 + .../example/shape_up_2022/MyApplication.kt | 15 ++++- .../example/shape_up_2022/NetworkService.kt | 34 +++++++++++ 6 files changed, 104 insertions(+), 41 deletions(-) create mode 100644 SHAPEUP2022/app/src/main/java/com/example/shape_up_2022/NetworkService.kt diff --git a/SHAPEUP2022/.idea/misc.xml b/SHAPEUP2022/.idea/misc.xml index fd034e5..80d6dfb 100644 --- a/SHAPEUP2022/.idea/misc.xml +++ b/SHAPEUP2022/.idea/misc.xml @@ -62,6 +62,8 @@ + + diff --git a/SHAPEUP2022/app/src/main/AndroidManifest.xml b/SHAPEUP2022/app/src/main/AndroidManifest.xml index f228f30..0d00546 100644 --- a/SHAPEUP2022/app/src/main/AndroidManifest.xml +++ b/SHAPEUP2022/app/src/main/AndroidManifest.xml @@ -11,52 +11,40 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" - android:theme="@style/Theme.SHAPEUP2022"> - - + android:theme="@style/Theme.SHAPEUP2022" + android:usesCleartextTraffic="true" > + + - - - - - - - - - + + - - + android:name=".MainActivity" + android:exported="true"> + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SHAPEUP2022/app/src/main/java/com/example/shape_up_2022/JoinCreate.kt b/SHAPEUP2022/app/src/main/java/com/example/shape_up_2022/JoinCreate.kt index 2ef57d7..9deaf9c 100644 --- a/SHAPEUP2022/app/src/main/java/com/example/shape_up_2022/JoinCreate.kt +++ b/SHAPEUP2022/app/src/main/java/com/example/shape_up_2022/JoinCreate.kt @@ -9,6 +9,10 @@ import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment import com.example.shape_up_2022.databinding.FragmentJoinCreateBinding +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response +import android.util.Log // TODO: Rename parameter arguments, choose names that match @@ -55,7 +59,6 @@ class JoinCreate : Fragment(){ val new_password = binding.inputNewpassword val check_password = binding.checkPassword - // 핸들러 적용 var textWatcher = object : TextWatcher { override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) { @@ -65,7 +68,7 @@ class JoinCreate : Fragment(){ if (input_name.length() > 0 && input_id.length() > 0 && new_password.length() > 0 && check_password.length() > 0){ binding.nextCreate.isEnabled = true binding.nextCreate.setBackgroundColor(Color.parseColor("#FF9966")); - } else{ + } else { binding.nextCreate.isEnabled = false binding.nextCreate.setBackgroundColor(Color.parseColor("#d3d3d3")); } @@ -82,6 +85,31 @@ class JoinCreate : Fragment(){ new_password.addTextChangedListener(textWatcher) check_password.addTextChangedListener(textWatcher) + + + /* 회원가입 */ + Log.d("mobileApp", "회원가입 버튼을 누름") + + val call: Call = MyApplication.networkServiceAuth.register( + RegisterReq("test5","test5@gmail.com", "55555555") + ) + + call?.enqueue(object : Callback{ + override fun onResponse(call: Call, response: Response) { + if(response.isSuccessful){ + Log.d("mobileApp", "$response") + } + } + + override fun onFailure(call: Call, t: Throwable) { + Log.d("mobileApp", "onFailure $t") + } + }) + + + + + return binding.root } diff --git a/SHAPEUP2022/app/src/main/java/com/example/shape_up_2022/JoinShare.kt b/SHAPEUP2022/app/src/main/java/com/example/shape_up_2022/JoinShare.kt index 0c358ed..af15d71 100644 --- a/SHAPEUP2022/app/src/main/java/com/example/shape_up_2022/JoinShare.kt +++ b/SHAPEUP2022/app/src/main/java/com/example/shape_up_2022/JoinShare.kt @@ -34,6 +34,8 @@ class JoinShare : Fragment() { inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { + + // 반려견 공유 코드를 입력하면 다음으로 val binding = FragmentJoinShareBinding.inflate(inflater, container, false) binding.nextShare.setOnClickListener { (activity as JoinActivity).gotoMainActivity() diff --git a/SHAPEUP2022/app/src/main/java/com/example/shape_up_2022/MyApplication.kt b/SHAPEUP2022/app/src/main/java/com/example/shape_up_2022/MyApplication.kt index e9d94cf..5893815 100644 --- a/SHAPEUP2022/app/src/main/java/com/example/shape_up_2022/MyApplication.kt +++ b/SHAPEUP2022/app/src/main/java/com/example/shape_up_2022/MyApplication.kt @@ -5,17 +5,26 @@ import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory class MyApplication: Application() { - companion object{ + companion object { //유튜브 - var networkService2 : NetworkService2 + var networkService2: NetworkService2 val retrofit2: Retrofit - get()= Retrofit.Builder() + get() = Retrofit.Builder() .baseUrl("https://www.googleapis.com/") .addConverterFactory(GsonConverterFactory.create()) .build() + // 로그인 + var networkServiceAuth: NetworkService + val retrofitAuth: Retrofit + get() = Retrofit.Builder() + .baseUrl("http://ec2-13-124-250-65.ap-northeast-2.compute.amazonaws.com:5000/") + .addConverterFactory(GsonConverterFactory.create()) + .build() + init{ networkService2 = retrofit2.create(NetworkService2::class.java) + networkServiceAuth = retrofitAuth.create(NetworkService::class.java) } } } \ No newline at end of file diff --git a/SHAPEUP2022/app/src/main/java/com/example/shape_up_2022/NetworkService.kt b/SHAPEUP2022/app/src/main/java/com/example/shape_up_2022/NetworkService.kt new file mode 100644 index 0000000..ba2fdae --- /dev/null +++ b/SHAPEUP2022/app/src/main/java/com/example/shape_up_2022/NetworkService.kt @@ -0,0 +1,34 @@ +package com.example.shape_up_2022 + +import retrofit2.Call +import retrofit2.http.* + +interface NetworkService { + @POST("api/user/register") + fun register( + @Body user: RegisterReq, + ): Call + + @POST("api/user/login") + fun login( + @Body user: LoginReq, + ): Call + + @GET("api/user/logout") + fun logout( + @Body user: LogoutReq + ): Call + +} + +data class RegisterReq(val name: String, val email: String, val password: String) + +data class RegisterRes(val success: String) + +data class LoginReq(val email: String, val password: String) + +data class LoginRes(val loginSuccess: String, val message: String) + +data class LogoutReq(val _id: String, val email: String, val password: String) + +data class LogoutRes(val success: String) \ No newline at end of file