Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SPOTeam_android/.idea/deploymentTargetSelector.xml

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

Original file line number Diff line number Diff line change
Expand Up @@ -668,4 +668,19 @@ data class FinishedStudyItem(
val finishedAt: String?
)

data class WithdrawResponse(
val isSuccess: Boolean,
val code: String,
val message: String,
val result: WithdrawResult?
)

data class WithdrawResult(
val memberId: Int,
val name: String,
val email: String,
val inactive: String
)



Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import com.example.spoteam_android.StudyReasons
import com.example.spoteam_android.ThemeApiResponse
import com.example.spoteam_android.ThemePreferences
import com.example.spoteam_android.ValidateEmailResponse
import com.example.spoteam_android.WithdrawResponse
import com.example.spoteam_android.YourResponse
import retrofit2.Call
import retrofit2.Response
Expand All @@ -26,6 +27,7 @@ import retrofit2.http.FormUrlEncoded
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.Headers
import retrofit2.http.PATCH
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query
Expand Down Expand Up @@ -89,4 +91,10 @@ interface LoginApiService {
@Body request: NickNameRequest
): Call<NickNameResponse>

//회원 탈퇴
@PATCH("spot/withdraw")
fun withdraw(): Call<WithdrawResponse>



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.example.spoteam_android.ui.mypage

import android.app.Dialog
import android.content.Context
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.view.Window
import android.widget.Button
import android.widget.ImageView
import com.example.spoteam_android.R

