diff --git a/app/build.gradle b/app/build.gradle index e4d9efb6cc..848fc3c004 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "org.ole.planet.myplanet" minSdkVersion 26 targetSdkVersion 34 - versionCode 2117 - versionName "0.21.17" + versionCode 2118 + versionName "0.21.18" ndkVersion '21.3.6528147' testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/team/TeamDetailFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/team/TeamDetailFragment.kt index 13bc105782..d039299051 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/team/TeamDetailFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/team/TeamDetailFragment.kt @@ -42,8 +42,34 @@ class TeamDetailFragment : BaseTeamFragment() { fragmentTeamDetailBinding.subtitle.text = team?.type if (!isMyTeam) { - fragmentTeamDetailBinding.llActionButtons.visibility = View.GONE + fragmentTeamDetailBinding.btnAddDoc.isEnabled = false + fragmentTeamDetailBinding.btnAddDoc.visibility = View.GONE + val currentTeam = team + if (currentTeam != null && !currentTeam._id.isNullOrEmpty()) { + + val isUserRequested = currentTeam.requested(user?.id, mRealm) + + if (isUserRequested) { + fragmentTeamDetailBinding.btnLeave.text = getString(R.string.requested) + fragmentTeamDetailBinding.btnLeave.isEnabled = false + } else { + fragmentTeamDetailBinding.btnLeave.text = getString(R.string.join) + fragmentTeamDetailBinding.btnLeave.setOnClickListener { + RealmMyTeam.requestToJoin(currentTeam._id!!, user, mRealm) + fragmentTeamDetailBinding.btnLeave.text = getString(R.string.requested) + fragmentTeamDetailBinding.btnLeave.isEnabled = false + } + } + } else { + throw IllegalStateException("Team or team ID is null, cannot proceed.") + } + } else { + + fragmentTeamDetailBinding.btnAddDoc.isEnabled = true + fragmentTeamDetailBinding.btnAddDoc.visibility = View.VISIBLE + fragmentTeamDetailBinding.btnLeave.isEnabled = true + fragmentTeamDetailBinding.btnLeave.visibility = View.VISIBLE fragmentTeamDetailBinding.btnLeave.setOnClickListener { AlertDialog.Builder(requireContext()).setMessage(R.string.confirm_exit) .setPositiveButton(R.string.yes) { _: DialogInterface?, _: Int -> diff --git a/app/src/main/res/layout/fragment_team_detail.xml b/app/src/main/res/layout/fragment_team_detail.xml index 99ad60c3c2..8938f536a7 100644 --- a/app/src/main/res/layout/fragment_team_detail.xml +++ b/app/src/main/res/layout/fragment_team_detail.xml @@ -63,7 +63,7 @@