diff --git a/app/src/main/java/com/project/jangburich/api/ApiService.kt b/app/src/main/java/com/project/jangburich/api/ApiService.kt index 6b1c161..b4307cf 100644 --- a/app/src/main/java/com/project/jangburich/api/ApiService.kt +++ b/app/src/main/java/com/project/jangburich/api/ApiService.kt @@ -4,6 +4,7 @@ import com.project.jangburich.api.request.group.CreateGroupRequest import com.project.jangburich.api.request.login.SaveSignUpInfoRequest import com.project.jangburich.api.request.store.PrepayRequest import com.project.jangburich.api.response.BaseResponse +import com.project.jangburich.api.response.group.CreateGroupResponse import com.project.jangburich.api.response.group.GetGroupInfoWithCodeResponse import com.project.jangburich.api.response.group.GetGroupResponse import com.project.jangburich.api.response.home.GetHomeDataResponse @@ -47,7 +48,7 @@ interface ApiService { fun createGroup( @Header("Authorization") token: String, @Body parameters: CreateGroupRequest - ): Call> + ): Call> // 그룹 정보 가져오기 @GET("/teams") diff --git a/app/src/main/java/com/project/jangburich/api/request/group/CreateGroupRequest.kt b/app/src/main/java/com/project/jangburich/api/request/group/CreateGroupRequest.kt index d47c85c..ff255a4 100644 --- a/app/src/main/java/com/project/jangburich/api/request/group/CreateGroupRequest.kt +++ b/app/src/main/java/com/project/jangburich/api/request/group/CreateGroupRequest.kt @@ -4,7 +4,6 @@ data class CreateGroupRequest( val teamType: String, val teamName: String, val description: String, - val secretCode: String, val teamLeaderAccountNumber: String, val bankName: String ) diff --git a/app/src/main/java/com/project/jangburich/api/response/group/CreateGroupResponse.kt b/app/src/main/java/com/project/jangburich/api/response/group/CreateGroupResponse.kt new file mode 100644 index 0000000..ce98b70 --- /dev/null +++ b/app/src/main/java/com/project/jangburich/api/response/group/CreateGroupResponse.kt @@ -0,0 +1,5 @@ +package com.project.jangburich.api.response.group + +data class CreateGroupResponse( + val uuid: String +) \ No newline at end of file diff --git a/app/src/main/java/com/project/jangburich/ui/group/CreateGroupCompleteFragment.kt b/app/src/main/java/com/project/jangburich/ui/group/CreateGroupCompleteFragment.kt index c7a4c3f..d335432 100644 --- a/app/src/main/java/com/project/jangburich/ui/group/CreateGroupCompleteFragment.kt +++ b/app/src/main/java/com/project/jangburich/ui/group/CreateGroupCompleteFragment.kt @@ -38,7 +38,7 @@ class CreateGroupCompleteFragment : Fragment() { transaction.commit() } buttonMyGroup.setOnClickListener { - + mainActivity.binding.bottomNavigation.selectedItemId = R.id.menu_group } } diff --git a/app/src/main/java/com/project/jangburich/ui/group/CreateGroupInfoFragment.kt b/app/src/main/java/com/project/jangburich/ui/group/CreateGroupInfoFragment.kt index 4b23a6e..3d18ede 100644 --- a/app/src/main/java/com/project/jangburich/ui/group/CreateGroupInfoFragment.kt +++ b/app/src/main/java/com/project/jangburich/ui/group/CreateGroupInfoFragment.kt @@ -36,20 +36,10 @@ class CreateGroupInfoFragment : Fragment() { checkEnable() textViewDescriptionCount.text = "${editTextDescription.length()}/100" } - editTextCode.addTextChangedListener { - checkEnable() - textViewCodeCount.text = "${editTextCode.length()}/10" - if(isValidInput(editTextCode.text.toString())) { - textViewCodeError.visibility = View.INVISIBLE - } else { - textViewCodeError.visibility = View.VISIBLE - } - } buttonNext.setOnClickListener { MyApplication.groupName = editTextName.text.toString() MyApplication.groupDescription = editTextDescription.text.toString() - MyApplication.groupSecretCode = editTextCode.text.toString() val nextFragment = CreateGroupAccountFragment() @@ -66,7 +56,7 @@ class CreateGroupInfoFragment : Fragment() { fun checkEnable() { binding.run { - if(editTextName.text.isNotEmpty() && editTextDescription.text.isNotEmpty() && editTextCode.text.isNotEmpty()) { + if(editTextName.text.isNotEmpty() && editTextDescription.text.isNotEmpty()) { buttonNext.isEnabled = true } else { buttonNext.isEnabled = false @@ -84,7 +74,6 @@ class CreateGroupInfoFragment : Fragment() { fun initView() { binding.run { buttonNext.isEnabled = false - textViewCodeError.visibility = View.INVISIBLE mainActivity.hideBottomNavigation(true) diff --git a/app/src/main/java/com/project/jangburich/ui/group/CreateGroupInviteFragment.kt b/app/src/main/java/com/project/jangburich/ui/group/CreateGroupInviteFragment.kt index e8a9123..bdd55a5 100644 --- a/app/src/main/java/com/project/jangburich/ui/group/CreateGroupInviteFragment.kt +++ b/app/src/main/java/com/project/jangburich/ui/group/CreateGroupInviteFragment.kt @@ -1,10 +1,14 @@ package com.project.jangburich.ui.group +import android.content.ClipData +import android.content.ClipboardManager +import android.content.Context import android.os.Bundle import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.Toast import com.project.jangburich.MyApplication import com.project.jangburich.R import com.project.jangburich.databinding.FragmentCreateGroupInviteBinding @@ -28,6 +32,10 @@ class CreateGroupInviteFragment : Fragment() { binding.run { textViewCode.text = MyApplication.groupSecretCode + buttonCopy.setOnClickListener { + copyTextToClipboard(mainActivity, MyApplication.groupSecretCode) + } + buttonNext.setOnClickListener { val nextFragment = CreateGroupCompleteFragment() @@ -41,6 +49,20 @@ class CreateGroupInviteFragment : Fragment() { return binding.root } + fun copyTextToClipboard(context: Context, text: String) { + // ClipboardManager 인스턴스 가져오기 + val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager + + // 클립 데이터 생성 + val clip = ClipData.newPlainText("Copied Text", text) + + // 클립보드에 데이터 복사 + clipboard.setPrimaryClip(clip) + + // 사용자에게 복사 알림 + Toast.makeText(context, "텍스트가 복사되었습니다.", Toast.LENGTH_SHORT).show() + } + fun initView() { binding.run { mainActivity.hideBottomNavigation(true) diff --git a/app/src/main/java/com/project/jangburich/ui/group/viewModel/GroupViewModel.kt b/app/src/main/java/com/project/jangburich/ui/group/viewModel/GroupViewModel.kt index cccee5d..4e33c16 100644 --- a/app/src/main/java/com/project/jangburich/ui/group/viewModel/GroupViewModel.kt +++ b/app/src/main/java/com/project/jangburich/ui/group/viewModel/GroupViewModel.kt @@ -11,6 +11,7 @@ import com.project.jangburich.api.TokenManager import com.project.jangburich.api.request.group.CreateGroupRequest import com.project.jangburich.api.request.store.PrepayRequest import com.project.jangburich.api.response.BaseResponse +import com.project.jangburich.api.response.group.CreateGroupResponse import com.project.jangburich.api.response.group.GetGroupInfoWithCodeResponse import com.project.jangburich.api.response.group.GetGroupResponse import com.project.jangburich.api.response.home.GetHomeDataResponse @@ -39,20 +40,22 @@ class GroupViewModel: ViewModel() { val apiClient = ApiClient(activity) val tokenManager = TokenManager(activity) - var groupInfo = CreateGroupRequest(MyApplication.groupType, MyApplication.groupName, MyApplication.groupDescription, MyApplication.groupSecretCode, MyApplication.groupAccountNumber, MyApplication.groupBankName) + var groupInfo = CreateGroupRequest(MyApplication.groupType, MyApplication.groupName, MyApplication.groupDescription, MyApplication.groupAccountNumber, MyApplication.groupBankName) apiClient.apiService.createGroup("Bearer ${tokenManager.getAccessToken()}", groupInfo).enqueue(object : - Callback> { + Callback> { override fun onResponse( - call: Call>, - response: Response> + call: Call>, + response: Response> ) { Log.d("##", "onResponse 성공: " + response.body().toString()) if (response.isSuccessful) { // 정상적으로 통신이 성공된 경우 - val result: BaseResponse? = response.body() + val result: BaseResponse? = response.body() Log.d("##", "onResponse 성공: " + result?.toString()) + MyApplication.groupSecretCode = result?.data?.uuid!! + val nextFragment = CreateGroupInviteFragment() val transaction = activity.manager.beginTransaction() @@ -61,7 +64,7 @@ class GroupViewModel: ViewModel() { transaction.commit() } else { // 통신이 실패한 경우(응답코드 3xx, 4xx 등) - var result: BaseResponse? = response.body() + var result: BaseResponse? = response.body() Log.d("##", "onResponse 실패") Log.d("##", "onResponse 실패: " + response.code()) Log.d("##", "onResponse 실패: " + response.body()) @@ -71,7 +74,7 @@ class GroupViewModel: ViewModel() { } } - override fun onFailure(call: Call>, t: Throwable) { + override fun onFailure(call: Call>, t: Throwable) { // 통신 실패 Log.d("##", "onFailure 에러: " + t.message.toString()) } diff --git a/app/src/main/res/layout/fragment_create_group_info.xml b/app/src/main/res/layout/fragment_create_group_info.xml index 5c478f7..1fc7983 100644 --- a/app/src/main/res/layout/fragment_create_group_info.xml +++ b/app/src/main/res/layout/fragment_create_group_info.xml @@ -104,54 +104,6 @@ app:layout_constraintBottom_toBottomOf="@+id/editText_description" app:layout_constraintEnd_toEndOf="@+id/editText_description" /> - - - - - - - -