class LogOutCompleteDialog(
private val context: Context,
private val onConfirm: () -> Unit
) {
private val dlg = Dialog(context)

fun start() {
dlg.requestWindowFeature(Window.FEATURE_NO_TITLE)
dlg.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
dlg.setContentView(R.layout.dialog_logout_complete)

val confirmButton: Button = dlg.findViewById(R.id.dialog_complete_bt)
val closeButton: ImageView = dlg.findViewById(R.id.close_iv)

confirmButton.setOnClickListener {
onConfirm()
dlg.dismiss()
}

closeButton.setOnClickListener {
onConfirm()
dlg.dismiss()
}

dlg.show()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,27 @@ import com.example.spoteam_android.R

class LogOutDialog(
private val context: Context,
private val onConfirm: () -> Unit //로그아웃 실행을 콜백함.
private val onConfirm: () -> Unit
) {
private val dlg = Dialog(context)

fun start() {
//다이얼로그 배경처리 관련 로직
dlg.requestWindowFeature(Window.FEATURE_NO_TITLE)
dlg.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
dlg.setContentView(R.layout.dialog_logout)

//다이얼로그 내 버튼별 UI 설정
val logoutBtn: Button = dlg.findViewById(R.id.logout_bt)
val cancelBtn: Button = dlg.findViewById(R.id.cancel_bt)
val closeIv: ImageView = dlg.findViewById(R.id.close_iv)

// 로그아웃 버튼 클릭 시 로그아웃 실행
logoutBtn.setOnClickListener {
onConfirm() // 마이페이지프래그먼트에있는 플랫폼별 로그아웃실행
dlg.dismiss() //다이얼로그 닫기
onConfirm()
dlg.dismiss()
}

// 취소 버튼 및 닫기 버튼 클릭 시 다이얼로그 닫기
cancelBtn.setOnClickListener { dlg.dismiss() }
closeIv.setOnClickListener { dlg.dismiss() }

dlg.show() //다이얼로그 표시
dlg.show()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.example.spoteam_android.RetrofitInstance
import com.example.spoteam_android.StudyItem
import com.example.spoteam_android.StudyResponse
import com.example.spoteam_android.ThemeApiResponse
import com.example.spoteam_android.WithdrawResponse
import com.example.spoteam_android.databinding.FragmentMypageBinding
import com.example.spoteam_android.login.LoginApiService
import com.example.spoteam_android.login.StartLoginActivity
Expand All @@ -33,7 +34,7 @@ import com.example.spoteam_android.ui.community.MyPageStudyNumInfo
import com.example.spoteam_android.ui.community.MyPageStudyNumResponse
import com.example.spoteam_android.ui.community.ScrapFragment
import com.example.spoteam_android.ui.interestarea.FinishedStudyApiService
import com.example.spoteam_android.ui.mypage.cancel.CancelSPOTFragment
import com.example.spoteam_android.ui.mypage.cancel.CancelDialog
import com.example.spoteam_android.ui.mypage.rule.CommunityPrivacyPolicyFragment
import com.example.spoteam_android.ui.mypage.rule.CommunityRestrictionsFragment
import com.example.spoteam_android.ui.mypage.rule.CommunityRuleFragment
Expand Down Expand Up @@ -75,7 +76,6 @@ class MyPageFragment : Fragment() {
frameLayoutInProgress.setOnClickListener { navigateToFragment(ParticipatingStudyFragment()) }
frameLayoutRecruiting.setOnClickListener { navigateToFragment(ConsiderAttendanceFragment()) }
framelayoutApplied.setOnClickListener { navigateToFragment(PermissionWaitFragment()) }
framelayoutDeleteAccount.setOnClickListener { showConfirmationDialog("회원 탈퇴", "정말로 회원 탈퇴를 진행하시겠습니까? 탈퇴 시 모든 데이터가 삭제됩니다.") { performAccountDeletion() } }
framelayoutLogout.setOnClickListener {
val dialog = LogOutDialog(requireContext()){
performLogout()
Expand All @@ -93,7 +93,10 @@ class MyPageFragment : Fragment() {
framelayout9.setOnClickListener{navigateToFragment(CommunityPrivacyPolicyFragment())}
framelayout10.setOnClickListener{navigateToFragment(CommunityTermsOfUseFragment())}

tvDeleteAccount.setOnClickListener{navigateToFragment(CancelSPOTFragment())}
framelayoutDeleteAccount.setOnClickListener{ val dialog = CancelDialog(requireContext()) {
performWithdrawal()
}
dialog.start()}
}
}

Expand Down Expand Up @@ -200,7 +203,7 @@ class MyPageFragment : Fragment() {
val sharedPreferences = requireActivity().getSharedPreferences("MyPrefs", Context.MODE_PRIVATE)
val loginPlatform = sharedPreferences.getString("loginPlatform", null)

when (loginPlatform) { //플랫폼별 로그인 구현. 일반로그인은 아직 구현중
when (loginPlatform) {
"kakao" -> logoutFromKakao()
"naver" -> logoutFromNaver()
else -> {
Expand All @@ -212,7 +215,6 @@ class MyPageFragment : Fragment() {
private fun logoutFromKakao() {
UserApiClient.instance.logout { error ->
if (error != null) {
// 🔸 이미 로그아웃된 상태라면 에러가 나올 수 있음
Log.w("MyPageFragment", "카카오 로그아웃 실패 또는 이미 로그아웃됨: ${error.message}")
} else {
Log.i("MyPageFragment", "카카오 로그아웃 성공")
Expand All @@ -222,20 +224,19 @@ class MyPageFragment : Fragment() {
clearSharedPreferences()
RetrofitInstance.setAuthToken(null)

Toast.makeText(requireContext(), "로그아웃되었습니다", Toast.LENGTH_SHORT).show()
navigateToLoginScreen()
showLogoutCompleteDialog()
}
}


private fun logoutFromNaver() {
NaverIdLoginSDK.logout()

clearSharedPreferences()

RetrofitInstance.setAuthToken(null)

Toast.makeText(requireContext(), "네이버 로그아웃 성공", Toast.LENGTH_SHORT).show()
navigateToLoginScreen()
showLogoutCompleteDialog()
}

private fun fetchFinishedStudyData() {
Expand Down Expand Up @@ -403,12 +404,39 @@ class MyPageFragment : Fragment() {
startActivity(intent)
}

private fun showConfirmationDialog(title: String, message: String, onConfirm: () -> Unit) {
AlertDialog.Builder(requireContext())
.setTitle(title)
.setMessage(message)
.setPositiveButton("확인") { _, _ -> onConfirm() }
.setNegativeButton("취소", null)
.show()
//스터디 탈퇴 로직은 도입전.
private fun performWithdrawal() {
val service = RetrofitInstance.retrofit.create(LoginApiService::class.java)

service.withdraw().enqueue(object : Callback<WithdrawResponse> {
override fun onResponse(call: Call<WithdrawResponse>, response: Response<WithdrawResponse>) {
if (response.isSuccessful && response.body()?.isSuccess == true) {
RetrofitInstance.setAuthToken(null)
clearSharedPreferences()
showWithdrawCompleteDialog()
} else {
Log.e("탈퇴 실패", response.errorBody()?.string() ?: "알 수 없는 오류")
}
}

override fun onFailure(call: Call<WithdrawResponse>, t: Throwable) {
Log.e("탈퇴 실패", t.message ?: "네트워크 오류")
}
})
}

private fun showLogoutCompleteDialog() {
val dialog = LogOutCompleteDialog(requireContext()) {
navigateToLoginScreen()
}
dialog.start()
}
private fun showWithdrawCompleteDialog() {
val dialog = CancelFinishDialog(requireContext()) {
navigateToLoginScreen()
}
dialog.start()
}


}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.spoteam_android.ui.mypage

import LocationStudyFragment
import android.content.Context
import android.os.Bundle
import android.util.Log
Expand Down Expand Up @@ -48,7 +49,6 @@ class RegionPreferenceFragment : Fragment() {
Toast.makeText(requireContext(), "Email not provided", Toast.LENGTH_SHORT).show()
}

// 이유 수정 버튼 클릭 시
binding.checklistspotLocationEditBt.setOnClickListener {
val fragment = TemporaryRegionFragment()
val bundle = Bundle().apply {
Expand Down Expand Up @@ -116,9 +116,9 @@ class RegionPreferenceFragment : Fragment() {

private fun displayRegions(regions: List<Region>) {
val linearLayout = binding.fragmentRegionPreferenceLinearLayout
linearLayout.removeAllViews() // 기존 TextView를 모두 제거
selectedRegions.clear() // 새로운 데이터로 채우기 전에 리스트를 초기화
selectedCodes.clear() // 코드 리스트도 초기화
linearLayout.removeAllViews()
selectedRegions.clear()
selectedCodes.clear()

for (region in regions) {
val regionText = "${region.province} ${region.district} ${region.neighborhood}"
Expand Down Expand Up @@ -150,6 +150,27 @@ class RegionPreferenceFragment : Fragment() {
linearLayout.addView(textView)
}
}
private fun createStyledRegionView(regionText: String): TextView {
return TextView(requireContext()).apply {
text = regionText
textSize = 14.4f
setPadding(30, 35, 50, 35)
setTextColor(resources.getColor(R.color.b500, null))
setBackgroundResource(R.drawable.button_background)
typeface = ResourcesCompat.getFont(requireContext(), R.font.suit_semi_bold)

val params = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT
).apply {
marginStart = 20
marginEnd = 20
topMargin = 25
}
layoutParams = params
}
}



private fun goToLocationFragment() {
Expand Down
Loading