Skip to content

Commit

Permalink
#31 회원가입 요청 코드 작성(초안)
Browse files Browse the repository at this point in the history
  • Loading branch information
yellow-jam committed Jun 29, 2022
1 parent 1f7f4ad commit d323313
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 41 deletions.
2 changes: 2 additions & 0 deletions SHAPEUP2022/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 24 additions & 36 deletions SHAPEUP2022/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,52 +11,40 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.SHAPEUP2022">
<activity
android:name=".YoutubeActivity"
android:exported="false" />
<activity
android:name=".SimulationActivity"
android:exported="false" />
android:theme="@style/Theme.SHAPEUP2022"
android:usesCleartextTraffic="true" >


<activity
android:name=".TempMainActivity"
android:exported="true">
</activity>
<activity
android:name=".SettingActivity"
android:exported="false" />
<activity
android:name=".MyPageActivity"
android:exported="false" />
<activity
android:name=".AchieveActivity"
android:exported="false" />
<activity
android:name=".preferenceActivity"
android:exported="false" /> <!-- 시작 및 회원가입/로그인 -->
<activity
android:name=".StartActivity"
android:exported="true" />
<activity
android:name=".LoginActivity"
android:exported="true" />
<activity
android:name=".JoinActivity"
android:exported="true" />
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>


<activity
android:name=".ToDoActivity"
android:exported="false" /> <!-- 정보 -->
<activity android:name=".AlarmActivity" />
<activity android:name=".BudgetActivity" />
android:name=".MainActivity"
android:exported="true">
</activity>


<activity android:name=".AchieveActivity" android:exported="false" />
<activity android:name=".AlarmActivity" android:exported="false" />
<activity android:name=".BudgetActivity" android:exported="false" />
<activity android:name=".JoinActivity" android:exported="false" />
<activity android:name=".LoginActivity" android:exported="false" />
<activity android:name=".MyPageActivity" android:exported="false" />
<activity android:name=".preferenceActivity" android:exported="false" />
<activity android:name=".SettingActivity" android:exported="false" />
<activity android:name=".SimulationActivity" android:exported="false" />
<activity android:name=".StartActivity" android:exported="false" />
<activity android:name=".ToDoActivity" android:exported="false" />
<activity android:name=".YoutubeActivity" android:exported="false" />

</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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"));
}
Expand All @@ -82,6 +85,31 @@ class JoinCreate : Fragment(){
new_password.addTextChangedListener(textWatcher)
check_password.addTextChangedListener(textWatcher)



/* 회원가입 */
Log.d("mobileApp", "회원가입 버튼을 누름")

val call: Call<RegisterRes> = MyApplication.networkServiceAuth.register(
RegisterReq("test5","[email protected]", "55555555")
)

call?.enqueue(object : Callback<RegisterRes>{
override fun onResponse(call: Call<RegisterRes>, response: Response<RegisterRes>) {
if(response.isSuccessful){
Log.d("mobileApp", "$response")
}
}

override fun onFailure(call: Call<RegisterRes>, t: Throwable) {
Log.d("mobileApp", "onFailure $t")
}
})





return binding.root
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Original file line number Diff line number Diff line change
@@ -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<RegisterRes>

@POST("api/user/login")
fun login(
@Body user: LoginReq,
): Call<LoginRes>

@GET("api/user/logout")
fun logout(
@Body user: LogoutReq
): Call<LogoutRes>

}

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)

0 comments on commit d323313

Please sign in to comment.