-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat] #133 Find PW View & NicknameCheck & API Connection
- Loading branch information
Showing
19 changed files
with
551 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
app/src/main/java/com/example/infraandroid/id/model/PWService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.example.infraandroid.id.model | ||
|
||
import retrofit2.Call | ||
import retrofit2.http.Body | ||
import retrofit2.http.PATCH | ||
|
||
interface PWService { | ||
@PATCH("/user/reset-pw") | ||
fun findPWInfo( | ||
@Body body : RequestPWData | ||
): Call<ResponsePWData> | ||
} |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/example/infraandroid/id/model/RequestPWData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.example.infraandroid.id.model | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class RequestPWData( | ||
@SerializedName("user_phone") | ||
var userPhone : String | ||
) |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/example/infraandroid/id/model/ResponsePWData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.example.infraandroid.id.model | ||
|
||
data class ResponsePWData( | ||
val isSuccess: Boolean, | ||
val code: Int, | ||
val message: String, | ||
val result: String, | ||
) |
101 changes: 101 additions & 0 deletions
101
app/src/main/java/com/example/infraandroid/id/view/FindPWFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package com.example.infraandroid.id.view | ||
|
||
import android.os.Bundle | ||
import android.text.Editable | ||
import android.text.TextWatcher | ||
import android.util.Log | ||
import android.widget.EditText | ||
import androidx.lifecycle.ViewModelProvider | ||
import androidx.navigation.findNavController | ||
import com.example.infraandroid.R | ||
import com.example.infraandroid.category.model.ResponseViewIdeaData | ||
import com.example.infraandroid.databinding.FragmentFindPwBinding | ||
import com.example.infraandroid.id.model.RequestPWData | ||
import com.example.infraandroid.id.model.ResponsePWData | ||
import com.example.infraandroid.id.viewmodel.SignUpViewModel | ||
import com.example.infraandroid.myinfo.myideamanage.model.MyProjectViewModel | ||
import com.example.infraandroid.util.BaseFragment | ||
import com.example.infraandroid.util.ServiceCreator | ||
import retrofit2.Call | ||
import retrofit2.Callback | ||
import retrofit2.Response | ||
import retrofit2.http.Tag | ||
import java.util.regex.Pattern | ||
|
||
class FindPWFragment : BaseFragment<FragmentFindPwBinding>(R.layout.fragment_find_pw){ | ||
private lateinit var viewModel : MyProjectViewModel | ||
private val TAG = "로그" | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
activity?.run{ | ||
viewModel = ViewModelProvider(this, ViewModelProvider.NewInstanceFactory()) | ||
.get(MyProjectViewModel::class.java) | ||
} | ||
} | ||
|
||
override fun FragmentFindPwBinding.onCreateView() { | ||
} | ||
|
||
override fun FragmentFindPwBinding.onViewCreated() { | ||
val inputPhoneNumEditText = binding.inputNumEditText | ||
val nextButton = binding.goToSecondPwButton | ||
val backButton = binding.findPwBackButton | ||
|
||
//다음 버튼 활성화 설정 | ||
inputPhoneNumEditText.addTextChangedListener(object : TextWatcher{ | ||
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) { | ||
nextButton.isEnabled = false | ||
} | ||
|
||
override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) { | ||
if (Pattern.matches("^\\d{3}-\\d{3,4}-\\d{4}$", inputPhoneNumEditText.text.toString())) { | ||
nextButton.isEnabled = true | ||
} | ||
} | ||
|
||
override fun afterTextChanged(p0: Editable?) { | ||
if (Pattern.matches("^\\d{3}-\\d{3,4}-\\d{4}$", inputPhoneNumEditText.text.toString())) { | ||
nextButton.isEnabled = true | ||
} | ||
} | ||
}) | ||
|
||
//뒤로 가기 눌렀을 때 로그인 화면 | ||
backButton.setOnClickListener { | ||
it.findNavController().navigate(R.id.action_findPWFragment_to_login_fragment) | ||
} | ||
|
||
//비밀번호 조회 서버 연결 | ||
nextButton.setOnClickListener { | ||
val requestPWData = RequestPWData( | ||
userPhone = inputPhoneNumEditText.text.toString() | ||
) | ||
it.findNavController().navigate(R.id.action_findPWFragment_to_findPWSecondFragment) | ||
|
||
val call: Call<ResponsePWData> = ServiceCreator.pwService | ||
.findPWInfo(requestPWData) | ||
|
||
call.enqueue(object: Callback<ResponsePWData>{ | ||
override fun onResponse( | ||
call: Call<ResponsePWData>, | ||
response: Response<ResponsePWData> | ||
) { | ||
if(response.isSuccessful){ | ||
Log.d(TAG, "onResponse: 서버 연결 성공" + response.body()?.code) | ||
} | ||
else{ | ||
Log.d(TAG, "onResponse: 실패" + response.body()?.code + response.body()?.message) | ||
} | ||
} | ||
|
||
override fun onFailure(call: Call<ResponsePWData>, t: Throwable) { | ||
Log.d(TAG, "onFailure: $t") | ||
} | ||
}) | ||
} | ||
|
||
|
||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
app/src/main/java/com/example/infraandroid/id/view/FindPWSecondFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.example.infraandroid.id.view | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.ImageView | ||
import androidx.fragment.app.Fragment | ||
import androidx.navigation.findNavController | ||
import com.example.infraandroid.R | ||
import com.example.infraandroid.databinding.FragmentSecondFindPwBinding | ||
|
||
class FindPWSecondFragment : Fragment() { | ||
private var mBinding : FragmentSecondFindPwBinding? = null | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
val binding = FragmentSecondFindPwBinding.inflate(inflater, container, false) | ||
mBinding = binding | ||
return mBinding?.root | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
val backButton = mBinding?.findPwBackButton as ImageView | ||
|
||
//뒤로 가기 버튼 눌렀을 때 로그인 화면 | ||
backButton.setOnClickListener { | ||
it.findNavController().navigate(R.id.action_findPWSecondFragment_to_login_fragment) | ||
} | ||
} | ||
|
||
override fun onDestroyView() { | ||
mBinding = null | ||
super.onDestroyView() | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...ain/java/com/example/infraandroid/myinfo/myinfomodify/model/NicknameDoubleCheckService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.example.infraandroid.myinfo.myinfomodify.model | ||
|
||
import retrofit2.Call | ||
import retrofit2.http.Body | ||
import retrofit2.http.POST | ||
|
||
interface NicknameDoubleCheckService { | ||
@POST("/user/valid-nickname") | ||
fun doublecheck( | ||
@Body body : RequestNicknameCheckData | ||
): Call<ResponseNicknameCheckData> | ||
} |
8 changes: 8 additions & 0 deletions
8
.../main/java/com/example/infraandroid/myinfo/myinfomodify/model/RequestNicknameCheckData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.example.infraandroid.myinfo.myinfomodify.model | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class RequestNicknameCheckData( | ||
@SerializedName("user_nickname") | ||
val userNickname : String, | ||
) |
8 changes: 8 additions & 0 deletions
8
...main/java/com/example/infraandroid/myinfo/myinfomodify/model/ResponseNicknameCheckData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.example.infraandroid.myinfo.myinfomodify.model | ||
|
||
data class ResponseNicknameCheckData( | ||
val isSuccess: Boolean, | ||
val code: Int, | ||
val message: String, | ||
val result: String | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.